14 namespace DoFSpaceIO {
18 std::map<std::string, std::string> cli_to_combined_keys{
19 {
"scelnames",
"scelnames"},
20 {
"confignames",
"confignames"},
21 {
"selection",
"config_selection"},
23 {
"calc_wedge",
"calc_wedge"}
38 std::set<std::string> do_not_allow{
"scelnames",
"supercell_selection",
39 "supercells",
"sublats",
40 "sites",
"cluster_specs"};
42 for (
auto key : do_not_allow) {
44 std::stringstream msg;
45 msg <<
"Error in dof_space_analysis: \"" << key
46 <<
"\" is not an allowed option.";
47 parser.
error.insert(msg.str());
60 for (
DoFKey const &dof : dofs) {
63 std::stringstream msg;
64 msg <<
"Error parsing \"dofs\": \"" << dof <<
"\" is invalid.";
65 parser.
error.insert(msg.str());
76 "Analyze DoF spaces (--dof-space-analysis): \n\n"
78 " The --dof-space-analysis option writes a symmetry analysis of one or "
85 " - Specify one or more DoF spaces and a symmetry group via selection "
87 " configurations and DoF type. "
89 " - The supercell, selected sites, DoF type, and subspace determine "
93 " - The configuration factor group (symmetry operations that keep the "
95 " supercell lattice and the configuration DoF values invariant) is "
97 " for symmetry analysis. "
99 " - The analysis finds irreducible representations of the DoF vector "
101 " optionally calculates the symmetrically unique wedges in that "
104 std::string custom_options =
106 " JSON options (--input or --settings): "
109 " dofs: array of string (optional, override with --dofs) "
111 " Name of degree of freedoms for which the DoF space analysis is "
113 " for each input configuration. The default includes all DoF types "
118 " calc_wedge: bool (optional, default=false, override with "
120 " Perform calculation of irreducible wedge (may significantly slow "
125 " write_symmetry: bool (optional, default=true) "
127 " If true (default), write the lattice point group, factor group "
129 " leave the configuration and selected sites invariant), and "
131 " group (factor group operations excluding translations) of the "
136 " write_structure: bool (optional, default=true) "
138 " If true (default), write a \"structure.json\" file containing the "
140 " generated from the configuration DoF. "
143 " output_type: string (optional, default=\"symmetry_directory\") "
145 " Selects how output files are written. Options are: "
148 " \"symmetry_directory\": (default) "
150 " If selected, only accepts \"confignames\" and "
151 "\"config_selection\" \n"
152 " to specify the initial state for analysis and the results are "
154 " dedicated folders in the CASM project symmetry directory: "
156 " \"<project_path>/symmetry/analysis/<configname>\". "
161 " If selected, accept any input for specifying the initial state "
163 " analysis, including \"scelnames\", \"supercell_selection\", "
165 " \"sublats\", \"sites\", and \"cluster_specs\", and the results "
167 " in indexed folders "
168 "\"<output_dir>/dof_space_analysis/state.<index>\". \n\n"
170 " \"combined_json\": "
172 " If selected, accept any input for specifying the initial state "
174 " analysis, including \"scelnames\", \"supercell_selection\", "
176 " \"sublats\", \"sites\", and \"cluster_specs\", and the results "
178 " in a single JSON file \"<output_dir>/dof_space_analysis.json\" "
180 " of being written separately. "
183 " output_dir: string (optional, default=current path) "
185 " Selects where output files are written. "
207 using namespace DoFSpaceIO;
212 log.
indent() <<
"json_options:\n" << json_options << std::endl << std::endl;
214 << cli_options_as_json << std::endl
220 json_options, cli_options_as_json);
222 log.
indent() <<
"Input:\n" << json_combined << std::endl << std::endl;
226 std::runtime_error error_if_invalid{
227 "Error reading `casm sym --dof-space-analysis` input"};
231 DoFSpaceAnalysisOptions options;
237 parser.optional_else(options.calc_wedge,
"calc_wedge",
false);
240 parser.optional_else(options.write_symmetry,
"write_symmetry",
true);
243 parser.optional_else(options.write_structure,
"write_structure",
true);
247 std::string output_type;
248 parser.optional_else(output_type,
"output_type",
249 std::string(
"symmetry_directory"));
253 parser.optional_else(output_dir,
"output_dir", fs::current_path());
257 typedef std::vector<std::pair<std::string, ConfigEnumInput>>
258 NamedConfigEnumInput;
259 auto input_parser_ptr = parser.parse_as<NamedConfigEnumInput>(
263 auto const &named_inputs = *input_parser_ptr->value;
267 if (output_type ==
"combined_json") {
270 CombinedJsonOutput output{output_dir};
272 }
else if (output_type ==
"sequential") {
275 SequentialDirectoryOutput output{output_dir};
277 }
else if (output_type ==
"symmetry_directory") {
283 SymmetryDirectoryOutput output{
primclex.dir()};
287 "Error: 'output_type' must be one of \"symmetry_directory\" (default), "
288 "\"sequential\", or \"combined_json\"";
289 parser.insert_error(
"output_type", msg);
void end_section()
End a section.
Log & subsection()
Create a subsection.
void begin(const std::string &what)
PrimClex is the top-level data structure for a CASM project.
Represents a supercell of the primitive parent crystal structure.
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
std::vector< DoFKey > all_dof_types(BasicStructure const &_struc)
jsonParser combine_dof_space_analysis_json_options(jsonParser const &json_options, jsonParser const &cli_options_as_json)
void parse_dofs(ParentInputParser &parser, std::vector< DoFKey > &dofs, std::vector< DoFKey > const &all_dof_types)
void dof_space_analysis(std::vector< std::pair< std::string, ConfigEnumInput >> const &named_inputs, DoFSpaceAnalysisOptions const &options, OutputImpl &output)
void require_database_configurations(ParentInputParser &parser)
std::string description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to string.
void dof_space_analysis(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Perform DoF space analysis.
jsonParser & combine_json_options(std::map< std::string, std::string > const &source_to_combined_keys, jsonParser const &json_source, jsonParser &json_combined)
Copy from json_source to json_combined
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
std::string dof_space_analysis_desc()
Describe DoF space analysis input.
std::string parse_ConfigEnumInput_desc()
A string describing the JSON format for parsing named ConfigEnumInput.
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
std::set< std::string > error