3 #include <boost/filesystem.hpp>
22 double large_tol,
double increment,
23 std::ostream &print_stream) {
24 std::vector<double> tols;
25 std::vector<bool> is_group;
26 std::vector<int> num_ops, num_enforced_ops;
27 std::vector<std::string>
name;
31 double orig_tol =
lattice.tol();
32 for (
double i = small_tol; i < large_tol; i += increment) {
51 for (
Index i = 0; i < tols.size(); i++) {
52 print_stream << tols[i] <<
"\t" << num_ops[i] <<
"\t" << is_group[i] <<
"\t"
53 << num_enforced_ops[i] <<
"\t name: " <<
name[i] <<
"\n";
61 double enforced_tol) {
98 log <<
"\n***************************\n" << std::endl;
99 log <<
"Symmetrizing: " << poscar_path << std::endl;
100 log <<
"with tolerance: " << tol << std::endl;
132 fs::path POSCARpath_i =
"POSCAR_sym";
133 file_i.open(POSCARpath_i);
170 fs::path output_poscar_location,
double enforced_tol,
174 log <<
"\n***************************\n" << std::endl;
175 log <<
"Symmetrizing: " << input_poscar_location << std::endl;
176 log <<
"with tolerance: " << enforced_tol << std::endl;
179 fs::ifstream infile{input_poscar_location};
185 if (!input_structure_is_primitive) {
186 log <<
"The input structure is not primitive." << std::endl;
187 log <<
"The primitive structure will be generated and symmetrized."
199 input_structure, enforced_tol);
204 bool test_factor_group_valid =
207 Index input_factor_group_size = input_structure.factor_group().size();
209 log <<
"Factor group size of input structure: " << input_factor_group_size
211 log <<
"Factor group size with enforced tolerance: " << test_factor_group_size
215 Structure const *output_structure =
nullptr;
216 if (test_factor_group_valid &&
217 (test_factor_group_size > input_factor_group_size)) {
218 log <<
"Writing symmetrized structure: " << output_poscar_location
220 output_structure = &test_structure;
222 log <<
"Higher symmetry not found the specified tolerance." << std::endl;
223 if (input_structure_is_primitive) {
224 log <<
"Writing input structure, unchanged: " << output_poscar_location
227 log <<
"Writing primitive of input structure: " << output_poscar_location
230 output_structure = &input_structure;
235 input_structure.structure().title()};
237 fs::ofstream file{output_poscar_location};
248 "Symmetrize a POSCAR (--symmetrize POSCAR_LOCATION --tol ENFORCED_TOL): "
251 " The --symmetrize option implements a method to adjust a structure's "
253 " and basis to increase factor group symmetry. "
257 " - Read a VASP POSCAR file from POSCAR_LOCATION and, if not primitive, "
259 " its primitive structure. "
261 " - Construct a symmetrized lattice such that the point group of the "
263 " is equal to that of the input structure's lattice when using "
265 " to check for lattice equivalence. The symmetrized lattice vectors "
267 " obtaining through a process of applying operations in the enforced "
269 " group, averaging, and then rotating to match the original lattice "
273 " - Construct a symmetrized structure with factor group equal to that "
275 " generated for the input structure when using ENFORCED_TOL to check "
277 " structure equivalence. The symmetrized structure's basis is "
279 " by setting basis site coordinates equal to the average coordinate "
281 " positions found after applying each operation in the enforced "
283 " to the original basis sites. "
285 " - Write the symmetrized structure to \"POSCAR_sym\". "
296 std::map<std::string, std::string> cli_to_combined_keys{
298 {
"symmetrize",
"symmetrize"}
306 std::string poscar_path;
307 parser.
require(poscar_path,
"symmetrize");
310 parser.require(enforced_tol,
"tol");
312 std::runtime_error error_if_invalid{
313 "Error reading `casm sym --symmetrize` input"};
PrimClex is the top-level data structure for a CASM project.
Structure specifies the lattice and atomic basis of a crystal.
const xtal::BasicStructure & structure() const
const Lattice & lattice() const
const MasterSymGroup & factor_group() const
SymGroup is a collection of symmetry operations that satisfy the group property The symmetry operatio...
bool is_group(double tol=TOL) const
Check to see if SymGroup satisfies the group property.
Print POSCAR with formating options.
void print(std::ostream &sout) const
Print POSCAR to stream.
BasicStructure specifies the lattice and atomic basis of a crystal.
void set_lattice(const Lattice &lattice, COORD_TYPE mode)
static BasicStructure from_poscar_stream(std::istream &poscar_stream, double tol=TOL)
const std::string & title() const
const Lattice & lattice() const
void set_tol(double _tol)
GenericDatumFormatter< std::string, ConfigEnumDataType > name()
ConfigIO::GenericConfigFormatter< jsonParser > structure()
ConfigIO::GenericConfigFormatter< bool > is_primitive()
GenericVectorXdScelFormatter lattice()
std::vector< SymOp > make_factor_group(const BasicStructure &struc, double tol=TOL)
BasicStructure make_primitive(const BasicStructure &non_primitive_struc, double tol=TOL)
Returns the smallest possible tiling unit of the given structure.
std::vector< SymOp > SymOpVector
xtal::SimpleStructure make_simple_structure(Supercell const &_scel, ConfigDoF const &_dof, std::vector< DoFKey > const &_which_dofs={})
Construct from ConfigDoF _dof belonging to provided Supercell _scel.
std::string description(const SymOp &op, const xtal::Lattice &lat, SymInfoOptions opt=SymInfoOptions())
Print SymInfo to string.
jsonParser & combine_json_options(std::map< std::string, std::string > const &source_to_combined_keys, jsonParser const &json_source, jsonParser &json_combined)
Copy from json_source to json_combined
std::string symmetrize_desc()
Describe the symmetrize method.
void report_and_throw_if_invalid(KwargsParser const &parser, Log &log, ErrorType error)
INDEX_TYPE Index
For long integer indexing:
void symmetrize(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Adjust a structure's lattice and basis to increase factor group symmetry.
void _print_factor_group_convergence(const Structure &struc, double small_tol, double large_tol, double increment, std::ostream &print_stream)
void symmetrize_v1(fs::path poscar_path, double tol)
SymGroup make_enforced_factor_group(xtal::BasicStructure basic_structure, double enforced_tol)
Return SymGroup calculated for basic_structure with specified tolerance.
void symmetrize_v2(fs::path input_poscar_location, fs::path output_poscar_location, double enforced_tol, double input_tol)