44 namespace ConfigEnumIO {
51 template <
typename ConfigEnumDataType>
55 "Subwedge index (determines axes defining normal coordinate).",
57 return data.enumerator.subwedge_index();
64 "Generate strain perturbations of one or more initial "
65 "configurations.\n\n";
67 std::string custom_options =
68 " axes: matrix or JSON object (optional) \n"
69 " Coordinate axes of the DoF grid. Default value is the identity \n"
70 " matrix of DoF space dimension Each element in an axis vector \n"
71 " correponds to an individual DoF. Each axis vector corresponds \n"
72 " to a normal mode. Use the option \n"
73 " `\"print_dof_space_and_quit\": true` to print DoF space \n"
74 " information with a glossary describing which DoF is specified \n"
75 " by which vector element. The 'axes' may be rank deficient \n"
76 " indicating enumeration should occur in a subspace of the full \n"
77 " DoF space specified by the \"dof\" value and initial \n"
78 " enumeration state. \n\n"
80 " Example if matrix (row vector matix): \n"
82 " [1, 1, 1, 1, 1, 1], \n"
83 " [1,-1, 0,-1, 1, 0], \n"
84 " [1,-1, 0, 1,-1, 0] \n"
87 " Example if JSON object (named axis vectors): \n"
89 " \"q1\": [1, 1, 1, 1, 1, 1], \n"
90 " \"q2\": [1,-1, 0,-1, 1, 0], \n"
91 " \"q3\": [1,-1, 0, 1,-1, 0] \n"
95 " - If some \"qi\" in the range [1, DoF space dimension] are \n"
96 " missing, then enumeration is performed in the subspace \n"
97 " specified by the axes that are provided. \n\n"
99 " sym_axes: bool (optional, default=false) \n"
100 " If true, constructs symmetry-adapted grid axes as the symmetry-\n"
101 " adapted DoF order parameters of the input state in the space \n"
102 " specified by \"axes\". Run with option \n"
103 " `\"print_dof_space_and_quit\": true` to obtain the analysis \n"
104 " report including the symmetry-adapted axes before doing the \n"
105 " enumeration. If `\"sym_axes\": true`, the enumeration grid may \n"
106 " not be specified using vector-valued \"min\", \"max\", \n"
107 " \"increment\", or \"num\". \n\n"
109 " print_dof_space_and_quit: boolean (optional, default=false) \n"
110 " If true, print DoF space information for each initial \n"
111 " enumeration state and quit. If `\"sym_axes\": true`, will also \n"
112 " print irreducible subspaces and symmetry-adapted axes. \n\n"
114 " min: number, or array of numbers (optional) \n"
115 " Minimum, starting value of grid counter. If number, specifies \n"
116 " using a constant array of DoF space dimension with that given \n"
118 " Ex: \"min\" : -0.1 ( --> [-0.1, -0.1, ..., -0.1]) \n"
119 " If array, dimension must be equal to the \"axes\" dimension and\n"
120 " `\"sym_axes\" must be false`. \n"
121 " Ex: \"min\" : [-0.05, -0.1, -0.1] \n\n"
123 " max: number, or array of numbers (required) \n"
124 " Maximum, final value of grid counter. If number, specifies \n"
125 " using a constant array of DoF space dimension with that given \n"
127 " Ex: \"max\" : 0.1 ( --> [0.1, 0.1, ..., 0.1]) \n"
128 " If array, dimension must be equal to the \"axes\" dimension and\n"
129 " `\"sym_axes\" must be false`. \n"
130 " Ex: \"max\" : [0.05, 0.1, 0.1] \n\n"
132 " increment: number, or array of numbers (optional) \n"
133 " Amount by which to increment counter elements. If number, \n"
134 " specifies using a constant array of DoF space dimension with \n"
135 " that given value. \n"
136 " Ex: \"increment\" : 0.01 ( --> [0.01, 0.01, ..., 0.01]) \n"
137 " If array, dimension must be equal to the \"axes\" dimension and\n"
138 " `\"sym_axes\" must be false`. \n"
139 " Ex: \"increment\" : [0.005, 0.01, 0.01] \n"
140 " One of \"increment\" or \"num\" must be given. \n\n"
142 " num: int, or array of int (optional) \n"
143 " Number of values to include. Must be >= 1. If \"num\" is 1, \n"
144 " only include a point at the \"min\" value along specified \n"
145 " dimensions (this is equivalent to min=min, increment=(max-min),\n"
146 " max=max-increment/10.). If \"num\" is >1, include that many \n"
147 " points, including the \"min\" and \"max\" (this is equivalent \n"
148 " to min=min, increment=(max-min)/(num-1), max=max+inc/10.). \n"
149 " Ex: \"increment\" : 11 ( --> [11, 11, ..., 11]) \n"
150 " If array, dimension must be equal to the \"axes\" dimension. \n"
151 " Ex: \"num\" : [5, 11, 11] \n"
152 " One of \"increment\" or \"num\" must be given. \n\n"
154 " trim_corners: bool (optional, default=true) \n"
155 " If true, any grid points outside the largest ellipsoid \n"
156 " inscribed within the extrema of the grid will be discarded. \n\n"
158 " output_dir: string (optional, default=current path) \n"
159 " Selects where output files are written. \n\n";
161 std::string examples =
163 " To enumerate all strain perturbations of a particular "
165 " casm enum --method ConfigEnumStrain -i \n"
167 " \"confignames\" : [\"SCEL4_1_4_1_0_0_0/3\"],\n"
168 " \"increment\" : [0.01, 0.01, 0.01, 0., 0., 0.],\n"
169 " \"max\" : [0.05, 0.05, 0,05, 0., 0., 0.]\n"
180 namespace ConfigEnumStrainInterface_impl {
190 bool _make_symmetry_adapted_axes,
215 std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report)
const;
224 std::optional<SymRepTools_v2::VectorSpaceSymReport> sym_report;
230 params.
wedges = sym_report->irreducible_wedge;
255 std::optional<SymRepTools_v2::VectorSpaceSymReport> &sym_report)
const {
259 log <<
"Performing DoF space analysis: " <<
name << std::endl;
275 formatter.
push_back(ConfigEnumIO::name<ConfigEnumDataType>(),
276 ConfigEnumIO::selected<ConfigEnumDataType>(),
277 ConfigEnumIO::is_new<ConfigEnumDataType>(),
278 ConfigEnumIO::is_existing<ConfigEnumDataType>());
281 ConfigEnumIO::is_excluded_by_filter<ConfigEnumDataType>());
284 ConfigEnumIO::initial_state_index<ConfigEnumDataType>(),
285 ConfigEnumIO::initial_state_name<ConfigEnumDataType>(),
286 ConfigEnumIO::initial_state_configname<ConfigEnumDataType>());
288 formatter.
push_back(ConfigEnumIO::subwedge_index<ConfigEnumDataType>());
291 ConfigEnumIO::normal_coordinate<ConfigEnumDataType>(),
292 make_datum_formatter_adapter<ConfigEnumDataType, Configuration>(
294 if (prim_strain_metric !=
"F") {
296 make_datum_formatter_adapter<ConfigEnumDataType, Configuration>(
318 bool sym_axes_option) {
319 parser.
value = notstd::make_unique<ConfigEnumStrainParams>();
320 auto ¶ms = *parser.
value;
328 }
catch (std::exception &e) {
329 parser.
error.insert(e.what());
334 params.dof, supercell.
prim(),
336 initial_state.
sites());
340 if (grid_parser->valid()) {
341 axes_params = *grid_parser->value;
345 std::stringstream msg;
346 msg <<
"Error: Vector input for enumeration ranges (\"min\", \"max\", "
347 "\"increment\" or \"num\") is not allowed with `\"sym_axes\": "
349 throw std::runtime_error(msg.str());
353 if (!parser.
self.
contains(
"min") && sym_axes_option ==
true) {
354 params.auto_range =
true;
356 params.auto_range =
false;
361 parser.
optional_else(params.trim_corners,
"trim_corners",
true);
366 jsonParser const &cli_options_as_json)
const {
367 using namespace ConfigEnumStrainInterface_impl;
374 std::runtime_error error_if_invalid{
375 "Error reading ConfigEnumStrain JSON input"};
389 typedef std::vector<std::pair<std::string, ConfigEnumInput>>
390 NamedInitialEnumerationStates;
391 auto input_parser_ptr = parser.
parse_as<NamedInitialEnumerationStates>(
395 auto const &named_initial_states = *input_parser_ptr->value;
401 bool sym_axes_option;
403 log.
indent() <<
"sym_axes: " << std::boolalpha << sym_axes_option
415 named_initial_states[0].second, axes_params, sym_axes_option);
418 log.
indent() <<
"axes: (column vectors) \n" << axes_params.
axes << std::endl;
435 bool print_dof_space_and_quit_option;
437 "print_dof_space_and_quit",
false);
438 log.
indent() <<
"print_dof_space_and_quit: " << std::boolalpha
439 << print_dof_space_and_quit_option << std::endl;
443 parser.
optional_else(output_dir,
"output_dir", fs::current_path());
450 MakeEnumerator make_enumerator_f{options, params, axes_params,
451 sym_axes_option, dof_space_output};
453 if (print_dof_space_and_quit_option) {
454 log.
begin(
"Print DoF Space and Quit Option");
455 std::optional<SymRepTools_v2::VectorSpaceSymReport> sym_report;
457 for (
auto const &pair : named_initial_states) {
458 std::string
const &
name = pair.first;
460 make_enumerator_f.make_and_write_dof_space(i,
name, initial_state,
469 log.
begin(
"ConfigEnumStrain enumeration");
471 primclex, options, make_enumerator_f, named_initial_states.begin(),
472 named_initial_states.end(), make_enumerator_f.make_formatter());
static const std::string enumerator_name
Eigen::VectorXd normal_coordinate() const
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
The strain DoF value of the configuration.
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...
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
std::set< Index > const & sites() const
Configuration const & configuration() const
std::vector< PermuteIterator > make_invariant_subgroup(ConfigEnumInput const &config_enum_input)
DoFKey get_strain_dof_key(BasicStructure const &structure)
std::string get_strain_metric(DoFKey strain_dof_key)
GenericDatumFormatter< Index, ConfigEnumDataType > subwedge_index()
Eigen::VectorXd get_normal_coordinate(EnumeratorType const &enumerator)
ConfigEnumData< ConfigEnumStrain, 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 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.
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.
bool make_symmetry_adapted_axes
DoFSpaceIO::SequentialDirectoryOutput & dof_space_output
DoFSpace make_and_write_dof_space(Index index, std::string name, ConfigEnumInput const &initial_state, std::optional< SymRepTools_v2::VectorSpaceSymReport > &sym_report) const
ConfigEnumStrain operator()(Index index, std::string name, ConfigEnumInput const &initial_state) const
ConfigEnumStrainParams const & params_template
MakeEnumerator(ConfigEnumOptions const &_options, ConfigEnumStrainParams const &_params, AxesCounterParams const &_axes_params, bool _make_symmetry_adapted_axes, DoFSpaceIO::SequentialDirectoryOutput &_dof_space_output)
ConfigEnumOptions const & options
AxesCounterParams const & axes_params
DataFormatter< ConfigEnumDataType > make_formatter() const
std::vector< SymRepTools_v2::SubWedge > wedges
DoFKey dof
Type of strain.
std::set< std::string > error