CASM  1.1.0
A Clusters Approach to Statistical Mechanics
SharedPrim_data_io.cc
Go to the documentation of this file.
2 
10 
11 namespace CASM {
12 
13 namespace SharedPrim_dataformatter_impl {
14 
15 typedef std::shared_ptr<const Structure> SharedPrim;
16 
17 // use for ValueType=bool, int, double, std::string, jsonParser
18 template <typename ValueType>
20 
23 
26 
29 
32 
33 // -- lattice point group info
34 
37  "lattice_point_group", "Lattice point group, in JSON format.",
38  [](SharedPrim const &shared_prim) -> jsonParser {
39  SymGroup lattice_pg{
41  jsonParser json;
42  write_symgroup(lattice_pg, json);
43  return json;
44  });
45 }
46 
49  "lattice_point_group_name", "Lattice point group name.",
50  [](SharedPrim const &shared_prim) -> std::string {
51  SymGroup lattice_pg{
53  return lattice_pg.get_name();
54  });
55 }
56 
59  "lattice_point_group_size", "Lattice point group size.",
60  [](SharedPrim const &shared_prim) -> Index {
61  SymGroup lattice_pg{
63  return lattice_pg.size();
64  });
65 }
66 
67 // -- factor group info
68 
71  "factor_group", "Factor group, in JSON format.",
72  [](SharedPrim const &shared_prim) -> jsonParser {
73  jsonParser json;
74  write_symgroup(shared_prim->factor_group(), json);
75  return json;
76  });
77 }
78 
81  "factor_group_name", "Factor group name.",
82  [](SharedPrim const &shared_prim) -> std::string {
83  return shared_prim->factor_group().get_name();
84  });
85 }
86 
88  return SharedPrimFormatter<Index>("factor_group_size", "Factor group size.",
89  [](SharedPrim const &shared_prim) -> Index {
90  return shared_prim->factor_group().size();
91  });
92 }
93 
94 // -- crystal point group info
95 
98  "crystal_point_group", "Crystal point group, in JSON format.",
99  [](SharedPrim const &shared_prim) -> jsonParser {
100  jsonParser json;
101  write_symgroup(shared_prim->point_group(), json);
102  return json;
103  });
104 }
105 
108  "crystal_point_group_name", "Crystal point group name.",
109  [](SharedPrim const &shared_prim) -> std::string {
110  return shared_prim->point_group().get_name();
111  });
112 }
113 
115  return SharedPrimFormatter<Index>("crystal_point_group_size",
116  "Crystal point group size",
117  [](SharedPrim const &shared_prim) -> Index {
118  return shared_prim->point_group().size();
119  });
120 }
121 
124  "basis_rep",
125  "Describes how integral site coordinates transform under application of "
126  "symmetry. The element `basis_rep[i]` contains `matrix`, "
127  "`sublattice_permute`, and `sublattice_shift`, which describe how the "
128  "`i`th factor group operation transforms a basis site (b, r_frac) -> "
129  "(b', r_frac') according to: `b' = sublattice_permute[b]` and `r_frac' = "
130  "matrix * r_frac + sublattice_shift[b]`, where `b` is the basis "
131  "index and `r_frac` is the integer unit cell coordinate of a site.",
132  [](SharedPrim const &shared_prim) -> jsonParser {
133  jsonParser json;
134  write_basis_permutation_rep(shared_prim->factor_group(), json,
135  shared_prim->basis_permutation_symrep_ID());
136  return json;
137  });
138 }
139 
142  "occ_permutation_rep",
143  "The permutation occ_permutation_rep[b][i] describes how the `i`th "
144  "factor group operation transforms anisotropic occupant values on "
145  "sublattice `b`. The convention when applying symmetry operations to "
146  "transform occupation values is to first transform the occupant value "
147  "on site `l` (which is on sublattice `b`) according to `occ(l) = "
148  "occ_permutation_rep[b][i][occ(l)]`, then to permute occupant values "
149  "among sites.",
150  [](SharedPrim const &shared_prim) -> jsonParser {
151  jsonParser json;
152  write_occ_permutation_rep(shared_prim->factor_group(), json,
153  shared_prim->occupant_symrep_IDs());
154  return json;
155  });
156 }
157 
158 // - matrix, vector<UnitCellCoord>, permutation
159 // basis_permutation_matrix_rep // vector<PermutationMatrix>
160 // occ_rep // vector<SymPermutation>
161 // site_dof_rep
162 // global_dof_rep
163 
166  "is_primitive", "Returns true if structure is the primitive structure",
167  [](SharedPrim const &shared_prim) -> double {
169  });
170 }
171 
174  "primitive", "Returns the primitive structure, in prim JSON format.",
175  [](SharedPrim const &shared_prim) -> jsonParser {
176  xtal::BasicStructure primitive_struc =
177  xtal::make_primitive(*shared_prim, shared_prim->lattice().tol());
178 
179  jsonParser json;
180  bool include_va = false;
181  return to_json(primitive_struc, json, FRAC, include_va);
182  });
183 }
184 
187  "volume", "Prim cell volume (length^3)",
188  [](SharedPrim const &shared_prim) -> double {
189  return shared_prim->lattice().volume();
190  });
191 }
192 
195  "lattice", "Lattice vectors, unrolled: (a0, a1, a2, b0, ...)",
196  [](SharedPrim const &shared_prim) -> Eigen::VectorXd {
197  Eigen::Matrix<double, 3, 3, Eigen::ColMajor> L =
198  shared_prim->lattice().lat_column_mat();
199  return Eigen::Map<Eigen::VectorXd>(L.data(), L.size());
200  });
201 }
202 
205  "lattice_column_matrix", "Lattice vectors, as column vector matrix",
206  [](SharedPrim const &shared_prim) -> Eigen::MatrixXd {
207  return shared_prim->lattice().lat_column_mat();
208  });
209 }
210 
213  "lattice_params", "Lattice parameters, as: (a, b, c, alpha, beta, gamma)",
214  [](SharedPrim const &shared_prim) -> Eigen::VectorXd {
215  Eigen::VectorXd res(6);
216  Lattice const &lattice = shared_prim->lattice();
217  res << lattice.length(0), lattice.length(1), lattice.length(2),
218  lattice.angle(0), lattice.angle(1), lattice.angle(2);
219  return res;
220  });
221 }
222 
225  "asymmetric_unit", "Sets of indices of equivalent basis sites",
226  [](SharedPrim const &shared_prim) -> jsonParser {
228  auto symop_vector = adapter(shared_prim->factor_group().begin(),
229  shared_prim->factor_group().end());
230  auto asym_unit =
231  xtal::make_asymmetric_unit(shared_prim->structure(), symop_vector);
232  jsonParser json;
233  to_json(asym_unit, json);
234  return json;
235  });
236 }
237 
238 } // namespace SharedPrim_dataformatter_impl
239 
240 template <>
241 DataFormatterDictionary<std::shared_ptr<const Structure>>
242 make_attribute_dictionary<std::shared_ptr<const Structure>>() {
243  using namespace SharedPrim_dataformatter_impl;
244  DataFormatterDictionary<SharedPrim> dict;
251  asymmetric_unit());
252 
253  return dict;
254 }
255 
256 } // namespace CASM
std::shared_ptr< Structure const > shared_prim
A DatumFormatter that returns a 1D value of specified type, via functions that may be specified at ru...
A DatumFormatter that returns a 2D value of specified type, via functions that may be specified at ru...
A DatumFormatter that returns a value of specified type, via functions that may be specified at runti...
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
Definition: SymGroup.hh:42
const std::string & get_name() const
Definition: SymGroup.cc:1668
static SymGroup lattice_point_group(Lattice const &_lat)
Definition: SymGroup.cc:779
BasicStructure specifies the lattice and atomic basis of a crystal.
VectorXdSharedPrimFormatter lattice()
SharedPrimFormatter< std::string > lattice_point_group_name()
SharedPrimFormatter< Index > crystal_point_group_size()
SharedPrimFormatter< Index > factor_group_size()
Generic2DDatumFormatter< Eigen::MatrixXd, SharedPrim > MatrixXdSharedPrimFormatter
SharedPrimFormatter< jsonParser > factor_group()
SharedPrimFormatter< jsonParser > occ_permutation_rep()
MatrixXdSharedPrimFormatter lattice_column_matrix()
SharedPrimFormatter< jsonParser > asymmetric_unit()
SharedPrimFormatter< jsonParser > primitive()
SharedPrimFormatter< std::string > crystal_point_group_name()
Generic2DDatumFormatter< Eigen::MatrixXi, SharedPrim > MatrixXiSharedPrimFormatter
std::shared_ptr< const Structure > SharedPrim
SharedPrimFormatter< Index > lattice_point_group_size()
Generic1DDatumFormatter< Eigen::VectorXi, SharedPrim > VectorXiSharedPrimFormatter
VectorXdSharedPrimFormatter lattice_params()
SharedPrimFormatter< double > volume()
SharedPrimFormatter< jsonParser > lattice_point_group()
Generic1DDatumFormatter< Eigen::VectorXd, SharedPrim > VectorXdSharedPrimFormatter
SharedPrimFormatter< std::string > factor_group_name()
SharedPrimFormatter< bool > is_primitive()
SharedPrimFormatter< jsonParser > crystal_point_group()
SharedPrimFormatter< jsonParser > basis_rep()
std::set< std::set< Index > > make_asymmetric_unit(const xtal::BasicStructure &struc, const std::vector< SymOp > &factor_group)
Return indices of equivalent basis sites.
BasicStructure make_primitive(const BasicStructure &non_primitive_struc, double tol=TOL)
Returns the smallest possible tiling unit of the given structure.
bool is_primitive(const BasicStructure &struc, double tol=TOL)
Main CASM namespace.
Definition: APICommand.hh:8
Eigen::MatrixXd MatrixXd
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
const COORD_TYPE FRAC
Definition: enum.hh:8
void write_symgroup(SymGroup const &grp, jsonParser &json)
void write_occ_permutation_rep(SymGroup const &grp, jsonParser &json, std::vector< SymGroupRepID > occupant_symrep_IDs)
void write_basis_permutation_rep(SymGroup const &grp, jsonParser &json, SymGroupRepID symgrouprep_id)
Describes how integral site coordinates transform under application of symmetry.
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
Eigen::VectorXd VectorXd