48 "1 or more files containing a 3x3 transformation matrix used to create a supercell.")
51 "If it exists, find the transformation matrix.")
55 "File with structure (POSCAR type) to use.")
59 "Name of supercell to use as unit cell. For ex. 'SCEL2_2_1_1_0_0_0'.")
62 "Construct the superdupercell, the minimum supercell of all input supercells "
63 "and configurations.")
66 "When constructing the superdupercell, do not consider other symmetrically "
67 "equivalent orientations.")
71 "Transforms the transformation matrix, T -> T', where T' = T*M, such that "
72 "(T').determininant() >= V. This has the effect that a supercell has a "
76 "Used with --min-volume to enforce that T' = T*m*I, where I is the identity "
77 "matrix, and m is a scalar. This has the effect of preserving the shape "
78 "of the resulting supercell, but increasing the volume.")
81 "When used with --duper, show how the input lattices are transformed "
82 "to tile the superdupercell.")
84 (
"add-canonical,a",
"Will add the generated super configuration in it's "
85 "canonical form in the equivalent niggli supercell.")
88 "Print using VASP5 style (include atom name line)")
92 "Tolerance used for checking symmetry");
109 std::string unitscelname;
111 std::vector<fs::path> tmatfile, abs_tmatfile, config_path;
116 po::variables_map vm;
122 po::store(po::parse_command_line(args.
argc, args.
argv, super_opt.
desc()), vm);
124 if(!vm.count(
"help") && !vm.count(
"desc")) {
125 if(!vm.count(
"duper")) {
126 if(vm.count(
"transf-mat") + vm.count(
"get-transf-mat") != 1) {
127 args.
err_log <<
"Error in 'casm super'. Only one of --transf-mat or --get-transf-mat may be chosen." << std::endl;
130 if(configname.size() > 1 || scelname.size() > 1 || tmatfile.size() > 1) {
131 args.
err_log <<
"ERROR: more than one --confignames, --scelnames, or --transf-mat argument "
132 "is only allowed for option --duper" << std::endl;
135 if(config_path.size() > 0) {
136 args.
err_log <<
"ERROR: the --configs option is only allowed with option --duper" << std::endl;
144 if(vm.count(
"help")) {
146 args.
log << super_opt.
desc() << std::endl;
151 if(vm.count(
"desc")) {
153 args.
log << super_opt.
desc() << std::endl;
154 args.
log <<
"DESCRIPTION" << std::endl;
156 " casm super --transf-mat T \n" <<
157 " - Print super lattice of the PRIM lattice \n" <<
159 " casm super --structure POSCAR --transf-mat T \n" <<
160 " - Print superstructure of a POSCAR \n" <<
162 " casm super --confignames configname --transf-mat T \n" <<
163 " - Print superstructure of a configuration \n" <<
165 " casm super --structure POSCAR --unitcell scelname --get-transf-mat \n" <<
166 " - Check if POSCAR lattice is a supercell of unit cell lattice and \n" <<
167 " if so print the transformation matrix \n" <<
168 " - Uses primitive cell for unitcell if none given \n" <<
170 " casm super --scelnames scelname --unitcell scelname --get-transf-mat\n" <<
171 " - Check if configuration lattice is a supercell of unit cell lattice.\n" <<
172 " and print the transformation matrix \n" <<
173 " - Uses primitive cell for unitcell if none given \n\n" <<
175 " casm super --duper --scelnames scel1 [scel2 ...] --confignames con1 [con2 ...]\n"
176 " --configs [mylist ...] --transf-mat M1 [M2 ...] \n" <<
177 " - Makes the superdupercell of the lattices of all inputs \n" <<
178 " - Using '--configs' with no arguments is equivalent to '--configs MASTER',\n" <<
179 " which uses the master config list \n" <<
180 " - Default applies prim point group ops to try to find minimum volume\n" <<
181 " superdupercell, disable with '--fixed-orientation' \n\n";
199 catch(po::error &e) {
200 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
204 catch(std::exception &e) {
205 args.
err_log <<
"Unhandled Exception reached the top of main: "
206 << e.what() <<
", application will now exit" << std::endl;
217 if(vm.count(
"vasp5")) {
232 for(
auto && file : tmatfile) {
233 abs_tmatfile.push_back(fs::absolute(file));
235 abs_structfile = fs::absolute(structfile);
237 if(vm.count(
"structure") && vm.count(
"transf-mat")) {
239 if(!fs::exists(abs_structfile)) {
240 args.
log <<
"ERROR: " << abs_tmatfile[0] <<
" not found." << std::endl;
246 if(!fs::exists(abs_tmatfile[0])) {
247 args.
log <<
"ERROR: " << abs_tmatfile[0] <<
" not found." << std::endl;
251 fs::ifstream file(abs_tmatfile[0]);
256 super.
title = std::string(
"Supercell of ") + unitcell.
title;
273 std::unique_ptr<PrimClex> uniq_primclex;
276 if(vm.count(
"duper")) {
279 std::map<std::string, Lattice> lat;
280 std::map<std::string, Lattice> config_lat;
283 if(vm.count(
"transf-mat")) {
284 for(
auto it = abs_tmatfile.begin(); it != abs_tmatfile.end(); ++it) {
285 Eigen::Matrix<int, 3, 3, Eigen::RowMajor> T;
286 fs::ifstream file(*it);
287 for(
int i = 0; i < 9; i++) {
296 if(vm.count(
"scelnames")) {
297 for(
auto it = scelname.begin(); it != scelname.end(); ++it) {
303 if(vm.count(
"confignames")) {
304 for(
auto it = configname.begin(); it != configname.end(); ++it) {
310 if(vm.count(
"configs")) {
313 if(config_path.size() == 0) {
316 config_lat[it.name()] = lat[it.name()] = it->get_supercell().get_real_super_lattice();
321 for(
auto c_it = config_path.begin(); c_it != config_path.end(); ++c_it) {
322 if(c_it->string() ==
"MASTER") {
325 config_lat[it.name()] = lat[it.name()] = it->get_supercell().get_real_super_lattice();
331 config_lat[it.name()] = lat[it.name()] = it->get_supercell().get_real_super_lattice();
339 std::vector<Lattice> lat_only;
340 for(
auto it = lat.begin(); it != lat.end(); ++it) {
341 lat_only.push_back(it->second);
347 if(vm.count(
"fixed-orientation")) {
353 if(vm.count(
"min-volume")) {
355 args.
log <<
" Enforcing minimum volume: " << min_vol;
356 if(vm.count(
"fixed-shape")) {
357 args.
log <<
" (with fixed shape)";
365 args.
log <<
" Superdupercell lattice: \n" << superduper.
lat_column_mat() <<
"\n\n";
367 args.
log <<
" Initial transformation matrix:\n" << T
368 <<
"\n (volume = " << T.cast<
double>().determinant() <<
")\n\n";
376 args.
log <<
" Superdupercell lattice: \n" << superduper.lat_column_mat() <<
"\n\n";
378 args.
log <<
" Transformation matrix, after enforcing mininum volume:\n"
379 << S <<
"\n (volume = " << S.cast<
double>().determinant() <<
")\n\n";
386 args.
log <<
"--- Lattices as column vector matrices ---\n\n";
390 args.
log <<
" Superdupercell lattice: \n" << superduper.
lat_column_mat() <<
"\n\n";
392 args.
log <<
" Transformation matrix, relative the primitive cell:\n";
395 if(vm.count(
"verbose")) {
396 args.
log <<
"Transformation matrices: \n";
397 for(
auto it = lat.begin(); it != lat.end(); ++it) {
398 args.
log <<
"--- \n";
399 args.
log <<
" Unit: " << it->first <<
":\n"
400 << it->second.lat_column_mat() <<
"\n\n";
403 args.
log <<
" Superduper = (op*unit) * T\n\nop:\n";
404 args.
log << res.first->matrix() <<
"\n\n";
406 args.
log << res.second <<
"\n\n";
409 args.
log <<
"--- \n";
412 args.
log <<
" Writing SCEL..." << std::endl;
414 args.
log <<
" DONE\n";
417 if(vm.count(
"add-canonical")) {
418 args.
log <<
"Add super configurations:\n";
419 for(
auto it = config_lat.begin(); it != config_lat.end(); ++it) {
429 args.
log <<
" " << it->first <<
" -> " << superduper_scel.
get_config(config_index).
name() <<
"\n";
433 args.
log <<
" Writing config_list..." << std::endl << std::endl;
435 args.
log <<
" DONE\n";
441 else if(vm.count(
"transf-mat")) {
444 if(!fs::exists(abs_tmatfile[0])) {
445 args.
log <<
"ERROR: " << abs_tmatfile[0] <<
" not found." << std::endl;
448 fs::ifstream file(abs_tmatfile[0]);
452 args.
log <<
"Read transformation matrix, T: \n" << T <<
"\n\n";
455 if(vm.count(
"min-volume")) {
457 if(!vm.count(
"fixed-shape")) {
458 args.
log <<
" Enforcing minimum volume: \n";
459 args.
log <<
" Finding T' = T*M, such that (T').determinant() >= " << min_vol;
462 args.
log <<
" Enforcing minimum volume (with fixed shape): \n";
463 args.
log <<
" Finding T' = T*m*I, such that (T').determinant() >= " << min_vol;
470 args.
log <<
" Initial transformation matrix:\n" << T
471 <<
"\n (volume = " << T.cast<
double>().determinant() <<
")\n\n";
478 vm.count(
"fixed-shape"));
483 args.
log <<
" Transformation matrix, after enforcing mininum volume:\n"
484 << T <<
"\n (volume = " << T.cast<
double>().determinant() <<
")\n\n";
489 if(vm.count(
"scelnames")) {
493 args.
log <<
" Unit cell: " << scelname[0] <<
"\n\n";
501 args.
log <<
" Add supercell: " << super_scel.
get_name() <<
"\n\n";
505 args.
log <<
" Transformation matrix: \n" << super_scel.
get_transf_mat() <<
"\n\n";
507 args.
log <<
" Writing SCEL..." << std::endl;
509 args.
log <<
" DONE\n";
513 else if(vm.count(
"confignames")) {
515 std::stringstream ss;
522 std::istringstream iss(ss.str());
526 args.
log <<
"Unit structure:";
527 args.
log <<
"\n------\n";
529 args.
log <<
"\n------\n";
534 super.
title = std::string(
"Supercell of ") + con.
name();
536 args.
log <<
"Super structure:";
537 args.
log <<
"\n------\n";
539 args.
log <<
"\n------\n";
541 if(vm.count(
"add-canonical")) {
545 double vol_tol = 0.25;
546 double lattice_weight = 0.5;
547 ConfigMapper configmapper(primclex, lattice_weight, vol_tol, map_opt, tol);
549 std::string imported_name;
551 std::vector<Index> best_assignment;
559 args.
log <<
" The configuration was imported successfully as "
560 << imported_name << std::endl << std::endl;
564 args.
log <<
" The configuration was mapped onto pre-existing equivalent structure "
565 << imported_name << std::endl << std::endl;
569 json_src[
"supercell_of"] = configname[0];
573 args.
log <<
" Writing SCEL..." << std::endl;
575 args.
log <<
" Writing config_list..." << std::endl << std::endl;
577 args.
log <<
" DONE" << std::endl << std::endl;
592 Eigen::Matrix3i H_canon;
596 Eigen::Matrix3i T_niggli =
iround(U.inverse() * S_niggli);
599 std::stringstream s_name;
600 s_name <<
"SCEL" << H_niggli(0, 0)*H_niggli(1, 1)*H_niggli(2, 2) <<
"_"
601 << H_niggli(0, 0) <<
"_" << H_niggli(1, 1) <<
"_" << H_niggli(2, 2) <<
"_"
602 << H_niggli(1, 2) <<
"_" << H_niggli(0, 2) <<
"_" << H_niggli(0, 1);
607 args.
log <<
"--- Lattices as column vector matrices ---\n\n";
609 args.
log <<
"Prim lattice, U:\n" << U <<
"\n\n";
611 args.
log <<
"Super lattice, S = U*T:\n" << S <<
"\n\n";
613 args.
log <<
"This is equivalent to '" << s_name.str() <<
"', the equivalent super lattice \n" <<
614 "in the standard orientation niggli cell, S_niggli:\n" << S_niggli <<
"\n\n";
616 args.
log <<
"The transformation matrix (S_niggli = U*T) for '" << s_name.str() <<
"' is:\n" << T_niggli <<
"\n\n";
619 args.
log <<
"--- Lattices as row vector matrices ---\n\n";
621 args.
log <<
"Prim lattice:\n" << U.transpose() <<
"\n\n";
623 args.
log <<
"Super lattice:\n" << S.transpose() <<
"\n\n";
625 args.
log <<
"This is equivalent to '" << s_name.str() <<
"', the equivalent super lattice \n" <<
626 "in the standard orientation niggli cell:\n" << S_niggli.transpose() <<
"\n\n";
633 if(vm.count(
"get-transf-mat")) {
637 if(vm.count(
"unitcell")) {
643 if(vm.count(
"structure")) {
646 else if(vm.count(
"scelnames")) {
650 args.
log <<
"Error in 'casm super --get-transf-mat'. No --structure or --scelnames given." << std::endl << std::endl;
654 args.
log <<
"--- Lattices as column vector matrices ---\n\n";
665 args.
log <<
"The super lattice is a supercell of the unit lattice.\n\n";
667 args.
log <<
"The transformation matrix, T, where S = U*T, is: \n" <<
iround(T) <<
"\n\n";
670 args.
log <<
"The super lattice is NOT a supercell of the unit lattice.\n\n";
672 args.
log <<
"The transformation matrix, T, where S = U*T, is: \n" << T <<
"\n\n";
const Configuration & get_config(Index i) const
Data structure holding basic CASM command info.
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
std::string get_name() const
Return supercell name.
const fs::path & struct_path() const
void write_config_list(std::set< std::string > scel_to_delete={})
Lattice superdupercell(const Lattice &lat1, const Lattice &lat2)
returns Lattice that is smallest possible supercell of both input Lattice
void add_scelnames_suboption()
Add a –scelnames suboption.
const SymGroup & point_group() const
Structure specifies the lattice and atomic basis of a crystal.
void set_atom_names_off()
Do not print atom names line.
void set_atom_names_on()
Print atom names line.
void add_help_suboption()
Add a plain –help suboption.
iterator selected_config_begin()
BasicStructure create_superstruc(const Lattice &scel_lat, double map_tol=TOL) const
Shortcut routine to create a supercell structure and fill it with sites.
void push_back_source(const jsonParser &source)
Eigen::Matrix3i enforce_min_volume(const UnitType &unit, const Eigen::Matrix3i &T, const SymGroup &point_grp, Index volume, bool fix_shape=false)
Return a transformation matrix that ensures a supercell of at least some volume.
const Lattice & get_real_super_lattice() const
void add_configlists_nodefault_suboption()
Add –configs suboption (no default)
Lattice make_supercell(const Lattice &lat, const Eigen::Matrix3i &transf_mat)
Returns a super Lattice.
const Lattice & lattice() const
Represents a supercell of the primitive parent crystal structure.
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
static std::string path()
Get value_type string for path completion.
static std::string supercell()
Get value_type string for supercell completion.
int super_command(const CommandArgs &args)
void print(std::ostream &sout)
Print POSCAR to stream.
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
const po::options_description & desc()
Get the program options, filled with the initialized values.
COORD_MODE specifies the current coordinate mode (Fractional or Cartesian)
EigenIndex Index
For long integer indexing:
void sort()
Default sort is by atom name.
std::vector< fs::path > m_transf_mat_paths
std::string m_unit_scel_str
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...
iterator selected_config_end()
const std::string & unit_scel_str() const
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
bool add_config(const Configuration &config)
const std::vector< std::string > & config_strs() const
Returns the names of the supercells for add_configname_suboption(), for when multiple=false.
PrimClex is the top-level data structure for a CASM project.
std::string title
User-specified name of this Structure.
std::string name() const
SCELV_A_B_C_D_E_F/i.
virtual void read(std::istream &stream)
Print intpolated images in seperate directries.
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") ...
void add_confignames_suboption()
Add a –confignames suboption.
std::pair< Eigen::MatrixXi, Eigen::MatrixXi > hermite_normal_form(const Eigen::MatrixXi &M)
Return the hermite normal form, M == H*V.
void print_supercells(std::set< std::string > scel_to_delete={}) const
void set_coord_mode(COORD_TYPE mode)
Set coordinate mode.
Index add_supercell(const Lattice &superlat)
const std::vector< std::string > & supercell_strs() const
Returns the list of the supercells for add_scelnames_suboption()
bool is_integer(const Eigen::MatrixBase< Derived > &M, double tol)
Check if Eigen::Matrix is integer.
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
PrimClex & make_primclex_if_not(const CommandArgs &args, std::unique_ptr< PrimClex > &uniq_primclex)
If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or c...
Print POSCAR with formating options.
const Supercell & get_supercell(Index i) const
const Access supercell by index
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...
void error(const std::string &what)
Supercell & get_supercell() const
Get the Supercell for this Configuration.
Eigen::CwiseUnaryOp< decltype(std::ptr_fun(boost::math::iround< typename Derived::Scalar >)), const Derived > iround(const Eigen::MatrixBase< Derived > &val)
Round Eigen::MatrixXd to Eigen::MatrixXi.
const Eigen::Matrix3i & get_transf_mat() const
ConfigIO::GenericConfigFormatter< std::string > scelname()
void initialize() override
Fill in the options descriptions accordingly.
const std::vector< fs::path > & transf_mat_paths() const
const std::vector< fs::path > & selection_paths() const
Returns the string corresponding to add_config_suboption()
A Configuration represents the values of all degrees of freedom in a Supercell.
const Structure & get_prim() const
const Access to primitive Structure
bool import_structure_occupation(const fs::path &pos_path, std::string &imported_name, jsonParser &relaxation_properties, std::vector< Index > &best_assignment, Eigen::Matrix3d &cart_op) const
imports structure specified by 'pos_path' into primclex() by finding optimal mapping and then setting...