CASM  1.1.0
A Clusters Approach to Statistical Mechanics
BasicStructureIO.hh
Go to the documentation of this file.
1 #ifndef CASM_xtal_BasicStructure_io
2 #define CASM_xtal_BasicStructure_io
3 
4 #include <boost/filesystem/path.hpp>
5 #include <map>
6 #include <string>
7 
9 #include "casm/global/eigen.hh"
10 #include "casm/global/enum.hh"
11 
12 namespace CASM {
13 namespace xtal {
14 class Lattice;
15 class SpeciesAttribute;
16 class AtomPosition;
17 class Molecule;
18 class Site;
19 class BasicStructure;
20 } // namespace xtal
21 
22 // --- These functions are for casm I/O -----------
23 
24 class AnisoValTraits;
25 template <typename T>
26 class ParsingDictionary;
27 template <typename T>
28 struct jsonConstructor;
29 class jsonParser;
30 
31 // --------- PrimIO Declarations
32 // --------------------------------------------------
33 
35 jsonParser const &from_json(xtal::SpeciesAttribute &_attr,
36  jsonParser const &json);
37 
39 jsonParser &to_json(xtal::SpeciesAttribute const &_attr, jsonParser &json);
40 
43 jsonParser &to_json(const xtal::AtomPosition &apos, jsonParser &json,
44  Eigen::Ref<const Eigen::Matrix3d> const &cart2frac);
45 
48 void from_json(xtal::AtomPosition &apos, const jsonParser &json,
49  Eigen::Ref<const Eigen::Matrix3d> const &frac2cart,
50  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
51 
52 template <>
53 struct jsonConstructor<xtal::AtomPosition> {
56  const jsonParser &json, Eigen::Matrix3d const &f2c_mat,
57  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
58 };
59 
60 jsonParser &to_json(const xtal::Molecule &mol, jsonParser &json,
61  Eigen::Ref<const Eigen::Matrix3d> const &c2f_mat);
62 
63 void from_json(xtal::Molecule &mol, const jsonParser &json,
64  Eigen::Ref<const Eigen::Matrix3d> const &f2c_mat,
65  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
66 
67 template <>
68 struct jsonConstructor<xtal::Molecule> {
70  const jsonParser &json, Eigen::Ref<const Eigen::Matrix3d> const &f2c_mat,
71  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
72 };
73 
74 template <>
75 struct jsonConstructor<xtal::Site> {
76  static xtal::Site from_json(
77  const jsonParser &json, xtal::Lattice const &_home, COORD_TYPE coordtype,
78  std::map<std::string, xtal::Molecule> const &mol_map,
79  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
80 };
81 
82 jsonParser &to_json(const xtal::Site &value, jsonParser &json,
83  COORD_TYPE coordtype);
84 
85 void from_json(xtal::Site &value, const jsonParser &json,
86  xtal::Lattice const &_home, COORD_TYPE coordtype,
87  std::map<std::string, xtal::Molecule> const &mol_map,
88  ParsingDictionary<AnisoValTraits> const &_aniso_val_dict);
89 
91  fs::path filename, double xtal_tol,
92  ParsingDictionary<AnisoValTraits> const *_aniso_val_dict = nullptr);
93 
95  jsonParser const &json, double xtal_tol,
96  ParsingDictionary<AnisoValTraits> const *_aniso_val_dict = nullptr);
97 
99 void write_prim(const xtal::BasicStructure &prim, fs::path filename,
100  COORD_TYPE mode, bool include_va = false);
101 
103 void write_prim(const xtal::BasicStructure &prim, jsonParser &json,
104  COORD_TYPE mode, bool include_va = false);
105 
106 void from_json(
107  xtal::BasicStructure &prim, jsonParser const &json, double xtal_tol,
108  ParsingDictionary<AnisoValTraits> const *_aniso_val_dict = nullptr);
109 
111  COORD_TYPE mode, bool include_va = false);
112 
113 } // namespace CASM
114 
115 #endif
Parsing dictionary for obtaining the correct MoleculeAttribute given a name.
An atomic species associated with a position in space.
Definition: Molecule.hh:27
BasicStructure specifies the lattice and atomic basis of a crystal.
Class representing a Molecule.
Definition: Molecule.hh:93
Eigen::Matrix3d frac2cart(const Eigen::Ref< const Eigen::Matrix3d > &frac_mat, const Lattice &lat)
Returns 'cart_mat' which is transformation of 'frac_mat' if cart_vec_after = cart_mat*cart_vec then f...
Definition: Lattice.hh:270
Eigen::Matrix3d cart2frac(const Eigen::Ref< const Eigen::Matrix3d > &cart_mat, const Lattice &lat)
Returns 'frac_mat' which is transformation of 'cart_mat' if cart_vec_after = cart_mat*cart_vec then f...
Definition: Lattice.hh:258
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
COORD_TYPE
Definition: enum.hh:6
void write_prim(const xtal::BasicStructure &prim, fs::path filename, COORD_TYPE mode, bool include_va=false)
Write prim.json to file.
Eigen::Matrix3d Matrix3d
xtal::BasicStructure read_prim(fs::path filename, double xtal_tol, ParsingDictionary< AnisoValTraits > const *_aniso_val_dict=nullptr)
void from_json(ClexDescription &desc, const jsonParser &json)
Helper struct for constructing objects that need additional data.
Definition: jsonParser.hh:548
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:551