1 #ifndef CASM_ScelEnum_impl
2 #define CASM_ScelEnum_impl
10 template<
bool IsConst>
11 const std::string ScelEnumByNameT<IsConst>::enumerator_name =
"ScelEnumByName";
18 template<
bool IsConst>
21 std::initializer_list<std::string> scelnames) :
23 m_primclex(&primclex) {
26 for(
auto it = scelnames.begin(); it != scelnames.end(); ++it) {
37 template<
bool IsConst>
38 template<
typename ScelNameIterator>
41 ScelNameIterator begin,
42 ScelNameIterator end) :
44 m_primclex(&primclex) {
46 for(
auto it = begin; it !=
end; ++it) {
57 template<
bool IsConst>
62 m_primclex(&primclex) {
65 for(
auto it = input.
begin(); it != input.
end(); ++it) {
71 template<
bool IsConst>
73 return enumerator_name;
77 template<
bool IsConst>
82 template<
bool IsConst>
85 this->_set_size(m_scelptr.size());
86 if(this->size() > 0) {
87 this->_initialize(m_scelptr[0]);
95 template<
bool IsConst>
105 template<
bool IsConst>
107 m_primclex(&primclex),
108 m_existing_only(existing_only) {
133 bool _get_else(
const jsonParser &json, std::string key,
bool default_value) {
135 json.
get_else<
bool>(tmp, key, default_value);
150 template<
bool IsConst>
154 template<
bool IsConst>
156 return enumerator_name;
160 template<
bool IsConst>
164 while(!_include(*m_lat_it) && m_lat_it != m_lat_end) {
168 if(m_lat_it != m_lat_end) {
169 this->_set_current_ptr(&m_primclex->get_supercell(m_primclex->add_supercell(*m_lat_it)));
170 this->_increment_step();
178 template<
bool IsConst>
180 if(m_existing_only) {
183 m_primclex->get_prim().point_group(),
184 m_primclex->crystallography_tol());
186 return m_primclex->contains_supercell(tmp);
191 template<
bool IsConst>
193 return enumerator_name;
197 template<
bool IsConst>
201 template<
bool IsConst>
206 " min: int, >0 (default=1)\n"
207 " The minimum volume supercell to enumerate. The volume is measured\n"
208 " relative the unit cell being used to generate supercells.\n"
210 " max: int, >= min (default=max existing scel_size)\n"
211 " The maximum volume supercell to enumerate. The volume is measured\n"
212 " relative the unit cell being used to generate supercells.\n"
214 " existing_only: bool (default=true)\n"
215 " If true, only existing supercells are used. This is useful when it\n"
216 " is used as input to a Configuration enumeration method.\n"
218 " dirs: string (default=\"abc\")\n"
219 " This option may be used to restrict the supercell enumeration to 1, \n"
220 " 2 or 3 of the lattice vectors, to get 1-, 2-, or 3-dimensional \n"
221 " supercells. By specifying combinations of 'a', 'b', and 'c', you \n"
222 " determine which of the unit cell lattice vectors you want to \n"
223 " enumerate over. For example, to enumerate 1-dimensional supercells \n"
224 " along the 'c' use \"dirs\":\"c\". If you want 2-dimensional \n"
225 " supercells along the 'a' and 'c' lattice vectors, specify \n"
226 " \"dirs\":\"ac\". \n"
228 " unit_cell: 3x3 matrix of int, or string (default=identity matrix) \n"
229 " This option may be used to specify the unit cell. It may be \n"
230 " specified using a 3x3 matrix of int, representing the transformation\n"
231 " matrix, T, such that U = P*T, where P are the primitive lattice \n"
232 " and U are the unit cell lattice vectors. For example, a unit cell \n"
233 " that whose lattice vectors are (2*a+b, b, c) (with respect to the \n"
234 " the primitive cell vectors) could be specified using:\n"
236 " \"unit_cell\" : [\n"
242 " Or it may be specified by \n"
243 " the name of the existing supercell to use as the unit cell, for \n"
246 " \"unit_cell\" : \"SCEL2_1_1_2_0_0_0\"\n"
248 " name: JSON array of string (optional)\n"
249 " As an alternative to the above options, an array of existing supercell\n"
250 " names to explicitly indicate which supercells to act on. If this is \n"
251 " included, other properties are ignored. This is useful as an input \n"
252 " to other enumeration methods, such as ConfigEnumAllOccupations when \n"
253 " supercells have already been enumerated. \n"
257 " To enumerate supercells up to and including size 4:\n"
258 " casm enum --method SuperConfigEnum -i '{\"max\": 4}' \n"
260 " To enumerate 2d supercells up to and including size 4:\n"
261 " casm enum --method SuperConfigEnum -i '{\"max\": 4, \"dirs\": \"ab\"}' \n"
263 " If the prim is primitive FCC, two dimensional supercells of the \n"
264 " conventional FCC unit cell up to and including 4x the unit cell volume\n"
265 " could be enumerated using:\n"
267 " casm enum --method SuperConfigEnum -i \n"
271 " \"dirs\": \"ab\",\n"
272 " \"unit_cell\" : [\n"
281 template<
bool IsConst>
288 log.
begin(enumerator_name);
291 Index list_size = supercell_list.size();
297 if(enum_opt.
vm().count(
"min")) {
300 if(enum_opt.
vm().count(
"max")) {
304 ScelEnum scel_enum(primclex, input);
305 for(
auto &scel : scel_enum) {
307 if(supercell_list.size() != list_size) {
308 log <<
" Generated: " << scel.get_name() <<
"\n";
311 log <<
" Generated: " << scel.get_name() <<
" (already existed)\n";
314 list_size = supercell_list.size();
316 log <<
" DONE." << std::endl << std::endl;
318 log <<
"Write SCEL..." << std::endl;
320 log <<
" DONE" << std::endl << std::endl;
322 log <<
"Writing config_list..." << std::endl;
324 log <<
" DONE" << std::endl;
332 template<
bool IsConst>
336 m_enum.ptr.reset(
new ScelEnumByName(primclex, input[
"name"]));
339 m_enum.ptr.reset(
new ScelEnumByProps(primclex, input));
342 m_it = m_enum.begin();
343 m_end = m_enum.end();
346 this->_initialize(&(*m_it));
356 template<
bool IsConst>
360 this->_set_current_ptr(&(*m_it));
361 this->_increment_step();
ScelEnumT(PrimClex &primclex, const jsonParser &input)
Construct with PrimClex and JSON settings.
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
boost::container::stable_vector< Supercell > & get_supercell_list()
Access entire supercell_list.
static int run(PrimClex &primclex, const jsonParser &kwargs, const Completer::EnumOption &enum_opt)
void write_config_list(std::set< std::string > scel_to_delete={})
iterator end()
Returns iterator to end of JSON object or JSON array.
std::string name() const override
Derived enumerators must implement name, via ENUM_MEMBERS.
Data structure for holding supercell enumeration properties.
Supercell * at_step(step_type n) override
Implements at_step.
std::unique_ptr< SupercellEnumerator< Lattice > > m_lattice_enum
A fake container of supercell matrices.
const Lattice & lattice() const
Enumerate over Supercell.
Represents a supercell of the primitive parent crystal structure.
iterator begin()
Returns const_iterator to beginning of JSON object or JSON array.
std::vector< Supercell * > m_scelptr
void begin(const std::string &what)
void increment() override
Implements increment over supercells.
void increment() override
Implements increment over all occupations.
const MasterSymGroup & factor_group() const
std::string name() const override
Derived enumerators must implement name, via ENUM_MEMBERS.
ScelEnumProps make_scel_enum_props(PrimClex &primclex, const jsonParser &input)
Make a ScelEnumProps object from JSON input.
EigenIndex Index
For long integer indexing:
void _invalidate()
Call if enumeration complete.
ScelEnumByPropsT(PrimClex &primclex, const ScelEnumProps &enum_props, bool existing_only=false)
Construct with PrimClex and ScelEnumProps settings.
Lattice canonical_equivalent_lattice(const Lattice &in_lat, const SymGroup &point_grp, double compare_tol)
Find the niggli, most standard oriented version of the given orbit (defined by the given SymGroup) of...
ScelEnumByNameT(PrimClex &primclex, std::initializer_list< std::string > scelnames)
Construct with PrimClex and ScelEnumProps settings.
Base class for implementing specialized random access enumerators.
bool get_else(T &t, const std::string &key, const T &default_value, Args...args) const
PrimClex is the top-level data structure for a CASM project.
SupercellEnumerator< Lattice >::const_iterator m_lat_it
void print_supercells(std::set< std::string > scel_to_delete={}) const
Index add_supercell(const Lattice &superlat)
po::variables_map & vm()
Get the variables map.
const Supercell & get_supercell(Index i) const
const Access supercell by index
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
bool _include(const Lattice &lat) const
Check for existing supercells.
SupercellEnumerator< Lattice >::const_iterator m_lat_end
std::string name() const override
Derived enumerators must implement name, via ENUM_MEMBERS.
Enumerate over Supercell.
ScelEnumT< false > ScelEnum
const Structure & get_prim() const
const Access to primitive Structure