22 "SuperConfigEnum: \n\n"
24 " supercells: ScelEnum JSON settings (default='{\"existing_only\"=true}')\n"
25 " Indicate supercells to enumerate super-configurations in using ScelEnum\n"
26 " input format, but the \"name\" option is not allowed. See 'ScelEnum' \n"
27 " description for details. \n\n"
29 " subconfigs: string or JSON array\n"
30 " Indicate supercells to enumerate all occupational configurations in. May \n"
31 " be a JSON array of configuration names, or string specifying a \n"
32 " configuration selection file anme. By default, all existing supercells \n"
33 " are used. See 'ScelEnum' description for details. \n\n"
35 " primitive_only: bool (default=true)\n"
36 " If true, only the primitive form of a configuration is saved in the \n"
37 " configuration list. Otherwise, both primitive and non-primitive \n"
38 " configurations are saved. \n\n"
40 " filter: string (optional, default=None)\n"
41 " A query command to use to filter which configurations are kept. \n"
44 " To enumerate super-configurations of listed sub-configurations:\n"
45 " casm enum --method SuperConfigEnum -i \n"
47 " \"supercells\": { \n"
49 " \"unit_cell\": \"SCEL2_1_2_1_0_0_0\" \n"
51 " \"subconfigs\": [\n"
52 " \"SCEL1_1_1_1_0_0_0/0\",\n"
53 " \"SCEL2_1_2_1_0_0_0/0\",\n"
54 " \"SCEL2_1_2_1_0_0_0/1\"\n"
58 " To enumerate super-configurations of listed sub-configurations from a \n"
60 " casm enum --method SuperConfigEnum -i \n"
62 " \"supercells\": { \n"
64 " \"unit_cell\": \"SCEL2_1_2_1_0_0_0\" \n"
66 " \"subconfigs\": \"selection_filename\"\n"
76 std::map<Configuration, std::string> &prim_subconfig) {
78 auto check_is_supercell = [&](
const Lattice & plat) {
88 throw std::invalid_argument(
89 "Error in SuperConfigEnum JSON input: 'subconfigs' is required");
92 log <<
"Input sub-configurations:\n";
93 if(kwargs[
"subconfigs"].is_array()) {
95 for(
auto it = j.
begin(); it != j.
end(); ++it) {
97 log <<
" " << config.
name() <<
"\n";
101 primclex.
err_log() <<
"subconfig: " << config.
name() <<
"\n";
105 throw std::invalid_argument(
"Error in SuperConfigEnum: subconfig does not fit in the unit cell");
107 prim_subconfig.insert(std::make_pair(pconfig, config.
name()));
113 log <<
" " << it->name() <<
"\n";
117 primclex.
err_log() <<
"subconfig: " << it->name() <<
"\n";
118 primclex.
err_log() <<
"subconfig transf_mat: \n" << it->get_supercell().get_transf_mat() <<
"\n";
121 throw std::invalid_argument(
"Error in SuperConfigEnum: subconfig does not fit in the unit cell");
123 prim_subconfig.insert(std::make_pair(pconfig, it->
name()));
133 const std::map<Configuration, std::string> &prim_subconfig,
134 std::vector<Configuration> &subconfig) {
136 primclex.
log() <<
"\nGenerating equivalents: \n";
137 for(
auto &_pair : prim_subconfig) {
138 auto &pconfig = _pair.first;
141 for(
auto it = e.begin(); it != e.end(); ++it) {
142 subconfig.push_back(*it);
143 primclex.
log() <<
" Config: " << it->name() <<
"\n" << *it <<
"\n";
146 primclex.
log() << std::endl;
155 if(_kwargs.
contains(
"name") || enum_opt.
vm().count(
"scelnames")) {
156 throw std::invalid_argument(
157 "Error in SuperConfigEnum JSON input: 'name' is not allowed in the 'supercell' option");
161 bool primitive_only =
true;
162 _kwargs.
get_if(primitive_only,
"primitive_only");
171 Supercell unit_cell(&primclex, *superlat_enum->begin());
175 std::map<Configuration, std::string> prim_subconfig;
184 std::vector<Configuration> subconfig;
193 return notstd::make_unique<SuperConfigEnum>(scel, subconfig.begin(), subconfig.end());
199 superlat_enum->begin(),
200 superlat_enum->end(),
212 if(&it->get_supercell() != &(
sub_config().begin()->get_supercell())) {
213 throw std::runtime_error(
"Error constructing SuperConfigEnum: "
214 "Sub-Configurations with different Supercells");
248 return c.has_occupation();
253 return c.has_displacement();
276 bool is_valid_config {
false};
const_displacement_t disp(Index site_l) const
Occupant displacement.
iterator end()
Returns iterator to end of JSON object or JSON array.
const int & occ(Index site_l) const
Occupant variable on site l.
A Counter allows looping over many incrementing variables in one loop.
std::vector< std::vector< Index > > m_index_map
m_current->occ(m_index_map[i][j]) = m_sub_scel[i].occ(j)
std::vector< std::string > make_enumerator_filter_expr(const jsonParser &_kwargs, const Completer::EnumOption &enum_opt)
Standardizes parsing casm enum filter expressions.
bool get_if(T &t, const std::string &key, Args...args) const
const std::vector< Configuration > & sub_config() const
Access the sub-configurations.
iterator selected_config_begin()
void _generate_equivalents(const PrimClex &primclex, Supercell &unit_cell, const std::map< Configuration, std::string > &prim_subconfig, std::vector< Configuration > &subconfig)
const ConfigDoF & configdof() const
const Access the DoF
const Lattice & get_real_super_lattice() const
Base class for generic use of enumerators that may be accessed through the API.
virtual jsonParser source(step_type step) const
Configuration primitive() const
Return the primitive Configuration.
notstd::cloneable_ptr< Configuration > m_current
The 'current' Configuration.
Counter< Array< int > > m_counter
const Lattice & ideal_lattice() const
Represents a supercell of the primitive parent crystal structure.
iterator begin()
Returns const_iterator to beginning of JSON object or JSON array.
bool _check_current() const
Returns true if current() satisifies requested conditions.
static const std::string enumerator_name
Template class to be specialized for each enumerator that may be accessed via the API...
void _init()
Used by constructor.
bool has_occupation() const
True if Configuration has occupation DoF.
value_type & _current()
Access the current ObjectType by reference.
double crystallography_tol() const
const MasterSymGroup & factor_group() const
int insert_configs_via_lattice_enum(std::string method, PrimClex &primclex, LatticeIterator begin, LatticeIterator end, ConfigEnumConstructor f, std::vector< std::string > filter_expr, bool primitive_only)
Standardizes insertion from enumerators that construct configurations.
std::vector< Configuration > & _sub_config()
Access the sub-configurations.
EigenIndex Index
For long integer indexing:
void _invalidate()
Call if enumeration complete.
A container class for the different degrees of freedom a Configuration might have.
iterator selected_config_end()
step_type step() const
Increments with each enumerated object.
CASM::EnumInterfaceBase * make_SuperConfigEnum_interface()
std::unique_ptr< SupercellEnumerator< Lattice > > make_enumerator_superlat_enum(PrimClex &primclex, const jsonParser &_kwargs, const Completer::EnumOption &enum_opt)
Standardizes parsing casm enum input options to make an SupercellEnumerator ...
PrimClex is the top-level data structure for a CASM project.
UnitCellCoord uccoord(Index i) const
void _generate_primitives(PrimClex &primclex, const Supercell &unit_cell, const jsonParser &kwargs, std::map< Configuration, std::string > &prim_subconfig)
bool valid() const
Returns false if enumeration is complete.
std::string name() const
SCELV_A_B_C_D_E_F/i.
const Configuration & configuration(const std::string &configname) const
access configuration by name (of the form "scellname/[NUMBER]", e.g., ("SCEL1_1_1_1_0_0_0/0") ...
Index find(const UnitCellCoord &bijk) const
void increment() override
Implement increment.
po::variables_map & vm()
Get the variables map.
void _set_step(step_type val)
Set current step value.
void set_source(const jsonParser &source)
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
std::vector< Configuration > m_sub_config
A vector containing each possible sub_config.
std::pair< bool, Eigen::MatrixXi > is_supercell(const Lattice &scel, const Lattice &unit, double tol)
Check if scel is a supercell of unitcell unit and some integer transformation matrix T...
Supercell & _sub_supercell()
Access the sub-config supercell.
void error(const std::string &what)
const Array< int > & counter() const
Access the current value of the counter.
Supercell & get_supercell() const
Get the Supercell for this Configuration.
displacement_t disp(Index i)
UnitCell unitcell(Index i) const
const Eigen::Matrix3i & get_transf_mat() const
void _fill(const Array< int > &counter_val, Configuration &config)
static int run(PrimClex &primclex, const jsonParser &kwargs, const Completer::EnumOption &enum_opt)
const PrimGrid & prim_grid() const
Access the PrimGrid.
Supercell & _target_supercell()
Access the super-config supercell.
bool has_displacement() const
True if Configuration has displacement DoF.
void _increment_step()
Increment current step value.
static const std::string interface_help
Enumerate all equivalent Configurations in a Supercell, as generated by Supercell factor group symmet...
A Configuration represents the values of all degrees of freedom in a Supercell.
const Structure & get_prim() const
const Access to primitive Structure
notstd::cloneable_ptr< PrimGrid > m_prim_grid
A PrimGrid that tiles thes sub_scel into the ref_scel.