CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
import.cc
Go to the documentation of this file.
1 #include <cstring>
2 #include <tuple>
3 
7 #include "casm/clex/PrimClex.hh"
8 #include "casm/casm_io/VaspIO.hh"
9 
11 
12 namespace CASM {
13  namespace Import_impl {
14  // record some pieces of data from each import. These are used to resolve conflicts at the end
15  // the 'relaxjson' datarecord stores relaxation properties that will be merged into Configuration::calc_properties() during the final step
16  enum DataType {path = 0, relaxjson = 1, contcar = 2, energy = 3};
17  using Data = std::tuple<fs::path, jsonParser, std::string, std::pair<bool, double> >;
18  }
19 
20  namespace Completer {
22 
24  return m_lattice_weight;
25  }
26 
27  double ImportOption::vol_tolerance() const {
28  return m_vol_tolerance;
29  }
30 
31  double ImportOption::min_va_frac() const {
32  return m_min_va_frac;
33  }
34 
35  double ImportOption::max_va_frac() const {
36  return m_max_va_frac;
37  }
38  const std::vector<fs::path> &ImportOption::pos_vec() const {
39  return m_pos_vec;
40  }
41 
43  return m_batch_path;
44  }
45 
48 
49  m_desc.add_options()
50  ("pos,p", po::value<std::vector<fs::path> >(&m_pos_vec)->multitoken()->value_name(ArgHandler::path()), "Path(s) to structure(s) being imported (multiple allowed, but no wild-card matching)")
51  ("cost-weight,w", po::value<double>(&m_lattice_weight)->default_value(0.5),
52  "Adjusts cost function for mapping optimization (cost=w*lattice_deformation+(1-w)*basis_deformation).")
53  ("min-energy", "Resolve mapping conflicts based on energy rather than deformation.")
54  ("max-vol-change", po::value<double>(&m_vol_tolerance)->default_value(0.25),
55  "Adjusts range of SCEL volumes searched while mapping imported structure onto ideal crystal (only necessary if the presence of vacancies makes the volume ambiguous). Default is +/- 25% of relaxed_vol/prim_vol. Smaller values yield faster import, larger values may yield more accurate mapping.")
56  ("max-va-frac", po::value<double>(&m_max_va_frac)->default_value(0.5),
57  "Places upper bound on the fraction of sites that are allowed to be vacant after imported structure is mapped onto the ideal crystal. Smaller values yield faster execution, larger values may yield more accurate mapping. Has no effect if supercell volume can be inferred from the number of atoms in the structure. Default value allows up to 50% of sites to be vacant.")
58  ("min-va-frac", po::value<double>(&m_min_va_frac)->default_value(0.),
59  "Places lower bound on the fraction of sites that are allowed to be vacant after imported structure is mapped onto the ideal crystal. Nonzero values may yield faster execution if updating configurations that are known to have a large number of vacancies, at potential sacrifice of mapping accuracy. Has no effect if supercell volume can be inferred from the number of atoms in the structure. Default value allows as few as 0% of sites to be vacant.")
60  ("batch,b", po::value<fs::path>(&m_batch_path)->value_name(ArgHandler::path()), "Path to batch file, which should list one structure file path per line (can be used in combination with --pos)")
61  ("rotate,r", "Rotate structure to be consistent with setting of PRIM")
62  ("ideal,i", "Assume imported structures are unstrained (ideal) for faster importing. Can be slower if used on deformed structures, in which case more robust methods will be used")
63  //("strict,s", "Request that symmetrically equivalent configurations be treated as distinct.")
64  ("data,d", "Attempt to extract calculation data (properties.calc.json file) from the enclosing directory of the structure files, if it is available")
65  ("copy-additional-files", "Recursively copy other files from the same directory as the properties.calc.json file.");
66 
67  return;
68  }
69 
70  }
71 
74  void _cp_files(const fs::path &pos_path, const Configuration &config, bool copy_additional_files, Log &log);
75  void _recurs_cp_files(const fs::path &from_dir, const fs::path &to_dir, Log &log);
76 
77  // ///////////////////////////////////////
78  // 'import' function for casm
79  // (add an 'if-else' statement in casm.cpp to call this)
80 
95  int import_command(const CommandArgs &args) {
96 
97  double tol = TOL;
98  COORD_TYPE coordtype = FRAC;
99 
100  double vol_tol;
101  double lattice_weight;
102  std::vector<fs::path> pos_paths;
103  //fs::path dft_path, batch_path;
104  fs::path batch_path;
105  po::variables_map vm;
107  Completer::ImportOption import_opt;
108 
109  try {
110 
111  po::store(po::parse_command_line(args.argc, args.argv, import_opt.desc()), vm); // can throw
112 
115  if(vm.count("help")) {
116  args.log << std::endl;
117  args.log << import_opt.desc() << std::endl;
118 
119  return 0;
120  }
121 
122  if(vm.count("desc")) {
123  args.log << "\n";
124  args.log << import_opt.desc() << std::endl;
125 
126  args.log << "DESCRIPTION" << std::endl;
127  args.log << " Import structure specified by --pos. If it doesn't exist make a directory for it and copy data over" << std::endl;
128  args.log << " If a *.json file is specified, it will be interpreted as a 'calc.properties.json' file." << std::endl;
129  return 0;
130  }
131 
132  po::notify(vm); // throws on error, so do after help in case
133  // there are any problems
134 
135  vol_tol = import_opt.vol_tolerance();
136  lattice_weight = import_opt.lattice_weight();
137  pos_paths = import_opt.pos_vec();
138  batch_path = import_opt.batch_path();
139 
140  }
141  catch(po::error &e) {
142  args.err_log << import_opt.desc() << std::endl;
143  args.err_log << "ERROR: " << e.what() << std::endl << std::endl;
144  return 3;
145  }
146  catch(std::exception &e) {
147  args.err_log << import_opt.desc() << std::endl;
148  args.err_log << "ERROR: " << e.what() << std::endl << std::endl;
149  return 4;
150 
151  }
152 
153  if(!vm.count("pos") && !vm.count("batch")) {
154  args.err_log << import_opt.desc() << std::endl;
155  args.err_log << "No structures specified for import (specify structures using --pos or --batch)." << std::endl;
156  return 5;
157  }
158 
159  //read all the import paths
160  if(vm.count("batch")) {
161  if(!fs::exists(batch_path)) {
162  args.err_log << "ERROR: Batch import file does not exist at " << batch_path << "\n";
163  return 6;
164  }
165  fs::ifstream batchfile(batch_path);
166  fs::path tpath;
167  while(batchfile >> tpath) {
168  pos_paths.push_back(tpath);
169  batchfile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
170  }
171  if(tpath != pos_paths.back() && tpath.string().size() != 0 && fs::exists(tpath))
172  pos_paths.push_back(tpath);
173  }
174  {
175  if(pos_paths.size() == 0) {
176  args.err_log << "ERROR: No files specified for import.\n";
177  if(vm.count("batch"))
178  args.err_log << " Check batch file for errors.\n";
179  return 7;
180  }
181  bool missing_files(false);
182  for(auto it = pos_paths.cbegin(); it != pos_paths.cend(); ++it) {
183  if(!fs::exists(*it)) {
184  if(!missing_files)
185  args.err_log << "*** ERROR: Missing file(s):\n";
186  missing_files = true;
187  args.err_log << " " << fs::absolute(*it) << "\n";
188  }
189  }
190  if(missing_files)
191  return 8;
192  }
193 
194  COORD_MODE C(coordtype);
195 
196  const fs::path &root = args.root;
197  if(root.empty()) {
198  args.err_log.error("No casm project found");
199  args.err_log << std::endl;
200  return ERR_NO_PROJ;
201  }
202 
203  // If 'args.primclex', use that, else construct PrimClex in 'uniq_primclex'
204  // Then whichever exists, store reference in 'primclex'
205  std::unique_ptr<PrimClex> uniq_primclex;
206  PrimClex &primclex = make_primclex_if_not(args, uniq_primclex);
207  fs::path pwd = fs::current_path();
208 
209  int map_opt = ConfigMapper::none;
210  if(vm.count("rotate")) map_opt |= ConfigMapper::rotate;
211  if(vm.count("strict")) map_opt |= ConfigMapper::strict;
212  if(!vm.count("ideal")) map_opt |= ConfigMapper::robust;
213  ConfigMapper configmapper(primclex, lattice_weight, vol_tol, map_opt, tol);
214  configmapper.set_min_va_frac(import_opt.min_va_frac());
215  configmapper.set_max_va_frac(import_opt.max_va_frac());
216 
217 
218  // import_map keeps track of mapping collisions -- only used if vm.count("data")
219  // import_map[config_name] gives a list all the configuration paths that mapped onto configuration 'config_name' : import_map[config_name][i].first
220  // along with a list of the mapping properties {lattice_deformation, basis_deformation} : import_map[config_name][i].second
221  std::map<Configuration *, std::vector<Import_impl::Data> > import_map;
222  std::vector<std::string > error_log;
223  Index n_unique(0);
224  // iterate over structure files
225  args.log << " Beginning import of " << pos_paths.size() << " configuration" << (pos_paths.size() > 1 ? "s" : "") << "...\n" << std::endl;
226  for(auto it = pos_paths.begin(); it != pos_paths.end(); ++it) {
227  if(it != pos_paths.begin())
228  args.log << "\n***************************\n" << std::endl;
229 
230  fs::path pos_path, import_path;
231 
232  pos_path = fs::absolute(*it, pwd);
233  std::string imported_name;
234  BasicStructure<Site> import_struc;
235 
236  // If user requested data import, try to get structural data from properties.calc.json, instead of POS, etc.
237  // Since properties.calc.json would be used during 'casm update' to validate relaxation
238  if(vm.count("data")) {
239  fs::path dft_path = _calc_properties_path(primclex, pos_path);
240  if(!dft_path.empty()) {
241  pos_path = dft_path;
242  }
243  }
244 
245  //Import structure and make note of path
246  jsonParser relax_data;
247  std::pair<bool, double> checkenergy(false, 0.0);
248 
249  try {
250  if(pos_path.extension() == ".json" || pos_path.extension() == ".JSON") {
251  jsonParser datajson(pos_path);
252  if(datajson.contains("relaxed_energy")) {
253  checkenergy = std::pair<bool, double>(true, datajson["relaxed_energy"].get<double>());
254  }
255  from_json(simple_json(import_struc, "relaxed_"), datajson);
256  }
257  else {
258  fs::ifstream struc_stream(pos_path);
259  import_struc.read(struc_stream);
260  }
261 
262  Eigen::Matrix3d cart_op;
263  std::vector<Index> best_assignment;
264  jsonParser fullrelax_data;
265  if(configmapper.import_structure_occupation(import_struc, imported_name, fullrelax_data, best_assignment, cart_op, true)) {
266  args.log << " " << pos_path << "\n was imported successfully as " << imported_name << std::endl << std::endl;
267  n_unique++;
268  }
269  else {
270  args.log << " " << pos_path << "\n mapped onto pre-existing equivalent structure " << imported_name << std::endl << std::endl;
271  }
272  relax_data = fullrelax_data["best_mapping"];
273  args.log << " Relaxation stats -> lattice_deformation = " << relax_data["lattice_deformation"].get<double>()
274  << " basis_deformation = " << relax_data["basis_deformation"].get<double>() << std::endl << std::endl;;
275  }
276  catch(std::exception &e) {
277  args.err_log << " ERROR: Unable to import " << pos_path << " because \n"
278  << " -> " << e.what() << "\n\n";
279  error_log.push_back(it->string() + "\n -> " + e.what());
280  if(it != pos_paths.cend()) {
281  args.log << " Continuing...\n";
282  }
283  continue;
284  }
285 
286  Configuration &imported_config(primclex.configuration(imported_name));
287 
288  imported_config.push_back_source(jsonParser(std::make_pair("import_mapped", pos_path.string())));
289 
290 
291 
292  //Exit if user did not request not to copy data
293  if(!vm.count("data"))
294  continue;
295 
296  std::stringstream contcar_ss;
297  VaspIO::PrintPOSCAR(import_struc).print(contcar_ss);
298  import_map[&imported_config].push_back(Import_impl::Data(pos_path, relax_data, contcar_ss.str(), checkenergy));
299 
300  }
301 
302  // All the mapping is finished; now we migrate data, if requested
303  std::stringstream conflict_log;
304  if(vm.count("data")) {
305  args.log << " Attempting to import data..." << std::endl;
306  auto it(import_map.begin()), end_it(import_map.end());
307  for(; it != end_it; ++it) {
308  Configuration &imported_config = *(it->first);
309  std::vector<Import_impl::Data> &data_vec(it->second);
310 
311  fs::path import_path = fs::absolute(imported_config.get_path(), pwd);
312  bool preexisting(false);
313  if(_has_existing_files(imported_config.calc_dir())) {
314  preexisting = true;
315  }
316  Index mult = data_vec.size() + Index(preexisting);
317  double best_weight(1e19);
318  double best_energy(1e19);
319  Index best_conflict(0), best_ind(0);
320  if(mult > 1) {
321  conflict_log << " CONFLICT -> " << mult << " matching structures for config " << imported_config.name() << ": " << std::endl;
322  double w = lattice_weight;
323  Index conflict_ind(1);
324  if(preexisting) {
325  conflict_ind++;
326  conflict_log << " 1) Pre-existing data for " << imported_config.name() << " before import." << std::endl
327  << " Relaxation stats:" << std::endl;
328  if(imported_config.calc_properties().contains("basis_deformation") && imported_config.calc_properties().contains("lattice_deformation")) {
329  double ld = imported_config.calc_properties()["lattice_deformation"].get<double>();
330  double bd = imported_config.calc_properties()["basis_deformation"].get<double>();
331  conflict_log << " -- lattice_deformation = " << ld << "; basis_deformation = " << bd << "; weighted avg = " << w *ld + (1.0 - w)*bd << std::endl;
332  if(!vm.count("min-energy")) {
333  best_weight = w * ld + (1.0 - w) * bd;
334  best_conflict = 0;
335  best_ind = -1;
336  }
337  }
338  else {
339  conflict_log << " -- lattice_deformation = unknown; basis_deformation = unknown; weighted avg = unknown" << std::endl;
340  }
341  if(imported_config.calc_properties().contains("relaxed_energy")) {
342  conflict_log << " -- relaxed_energy = " << imported_config.calc_properties()["relaxed_energy"].get<double>() << std::endl;
343  if(vm.count("min-energy")) {
344  best_energy = imported_config.calc_properties()["relaxed_energy"].get<double>();
345  best_conflict = 0;
346  best_ind = -1;
347  }
348  }
349  else
350  conflict_log << " -- relaxed_energy = unknown" << std::endl;
351  conflict_log << std::endl;
352  }
353  for(Index i = 0; i < data_vec.size(); i++) {
354  fs::path pos_path = std::get<Import_impl::path>(data_vec[i]);
355  conflict_log << " " << conflict_ind++ << ") Structure imported from " << pos_path << "." << std::endl
356  << " Relaxation stats:" << std::endl;
357  jsonParser &relaxjson = std::get<Import_impl::relaxjson>(data_vec[i]);
358  double ld = relaxjson["lattice_deformation"].get<double>();
359  double bd = relaxjson["basis_deformation"].get<double>();
360  conflict_log << " -- lattice_deformation = " << ld << "; basis_deformation = " << bd << "; weighted avg = " << w *ld + (1.0 - w)*bd << std::endl;
361  if(std::get<Import_impl::energy>(data_vec[i]).first)
362  conflict_log << " -- relaxed_energy = " << std::get<Import_impl::energy>(data_vec[i]).second << std::endl;
363  else
364  conflict_log << " -- relaxed_energy = unknown" << std::endl;
365  conflict_log << std::endl;
366  if(vm.count("min-energy")) {
367  if(std::get<Import_impl::energy>(data_vec[i]).first) {
368  if(std::get<Import_impl::energy>(data_vec[i]).second < best_energy) {
369  best_energy = std::get<Import_impl::energy>(data_vec[i]).second;
370  best_conflict = conflict_ind - 1;
371  best_ind = i;
372  }
373  }
374  }
375  else {
376  if(w * ld + (1.0 - w)*bd < best_weight) {
377  best_weight = w * ld + (1.0 - w) * bd;
378  best_conflict = conflict_ind - 1;
379  best_ind = i;
380  }
381  }
382  }
383  if(preexisting) {
384  conflict_log << " ==> Resolution: No data will be imported since data already exists" << std::endl;
385  if(valid_index(best_ind)) {
386  if(!vm.count("min-energy"))
387  conflict_log << " *** WARNING: Conflicting config #" << best_conflict << " maps more closely onto ideal crystal! ***" << std::endl;
388  else
389  conflict_log << " *** WARNING: Conflicting config #" << best_conflict << " has a lower energy! ***" << std::endl;
390  }
391  }
392  else {
393  if(!vm.count("min-energy"))
394  conflict_log << " ==> Resolution: Import data from closest match, structure #" << best_conflict << std::endl;
395  else
396  conflict_log << " ==> Resolution: Import data from lowest energy config, structure #" << best_conflict << std::endl;
397  }
398  conflict_log << "\n ----------------------------------------------\n" << std::endl;
399  }
400  if(preexisting) {
401  continue;
402  }
403 
404  fs::path pos_path = std::get<Import_impl::path>(data_vec[best_ind]);
405  if(pos_path.extension() != ".json" && pos_path.extension() != ".JSON") {
406  args.log << " No calculation data was found in the enclosing directory of \n"
407  << " " << pos_path << std::endl
408  << " Continuing..." << std::endl;
409  continue;
410  }
411 
412  fs::path import_target = import_path / ("calctype." + primclex.settings().default_clex().calctype);
413 
414  _cp_files(pos_path, imported_config, vm.count("copy-additional-files"), args.log);
415 
416  if(!fs::exists(imported_config.get_pos_path()))
417  imported_config.write_pos();
418 
419  {
420  fs::ofstream contcar_out(import_target / "relaxed_structure.vasp");
421  contcar_out << std::get<Import_impl::contcar>(data_vec[best_ind]);
422  }
423 
424  jsonParser calc_data;
425  if(!imported_config.read_calc_properties(calc_data)) {
426  args.log << " WARNING: Some properties from " << pos_path << " were not valid. Viable values will still be recorded.\n";
427  }
428 
429  jsonParser &relaxjson = std::get<Import_impl::relaxjson>(data_vec[best_ind]);
430  //append relaxjson onto calc_data
431  auto jit = relaxjson.cbegin(), jit_end = relaxjson.cend();
432  for(; jit != jit_end; ++jit) {
433  calc_data[jit.name()] = *jit;
434  }
435  imported_config.set_calc_properties(calc_data);
436 
437  imported_config.push_back_source(jsonParser(std::make_pair("data_inferred_from_mapping", pos_path.string())));
438 
439  }
440  }
441  args.log << "\n***************************\n" << std::endl;
442 
443  args.log << " Finished importing " << pos_paths.size() << " structures";
444  if(n_unique == 0)
445  args.log << " (none of these are new or unique)";
446  else if(n_unique < pos_paths.size())
447  args.log << " (only " << n_unique << " of these " << (n_unique == 1 ? "is" : "are") << " new and unique)";
448  args.log << "." << std::endl;
449 
450  //Update directories
451  args.log << " Writing SCEL..." << std::endl;
452  primclex.print_supercells();
453  args.log << " Writing config_list..." << std::endl << std::endl;
454  primclex.write_config_list();
455  args.log << " DONE" << std::endl << std::endl;
456 
457  if(error_log.size() > 0) {
458  args.log << " WARNING: --The following paths could not be imported due to errors:\n";
459  for(auto it = error_log.cbegin(); it != error_log.cend(); ++it) {
460  args.log << *it
461  << "\n ----------------------------------------------\n" << std::endl;
462  }
463  args.log << "\n" << std::endl;
464  }
465  if(conflict_log.str().size()) {
466  args.log << " WARNING: -- The following conflicts were found\n" << std::endl
467  << conflict_log.str() << std::endl;
468 
469  args.log << " Please review these conflicts. A different resolution can be obtained by removing datafiles from\n"
470  << " the training_data directory and performing an import using a manually reduced set of files.\n";
471  }
472  args.log << " DONE" << std::endl << std::endl;
473 
474  args.log << std::endl;
475 
476  return 0;
477  };
478 
480  if(!fs::exists(p)) {
481  return false;
482  }
483  return std::distance(fs::directory_iterator(p), fs::directory_iterator());
484  }
485 
496 
497  // check 1: is a JSON file
498  if(pos_path.extension() == ".json" || pos_path.extension() == ".JSON") {
499  return pos_path;
500  }
501 
502  // check 2: /path/to/POS -> /path/to/calctype.current/properties.calc.json
503  {
504  fs::path dft_path = pos_path;
505  dft_path.remove_filename();
506  (dft_path /= ("calctype." + primclex.settings().default_clex().calctype)) /= "properties.calc.json";
507  if(fs::exists(dft_path)) {
508  return dft_path;
509  }
510  }
511 
512  // check 3: /path/to/POS -> /path/to/properties.calc.json
513  {
514  fs::path dft_path = pos_path;
515  dft_path.remove_filename();
516  dft_path /= "properties.calc.json";
517  if(fs::exists(dft_path)) {
518  return dft_path;
519  }
520  }
521 
522  // not found, return empty path
523  return fs::path();
524  }
525 
534  void _cp_files(const fs::path &pos_path, const Configuration &config, bool copy_additional_files, Log &log) {
535  fs::path p = config.calc_dir();
536  if(!fs::exists(p)) {
537  fs::create_directories(p);
538  }
539 
540  fs::path calc_props_path = _calc_properties_path(config.get_primclex(), pos_path);
541  if(calc_props_path.empty()) {
542  return;
543  }
544 
545  log.custom(std::string("Copy calculation files: ") + config.name());
546  if(!copy_additional_files) {
547  log << "cp " << calc_props_path << " " << p << std::endl;
548  fs::copy_file(calc_props_path, p / calc_props_path.filename());
549  }
550  else {
551  _recurs_cp_files(calc_props_path.remove_filename(), p, log);
552  }
553  log << std::endl;
554  }
555 
556  void _recurs_cp_files(const fs::path &from_dir, const fs::path &to_dir, Log &log) {
557  auto it = fs::directory_iterator(from_dir);
558  auto end = fs::directory_iterator();
559  for(; it != end; ++it) {
560  if(fs::is_regular_file(*it)) {
561  log << "cp " << *it << " " << to_dir << std::endl;
562  fs::copy_file(*it, to_dir / it->path().filename());
563  }
564  else {
565  fs::path new_to_dir = to_dir / it->path().filename();
566  fs::create_directories(new_to_dir);
567  _recurs_cp_files(*it, new_to_dir, log);
568  }
569  }
570  }
571 }
Data structure holding basic CASM command info.
void initialize() override
Fill in the options descriptions accordingly.
Definition: import.cc:46
std::vector< fs::path > m_pos_vec
Definition: Handlers.hh:538
void write_config_list(std::set< std::string > scel_to_delete={})
Definition: PrimClex.cc:450
double lattice_weight() const
Definition: import.cc:23
void from_json(ClexDescription &desc, const jsonParser &json)
bool _has_existing_files(fs::path p)
Definition: import.cc:479
PrimClex & get_primclex() const
Get the PrimClex for this Configuration.
PrimClex * primclex
Definition: settings.cc:101
void add_help_suboption()
Add a plain –help suboption.
Definition: Handlers.cc:276
void push_back_source(const jsonParser &source)
const std::vector< fs::path > & pos_vec() const
Definition: import.cc:38
Main CASM namespace.
Definition: complete.cpp:8
double max_va_frac() const
Definition: import.cc:35
Log & log
Definition: settings.cc:105
const double TOL
const_iterator cend() const
Returns const_iterator to end of JSON object or JSON array.
Definition: jsonParser.cc:480
static std::string path()
Get value_type string for path completion.
Definition: Handlers.cc:39
fs::path calc_dir() const
T get(Args...args) const
Get data from json, using one of several alternatives.
Definition: jsonParser.hh:729
bool read_calc_properties(jsonParser &parsed_props) const
void print(std::ostream &sout)
Print POSCAR to stream.
Definition: VaspIO.hh:509
double tol
void custom(const std::string &what)
Definition: Log.hh:96
const Properties & calc_properties() const
int import_command(const CommandArgs &args)
Definition: import.cc:95
const po::options_description & desc()
Get the program options, filled with the initialized values.
Definition: Handlers.cc:160
COORD_MODE specifies the current coordinate mode (Fractional or Cartesian)
fs::path get_pos_path() const
Path to various files.
void _cp_files(const fs::path &pos_path, const Configuration &config, bool copy_additional_files, Log &log)
Copy files in the same directory as properties.calc.json into the traning_data directory for a partic...
Definition: import.cc:534
void set_min_va_frac(double _min_va)
EigenIndex Index
For long integer indexing:
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
Definition: Handlers.hh:126
fs::path get_path() const
ProjectSettings & settings()
Definition: PrimClex.hh:116
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
double min_va_frac() const
Definition: import.cc:31
T max(const T &A, const T &B)
Definition: CASM_math.hh:32
SimpleJSonSiteStructure< true > simple_json(const BasicStructure< Site > &struc, const std::string &prefix)
Definition: jsonStruc.hh:110
std::string name() const
SCELV_A_B_C_D_E_F/i.
double vol_tolerance() const
Definition: import.cc:27
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") ...
Definition: PrimClex.cc:347
const fs::path & batch_path() const
Definition: import.cc:42
void _recurs_cp_files(const fs::path &from_dir, const fs::path &to_dir, Log &log)
Definition: import.cc:556
void print_supercells(std::set< std::string > scel_to_delete={}) const
Definition: PrimClex.cc:557
void set_calc_properties(const jsonParser &json)
Read calculation results into the configuration.
void set_max_va_frac(double _max_va)
void write_pos() const
Write the POS file to get_pos_path.
Eigen::Matrix3d Matrix3d
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.
Definition: VaspIO.hh:232
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:500
fs::path _calc_properties_path(const PrimClex &primclex, fs::path pos_path)
Return path to properties.calc.json that will be imported checking a couple possible locations relati...
Definition: import.cc:495
void error(const std::string &what)
Definition: Log.hh:86
Definition: Log.hh:9
std::tuple< fs::path, jsonParser, std::string, std::pair< bool, double > > Data
Definition: import.cc:17
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.
Definition: jsonParser.cc:455
const ClexDescription & default_clex() const
A Configuration represents the values of all degrees of freedom in a Supercell.
bool valid_index(Index i)
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...
#define ERR_NO_PROJ