CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigEnumSiteDoFsInterface.cc
Go to the documentation of this file.
2 
3 #include "casm/app/APICommand.hh"
13 #include "casm/clex/PrimClex.hh"
22 
23 namespace CASM {
24 
25 std::string ConfigEnumSiteDoFsInterface::desc() const {
26  std::string description =
27 
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"
31 
32  "1) Specification of one or more site DoF spaces to sample. This is done "
33  "via:\n\n"
34 
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"
44 
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"
53 
54  " Examples:\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 "
58  "dimensional disp)\n"
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. "
62  "If 2 sites from\n"
63  " sublattice b=0 are selected and 1 site from the sublattice b=1 "
64  "is selected:\n"
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"
68 
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"
76 
77  "2) Specification of a normal modes in the site DoF space. This can be "
78  "done through a\n"
79  " combination of the \"axes\" and \"sym_axes\" options:\n\n"
80 
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"
90 
91  " Notes on \"axes\":\n"
92  " - Each column in \"axes\" corresponds to an individual prim DoF, "
93  "which is printed to screen\n"
94  " - Examples:\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"
100 
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 "
106  "CASM:\n"
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 "
114  "that subgroup\n"
115  " - Uses the axes of the irreducible subspaces as the normal "
116  "coordinate axes\n\n"
117 
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 "
124  "screen\n"
125  " - The symmetry adapted axes can also be calculated via the `casm "
126  "sym` command\n"
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"
132 
133  "3) Choice of linear combinations of normal modes to apply to the chosen "
134  "Configuration:\n\n"
135 
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"
143 
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"
155 
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 "
159  "method generates\n"
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 "
163  "applies all the\n"
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";
169 
170  std::string custom_options =
171 
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"
176  " prim.json. \n\n"
177 
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"
189 
190  " Example if matrix (row vector matix): \n"
191  " \"axes\" : [ \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"
195  " ] \n\n"
196 
197  " Example if JSON object (named axis vectors): \n"
198  " \"axes\": { \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"
202  " } \n\n"
203 
204  " Note: \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"
208 
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"
218 
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"
224 
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"
230 
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"
234  " value. \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"
239 
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"
243  " value. \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"
248 
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"
258 
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"
270 
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"
274 
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"
278 
279  " output_dir: string (optional, default=current path) \n"
280  " Selects where output files are written. \n\n";
281 
282  std::string examples =
283  " Examples:\n"
284  " To enumerate all DoF perturbations of a particular configuration:\n"
285  " casm enum --method ConfigEnumSiteDoFs -i \n"
286  " '{ \n"
287  " \"confignames\": [ \n"
288  " \"SCEL4_1_4_1_0_0_0/3\"\n"
289  " ],\n"
290  " \"max\": 0.21, \n"
291  " \"increment\": 0.05, \n"
292  " } \n"
293  " }' \n\n";
294 
295  return name() + ": \n\n" + description + custom_options +
296  standard_ConfigEnumInput_help() + examples;
297 }
298 
301 }
302 
305  ConfigEnumInput const &initial_state, AxesCounterParams &axes_params,
306  bool sym_axes_option, bool exclude_homogeneous_modes) {
307  parser.value = notstd::make_unique<ConfigEnumSiteDoFsParams>();
308  auto &params = *parser.value;
309 
310  // 1) get DoF type -------------------------------------------------
311  // "dof" -> params.dof
312  parser.require(params.dof, "dof");
313 
314  Supercell const &supercell = initial_state.configuration().supercell();
315  Index dof_space_dimension = get_dof_space_dimension(
316  params.dof, supercell.prim(),
318  initial_state.sites());
319 
320  // 2) get axes and normal coordinate grid
321  // ------------------------------------------
322  auto grid_parser = parser.parse_as<AxesCounterParams>(dof_space_dimension);
323  if (grid_parser->valid()) {
324  axes_params = *grid_parser->value;
325  }
326 
327  if ((sym_axes_option || exclude_homogeneous_modes) &&
328  !axes_params.scalar_input) {
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());
334  }
335 
336  // 3) get min/max nonzero amplitudes -----------------------------------
337 
338  // "min_nonzero" -> params.min_nonzero
339  parser.optional_else(params.min_nonzero, "min_nonzero", Index{0});
340 
341  // "max_nonzero" -> params.max_nonzero
342  // note that help indicates default==axes.rows(), but that is
343  // params.axes.cols()
344  parser.optional_else(params.max_nonzero, "max_nonzero",
345  Index{params.axes.cols()});
346 
347  // Throw error if min_nonzero exceeds max_nonzero
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());
352  }
353 }
354 
356  InputParser<std::vector<std::pair<std::string, ConfigEnumInput>>> &parser) {
357  // TODO: should this check if the supercells & sites are the same, and not
358  // just the same number? if sym_axes==false, then using different sites /
359  // supercells might be bad
360 
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());
371  }
372  }
373  }
374 }
375 
376 namespace ConfigEnumSiteDoFsInterface_impl {
377 
379 
380 // This functor constructs a ConfigEnumSiteDoFs enumerator for a given initial
381 // state
384  ConfigEnumSiteDoFsParams const &_params,
385  AxesCounterParams const &_axes_params,
386  bool _make_symmetry_adapted_axes,
387  bool _exclude_homogeneous_modes,
388  DoFSpaceIO::SequentialDirectoryOutput &_dof_space_output)
389  : log(CASM::log()),
390  options(_options),
391  params_template(_params),
392  axes_params(_axes_params),
393  make_symmetry_adapted_axes(_make_symmetry_adapted_axes),
394  exclude_homogeneous_modes(_exclude_homogeneous_modes),
395  calc_wedges(false),
396  dof_space_output(_dof_space_output) {}
397 
406 
407  // constructs a ConfigEnumSiteDoFs for each initial_state
408  ConfigEnumSiteDoFs operator()(Index index, std::string name,
409  ConfigEnumInput const &initial_state) const;
410 
411  // constructs a symmetry adapted dof space and writes it to file as a record
413  Index index, std::string name, ConfigEnumInput const &initial_state,
414  std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report) const;
415 
416  // constructs a DataFormatter to record enumeration results
418 };
419 
420 // constructs a ConfigEnumSiteDoFs for each initial_state
422  Index index, std::string name, ConfigEnumInput const &initial_state) const {
423  std::optional<SymRepTools_v2::VectorSpaceSymReport> sym_report;
424  DoFSpace dof_space =
425  make_and_write_dof_space(index, name, initial_state, sym_report);
426 
428  params.axes = dof_space.basis();
429 
430  // set enumeration ranges
432  int dim = dof_space.subspace_dim();
433  params.min_val = Eigen::VectorXd::Constant(dim, axes_params.min_scalar);
434  params.max_val = Eigen::VectorXd::Constant(dim, axes_params.max_scalar);
435  params.inc_val = Eigen::VectorXd::Constant(dim, axes_params.inc_scalar);
436  } else {
437  params.min_val = axes_params.min_vector;
438  params.max_val = axes_params.max_vector;
439  params.inc_val = axes_params.inc_vector;
440  }
441 
442  return ConfigEnumSiteDoFs{initial_state, params};
443 }
444 
445 // constructs a symmetry adapted dof space and writes it to file as a record
447  Index index, std::string name, ConfigEnumInput const &initial_state,
448  std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report) const {
449  DoFSpace dof_space =
452  log << "Performing DoF space analysis: " << name << std::endl;
453  auto const &sym_info = initial_state.configuration().supercell().sym_info();
454  std::vector<PermuteIterator> group = make_invariant_subgroup(initial_state);
456  dof_space = exclude_homogeneous_mode_space(dof_space);
457  }
458  dof_space_output.write_symmetry(index, name, initial_state, group);
459  dof_space = make_symmetry_adapted_dof_space_v2(dof_space, sym_info, group,
460  calc_wedges, sym_report);
461  }
462  dof_space_output.write_dof_space(index, dof_space, name, initial_state,
463  sym_report);
464  return dof_space;
465 }
466 
467 // constructs a DataFormatter to record enumeration results
470  formatter.push_back(ConfigEnumIO::name<ConfigEnumDataType>(),
471  ConfigEnumIO::selected<ConfigEnumDataType>(),
472  ConfigEnumIO::is_new<ConfigEnumDataType>(),
473  ConfigEnumIO::is_existing<ConfigEnumDataType>());
474  if (options.filter) {
475  formatter.push_back(
476  ConfigEnumIO::is_excluded_by_filter<ConfigEnumDataType>());
477  }
478  formatter.push_back(
479  ConfigEnumIO::initial_state_index<ConfigEnumDataType>(),
480  ConfigEnumIO::initial_state_name<ConfigEnumDataType>(),
481  ConfigEnumIO::initial_state_configname<ConfigEnumDataType>(),
482  ConfigEnumIO::n_selected_sites<ConfigEnumDataType>());
483 
484  return formatter;
485 }
486 
487 } // namespace ConfigEnumSiteDoFsInterface_impl
488 
490  PrimClex &primclex, jsonParser const &json_options,
491  jsonParser const &cli_options_as_json) const {
492  Log &log = CASM::log();
493 
494  log.subsection().begin("ConfigEnumSiteDoFs");
495  ParentInputParser parser =
496  make_enum_parent_parser(log, json_options, cli_options_as_json);
497  std::runtime_error error_if_invalid{
498  "Error reading ConfigEnumSiteDoFs JSON input"};
499 
500  log.custom("Checking input");
501 
502  // 1) Parse ConfigEnumOptions ------------------
503 
504  auto options_parser_ptr = parser.parse_as<ConfigEnumOptions>(
506  primclex.settings().query_handler<Configuration>().dict());
507  report_and_throw_if_invalid(parser, log, error_if_invalid);
508  ConfigEnumOptions const &options = *options_parser_ptr->value;
509  print_options(log, options);
510  log.set_verbosity(options.verbosity);
511 
512  // 2) Parse initial enumeration states ------------------
513  typedef std::vector<std::pair<std::string, ConfigEnumInput>>
514  NamedInitialEnumerationStates;
515  auto input_parser_ptr = parser.parse_as<NamedInitialEnumerationStates>(
516  primclex.shared_prim(), &primclex, primclex.db<Supercell>(),
517  primclex.db<Configuration>());
519  report_and_throw_if_invalid(parser, log, error_if_invalid);
520  auto const &named_initial_states = *input_parser_ptr->value;
521  print_initial_states(log, named_initial_states);
522 
523  // 3) Parse ConfigEnumSiteDoFsParams ------------------
524 
525  // 3a) check for "sym_axes" option:
526  bool sym_axes_option;
527  parser.optional_else(sym_axes_option, "sym_axes", false);
528  log.indent() << "sym_axes: " << std::boolalpha << sym_axes_option
529  << std::endl;
530 
531  // 3c) check for "exclude_homogeneous_modes" option
532  bool exclude_homogeneous_modes;
533  parser.optional_else(exclude_homogeneous_modes, "exclude_homogeneous_modes",
534  false);
535  log.indent() << "exclude_homogeneous_modes: " << std::boolalpha
536  << exclude_homogeneous_modes << std::endl;
537 
538  // axes: column vector matrix
539  // - user input, else default = identity matrix of initial state dof space
540  // dimension
541  // - If sym_axes==false: normal mode coordinates used directly
542  // - If sym_axes==true: subspace to be symmetrized
543  AxesCounterParams axes_params;
544  auto params_parser_ptr = parser.parse_as<ConfigEnumSiteDoFsParams>(
545  named_initial_states[0].second, axes_params, sym_axes_option,
546  exclude_homogeneous_modes);
547  report_and_throw_if_invalid(parser, log, error_if_invalid);
548  ConfigEnumSiteDoFsParams const &params = *params_parser_ptr->value;
549  log.indent() << "axes: (column vectors) \n" << axes_params.axes << std::endl;
550  if (axes_params.scalar_input) {
551  log.indent() << "min: " << axes_params.min_scalar << std::endl;
552  log.indent() << "max: " << axes_params.max_scalar << std::endl;
553  log.indent() << "increment: " << axes_params.inc_scalar << std::endl;
554  } else {
555  log.indent() << "min: " << axes_params.min_vector.transpose() << std::endl;
556  log.indent() << "max: " << axes_params.max_vector.transpose() << std::endl;
557  log.indent() << "increment: " << axes_params.inc_vector.transpose()
558  << std::endl;
559  }
560  log.indent() << "min_nonzero: " << params.min_nonzero << std::endl;
561  log.indent() << "max_nonzero: " << params.max_nonzero << std::endl;
562 
563  // 3b) check for "print_dof_space_and_quit" option:
564  bool print_dof_space_and_quit_option;
565  parser.optional_else(print_dof_space_and_quit_option,
566  "print_dof_space_and_quit", false);
567 
568  // parse "output_dir" (optional, default = current_path)
569  fs::path output_dir;
570  parser.optional_else(output_dir, "output_dir", fs::current_path());
571  report_and_throw_if_invalid(parser, log, error_if_invalid);
572 
573  log << std::endl;
574 
575  // 4) Enumerate configurations ------------------
576 
577  DoFSpaceIO::SequentialDirectoryOutput dof_space_output{output_dir};
579  options,
580  params,
581  axes_params,
582  sym_axes_option,
583  exclude_homogeneous_modes,
584  dof_space_output};
585 
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;
590  Index i = 0;
591  for (auto const &pair : named_initial_states) {
592  std::string const &name = pair.first;
593  ConfigEnumInput const &initial_state = pair.second;
594  make_enumerator_f.make_and_write_dof_space(i, name, initial_state,
595  sym_report);
596  i++;
597  }
598  log.end_section();
599  return;
600  }
601 
602  log << std::endl;
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());
607  log.end_section();
608 }
609 
610 } // namespace CASM
static const std::string enumerator_name
std::string name() const override
Enumeration method name (i.e. "ConfigEnumAllOccupations")
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.
Extract data from objects of 'DataObject' class.
void push_back(const BaseDatumFormatter< DataObject > &new_formatter, const std::string &args)
Eigen::MatrixXd const & basis() const
Definition: DoFSpace.cc:227
Index subspace_dim() const
The DoF subspace dimension (equal to number of columns in basis).
Definition: DoFSpace.cc:233
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>
RequiredType optional_else(fs::path option, const RequiredType &_default, Args &&... args)
std::unique_ptr< RequiredType > require(fs::path option, Args &&... args)
std::shared_ptr< InputParser< RequiredType > > parse_as(Args &&... args)
std::unique_ptr< T > value
Definition: InputParser.hh:234
Definition: Log.hh:48
void end_section()
End a section.
Definition: Log.hh:192
void set_verbosity(int _verbosity)
Definition: Log.cc:57
void custom(const std::string &what)
Definition: Log.hh:139
Log & subsection()
Create a subsection.
Definition: Log.hh:186
Log & indent()
Definition: Log.hh:289
void begin(const std::string &what)
Definition: Log.hh:114
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
const Structure & prim() const
Definition: Supercell.cc:113
const SupercellSymInfo & sym_info() const
Definition: Supercell.cc:265
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
Main CASM namespace.
Definition: APICommand.hh:8
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.
Definition: DoFSpace.cc:673
Log & log()
Definition: Log.hh:424
DoFSpace make_dof_space(DoFKey dof_key, ConfigEnumInput const &input_state, std::optional< Eigen::MatrixXd > const &basis=std::nullopt)
Definition: DoFSpace.cc:487
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.
Definition: DoFSpace.cc:359
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)
Definition: stream_io.cc:6
INDEX_TYPE Index
For long integer indexing:
Definition: definitions.hh:39
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.
Definition: DoFSpace.cc:635
PrimClex * primclex
Definition: settings.cc:135
Data structure used for continuous DoF enumeration IO.
Definition: DoFSpace.hh:56
Eigen::MatrixXd axes
Definition: DoFSpace.hh:59
Eigen::VectorXd inc_vector
Definition: DoFSpace.hh:65
Eigen::VectorXd min_vector
Definition: DoFSpace.hh:63
Eigen::VectorXd max_vector
Definition: DoFSpace.hh:64
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)
DataFormatter< ConfigEnumDataType > make_formatter() const
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
Definition: Validator.hh:11