20 std::string custom_options =
21 " n_config: integer (optional, default=100) \n"
22 " How many random configurations to generate. Includes duplicate and "
24 " existing configurations. "
27 " magnitude: positive number (optional, default=1.0) \n"
28 " Magnitude used to scale random vector at each site. If "
29 "\"distribution\" == \"normal\",\n"
30 " magnitude specifies standard deviation of D-dimensional Gaussian (D "
32 " site DoF value). If \"distribution\" == \"uniform\", magnitude is "
33 "radius of D-dimensional\n"
34 " ball from which random vectors are chosen.\n\n"
36 " dof: string (required) \n"
37 " Name of site degree of freecom for which normal coordinates are to "
39 " Must be one of the degrees of freedom under consideration in the "
41 " as determined by prim.json\n\n"
43 " distribution: string (optional, default=\"normal\") \n"
44 " Distribution from which perturbation vectors are drawn. Options are "
46 " (i.e., uniform on the unit sphere), or \"normal\" (i.e., "
47 "zero-centered Gaussian).\n\n";
49 std::string examples =
51 " To enumerate 200 random occupations in supercells up to and "
53 " casm enum --method ConfigEnumRandomLocal -i \n"
54 " '{\"supercells\":{\"max\":4}, \"n_config\": 200}' \n"
56 " To enumerate 200 random occupations in all existing supercells:\n"
57 " casm enum --method ConfigEnumRandomLocal -i '{\"n_config\": 200}' "
60 " To enumerate 100 random occupations in all existing supercells:\n"
61 " casm enum --method ConfigEnumRandomLocal --all \n"
63 " To enumerate 200 random occupations in particular supercells:\n"
64 " casm enum --method ConfigEnumRandomLocal -i \n"
67 " \"SCEL1_1_1_1_0_0_0\",\n"
68 " \"SCEL2_1_2_1_0_0_0\",\n"
69 " \"SCEL4_1_4_1_0_0_0\"\n"
71 " \"n_config\": 200\n"
86 bool normal_distribution;
92 std::string distribution_name;
94 std::string{
"normal"});
95 if (distribution_name ==
"normal") {
96 normal_distribution =
true;
97 }
else if (distribution_name ==
"uniform") {
98 normal_distribution =
false;
100 std::stringstream msg;
101 msg <<
"Error: \"distribution\" must be \"normal\" (default) or "
103 parser.
error.insert(msg.str());
106 parser.
value = notstd::make_unique<ConfigEnumRandomLocalParams>(
107 mtrand, dof_key, n_config, mag, normal_distribution);
112 jsonParser const &cli_options_as_json)
const {
118 std::runtime_error error_if_invalid{
119 "Error reading ConfigEnumRandomLocal JSON input"};
135 auto input_parser_ptr =
136 parser.
parse_as<std::vector<std::pair<std::string, ConfigEnumInput>>>(
140 auto const &named_initial_states = *input_parser_ptr->value;
146 auto random_local_params_parser_ptr =
150 *random_local_params_parser_ptr->value;
154 auto make_enumerator_f = [&](
Index index, std::string
name,
162 formatter.
push_back(ConfigEnumIO::name<ConfigEnumDataType>(),
163 ConfigEnumIO::selected<ConfigEnumDataType>(),
164 ConfigEnumIO::is_new<ConfigEnumDataType>(),
165 ConfigEnumIO::is_existing<ConfigEnumDataType>());
168 ConfigEnumIO::is_excluded_by_filter<ConfigEnumDataType>());
171 ConfigEnumIO::initial_state_index<ConfigEnumDataType>(),
172 ConfigEnumIO::initial_state_name<ConfigEnumDataType>(),
173 ConfigEnumIO::initial_state_configname<ConfigEnumDataType>(),
174 ConfigEnumIO::n_selected_sites<ConfigEnumDataType>());
177 log.
begin(
"ConfigEnumRandomLocal enumeration");
180 named_initial_states.begin(),
181 named_initial_states.end(), formatter);
Enumerate random values for continuous degrees of freedom.
static const std::string enumerator_name
std::string desc() const override
void run(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json) const override
std::string name() const override
Enumeration method name (i.e. "ConfigEnumAllOccupations")
void end_section()
End a section.
void set_verbosity(int _verbosity)
void custom(const std::string &what)
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.
ConfigEnumData< ConfigEnumSiteDoFs, ConfigEnumInput > ConfigEnumDataType
std::string standard_ConfigEnumInput_help()
void print_initial_states(Log &log, NamedInitialStatesType const &named_initial_states)
ParentInputParser make_enum_parent_parser(Log &log, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Combine –input / –settings JSON with CLI options.
void enumerate_configurations(PrimClex const &primclex, ConfigEnumOptions const &options, MakeEnumeratorFunction make_enumerator_f, InputNameValuePairIterator name_value_pairs_begin, InputNameValuePairIterator name_value_pairs_end, DataFormatter< ConfigEnumDataType > const &formatter)
Enumerate configurations.
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
void print_options(Log &log, ConfigEnumOptions const &options)
INDEX_TYPE Index
For long integer indexing:
void parse(InputParser< ConfigEnumOptions > &parser, std::string method_name, PrimClex const &primclex, DataFormatterDictionary< Configuration > const &dict)
Options for the enumerate_configurations function.
int verbosity
Printing verbosity level.
std::function< bool(Configuration const &)> filter
If filter(configuration)==true, keep configuration, else skip.
Parameters controlling ConfigEnumRandomLocal.
std::set< std::string > error