18 std::cerr <<
"Error reading prim from " << filename << std::endl;
32 from_json(latvec_transpose, json[
"lattice_vectors"]);
34 Lattice lat(latvec_transpose.transpose());
45 std::string coordinate_mode;
46 from_json(coordinate_mode, json[
"coordinate_mode"]);
48 if(coordinate_mode ==
"Fractional") {
51 else if(coordinate_mode ==
"Direct") {
54 else if(coordinate_mode ==
"Cartesian") {
58 throw std::runtime_error(
59 std::string(
" Invalid: \"coordinate_mode\"\n") +
60 " Expected one of \"Fractional\", \"Direct\", or \"Cartesian\"");
64 for(
int i = 0; i < json[
"basis"].
size(); i++) {
67 Eigen::Vector3d coord(json[
"basis"][i][
"coordinate"][0].get<double>(),
68 json[
"basis"][i][
"coordinate"][1].get<double>(),
69 json[
"basis"][i][
"coordinate"][2].get<double>());
70 Site site(prim.lattice());
74 else if(mode ==
CART) {
80 from_json(occ_name, json[
"basis"][i][
"occupant_dof"]);
84 for(
int i = 0; i < occ_name.
size(); i++) {
86 tMol.
name = occ_name[i];
91 site.set_occ_value(0);
94 prim.basis.push_back(site);
110 outfile.
open(filename);
124 json[
"title"] = prim.
title;
133 json[
"coordinate_mode"] =
"Fractional";
135 else if(mode ==
CART) {
136 json[
"coordinate_mode"] =
"Cartesian";
140 for(
int i = 0; i < prim.
basis.
size(); i++) {
142 json[
"basis"][i][
"coordinate"].
put_array();
148 else if(mode ==
CART) {
156 for(
int j = 0; j < prim.
basis[i].site_occupant().
size(); j++) {
157 json[
"basis"][i][
"occupant_dof"][j] = prim.
basis[i].site_occupant()[j].name;
169 const SymOp &op = grp[i];
187 for(
int i = 0; i < grp.
size(); i++) {
199 for(
int i = 0; i < grp.
size(); i++) {
220 std::cerr <<
"Error reading chemical reference states from " << filename << std::endl;
250 if(json.
find(
"chemical_reference") == json.
end()) {
251 throw std::runtime_error(
"Error reading chemical reference states: Expected \"chemical_reference\" entry");
260 outfile.
open(filename);
271 to_json(chem_ref, json[
"chemical_reference"]);
302 std::cerr <<
"Error reading composition axes from " << _filename << std::endl;
317 if(json.
contains(
"standard_axes")) {
355 json[
"standard_axes"][
standard.cbegin()->first] =
true;
358 json[
"standard_axes"][it->first] = it->second;
361 for(
auto it =
custom.cbegin(); it !=
custom.cend(); ++it) {
362 json[
"custom_axes"][it->first] = it->second;
376 std::stringstream ss;
377 ss <<
"Error: The composition axes " << key <<
378 " can found in both the standard and custom compostion axes.\n\n" <<
379 "Please edit the custom composition axes to remove this ambiguity.";
389 std::stringstream ss;
390 ss <<
"Warning: The composition axes " << key <<
391 " can not be found in the standard or custom compostion axes.\n\n" <<
392 "Please use 'casm composition --select' to re-select your composition axes,\n" <<
393 "Please use 'casm composition --calc' to re-calc your standard axes,\n" <<
394 "or edit the custom composition axes.";
416 outfile.
open(nlistpath);
418 nlist_json = prim_nlist;
434 std::cerr <<
"Error reading: " << nlistpath;
496 const Site &site = equiv[0];
499 sitef[b][
"sublat"] = b;
500 sitef[b][
"asym_unit"] = no;
507 std::stringstream fname;
508 fname <<
"\\phi_" << b <<
'_' << f;
512 sitef[b][
"basis"][fname.str()][site.
site_occupant()[s].name] =
543 jsonParser &orbitf = json[
"cluster_functions"];
547 for(
Index j = 0; j < tree.
size(i); j++) {
550 tjson[
"orbit"] = std::vector<Index>({i, j, 0});
551 tjson[
"mult"] = tree.
orbit(i, j).size();
558 for(
Index nf = 0; nf < tbasis.size(); ++nf) {
559 tjson[
"orbit"][2] = nf;
560 tjson[
"prototype_function"] = tbasis[nf]->tex_formula();
566 for(
Index i = 0; i < orbitf.
size(); ++i) {
567 orbitf[i][
"linear_function_index"] = i;
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file"...
CompositionConverter curr
SymInfo info(Index i) const
ClustJsonHelper< ValueType > jsonHelper(ValueType &_value, const Structure &_struc, double tol=TOL)
std::map< std::string, CompositionConverter > standard
void from_json(ClexDescription &desc, const jsonParser &json)
iterator end()
Returns iterator to end of JSON object or JSON array.
bool get_if(T &t, const std::string &key, Args...args) const
void push_back(const T &toPush)
Structure specifies the lattice and atomic basis of a crystal.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void select(std::string key)
Set this->curr using key.
void write_symgroup(const SymGroup &grp, jsonParser &json)
const MoleculeOccupant & site_occupant() const
OccupantDoF< Molecule > MoleculeOccupant
void write_prim(const BasicStructure< Site > &prim, fs::path filename, COORD_TYPE mode)
Write prim.json to file.
void write_chemical_reference(const ChemicalReference &chem_ref, fs::path filename)
Write to a temporary file to ensure a good write, then rename.
const Lattice & lattice() const
fs::ofstream & ofstream()
Access underlying stream.
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Index ind_inverse(Index i) const
Get index of operation that is inverse of operation at(i)
const Array< Index >::X2 & get_multi_table() const
BasicStructure< Site > read_prim(fs::path filename)
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
jsonParser & put_null()
Puts 'null' JSON value.
const matrix_type & matrix() const
Const access of entire cartesian symmetry matrix.
const Eigen::Matrix3d & inv_lat_column_mat() const
Inverse of Lattice::lat_column_mat() It is the transformation matrix 'C2F', such that f = C2F * c whe...
SymOp is the Coordinate representation of a symmetry operation it keeps fraction (FRAC) and Cartesian...
void read(fs::path _filename)
Read CompositionAxes from file.
EigenIndex Index
For long integer indexing:
bool accept(const FunctionVisitor &visitor)
const Array< std::complex< double > >::X2 & character_table() const
void add_sym_info(const SymInfo &info, jsonParser &j)
Add to existing JSON object.
Array< CoordType > basis
Lattice vectors that specifies periodicity of the crystal.
Index size() const override
std::string title
User-specified name of this Structure.
ChemicalReference read_chemical_reference(fs::path filename, const Structure &prim, double tol)
Read chemical reference states from JSON file.
OutputIterator read_composition_axes(OutputIterator result, const jsonParser &json)
Read standard axes from JSON, and output to std::map ...
const Array< Index >::X2 & get_conjugacy_classes() const
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
CASM::jsonParser & to_json_array(const Eigen::MatrixBase< Derived > &value, CASM::jsonParser &json)
Write Eigen Matrix with 1 row or 1 column to JSON array.
const Lattice & lattice() const
PERIODICITY_TYPE periodicity() const
iterator find(const std::string &name)
Return iterator to JSON object value with 'name'.
void write_symop(const SymGroup &grp, Index i, jsonParser &j)
jsonParser & put_obj()
Puts new empty JSON object.
Index basis_ind() const
Access basis Index.
std::string possible_space_groups() const
void write_basis(const SiteOrbitree &tree, const Structure &prim, jsonParser &json, double tol)
Write summary of basis functions.
jsonParser & push_back(const T &value)
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value...
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Coordinate_impl::FracCoordinate frac()
Set the fractional coordinate vector.
const vector_type & tau() const
Const access of the cartesian translation vector, 'tau'.
const std::string & get_latex_name() const
GenericOrbit< ClustType > & orbit(Index np, Index no)
Access orbits using 2-D indexing.
void write(fs::path _filename)
Write CompositionAxes to file.
Index class_of_op(Index i) const
Get conjugacy class index of operation at(i)
Array< UnitCellCoord > read_prim_nlist(const fs::path &nlistpath)
const std::string & get_name() const
std::map< std::string, CompositionConverter > custom
static jsonParser object()
Returns an empty json object.
void write_prim_nlist(const Array< UnitCellCoord > &prim_nlist, const fs::path &nlistpath)
jsonParser & put_array()
Puts new empty JSON array.
static jsonParser array()
Returns an empty json array.
const GenericOrbitBranch< ClustType > & asym_unit() const
Index size(Index np) const
Number of orbits in OrbitBranch 'np'.
static COORD_TYPE CHECK()
get the current mode (call using COORD_MODE::CHECK())