21 std::shared_ptr<Structure const> open_shared_prim(fs::path root) {
23 return std::make_shared<Structure const>(
24 read_prim(settings.dir().prim(), settings.crystallography_tol()));
28 struct SupercellInfoData {
29 SupercellInfoData(std::shared_ptr<Structure const> _shared_prim,
30 SupercellSymInfo
const &_supercell_sym_info)
39 template <
typename ValueType>
40 using SupercellInfoFormatter =
41 GenericDatumFormatter<ValueType, SupercellInfoData>;
43 SupercellInfoFormatter<std::string> supercell_name() {
44 return SupercellInfoFormatter<std::string>(
46 "A name given to all equivalent super lattices of the prim lattice. See "
47 "the input option `supercell_name` for a more detailed description.",
48 [](SupercellInfoData
const &data) -> std::string {
50 data.supercell_sym_info.prim_lattice(),
51 data.supercell_sym_info.supercell_lattice());
55 SupercellInfoFormatter<std::string> canonical_supercell_name() {
56 return SupercellInfoFormatter<std::string>(
57 "canonical_supercell_name",
58 "Name of the canonical equivalent supercell. See the input option "
59 "`supercell_name` for a more detailed description.",
60 [](SupercellInfoData
const &data) -> std::string {
62 data.shared_prim->point_group(),
63 data.supercell_sym_info.prim_lattice(),
64 data.supercell_sym_info.supercell_lattice());
72 template <
typename ToType,
typename FromType>
78 return adaptable.supercell_sym_info;
86 DataFormatterDictionary<SupercellInfoData> make_supercell_info_dict() {
87 DataFormatterDictionary<SupercellInfoData> supercell_info_dict;
90 supercell_info_dict.insert(supercell_name(), canonical_supercell_name());
93 auto sym_info_dict = make_dictionary<SupercellSymInfo>();
94 for (
auto it = sym_info_dict.begin(); it != sym_info_dict.end(); ++it) {
96 supercell_info_dict.insert(
97 make_datum_formatter_adapter<SupercellInfoData, SupercellSymInfo>(
102 return supercell_info_dict;
109 "Get information about a supercell. The supercell is specified by \n"
110 "the prim and one of the following (else the primitive cell is \n"
112 "- transformation_matrix_to_super \n"
113 "- supercell_lattice_vectors \n"
114 "- supercell_lattice_column_matrix \n"
115 "- supercell_name \n\n";
117 std::string custom_options =
118 " prim: JSON object (optional, default=prim of current project) \n"
119 " See `casm format --prim` for details on the prim format. \n\n"
121 " transformation_matrix_to_super: 3x3 array of integer (optional) \n"
122 " Transformation matrix T, defining the supercell lattice vectors\n"
123 " S, in terms of the prim lattice vectors, P: `S = P * T`, where \n"
124 " S and P are column vector matrices. \n\n"
126 " supercell_lattice_vectors: 3x3 array of integer (optional) \n"
127 " Supercell lattice vectors, as a row vector matrix. \n\n"
129 " supercell_lattice_column_matrix: 3x3 array of integer (optional) \n"
130 " Supercell lattice vectors, as a column vector matrix. \n\n"
132 " supercell_name: string (optional) \n"
133 " A name given to all equivalent super lattices of the prim \n"
134 " lattice. From all super lattices which are equivalent via \n"
135 " crystal point group operations of prim, the canonical super \n"
136 " lattice is the equivalent lattice in niggli form which has the \n"
137 " most favorable orientation according to the CASM orientation \n"
138 " comparision criteria. These criteria compare the lattices as \n"
139 " column vector matrices and first favor symmetric matrices and \n"
140 " then favor non-negative lattice vectors which are aligned \n"
141 " nearest to the Cartesian axes. \n\n"
143 " For the canonical super lattice, the name is constructed from \n"
144 " the hermite normal form of `transformation_matrix_to_super`. \n"
145 " For a non-canonical super lattice, the name is the constructed \n"
146 " from the name of the canonical super lattice and the index of \n"
147 " the prim factor group operation that (excluding the shift) \n"
148 " transforms the canonical super lattice into this super lattice.\n"
150 " Example 1: Canonical supercell name \n"
152 " \"SCEL8_4_2_1_1_3_2\" \n"
154 " Example 2: Non-canonical supercell name representing a \n"
155 " re-orientation by application of prim factor group operation \n"
156 " with index 2 (indexing starting at 0). \n"
158 " \"SCEL8_4_2_1_1_3_2.2\" \n\n"
160 " properties: array of string (optional, default=[]) \n"
161 " An array of strings specifying which supercell properties to \n"
162 " output. The default value of an empty array will print all \n"
163 " properties. The allowed options are: \n\n";
165 std::stringstream ss;
166 auto dict = make_supercell_info_dict();
180 std::runtime_error error_if_invalid{
"Error reading SupercellInfo input"};
184 if (parser.self.contains(
"prim")) {
188 if (parser.valid()) {
189 shared_prim = std::make_shared<Structure const>(basic_structure);
200 }
catch (std::exception &e) {
201 parser.insert_error(
"prim", e.what());
204 std::stringstream msg;
205 msg <<
"Error in SupercellInfo: No \"prim\" in input and no project "
208 parser.insert_error(
"prim", msg.str());
214 if (parser.self.contains(
"transformation_matrix_to_super")) {
215 parser.optional(T,
"transformation_matrix_to_super");
218 }
else if (parser.self.contains(
"supercell_lattice_vectors")) {
220 parser.optional(L_transpose,
"supercell_lattice_vectors");
221 Lattice super_lattice{L_transpose.transpose()};
226 }
else if (parser.self.contains(
"supercell_lattice_column_matrix")) {
228 parser.optional(L,
"supercell_lattice_column_matrix");
234 }
else if (parser.self.contains(
"supercell_name")) {
235 std::string supercell_name;
236 parser.optional(supercell_name,
"supercell_name");
257 make_supercell_info_dict();
261 auto it = supercell_info_dict.
begin();
262 for (; it != supercell_info_dict.
end(); ++it) {
273 formatter.to_json(data, json);
274 log << json << std::endl;
SupercellSymInfo const & supercell_sym_info
std::shared_ptr< Structure const > shared_prim
PrimClex is the top-level data structure for a CASM project.
void run(jsonParser const &json_options, PrimClex const *primclex=nullptr) const override
Run prim info method.
std::string desc() const override
std::string name() const override
Enumeration method name (i.e. "prim", "supercell", "dof_space", etc.)
A class that collects all symmetry information for for performing symmetry transformations on the sit...
BasicStructure specifies the lattice and atomic basis of a crystal.
const Eigen::Matrix3l & transformation_matrix_to_super() const
Lattice make_superlattice(const Lattice &lat, const Eigen::Matrix< IntegralType, 3, 3, Options > &transf_mat)
Returns a super Lattice. Transformation matrix must be integer.
ProjectSettings open_project_settings(fs::path path_in_project)
xtal::Superlattice make_superlattice_from_supercell_name(Structure const &prim, std::string supercell_name)
Construct a Superlattice from the supercell name.
std::string make_canonical_supercell_name(Structure const &prim, xtal::Superlattice const &superlattice)
Make the canonical supercell name from a Superlattice.
std::string make_supercell_name(Structure const &prim, xtal::Superlattice const &superlattice)
Make the supercell name from a Superlattice.
ConfigIO::GenericConfigFormatter< jsonParser > properties()
IdentitySymRepBuilder Identity()
Eigen::Matrix3l make_transformation_matrix_to_super(const Lattice &tiling_unit, const Lattice &superlattice, double tol)
std::string description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to string.
xtal::BasicStructure read_prim(fs::path filename, double xtal_tol, ParsingDictionary< AnisoValTraits > const *_aniso_val_dict=nullptr)
fs::path find_casmroot(const fs::path &cwd)
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
SupercellSymInfo make_supercell_sym_info(Structure const &prim, Lattice const &super_lattice)
Matrix< long int, 3, 3 > Matrix3l
SupercellSymInfo const & operator()(SupercellInfoData const &adaptable) const