28 "The ConfigEnumSiteDoFs method generates configurations corresponding "
29 "excitations of collective \n"
30 "site DoF (normal) modes. The input consists of three components:\n\n"
32 "1) Specification of one or more site DoF spaces to sample. This is done "
35 " - Choice of site DoF type\n"
36 " - Specification of one or more configurations.\n"
37 " - Selection of particular sites in the configuration(s). Sites may "
38 "be selected by indicating\n"
39 " particular sites (\"sites\"), cluster of sites "
40 "(\"cluster_specs\"), or by all sites on\n"
41 " particular sublattices (\"sublats\"). By default, if none are "
42 "specified, then all sites in\n"
43 " the configuration are selected.\n\n"
45 " The total dimension of the specified site DoF space is equal to the "
46 "sum over all chosen\n"
47 " sites of the site DoF axes dimension. If the site DoF axes are the "
48 "same on all selected\n"
49 " sites, then the total dimension is (number of sites x site DoF "
50 "dimension). If the site\n"
51 " DoF space is restricted on some sublattices, then the total "
52 "dimension may be smaller.\n\n"
55 " - The standard \"disp\" basis is used on all sublattices. If 4 "
56 "sites are selected:\n"
57 " - The total site DoF space dimension is 12 = (4 sites) * (3 "
59 " - The standard \"disp\" basis is used on sublattice b=0, and on "
60 "sublattice b=1 the\n"
61 " \"disp\" axes are set to only allow 1 dimensional displacements. "
63 " sublattice b=0 are selected and 1 site from the sublattice b=1 "
65 " - The total site DoF space dimension is 7 =\n"
66 " (2 sites from sublattice b=0) * (3 dimensional disp) +\n"
67 " (1 site from sublatice b=1) * (1 dimensional disp)\n\n"
69 " Notes on \"cluster_specs\":\n"
70 " - The \"cluster_specs\" option may not be used with the \"sites\" "
71 "or \"sublats\" options.\n"
72 " - The cluster orbits are generated using the configuration factor "
73 "group symmetry and\n"
74 " then any orbits that are duplicated under periodic boundary "
75 "conditions are removed.\n\n\n"
77 "2) Specification of a normal modes in the site DoF space. This can be "
79 " combination of the \"axes\" and \"sym_axes\" options:\n\n"
81 " - The parameter \"axes\" is an optional row matrix of normal "
82 "coordinate axes. If it is not\n"
83 " provided, then it is set to the identity matrix with dimension "
84 "equal to the dimension of\n"
85 " the site DoF space specified by the choice of configuration and "
86 "selected sites. It is not\n"
87 " required to be full rank (i.e. number of axes rows < number of "
88 "axes columns is valid), in\n"
89 " which case it means Configurations are generated in a subspace.\n\n"
91 " Notes on \"axes\":\n"
92 " - Each column in \"axes\" corresponds to an individual prim DoF, "
93 "which is printed to screen\n"
95 " - Column c: type=\"disp\", component=(\"dx\", [1, 0, 0]), "
96 "sublattice index=b, unit cell=(i,j,k)\n"
97 " - Column c: type=\"disp\", component=(\"dxy\", [1, 1, 0]), "
98 "sublattice index=b, unit cell=(i,j,k)\n"
99 " - Each row is an axis in the total site DoF space\n\n"
101 " - If the optional parameter \"sym_axes\" is true (default=false), "
102 "then CASM will generate\n"
103 " symmetry adapted normal coordinate axes in the space (may be a "
104 "subspace) specified by\n"
105 " \"axes\" for each initial enumeration state. This means that "
107 " - Finds the configuration factor group (symmetry operations that "
108 "keep the supercell\n"
109 " lattice invariant and the configuration DoF values invariant)\n"
110 " - Finds the subgroup which also keeps the selected sites invariant "
111 "(does not permute\n"
112 " selected sites with unselected sites)\n"
113 " - Calculates the irreducible subspaces of the site DoF space under "
115 " - Uses the axes of the irreducible subspaces as the normal "
116 "coordinate axes\n\n"
118 " Notes on \"sym_axes\":\n"
119 " - If \"sym_axes\"==false, the coordinate axes are used directly "
120 "for the normal modes\n"
121 " - If \"sym_axes\"==true, symmetry adapted normal modes are "
122 "generated in the subspace defined\n"
123 " by \"axes\" (default is total site DoF space) and printed to "
125 " - The symmetry adapted axes can also be calculated via the `casm "
127 " - The user may take the symmetry adapted axes, rotate the "
128 "irreducible subspaces, and use\n"
129 " that as the \"axes\" input, with \"sym_axes\"=false, to "
130 "customize the choice of normal\n"
131 " coordinates.\n\n\n"
133 "3) Choice of linear combinations of normal modes to apply to the chosen "
136 " Even if \"axes\" are rank deficient, the site DoF space defined by "
137 "axes may quickly become\n"
138 " very high dimensional (number of sites x mean site DoF dimension), "
139 "so rather than sample the\n"
140 " entire space, ConfigEnumSiteDoFs perturbs the input configuration by "
141 "applying a linear\n"
142 " combination of normal modes.\n\n"
144 " The amplitudes of the normal modes is specified with the \"min\", "
145 "\"increment\", and \"max\"\n"
146 " parameters. These may be scalar valued, to set sampled amplitudes to "
147 "be the same along each\n"
148 " normal coordinate axes dimension. Of they may be vector valued in "
149 "order to customize the\n"
150 " sampled amplitudes along different dimensions. If the total "
151 "dimension of the site DoF\n"
152 " varies with choice of input configurations and selected sites, then "
153 "only the scalar input\n"
154 " option is allowed.\n\n"
156 " The parameters \"min_nonzero\" and \"max_nonzero\" specifies how "
157 "many normal mode amplitudes\n"
158 " should be nonzero (inclusive range [min_nonzero, max_nonzero]). The "
160 " all n choose k (n=site DoF space dimension, k iterates through "
161 "[min_nonzer, max_nonzero])\n"
162 " combinations of normal modes in that range, and for each combination "
164 " k chosen normal modes with amplitudes specified by \"min\" / "
165 "\"increment\" / \"max\". Note that\n"
166 " this may quickly become very large, depending on n, k, and the range "
167 "specified by \"min\" /\n"
168 " \"increment\" / \"max\".\n\n";
170 std::string custom_options =
172 " dof: string (required) \n"
173 " Name of degree of freedom for which normal coordinates are to \n"
174 " be generated. Must be one of the degrees of freedom under \n"
175 " consideration in the current project, as specified in \n"
178 " axes: matrix or JSON object (optional) \n"
179 " Coordinate axes of the DoF grid. Default value is the identity \n"
180 " matrix of DoF space dimension Each element in an axis vector \n"
181 " correponds to an individual DoF. Each axis vector corresponds \n"
182 " to a normal mode. Use the option \n"
183 " `\"print_dof_space_and_quit\": true` to print DoF space \n"
184 " information with a glossary describing which DoF is specified \n"
185 " by which vector element. The 'axes' may be rank deficient \n"
186 " indicating enumeration should occur in a subspace of the full \n"
187 " DoF space specified by the \"dof\" value and initial \n"
188 " enumeration state. \n\n"
190 " Example if matrix (row vector matix): \n"
192 " [1, 1, 1, 1, 1, 1], \n"
193 " [1,-1, 0,-1, 1, 0], \n"
194 " [1,-1, 0, 1,-1, 0] \n"
197 " Example if JSON object (named axis vectors): \n"
199 " \"q1\": [1, 1, 1, 1, 1, 1], \n"
200 " \"q2\": [1,-1, 0,-1, 1, 0], \n"
201 " \"q3\": [1,-1, 0, 1,-1, 0] \n"
205 " - If some \"qi\" in the range [1, DoF space dimension] are \n"
206 " missing, then enumeration is performed in the subspace \n"
207 " specified by the axes that are provided. \n\n"
209 " sym_axes: bool (optional, default=false) \n"
210 " If true, constructs symmetry-adapted grid axes as the symmetry-\n"
211 " adapted DoF order parameters of the input state in the space \n"
212 " specified by \"axes\". Run with option \n"
213 " `\"print_dof_space_and_quit\": true` to obtain the analysis \n"
214 " report including the symmetry-adapted axes before doing the \n"
215 " enumeration. If `\"sym_axes\": true`, the enumeration grid may \n"
216 " not be specified using vector-valued \"min\", \"max\", \n"
217 " \"increment\", or \"num\". \n\n"
219 " exclude_homogeneous_modes: bool (optional, default=false) \n"
220 " If true, homogeneous modes are removed from \"axes\" before \n"
221 " construcing symmetry adapted axes. In the case of \"disp\" DoF, \n"
222 " this excludes all rigid translations. This option is allowed \n"
223 " only for `\"sym_axes\": true`. \n\n"
225 " print_dof_space_and_quit: boolean (optional, default=false) \n"
226 " If true, print DoF space information for each initial \n"
227 " enumeration state and quit. If `\"sym_axes\": true`, will also \n"
228 " print irreducible subspaces, symmetry-adapted axes, and axes \n"
229 " excluding homogeneous modes. \n\n"
231 " min: number, or array of numbers (optional) \n"
232 " Minimum, starting value of grid counter. If number, specifies \n"
233 " using a constant array of DoF space dimension with that given \n"
235 " Ex: \"min\" : -0.1 ( --> [-0.1, -0.1, ..., -0.1]) \n"
236 " If array, dimension must be equal to the \"axes\" dimension and\n"
237 " `\"sym_axes\" must be false`. \n"
238 " Ex: \"min\" : [-0.05, -0.1, -0.1] \n\n"
240 " max: number, or array of numbers (required) \n"
241 " Maximum, final value of grid counter. If number, specifies \n"
242 " using a constant array of DoF space dimension with that given \n"
244 " Ex: \"max\" : 0.1 ( --> [0.1, 0.1, ..., 0.1]) \n"
245 " If array, dimension must be equal to the \"axes\" dimension and\n"
246 " `\"sym_axes\" must be false`. \n"
247 " Ex: \"max\" : [0.05, 0.1, 0.1] \n\n"
249 " increment: number, or array of numbers (optional) \n"
250 " Amount by which to increment counter elements. If number, \n"
251 " specifies using a constant array of DoF space dimension with \n"
252 " that given value. \n"
253 " Ex: \"increment\" : 0.01 ( --> [0.01, 0.01, ..., 0.01]) \n"
254 " If array, dimension must be equal to the \"axes\" dimension and\n"
255 " `\"sym_axes\" must be false`. \n"
256 " Ex: \"increment\" : [0.005, 0.01, 0.01] \n"
257 " One of \"increment\" or \"num\" must be given. \n\n"
259 " num: int, or array of int (optional) \n"
260 " Number of values to include. Must be >= 1. If \"num\" is 1, \n"
261 " only include a point at the \"min\" value along specified \n"
262 " dimensions (this is equivalent to min=min, increment=(max-min),\n"
263 " max=max-increment/10.). If \"num\" is >1, include that many \n"
264 " points, including the \"min\" and \"max\" (this is equivalent \n"
265 " to min=min, increment=(max-min)/(num-1), max=max+inc/10.). \n"
266 " Ex: \"increment\" : 11 ( --> [11, 11, ..., 11]) \n"
267 " If array, dimension must be equal to the \"axes\" dimension. \n"
268 " Ex: \"num\" : [5, 11, 11] \n"
269 " One of \"increment\" or \"num\" must be given. \n\n"
271 " min_nonzero: integer (optional, default = 0) \n"
272 " Minimum number of coordinate amplitudes that are allowed \n"
273 " to be nonzero. Must be less than or equal to \"max_nonzero\". \n\n"
275 " max_nonzero: integer (optional, default = axes.rows()) \n"
276 " Maximum number of coordinate amplitudes that are allowed to be \n"
277 " nonzero. Must be less than or equal to the \"axes\" dimension. \n\n"
279 " output_dir: string (optional, default=current path) \n"
280 " Selects where output files are written. \n\n";
282 std::string examples =
284 " To enumerate all DoF perturbations of a particular configuration:\n"
285 " casm enum --method ConfigEnumSiteDoFs -i \n"
287 " \"confignames\": [ \n"
288 " \"SCEL4_1_4_1_0_0_0/3\"\n"
291 " \"increment\": 0.05, \n"
306 bool sym_axes_option,
bool exclude_homogeneous_modes) {
307 parser.
value = notstd::make_unique<ConfigEnumSiteDoFsParams>();
308 auto ¶ms = *parser.
value;
312 parser.
require(params.dof,
"dof");
316 params.dof, supercell.
prim(),
318 initial_state.
sites());
323 if (grid_parser->valid()) {
324 axes_params = *grid_parser->value;
327 if ((sym_axes_option || exclude_homogeneous_modes) &&
329 std::stringstream msg;
330 msg <<
"Error: Vector input for enumeration ranges (\"min\", \"max\", "
331 "\"increment\" or \"num\") is not allowed with `\"sym_axes\": true` "
332 "or `\"exclude_homogeneous_modes\": true`.";
333 throw std::runtime_error(msg.str());
345 Index{params.axes.cols()});
348 if (params.min_nonzero > params.max_nonzero) {
349 std::stringstream msg;
350 msg <<
"'min_nonzero' value exceeds 'max_nonzero' value" << std::endl;
351 parser.
error.insert(msg.str());
356 InputParser<std::vector<std::pair<std::string, ConfigEnumInput>>> &parser) {
361 if (parser.valid() && parser.value !=
nullptr) {
362 auto const &named_initial_states = *parser.value;
363 Index nsites = named_initial_states[0].second.sites().size();
364 for (
auto const &name_value_pair : named_initial_states) {
365 if (name_value_pair.second.sites().size() != nsites) {
366 std::stringstream msg;
367 msg <<
"Error in ConfigEnumSiteDoFs: Starting configurations or "
368 "supercells passed to "
369 "must all have the same number of selected sites.";
370 parser.error.insert(msg.str());
376 namespace ConfigEnumSiteDoFsInterface_impl {
386 bool _make_symmetry_adapted_axes,
387 bool _exclude_homogeneous_modes,
414 std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report)
const;
423 std::optional<SymRepTools_v2::VectorSpaceSymReport> sym_report;
448 std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report)
const {
452 log <<
"Performing DoF space analysis: " <<
name << std::endl;
470 formatter.
push_back(ConfigEnumIO::name<ConfigEnumDataType>(),
471 ConfigEnumIO::selected<ConfigEnumDataType>(),
472 ConfigEnumIO::is_new<ConfigEnumDataType>(),
473 ConfigEnumIO::is_existing<ConfigEnumDataType>());
476 ConfigEnumIO::is_excluded_by_filter<ConfigEnumDataType>());
479 ConfigEnumIO::initial_state_index<ConfigEnumDataType>(),
480 ConfigEnumIO::initial_state_name<ConfigEnumDataType>(),
481 ConfigEnumIO::initial_state_configname<ConfigEnumDataType>(),
482 ConfigEnumIO::n_selected_sites<ConfigEnumDataType>());
491 jsonParser const &cli_options_as_json)
const {
497 std::runtime_error error_if_invalid{
498 "Error reading ConfigEnumSiteDoFs JSON input"};
513 typedef std::vector<std::pair<std::string, ConfigEnumInput>>
514 NamedInitialEnumerationStates;
515 auto input_parser_ptr = parser.
parse_as<NamedInitialEnumerationStates>(
520 auto const &named_initial_states = *input_parser_ptr->value;
526 bool sym_axes_option;
528 log.
indent() <<
"sym_axes: " << std::boolalpha << sym_axes_option
532 bool exclude_homogeneous_modes;
533 parser.
optional_else(exclude_homogeneous_modes,
"exclude_homogeneous_modes",
535 log.
indent() <<
"exclude_homogeneous_modes: " << std::boolalpha
536 << exclude_homogeneous_modes << std::endl;
545 named_initial_states[0].second, axes_params, sym_axes_option,
546 exclude_homogeneous_modes);
549 log.
indent() <<
"axes: (column vectors) \n" << axes_params.
axes << std::endl;
564 bool print_dof_space_and_quit_option;
566 "print_dof_space_and_quit",
false);
570 parser.
optional_else(output_dir,
"output_dir", fs::current_path());
583 exclude_homogeneous_modes,
586 if (print_dof_space_and_quit_option) {
587 log.
begin(
"Print DoF Space and Quit Option");
588 log <<
"For large spaces this may be slow..." << std::endl;
589 std::optional<SymRepTools_v2::VectorSpaceSymReport> sym_report;
591 for (
auto const &pair : named_initial_states) {
592 std::string
const &
name = pair.first;
594 make_enumerator_f.make_and_write_dof_space(i,
name, initial_state,
603 log.
begin(
"ConfigEnumSiteDoFs enumeration");
605 primclex, options, make_enumerator_f, named_initial_states.begin(),
606 named_initial_states.end(), make_enumerator_f.make_formatter());
static const std::string enumerator_name
std::string name() const override
Enumeration method name (i.e. "ConfigEnumAllOccupations")
std::string desc() const override
void run(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json) const override
const Supercell & supercell() const
Get the Supercell for this Configuration.
Eigen::MatrixXd const & basis() const
Index subspace_dim() const
The DoF subspace dimension (equal to number of columns in basis).
void write_symmetry(Index state_index, std::string const &identifier, ConfigEnumInput const &config_enum_input, SymGroup const &lattice_point_group, SymGroup const &factor_group, SymGroup const &crystal_point_group) override
void write_dof_space(Index state_index, DoFSpace const &dof_space, std::string const &identifier, ConfigEnumInput const &config_enum_input, std::optional< SymRepTools_v2::VectorSpaceSymReport > const &sym_report) override
Write dof space analysis.
Implementation that outputs to <output_dir>/dof_space/state.<index>
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.
const Structure & prim() const
const SupercellSymInfo & sym_info() const
Eigen::Matrix3l transformation_matrix_to_super() const
long-int transformation from primitive lattice vectors to supercell lattice vectors supercell_lattice...
std::set< Index > const & sites() const
Configuration const & configuration() const
std::vector< PermuteIterator > make_invariant_subgroup(ConfigEnumInput const &config_enum_input)
ConfigEnumData< ConfigEnumSiteDoFs, ConfigEnumInput > ConfigEnumDataType
std::string standard_ConfigEnumInput_help()
std::string description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to string.
void print_initial_states(Log &log, NamedInitialStatesType const &named_initial_states)
DoFSpace exclude_homogeneous_mode_space(DoFSpace const &dof_space)
Removes the homogeneous mode space from the DoFSpace basis.
DoFSpace make_dof_space(DoFKey dof_key, ConfigEnumInput const &input_state, std::optional< Eigen::MatrixXd > const &basis=std::nullopt)
Index get_dof_space_dimension(DoFKey dof_key, xtal::BasicStructure const &prim, std::optional< Eigen::Matrix3l > const &transformation_matrix_to_super=std::nullopt, std::optional< std::set< Index >> const &sites=std::nullopt)
Return dimension of DoFSpace.
void require_all_input_have_the_same_number_of_selected_sites(InputParser< std::vector< std::pair< std::string, ConfigEnumInput >>> &parser)
ParentInputParser make_enum_parent_parser(Log &log, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Combine –input / –settings JSON with CLI options.
GenericDatumFormatter< std::string, DataObject > name()
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)
DoFSpace make_symmetry_adapted_dof_space_v2(DoFSpace const &dof_space, SupercellSymInfo const &sym_info, std::vector< PermuteIterator > const &group, bool calc_wedges, std::optional< SymRepTools_v2::VectorSpaceSymReport > &symmetry_report)
Make DoFSpace with symmetry adapated basis.
Data structure used for continuous DoF enumeration IO.
Eigen::VectorXd inc_vector
Eigen::VectorXd min_vector
Eigen::VectorXd max_vector
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.
MakeEnumerator(ConfigEnumOptions const &_options, ConfigEnumSiteDoFsParams const &_params, AxesCounterParams const &_axes_params, bool _make_symmetry_adapted_axes, bool _exclude_homogeneous_modes, DoFSpaceIO::SequentialDirectoryOutput &_dof_space_output)
DoFSpaceIO::SequentialDirectoryOutput & dof_space_output
bool make_symmetry_adapted_axes
ConfigEnumSiteDoFsParams const & params_template
AxesCounterParams const & axes_params
ConfigEnumOptions const & options
DataFormatter< ConfigEnumDataType > make_formatter() const
bool exclude_homogeneous_modes
DoFSpace make_and_write_dof_space(Index index, std::string name, ConfigEnumInput const &initial_state, std::optional< SymRepTools_v2::VectorSpaceSymReport > &sym_report) const
ConfigEnumSiteDoFs operator()(Index index, std::string name, ConfigEnumInput const &initial_state) const
std::set< std::string > error