CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ScelEnumInterface.cc
Go to the documentation of this file.
2 
3 #include "casm/app/APICommand.hh"
9 #include "casm/clex/ScelEnum.hh"
11 
12 namespace CASM {
13 
14 std::string ScelEnumInterface::desc() const {
15  return
16 
17  "ScelEnum: \n\n"
18 
19  " min: int, >0 (optional, default=1, override with --min) "
20  "\n"
21  " The minimum volume supercell to enumerate. The volume is measured "
22  "\n"
23  " relative the unit cell being used to generate supercells. "
24  "\n"
25  "\n"
26  " max: int, >= min (optional, override with --max) "
27  "\n"
28  " The maximum volume supercell to enumerate. The volume is measured "
29  "\n"
30  " relative the unit cell being used to generate supercells. One of "
31  "\n"
32  " \"max\" or \"all\" must be given. "
33  "\n"
34  "\n"
35  " dirs: string (optional, default=\"abc\")\n"
36  " This option may be used to restrict the supercell enumeration to 1, "
37  "\n"
38  " 2 or 3 of the lattice vectors, to get 1-, 2-, or 3-dimensional "
39  "\n"
40  " supercells. By specifying combinations of 'a', 'b', and 'c', you "
41  "\n"
42  " determine which of the unit cell lattice vectors you want to "
43  "\n"
44  " enumerate over. For example, to enumerate 1-dimensional supercells "
45  "\n"
46  " along the 'c' use \"dirs\":\"c\". If you want 2-dimensional "
47  "\n"
48  " supercells along the 'a' and 'c' lattice vectors, specify "
49  "\n"
50  " \"dirs\":\"ac\". \n"
51  "\n"
52  " unit_cell: 3x3 matrix of int, or string (default=identity matrix) "
53  "\n"
54  " This option may be used to specify the unit cell. It may be "
55  "\n"
56  " specified using a 3x3 matrix of int, representing the "
57  "transformation\n"
58  " matrix, T, such that U = P*T, where P are the primitive lattice "
59  "\n"
60  " and U are the unit cell lattice vectors. For example, a unit cell "
61  "\n"
62  " that whose lattice vectors are (2*a+b, b, c) (with respect to the "
63  "\n"
64  " the primitive cell vectors) could be specified using:\n"
65  "\n"
66  " \"unit_cell\" : [\n"
67  " [2, 0, 0],\n"
68  " [1, 1, 0],\n"
69  " [0, 0, 1]\n"
70  " ]\n"
71  "\n"
72  " Or it may be specified with the name of an existing supercell to "
73  "use as \n"
74  " the unit cell, for example: \n"
75  "\n"
76  " \"unit_cell\" : \"SCEL2_1_1_2_0_0_0\"\n"
77  "\n"
78  " filter: string (optional, default=None, override with --filter)\n"
79  " A query command to use to filter which Configurations are kept. "
80  " \n\n"
81  "\n"
82  " dry_run: bool (optional, default=false, override with --dry-run)\n"
83  " Perform dry run.\n"
84  "\n"
85  "Examples:\n"
86  "\n"
87  " To enumerate supercells up to and including size 4:\n"
88  " casm enum --method ScelEnum -i '{\"max\": 4}' \n"
89  "\n"
90  " To enumerate 2d supercells up to and including size 4:\n"
91  " casm enum --method ScelEnum -i '{\"max\": 4, \"dirs\": \"ab\"}' \n"
92  "\n"
93  " If the prim is primitive FCC, two dimensional supercells of the \n"
94  " conventional FCC unit cell up to and including 4x the unit cell "
95  "volume\n"
96  " could be enumerated using:\n"
97  "\n"
98  " casm enum --method ScelEnum -i \n"
99  " '{\n"
100  " \"min\": 1,\n"
101  " \"max\": 4,\n"
102  " \"dirs\": \"ab\",\n"
103  " \"unit_cell\" : [\n"
104  " [-1, 1, 1],\n"
105  " [ 1, -1, 1],\n"
106  " [ 1, 1, -1]\n"
107  " ]\n"
108  " }'\n"
109  "\n";
110 }
111 
112 std::string ScelEnumInterface::name() const { return "ScelEnum"; }
113 
115  jsonParser const &cli_options_as_json) const {
116  // combine JSON options and CLI options
117  jsonParser json_combined =
118  combine_supercell_enum_json_options(json_options, cli_options_as_json);
119 
120  // Read input data from JSON
121  ParentInputParser parser{json_combined};
122  std::runtime_error error_if_invalid{"Error reading ScelEnum JSON input"};
123 
124  auto options_parser_ptr = parser.parse_as<EnumerateSupercellsOptions>(
126  primclex.settings().query_handler<Supercell>().dict());
127  report_and_throw_if_invalid(parser, log(), error_if_invalid);
128  EnumerateSupercellsOptions const &options = *options_parser_ptr->value;
129  log().set_verbosity(options.verbosity);
130 
131  auto scel_enum_props_parser_ptr =
132  parser.parse_as<xtal::ScelEnumProps>(primclex.db<Supercell>());
133  xtal::ScelEnumProps const &scel_enum_props =
134  *scel_enum_props_parser_ptr->value;
135 
136  ScelEnumByProps enumerator{primclex.shared_prim(), scel_enum_props};
137  enumerate_supercells(options, enumerator, primclex.db<Supercell>());
138 }
139 
140 } // namespace CASM
void set_verbosity(int _verbosity)
Definition: Log.cc:57
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
static const std::string enumerator_name
Definition: ScelEnum.hh:45
void run(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json) const override
std::string desc() const override
std::string name() const override
Enumeration method name (i.e. "ConfigEnumAllOccupations")
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
Data structure for holding supercell enumeration properties.
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser combine_supercell_enum_json_options(jsonParser const &json_options, jsonParser const &cli_options_as_json)
Log & log()
Definition: Log.hh:424
void enumerate_supercells(EnumerateSupercellsOptions const &options, EnumeratorType &enumerator, DB::Database< Supercell > &supercell_db)
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
PrimClex * primclex
Definition: settings.cc:135
Options for the enumerate_supercells function.
int verbosity
Printing verbosity level.