CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ConfigImport.cc
Go to the documentation of this file.
2 
17 
18 namespace CASM {
19 
20 template class DataFormatter<DB::ConfigIO::Result>;
21 
22 namespace Local {
23 
48  SimpleStructure const &simple_structure,
49  std::set<std::string> const &dof_managed_properties,
51  double total_cost) {
52  MappedProperties result;
53 
54  for (auto const &prop : simple_structure.properties) {
55  if (!dof_managed_properties.count(prop.first)) {
56  result.global[prop.first] = prop.second;
57  // If "*strain" is a property, rather than a DoF, we will also store the
58  // lattice
59  if (prop.first.find("strain") != std::string::npos) {
60  result.global["latvec"] = simple_structure.lat_column_mat;
61  }
62  }
63  }
64 
65  for (auto const &prop : simple_structure.mol_info.properties) {
66  if (!dof_managed_properties.count(prop.first)) {
67  result.site[prop.first] = prop.second;
68  // If "disp" is a property, rather than a DoF, we will also store the
69  // coordinates
70  if (prop.first == "disp") {
71  result.site["coordinate"] = simple_structure.mol_info.coords;
72  }
73  }
74  }
75 
76  result.scalar("lattice_deformation_cost") = lattice_deformation_cost;
77  result.scalar("atomic_deformation_cost") = atomic_deformation_cost;
78  result.scalar("total_cost") = total_cost;
79  return result;
80 }
81 
83  MappingNode const &_node, ConfigMapperResult::Individual const &_map) {
86  _node.atomic_node.cost, _node.cost);
87 }
88 } // namespace Local
89 
90 namespace DB {
91 
92 // --- Configuration specializations ---------------------------------------
93 
94 // --- Import<Configuration> ---
95 
97  return m_configmapper->settings();
98 }
99 
103  const PrimClex &primclex) {
104  // -- construct ConfigMapper --
105  m_configmapper.reset(
107 }
108 
122  fs::path p, std::vector<std::string> const &req_properties,
123  std::unique_ptr<Configuration> const &hint_config,
124  map_result_inserter result) const {
125  // need to set Result data (w/ defaults):
126  // - std::string pos = "";
127  // - MappedProperties mapped_props {origin:"", to:"", unmapped:{}, mapped:{}};
128  // - bool has_data = false;
129  // - bool has_complete_data = false;
130  // - bool is_new_config = false;
131  // - std::string fail_msg = "";
132  ConfigIO::Result res;
133  res.pos_path = p.string();
134 
135  if (!fs::exists(res.pos_path)) {
136  res.fail_msg = "Specified file does not exist!";
137  }
138  // read from structure file or properties.calc.json file (if exists)
139  SimpleStructure sstruc = this->_make_structure(res.pos_path);
140 
141  // do mapping
142  ConfigMapperResult map_result =
143  m_configmapper->import_structure(sstruc, hint_config.get());
144 
145  if (!map_result.success()) {
146  res.fail_msg = map_result.fail_msg;
147  *result++ = std::move(res);
148  return result;
149  }
150 
151  if (map_result.n_optimal() > 1) {
152  res.fail_msg = "There were " + std::to_string(map_result.n_optimal()) +
153  " optimal mappings, when only one was expected.";
154  *result++ = std::move(res);
155  return result;
156  }
157 
158  for (auto const &map : map_result.maps) {
159  // insert in database (note that this also/only inserts primitive)
160  ConfigInsertResult insert_result =
161  map.second.config.insert(settings().primitive_only);
162 
163  res.is_new_config = insert_result.insert_canonical;
164 
165  res.properties = Local::_make_mapped_properties(map.first, map.second);
166  res.properties.file_data = p.string();
167  res.properties.to = insert_result.canonical_it.name();
168  res.properties.origin = p.string();
169 
170  if (hint_config) {
171  res.properties.init_config = hint_config->name();
172  }
173 
174  for (std::string const &propname : req_properties) {
175  res.has_data = false;
176  res.has_complete_data = true;
177  if (res.properties.global.count(propname) ||
178  res.properties.site.count(propname)) {
179  res.has_data = true;
180  } else {
181  res.has_complete_data = false;
182  }
183  }
184 
185  // at this point, the mapped structure result is complete
186  *result++ = res;
187 
188  // it may be the structure was not primitive:
189  // - in which case we need to create a result indicating that the primitive
190  // was also inserted in the database,
191  // - but don't try to scale the data for the primitive
192  if (insert_result.canonical_it != insert_result.primitive_it) {
193  ConfigIO::Result prim_res;
194  prim_res.pos_path = res.pos_path;
195  prim_res.properties.file_data = res.properties.file_data;
196  prim_res.properties.origin =
197  "prim:" +
198  res.properties.origin; // insert_result.primitive_it.name();
199  prim_res.properties.to = insert_result.primitive_it.name();
200  prim_res.is_new_config = insert_result.insert_primitive;
201  // at this point, the mapped structure result is complete
202  *result++ = prim_res;
203  }
204  }
205  return result;
206 }
207 
213  const fs::path &p) const {
214  SimpleStructure sstruc;
215  if (p.extension() == ".json" || p.extension() == ".JSON") {
216  jsonParser json(p);
217  from_json(sstruc, json);
218  } else {
219  fs::ifstream struc_stream(p);
221  sstruc = make_simple_structure(struc);
222  }
223  return sstruc;
224 }
225 
226 // --- Import<Configuration> ---
227 
230  const StructureMap<Configuration> &mapper,
231  ImportSettings const &_set,
232  std::string const &report_dir)
233  :
234 
235  ImportT(primclex, mapper, _set, report_dir) {}
236 
237 const std::string Import<Configuration>::desc =
238 
239  "Import Configuration: \n\n"
240 
241  " 'casm import' of Configuration proceeds in two steps: \n\n"
242 
243  " 1) For each file: \n"
244  " - Read structure from VASP POSCAR type file or CASM "
245  "properties.calc.json \n"
246  " file. \n"
247  " - Map the structure onto a Configuration of the primitive crystal \n"
248  " structure. \n"
249  " - Record relaxation data (lattice & basis deformation cost). \n\n"
250 
251  " 2) If data import is requested, iterate over each import record and do "
252  "\n"
253  " the following:\n"
254  " - If multiple imported structures map onto a configuration for which "
255  "\n"
256  " there is no calculation data, import calculation data from the "
257  "\n"
258  " structure with the lowest \"conflict_score\". "
259  "\n"
260  " - If one or more imported structures map onto a configuration for "
261  "\n"
262  " which calculation data already exist, do not import any new data "
263  "\n"
264  " unless the \"overwrite\" option is given, in which case data and "
265  "\n"
266  " files are imported if the \"conflict_score\" will be improved. \n"
267  " - If data is imported, the corresponding properties.calc.json file "
268  "is\n"
269  " copied into the directory of the mapped configuration. Optionally, "
270  "\n"
271  " additional files in the directory of the imported structure file "
272  "may\n"
273  " also be copied. \n"
274  " - Reports are generated detailing the results of the import: \n"
275  " - import_map_fail: Structures that could not be mapped onto the "
276  " \n"
277  " primitive crystal structure. \n"
278  " - import_map_success: Configurations that were successfully mapped "
279  " \n"
280  " and imported into the Configuration database (or already "
281  "existed).\n"
282  " - import_data_fail: Structures with data that would be imported "
283  " \n"
284  " except preexisting data prevents it. \n"
285  " - import_conflict: Configurations that were mapped to by multiple "
286  " \n"
287  " structures. \n\n"
288 
289  "Settings: \n\n"
290 
291  " mapping: JSON object (optional)\n"
292  " A JSON object containing the following options controlling the "
293  "structure-\n"
294  " mapping algorithm:\n"
295 
296  " primitive_only: bool (optional, default=false)\n"
297  " By convention, primitive configurations are always imported along "
298  "with \n"
299  " non-primitive configurations. If false, only the primitive "
300  "configuration\n"
301  " will be imported. Note: data from non-primitive configurations is "
302  "never\n"
303  " used for primitive configurations.\n\n"
304 
305  " lattice_weight: number in range [0.0, 1.0] (optional, default=0.5) \n"
306  " Candidate configurations are compared using \"deformation_cost\" "
307  "to \n"
308  " determine the best mapping of the import structure to a "
309  " \n"
310  " configuration. The \"lattice_weight\" determines the relative "
311  "weight\n"
312  " of the \"lattice_deformation_cost\" and "
313  "\"atomic_deformation_cost\" \n"
314  " when calculating the total \"deformation_cost\". See _____ for "
315  " \n"
316  " details. \n\n"
317 
318  " max_vol_change: number (optional, default=0.3)\n"
319  " Adjusts range of SCEL volumes searched while mapping imported \n"
320  " structure onto ideal crystal (only necessary if the presence of \n"
321  " vacancies makes the volume ambiguous). Default is +/- 30% of the "
322  "rounded\n"
323  " integer volume (relaxed volume / primitive unit cell volume) of "
324  "the \n"
325  " structure . Smaller values yield faster execution, larger values "
326  "may \n"
327  " yield more accurate mapping.\n\n"
328 
329  " max_va_frac: number (optional, default=0.5)\n"
330  " Places upper bound on the fraction of sites that are allowed to "
331  "be \n"
332  " vacant after relaxed structure is mapped onto the ideal crystal. "
333  "\n"
334  " Smaller values yield faster execution, larger values may yield "
335  "more \n"
336  " accurate mapping. Has no effect if supercell volume can be "
337  "inferred \n"
338  " from the number of atoms in the structure. Default value allows "
339  "up to \n"
340  " 50% of sites to be vacant.\n\n"
341 
342  " min_va_frac: number (optional, default=0.0)\n"
343  " Places lower bound on the fraction of sites that are allowed to "
344  "be \n"
345  " vacant after relaxed structure is mapped onto the ideal crystal. "
346  "\n"
347  " Nonzero values may yield faster execution if updating "
348  "configurations \n"
349  " that are known to have a large number of vacancies, at potential "
350  "\n"
351  " sacrifice of mapping accuracy. Has no effect if supercell volume "
352  "can \n"
353  " be inferred from the number of atoms in the structure. Default "
354  "value \n"
355  " allows as few as 0% of sites to be vacant.\n\n"
356 
357  " ideal: bool (optional, default=false)\n"
358  " Assume imported structures are in the setting of the ideal "
359  "crytal.\n"
360  " This results in faster mapping, but may not identify the ideal "
361  "mapping.\n"
362  " If large mapping costs are encountered, try re-running with ideal "
363  ": false\n\n"
364 
365  " robust: bool (optional, default=false)\n"
366  " Perform additional checks to determine if mapping is degenerate "
367  "in cost\n"
368  " to other mappings, which can occur if the imported structure has "
369  "symmetry\n"
370  " that is incompatible with prim.json. Results in slower "
371  "execution.\n\n"
372 
373  " filter: string (optional) \n"
374  " Restricts the import to only consider supercells that match a "
375  "provided\n"
376  " casm query expression.\n\n"
377 
378  " forced_lattices: array of strings (optional) \n"
379  " Restricts the import to only consider supercells provided via a "
380  "list of\n"
381  " a list of their conventional names (i.e., "
382  "\"SCEL2_2_1_1_1_1_0\").\n\n"
383 
384  " data: JSON object (optional)\n"
385  " A JSON object containing the following options controlling when "
386  "calculated \n"
387  " properties are updated.\n\n"
388 
389  " import: bool (optional, default=false)\n"
390  " If true (default), attempt to import calculation results. Results "
391  "are \n"
392  " added from a \"properties.calc.json\" file which is checked for "
393  "in the\n"
394  " following locations, relative to the input file path, 'pos': \n"
395 
396  " 1) Is 'pos' a JSON file? If 'pos' ends in \".json\" or \".JSON\", "
397  "then\n"
398  " it is assumed to be a 'properties.calc.json' file.\n"
399  " 2) If / path / to / pos, checks for / path / to / "
400  "calctype.current / properties.calc.json\n"
401  " 3) If / path / to / pos, checks for / path / to / "
402  "properties.calc.json \n\n"
403 
404  " If false, only configuration structure is imported.\n\n"
405 
406  " additional_files: bool (optional, default = false)\n"
407  " If true, attempt to copy all files & directories in the same "
408  "directory\n"
409  " as the structure file or , if it exists, the properties.calc.json "
410  "file.\n"
411  " Files & directories will only by copied if there are no existing "
412  "files\n"
413  " or directories in the 'training_data' directory for the "
414  "configuration \n"
415  " the structure as been mapped to or \"overwrite\"=true.\n\n"
416 
417  " overwrite: bool (optional, default=false)\n"
418  " If true, data and files will be imported that overwrite existing\n"
419  " data and files, if the score calculated by the "
420  "\"conflict_score\"\n"
421  " for the configuration being mapped to will be improved.\n\n";
422 
424  const jsonParser &kwargs,
425  const Completer::ImportOption &import_opt) {
426  // -- collect input settings --
427 
428  ConfigMapping::Settings map_settings;
429  if (kwargs.contains("mapping")) from_json(map_settings, kwargs["mapping"]);
430 
431  ImportSettings import_settings;
432  if (kwargs.contains("data")) from_json(import_settings, kwargs["data"]);
433 
434  // get input report_dir, check if exists, and create new report_dir.i if
435  // necessary
436  std::string report_dir =
437  (fs::path(primclex.dir().reports_dir()) / "import_report").string();
438  report_dir = create_report_dir(report_dir);
439 
440  // 'mapping' subsettings are used to construct ConfigMapper, and also returns
441  // the 'used' settings
442  StructureMap<Configuration> mapper(map_settings, primclex);
443 
444  jsonParser used_settings;
445  used_settings["mapping"] = mapper.settings();
446  used_settings["data"] = import_settings;
447 
448  // -- print used settings --
449  Log &log = CASM::log();
450  log.read("Settings");
451  log << used_settings << std::endl << std::endl;
452 
453  // -- construct Import --
454  Import<Configuration> f(primclex, mapper, import_settings, report_dir);
455 
456  // -- read structure file paths --
457  std::set<fs::path> pos;
458  auto res =
459  construct_pos_paths(primclex, import_opt, std::inserter(pos, pos.end()));
460  if (res.second) {
461  return res.second;
462  }
463 
464  // -- read structure file paths --
465  f.import(pos.begin(), pos.end());
466 
467  return 0;
468 }
469 
470 const std::string Update<Configuration>::desc =
471 
472  "Update Configuration calculation results: \n\n"
473 
474  " 'casm update' of Configuration calculation results proceeds as follows: "
475  "\n\n"
476 
477  " For each Configuration in the input selection: \n"
478  " - Read properties.calc.json file from training_data directory. "
479  "\n"
480  " - Map the relaxed structure onto a Configuration of the primitive "
481  "crystal\n"
482  " structure. \n"
483  " - Record relaxation data: \n"
484  " - Lattice & basis deformation cost \n"
485  " - Initial configuration and relaxed configuration \n\n"
486  " - If multiple configurations relax onto a configuration for which "
487  "there \n"
488  " is no calculation data, the calculation data from the with the "
489  "lowest \n"
490  " conflict resolution score is used for the relaxed configuration.\n\n"
491 
492  "Settings: \n\n"
493 
494  " force: bool (optional, default=false) \n"
495  " Force update all specified Configuration, else use timestamps to "
496  " \n"
497  " determine which to update. \n"
498 
499  "Settings: \n\n"
500 
501  " mapping: JSON object (optional)\n"
502  " A JSON object containing the following options controlling the "
503  "structure-\n"
504  " mapping algorithm:\n"
505 
506  " primitive_only: bool (optional, default=false)\n"
507  " By convention, primitive configurations are always imported along "
508  "with \n"
509  " non-primitive configurations. If false, only the primitive "
510  "configuration\n"
511  " will be imported. Note: data from non-primitive configurations is "
512  "never\n"
513  " used for primitive configurations.\n\n"
514 
515  " lattice_weight: number in range [0.0, 1.0] (optional, default=0.5) \n"
516  " Candidate configurations are compared using \"deformation_cost\" "
517  "to \n"
518  " determine the best mapping of the import structure to a "
519  " \n"
520  " configuration. The \"lattice_weight\" determines the relative "
521  "weight\n"
522  " of the \"lattice_deformation_cost\" and "
523  "\"atomic_deformation_cost\" \n"
524  " when calculating the total \"deformation_cost\". See _____ for "
525  " \n"
526  " details. \n\n"
527 
528  " max_vol_change: number (optional, default=0.3)\n"
529  " Adjusts range of SCEL volumes searched while mapping imported \n"
530  " structure onto ideal crystal (only necessary if the presence of \n"
531  " vacancies makes the volume ambiguous). Default is +/- 30% of the "
532  "rounded\n"
533  " integer volume (relaxed volume / primitive unit cell volume) of "
534  "the \n"
535  " structure . Smaller values yield faster execution, larger values "
536  "may \n"
537  " yield more accurate mapping.\n\n"
538 
539  " max_va_frac: number (optional, default=0.5)\n"
540  " Places upper bound on the fraction of sites that are allowed to "
541  "be \n"
542  " vacant after relaxed structure is mapped onto the ideal crystal. "
543  "\n"
544  " Smaller values yield faster execution, larger values may yield "
545  "more \n"
546  " accurate mapping. Has no effect if supercell volume can be "
547  "inferred \n"
548  " from the number of atoms in the structure. Default value allows "
549  "up to \n"
550  " 50% of sites to be vacant.\n\n"
551 
552  " min_va_frac: number (optional, default=0.0)\n"
553  " Places lower bound on the fraction of sites that are allowed to "
554  "be \n"
555  " vacant after relaxed structure is mapped onto the ideal crystal. "
556  "\n"
557  " Nonzero values may yield faster execution if updating "
558  "configurations \n"
559  " that are known to have a large number of vacancies, at potential "
560  "\n"
561  " sacrifice of mapping accuracy. Has no effect if supercell volume "
562  "can \n"
563  " be inferred from the number of atoms in the structure. Default "
564  "value \n"
565  " allows as few as 0% of sites to be vacant.\n\n"
566 
567  " ideal: bool (optional, default=false)\n"
568  " Assume imported structures are in the setting of the ideal "
569  "crytal.\n"
570  " This results in faster mapping, but may not identify the ideal "
571  "mapping.\n"
572  " If large mapping costs are encountered, try re-running with ideal "
573  ": false\n\n"
574 
575  " fix_volume: bool (optional, default=false)\n"
576  " Assume imported structures have the same integer volume as the "
577  "starting\n"
578  " configuration. All supercells of this volume are considered for "
579  "mapping.\n"
580  " This assumption may fail for systems that allow vacancies, when "
581  "vacancy\n"
582  " concentration is high. Increases execution speed in these "
583  "cases.\n\n"
584 
585  " fix_lattice: bool (optional, default=false)\n"
586  " Assume imported structures have the same lattice as the starting "
587  "configuration\n"
588  " Only this supercell will be considered for mapping, but all "
589  "orientational\n"
590  " relationships will still be considered. Increases execution "
591  "speed, especially\n"
592  " at large supercell volume, but cannot detect relaxation to a "
593  "different supercell.\n\n"
594 
595  " robust: bool (optional, default=false)\n"
596  " Perform additional checks to determine if mapping is degenerate "
597  "in cost\n"
598  " to other mappings, which can occur if the imported structure has "
599  "symmetry\n"
600  " that is incompatible with prim.json. Results in slower "
601  "execution.\n\n"
602 
603  " data: JSON object (optional)\n"
604  " A JSON object containing the following options controlling how "
605  "calculated \n"
606  " properties are updated. After structural relaxation, a structural "
607  "that \n"
608  " began as structure 'A' may map more closely onto a different "
609  "structure, 'B'\n"
610  " In some cases, multiple structures may map onto the same 'B', and a "
611  "scoring\n"
612  " metric is used to specify which set of calculation data is "
613  "associated with \n"
614  " configuration 'B'. The following values determine the scoring "
615  "metric:\n\n"
616 
617  " \"deformation_cost\":\n"
618  " \"lattice_weight\": number, in range [0, 1.0]\n"
619 
620  " Uses a weighted sum of cost functions for lattice and basis \n"
621  " deformation. See below for complete definition. Ex: \n"
622  " {\"method\":\"deformation_cost\":, \"lattice_weight\":0.5} \n\n"
623 
624  " \"minimum\":\n"
625  " \"property\": property name (ex: \"energy\")\n"
626 
627  " Reads the specified property from the mapped properties and\n"
628  " selects the minimum to be the best mapping. Ex: \n"
629  " {\"method\":\"minimum\":, \"property\": \"energy\"} \n\n"
630 
631  " \"maximum\":\n"
632  " \"property\": property name (ex: \"energy\")\n"
633 
634  " Reads the specified property from the mapped properties and\n"
635  " selects the maximum to be the best mapping. Ex: \n"
636  " {\"method\":\"maximum\":, \"property\": \"energy\"} \n\n"
637 
638  " \"direct_selection\":\n"
639  " \"name\": configname to force as 'best' (ex: "
640  "\"SCEL3_1_1_3_0_0_0/4\")\n"
641 
642  " Directly specify which configuration's properties should be used. "
643  "Ex: \n"
644  " {\"method\":\"direct_selection\":, \"name\": "
645  "\"SCEL3_1_1_3_0_0_0/4\"} \n\n"
646 
647  " The default value used by CASM is:\n"
648  " {\"method\": \"minimum\", \"property\": \"energy\"}\n\n"
649 
650  "Deformation cost:\n"
651 
652  " The \"deformation_cost\" is:\n\n"
653 
654  " deformation_cost = w*lattice_deformation_cost + \n"
655  " (1.0-w)*atomic_deformation_cost,\n\n"
656 
657  " where \"w\" is the \"lattice_weight\" factor (default=0.5),\n\n"
658 
659  " the \"lattice_deformation_cost\" is the mean-square displacement of a \n"
660  " points on the surface of a sphere of volume equal to the atomic volume "
661  "\n"
662  " when it is deformed by the volume preserving deviatoric deformation \n"
663  " matrix, F_deviatoric:\n\n"
664 
665  " V = relaxed_atomic_volume;\n"
666  " F = deformation matrix (lattice_relaxed = F*lattice_ideal);\n"
667  " F_deviatoric = F/pow(F.determinant(), 1./3.);\n"
668  " I = 3x3 identity matrix;\n\n"
669 
670  " lattice_deformation_cost = pow( 3.*V / (4.*pi), 2.0/3.0) / 3.0 * \n"
671  " (0.5 * (F.t * F / pow(std::abs(F.determinant()), 2.0/3.0) - "
672  "I)).squaredNorm()\n\n"
673 
674  " and the \"atomic_deformation_cost\" is a cost function for the amount "
675  "of\n"
676  " basis site relaxation:\n\n"
677 
678  " D = 3xN matrix of basis site displacements (displacements are "
679  "applied \n"
680  " before strain)\n"
681  " Natoms = number of atoms in configuration\n"
682  " atomic_deformation_cost = (F*D * D.transpose() * "
683  "F.transpose()).trace() \n"
684  " / (max(Natoms, 1.))\n\n";
685 
688  const {
690  ConfigIO::default_import_formatters(dict, db_props());
691 
692  std::vector<std::string> col = {"initial_path",
693  "selected",
694  "to_configname",
695  "final_path",
696  "is_new_config",
697  "has_data",
698  "has_complete_data",
699  "preexisting_data",
700  "import_data",
701  "import_additional_files",
702  "score",
703  "best_score",
704  "is_best",
705  "lattice_deformation_cost",
706  "atomic_deformation_cost",
707  "energy"};
708 
709  return dict.parse(col);
710 }
711 
712 // --- Update<Configuration> ---
713 
716  const StructureMap<Configuration> &mapper,
717  std::string const &report_dir)
718  : UpdateT(primclex, mapper, report_dir) {}
719 
721  const jsonParser &kwargs,
722  const Completer::UpdateOption &update_opt) {
723  // -- collect input settings --
724 
725  const po::variables_map &vm = update_opt.vm();
726  jsonParser used;
727 
728  // general settings
729  bool force;
730  if (vm.count("force")) {
731  force = true;
732  } else {
733  kwargs.get_else(force, "force", false);
734  }
735  used["force"] = force;
736 
737  // 'mapping' subsettings are used to construct ConfigMapper and return 'used'
738  // settings values still need to figure out how to specify this in general
739  jsonParser map_json;
740  kwargs.get_else(map_json, "mapping", jsonParser());
741  ConfigMapping::Settings map_settings =
742  map_json.get<ConfigMapping::Settings>();
743  map_settings.primitive_only = true;
744 
745  StructureMap<Configuration> mapper(map_settings, primclex);
746  used["mapping"] = mapper.settings();
747 
748  // 'data' subsettings
749  // bool import_data = true;
750  // bool import_additional_files = false;
751  // bool overwrite = false;
752 
753  // -- print used settings --
754  Log &log = CASM::log();
755  log.read("Settings");
756  log << used << std::endl << std::endl;
757 
758  // get input report_dir, check if exists, and create new report_dir.i if
759  // necessary
760  std::string report_dir =
761  (fs::path(primclex.dir().reports_dir()) / "update_report").string();
762  report_dir = create_report_dir(report_dir);
763 
764  // -- construct Update --
765  Update<Configuration> f(primclex, mapper, report_dir);
766 
767  // -- read selection --
769 
770  // -- update --
771  f.update(sel, force);
772 
773  return 0;
774 }
775 
776 // Allow ConfigType to specialize the report formatting for 'update'
778  const {
780  ConfigIO::default_update_formatters(dict, db_props());
781 
782  std::vector<std::string> col = {"data_origin",
783  "selected",
784  "to_configname",
785  "has_data",
786  "has_complete_data",
787  "score",
788  "best_score",
789  "is_best",
790  "lattice_deformation_cost",
791  "atomic_deformation_cost",
792  "energy"};
793 
794  return dict.parse(col);
795 }
796 
797 } // namespace DB
798 } // namespace CASM
po::variables_map & vm()
Get the variables map.
Definition: Handlers.cc:310
const fs::path & selection_path() const
Returns the string corresponding to add_config_suboption()
Definition: Handlers.cc:338
std::string name() const
Definition: Database.hh:160
Configuration-specialized Import.
Definition: ConfigImport.hh:76
Generic ConfigType-dependent part of Import.
Definition: Import.hh:66
void import(PathIterator begin, PathIterator end)
Definition: Import_impl.hh:97
const ConfigMapping::Settings & settings() const
Returns settings used for mapping.
Definition: ConfigImport.cc:96
std::back_insert_iterator< std::vector< ConfigIO::Result > > map_result_inserter
Definition: ConfigImport.hh:41
Configuration-specialized Import.
Definition: ConfigImport.hh:96
Generic ConfigType-dependent part of Import.
Definition: Update.hh:30
void update(const DB::Selection< ConfigType > &selection, bool force)
Re-parse calculations 'from' all selected configurations.
Definition: Update_impl.hh:27
Parsing dictionary for constructing a DataFormatter<DataObject> object.
DataFormatter< DataObject > parse(const std::string &input) const
Use the vector of strings to build a DataFormatter<DataObject>
Extract data from objects of 'DataObject' class.
Definition: Log.hh:48
void read(const std::string &what)
Definition: Log.hh:104
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:55
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:601
BasicStructure specifies the lattice and atomic basis of a crystal.
static BasicStructure from_poscar_stream(std::istream &poscar_stream, double tol=TOL)
Representation of a crystal of molecular and/or atomic occupants, and any additional properties....
std::map< std::string, Eigen::MatrixXd > properties
std::string to_string(ENUM val)
Return string representation of enum class.
Definition: io_traits.hh:172
double crystallography_tol() const
Get the crystallography_tol.
Definition: PrimClex.cc:233
bool get_else(T &t, const std::string &key, const T &default_value, Args &&... args) const
Definition: jsonParser.hh:775
T get(Args &&... args) const
Get data from json, using one of several alternatives.
Definition: jsonParser.hh:716
GenericDatumFormatter< double, Result > lattice_deformation_cost()
Definition: ConfigData.cc:126
GenericDatumFormatter< double, Result > atomic_deformation_cost()
Definition: ConfigData.cc:137
void default_import_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm import'.
Definition: ConfigData.cc:201
void default_update_formatters(DataFormatterDictionary< Result > &dict, PropertiesDatabase &db_props)
Insert default formatters to dictionary, for 'casm update'.
Definition: ConfigData.cc:209
jsonParser const & from_json(ImportSettings &_set, jsonParser const &_json)
Definition: Import.cc:18
std::string create_report_dir(std::string report_dir)
Create a new report directory to avoid overwriting existing results.
Definition: ConfigData.cc:58
std::pair< OutputIterator, int > construct_pos_paths(const PrimClex &primclex, const Completer::ImportOption &import_opt, OutputIterator result)
Construct pos_paths from input args –pos && –batch.
Definition: Import_impl.hh:22
MappedProperties make_mapped_properties(SimpleStructure const &simple_structure, std::set< std::string > const &dof_managed_properties, double lattice_deformation_cost, double atomic_deformation_cost, double total_cost)
Definition: ConfigImport.cc:47
static MappedProperties _make_mapped_properties(MappingNode const &_node, ConfigMapperResult::Individual const &_map)
Definition: ConfigImport.cc:82
Main CASM namespace.
Definition: APICommand.hh:8
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.
Log & log()
Definition: Log.hh:424
void from_json(ClexDescription &desc, const jsonParser &json)
PrimClex * primclex
Definition: settings.cc:135
Holds results of Configuration::insert.
bool insert_canonical
True if canonical configuration did not exist before insertion.
iterator primitive_it
Iterator pointing at primitive.
bool insert_primitive
True if primitive did not exist before insertion.
iterator canonical_it
Iterator pointing at canonical, if existing.
std::set< std::string > dof_managed_properties
Data structure holding results of ConfigMapper algorithm.
std::string fail_msg
Failure message if could not map to prim.
std::map< MappingNode, Individual > maps
The configurations that the input structure mapped onto.
Index n_optimal(double tol=TOL) const
Struct with optional parameters for Config Mapping Specifies default parameters for all values,...
Data structure for mapping / import results.
Definition: ConfigData.hh:56
MappedProperties properties
Definition: ConfigData.hh:60
Struct with optional parameters for Config/Data Import Specifies default parameters for all values,...
Definition: Import.hh:34
double const & scalar(std::string const &_name) const
std::map< std::string, Eigen::MatrixXd > site
std::map< std::string, Eigen::MatrixXd > global
double cost
Total cost of best solution to the constrained assignment problem having some forced_on assignments.
double cost
strain_cost of the LatticeNode
AssignmentNode atomic_node
double cost
total, finalized cost, populated by a StrucMapCalculator. Not guaranteed to be a linear function of l...
Eigen::MatrixXd coords
(3 x names.size()) matrix of coordinates. coords.col(i) is Cartesian coordinate of site 'i'
std::map< std::string, Eigen::MatrixXd > properties
map of [property name, (m x names.size()) matrix] for all numerical site properties properties are as...