CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
ProjectSettings.cc
Go to the documentation of this file.
2 
3 #include <tuple>
4 #include "casm/app/AppIO.hh"
7 
10 
11 namespace CASM {
12 
21  }
22 
24  std::set<int> _default_nlist_sublat_indices(const Structure &prim) {
25  // for now, include sublattices with >= 2 components
26  std::set<int> sublat_indices;
27  for(int b = 0; b < prim.basis.size(); ++b) {
28  if(prim.basis[b].site_occupant().size() >= 2) {
29  sublat_indices.insert(b);
30  }
31  }
32  return sublat_indices;
33  }
34 
35  void ClexDescription::print(std::ostream &sout, bool is_default, int indent) const {
36  std::string in(indent, ' ');
37  sout << in << name;
38  if(is_default) {
39  sout << "*";
40  }
41  sout << ": \n";
42  sout << in << std::setw(16) << "property: " << property << "\n";
43  sout << in << std::setw(16) << "calctype: " << calctype << "\n";
44  sout << in << std::setw(16) << "ref: " << ref << "\n";
45  sout << in << std::setw(16) << "bset: " << bset << "\n";
46  sout << in << std::setw(16) << "eci: " << eci << "\n";
47  sout << "\n";
48  }
49 
51  bool operator<(const ClexDescription &A, const ClexDescription &B) {
52  return A.name < B.name;
53  }
54 
56  json.put_obj();
57  json["name"] = desc.name;
58  json["property"] = desc.property;
59  json["calctype"] = desc.calctype;
60  json["ref"] = desc.ref;
61  json["bset"] = desc.bset;
62  json["eci"] = desc.eci;
63  return json;
64  }
65 
66  void from_json(ClexDescription &desc, const jsonParser &json) {
67  from_json(desc.name, json["name"]);
68  from_json(desc.property, json["property"]);
69  from_json(desc.calctype, json["calctype"]);
70  from_json(desc.ref, json["ref"]);
71  from_json(desc.bset, json["bset"]);
72  from_json(desc.eci, json["eci"]);
73  }
74 
76  return contains(dir.all_calctype(), desc.calctype) &&
77  contains(dir.all_ref(desc.calctype), desc.ref) &&
78  contains(dir.all_bset(), desc.bset) &&
79  contains(dir.all_eci(desc.property, desc.calctype, desc.ref, desc.bset), desc.eci);
80  }
81 
82 
88  ProjectSettings::ProjectSettings(fs::path root, std::string name, const Logging &logging) :
89  Logging(logging),
90  m_dir(root),
91  m_name(name) {
92 
93  if(fs::exists(m_dir.casm_dir())) {
94  throw std::runtime_error(
95  std::string("Error in 'ProjectSettings(fs::path root, std::string name)'.\n") +
96  " A CASM project already exists at this location: '" + root.string() + "'");
97  }
98 
99  // check for a prim.json
100  if(!fs::is_regular_file(m_dir.prim())) {
101  throw std::runtime_error(
102  std::string("Error in 'ProjectSettings(fs::path root, std::string name)'.\n") +
103  " No prim.json file found at: " + m_dir.prim().string());
104  }
105 
106  // generate default nlist settings
107  Structure prim(read_prim(m_dir.prim()));
110  }
111 
117  Logging(logging),
118  m_dir(root) {
119 
120  if(fs::exists(m_dir.casm_dir())) {
121 
122  try {
123 
124  // read .casmroot current settings
125  fs::ifstream file(m_dir.project_settings());
126  jsonParser settings(file);
127 
128  from_json(m_properties, settings["curr_properties"]);
129 
130  if(settings.contains("cluster_expansions") && settings["cluster_expansions"].size()) {
131  from_json(m_clex, settings["cluster_expansions"]);
132 
133  // if no 'default_clex', use 'formation_energy' if that exists, else use first in clex list
134  if(!settings.get_if(m_default_clex, "default_clex")) {
135  if(m_clex.find("formation_energy") != m_clex.end()) {
136  m_default_clex = "formation_energy";
137  }
138  else {
139  m_default_clex = m_clex.begin()->first;
140  }
141  }
142  }
143  else {
144  ClexDescription desc("formation_energy", "formation_energy", "default", "default", "default", "default");
145  m_clex[desc.name] = desc;
146  m_default_clex = desc.name;
147  }
148 
149  auto _read_if = [&](std::pair<std::string, std::string> &opt, std::string name) {
150  if(settings.get_if(opt.first, name)) {
151  opt.second = "project_settings";
152  }
153  };
154 
155  auto _read_path_if = [&](std::pair<fs::path, std::string> &opt, std::string name) {
156  if(settings.get_if(opt.first, name)) {
157  opt.second = "project_settings";
158  }
159  };
160 
161  _read_if(m_cxx, "cxx");
162  _read_if(m_cxxflags, "cxxflags");
163  _read_if(m_soflags, "soflags");
164 
165  fs::path tmp;
166  if(settings.get_if(tmp, "casm_prefix")) {
167  m_casm_includedir.first = tmp / "include";
168  m_casm_includedir.second = "project_settings";
169  m_casm_libdir.first = tmp / "lib";
170  m_casm_libdir.second = "project_settings";
171  }
172  if(settings.get_if(tmp, "boost_prefix")) {
173  m_boost_includedir.first = tmp / "include";
174  m_boost_includedir.second = "project_settings";
175  m_boost_libdir.first = tmp / "lib";
176  m_boost_libdir.second = "project_settings";
177  }
178 
179  _read_path_if(m_casm_includedir, "casm_includedir");
180  _read_path_if(m_casm_libdir, "casm_libdir");
181  _read_path_if(m_boost_includedir, "boost_includedir");
182  _read_path_if(m_boost_libdir, "boost_libdir");
183 
184  settings.get_if(m_depr_compile_options, "compile_options");
185  settings.get_if(m_depr_so_options, "so_options");
186 
187 
188  // other options
189  settings.get_if(m_view_command, "view_command");
190  from_json(m_name, settings["name"]);
191 
192  // precision options
193  settings.get_else(m_crystallography_tol, "tol", TOL); // deprecated 'tol'
194  settings.get_if(m_crystallography_tol, "crystallography_tol");
195 
196  settings.get_else(m_lin_alg_tol, "lin_alg_tol", 1e-10);
197 
198  // read nlist settings, or generate defaults
199  Structure prim;
200  bool and_commit = false;
201  if(!settings.contains("nlist_weight_matrix") || !settings.contains("nlist_sublat_indices")) {
203  prim = Structure(read_prim(m_dir.prim()));
204  and_commit = true;
205  }
206 
207  if(settings.contains("nlist_weight_matrix")) {
208  from_json(m_nlist_weight_matrix, settings["nlist_weight_matrix"]);
209  }
210  else {
212  }
213 
214  if(settings.contains("nlist_sublat_indices")) {
215  from_json(m_nlist_sublat_indices, settings["nlist_sublat_indices"]);
216  }
217  else {
219  }
220 
221  // migrate existing query_alias from deprecated 'query_alias.json'
222  jsonParser &alias_json = settings["query_alias"];
223  if(fs::exists(m_dir.query_alias())) {
224  jsonParser depr(m_dir.query_alias());
225  for(auto it = depr.begin(); it != depr.end(); ++it) {
226  if(!alias_json.contains(it.name())) {
227  alias_json[it.name()] = it->get<std::string>();
228  and_commit = true;
229  }
230  }
231  }
232 
233  // add aliases to dictionary
234  if(alias_json.size()) {
235  auto &q = query_handler<Configuration>();
236  for(auto it = alias_json.begin(); it != alias_json.end(); ++it) {
237  q.add_alias(it.name(), it->get<std::string>());
238  }
239  }
240 
241  if(and_commit) {
242  commit();
243  }
244 
245  }
246  catch(std::exception &e) {
247  std::cerr << "Error in ProjectSettings::ProjectSettings(const fs::path root).\n" <<
248  " Error reading " << m_dir.project_settings() << std::endl;
249  throw e;
250  }
251  }
252  else if(!fs::exists(m_dir.casm_dir())) {
253  throw std::runtime_error(
254  std::string("Error in 'ProjectSettings(fs::path root, std::string name)'.\n") +
255  " A CASM project does not exist at this location: '" + root.string() + "'");
256  }
257 
258  }
259 
260 
262  std::string ProjectSettings::name() const {
263  return m_name;
264  }
265 
267  std::vector<std::string> &ProjectSettings::properties() {
268  return m_properties;
269  }
270 
271 
272  const std::map<std::string, ClexDescription> &ProjectSettings::cluster_expansions() const {
273  return m_clex;
274  }
275 
276  bool ProjectSettings::has_clex(std::string name) const {
277  return m_clex.find(name) != m_clex.end();
278  }
279 
280  const ClexDescription &ProjectSettings::clex(std::string name) const {
281  return m_clex.find(name)->second;
282  }
283 
285  if(m_clex.find(desc.name) != m_clex.end()) {
286  return false;
287  }
288  m_clex[desc.name] = desc;
289  return true;
290  }
291 
293  if(cluster_expansions().size() == 1) {
294  return false;
295  }
296 
297  if(m_default_clex == desc.name) {
298  for(auto it = m_clex.begin(); it != m_clex.end(); ++it) {
299  if(it->first != desc.name) {
300  m_default_clex = it->first;
301  break;
302  }
303  }
304  }
305 
306  return m_clex.erase(desc.name);
307  }
308 
310  return m_clex.find(m_default_clex)->second;
311  }
312 
313  bool ProjectSettings::set_default_clex(const std::string &clex_name) {
314  if(m_clex.find(clex_name) != m_clex.end()) {
315  m_default_clex = clex_name;
316  return true;
317  }
318  return false;
319  }
320 
323  m_clex[desc.name] = desc;
324  m_default_clex = desc.name;
325  return true;
326  }
327 
328 
331  return m_nlist_weight_matrix;
332  }
333 
335  const std::set<int> &ProjectSettings::nlist_sublat_indices() const {
336  return m_nlist_sublat_indices;
337  }
338 
340  std::pair<std::string, std::string> ProjectSettings::cxx() const {
341  return m_cxx.first.empty() ? RuntimeLibrary::default_cxx() : m_cxx;
342  }
343 
345  std::pair<std::string, std::string> ProjectSettings::cxxflags() const {
346  return m_cxxflags.first.empty() ? RuntimeLibrary::default_cxxflags() : m_cxxflags;
347  }
348 
350  std::pair<std::string, std::string> ProjectSettings::soflags() const {
351  return m_soflags.first.empty() ? RuntimeLibrary::default_soflags() : m_soflags;
352  }
353 
355  std::pair<fs::path, std::string> ProjectSettings::casm_includedir() const {
357  }
358 
360  std::pair<fs::path, std::string> ProjectSettings::casm_libdir() const {
362  }
363 
365  std::pair<fs::path, std::string> ProjectSettings::boost_includedir() const {
367  }
368 
370  std::pair<fs::path, std::string> ProjectSettings::boost_libdir() const {
372  }
373 
375  std::string ProjectSettings::compile_options() const {
376  if(!m_depr_compile_options.empty()) {
377  return m_depr_compile_options;
378  }
379  else {
380  // else construct from pieces
381  return cxx().first + " " + cxxflags().first + " " +
382  include_path(casm_includedir().first) + " " +
384  }
385  }
386 
388  std::string ProjectSettings::so_options() const {
389  // default to read deprecated 'so_options'
390  if(!m_depr_so_options.empty()) {
391  return m_depr_so_options;
392  }
393  else {
394  // else construct from pieces
395  return cxx().first + " " + soflags().first + " " +
396  link_path(boost_libdir().first) + " " +
397  link_path(casm_libdir().first);
398  }
399  }
400 
402  std::string ProjectSettings::view_command() const {
403  return m_view_command;
404  }
405 
408  return m_crystallography_tol;
409  }
410 
413  return m_lin_alg_tol;
414  }
415 
416 
417  // ** Clexulator names **
418 
419  std::string ProjectSettings::clexulator() const {
420  return name() + "_Clexulator";
421  }
422 
423 
424  // ** Add directories for additional project data **
425 
428  return fs::create_directory(m_dir.casm_dir());
429  }
430 
433  return fs::create_directory(m_dir.symmetry_dir());
434  }
435 
437  bool ProjectSettings::new_bset_dir(std::string bset) const {
438  return fs::create_directories(m_dir.bset_dir(bset));
439  }
440 
442  bool ProjectSettings::new_clex_dir(std::string clex) const {
443  return fs::create_directories(m_dir.clex_dir(clex));
444  }
445 
446 
449  return fs::create_directories(m_dir.calc_settings_dir(calctype));
450  }
451 
454  return fs::create_directories(m_dir.supercell_calc_settings_dir(scelname, calctype));
455  }
456 
459  return fs::create_directories(m_dir.configuration_calc_settings_dir(configname, calctype));
460  }
461 
462 
464  bool ProjectSettings::new_ref_dir(std::string calctype, std::string ref) const {
465  return fs::create_directories(m_dir.ref_dir(calctype, ref));
466  }
467 
469  bool ProjectSettings::new_eci_dir(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const {
470  return fs::create_directories(m_dir.eci_dir(property, calctype, ref, bset, eci));
471  }
472 
473 
474  // ** Change current settings **
475 
477  const std::vector<std::string> &ProjectSettings::properties() const {
478  return m_properties;
479  }
480 
481 
485 
486  // changing the neighbor list properties requires updating Clexulator source code
487  // for now we just remove existing source/compiled files
489 
491  return true;
492  }
493 
494 
496  bool ProjectSettings::set_cxx(std::string opt) {
497  m_cxx = std::make_pair(opt, "project_settings");
498  return true;
499  }
500 
502  bool ProjectSettings::set_cxxflags(std::string opt) {
503  m_cxxflags = std::make_pair(opt, "project_settings");
504  return true;
505  }
506 
508  bool ProjectSettings::set_soflags(std::string opt) {
509  m_soflags = std::make_pair(opt, "project_settings");
510  return true;
511  }
512 
515  m_casm_includedir = std::make_pair(prefix / "include", "project_settings");
516  m_casm_libdir = std::make_pair(prefix / "lib", "project_settings");
517  return true;
518  }
519 
522  m_casm_includedir = std::make_pair(dir, "project_settings");
523  return true;
524  }
525 
528  m_casm_libdir = std::make_pair(dir, "project_settings");
529  return true;
530  }
531 
534  m_boost_includedir = std::make_pair(prefix / "include", "project_settings");
535  m_boost_libdir = std::make_pair(prefix / "lib", "project_settings");
536  return true;
537  }
538 
541  m_boost_includedir = std::make_pair(dir, "project_settings");
542  return true;
543  }
544 
547  m_boost_libdir = std::make_pair(dir, "project_settings");
548  return true;
549  }
550 
552  bool ProjectSettings::set_compile_options(std::string opt) {
554  return true;
555  }
556 
558  bool ProjectSettings::set_so_options(std::string opt) {
559  m_depr_so_options = opt;
560  return true;
561  }
562 
563 
565  bool ProjectSettings::set_view_command(std::string opt) {
566  m_view_command = opt;
567  return true;
568  }
569 
572  m_crystallography_tol = _tol;
573  return true;
574  }
575 
578  m_lin_alg_tol = _tol;
579  return true;
580  }
581 
583  void ProjectSettings::commit() const {
584 
585  try {
586  SafeOfstream file;
587  file.open(m_dir.project_settings());
588  jsonParser json;
589  to_json(json).print(file.ofstream(), 2, 18);
590  file.close();
591  }
592  catch(...) {
593  std::cerr << "Uncaught exception in ProjectSettings::commit()" << std::endl;
595  throw;
596  }
597 
598  }
599 
603  auto all_bset = m_dir.all_bset();
604  for(auto it = all_bset.begin(); it != all_bset.end(); ++it) {
605  fs::remove(m_dir.clexulator_src(name(), *it));
606  fs::remove(m_dir.clexulator_o(name(), *it));
607  fs::remove(m_dir.clexulator_so(name(), *it));
608  }
609  }
610 
619  }
620 
622 
623  json = jsonParser::object();
624 
625  json["name"] = name();
626  json["cluster_expansions"] = cluster_expansions();
627  json["curr_properties"] = properties();
628  json["default_clex"] = m_default_clex;
629  json["nlist_weight_matrix"] = nlist_weight_matrix();
630  json["nlist_sublat_indices"] = nlist_sublat_indices();
631 
632 
633  auto _write_if = [&](std::string name, std::string val) {
634  if(!val.empty()) {
635  json[name] = val;
636  };
637  };
638 
639  _write_if("cxx", m_cxx.first);
640  _write_if("cxxflags", m_cxxflags.first);
641  _write_if("soflags", m_soflags.first);
642  _write_if("casm_includedir", m_casm_includedir.first.string());
643  _write_if("casm_libdir", m_casm_libdir.first.string());
644  _write_if("boost_includedir", m_boost_includedir.first.string());
645  _write_if("boost_libdir", m_boost_libdir.first.string());
646  _write_if("compile_options", m_depr_compile_options);
647  _write_if("so_options", m_depr_so_options);
648 
649  json["view_command"] = view_command();
650  json["crystallography_tol"] = crystallography_tol();
651  json["crystallography_tol"].set_scientific();
652  json["lin_alg_tol"] = lin_alg_tol();
653  json["lin_alg_tol"].set_scientific();
654  json["query_alias"] = query_handler<Configuration>().aliases();
655 
656  return json;
657  }
658 
659  namespace {
660  std::string _wdefaultval(std::string name, std::pair<std::string, std::string> val) {
661  return name + ": '" + val.first + "' (" + val.second + ")\n";
662  }
663 
664  std::string _wdefaultval(std::string name, std::pair<fs::path, std::string> val) {
665  return _wdefaultval(name, std::make_pair(val.first.string(), val.second));
666  }
667  }
668 
670  log.custom<Log::standard>("Compiler settings");
671  log << _wdefaultval("cxx", cxx())
672  << _wdefaultval("cxxflags", cxxflags())
673  << _wdefaultval("soflags", soflags())
674  << _wdefaultval("casm_includedir", casm_includedir())
675  << _wdefaultval("casm_libdir", casm_libdir())
676  << _wdefaultval("boost_includedir", boost_includedir())
677  << _wdefaultval("boost_libdir", boost_libdir()) << std::endl;
678 
679  if(!m_depr_compile_options.empty()) {
680  log << "Note: using deprecated 'compile_options' value from .casm/project_settings.json \n"
681  "explicitly instead of individual compiler settings (cxx, cxxflags, casm_includedir,\n"
682  "boost_includedir).\n"
683  "Delete 'compile_options' from .casm/project_settings.json manually \n"
684  "to use begin using the individually set settings.\n";
685  }
686  log << "compile command: '" << compile_options() << "'\n\n";
687 
688  if(!m_depr_so_options.empty()) {
689  log << "Note: using deprecated 'so_options' value from .casm/project_settings.json \n"
690  "explicitly instead of individual compiler settings (cxx, cxxflags, boost_libdir).\n"
691  "Delete 'so_options' from .casm/project_settings.json manually \n"
692  "to use begin using the individually set settings.\n";
693  }
694  log << "so command: '" << so_options() << "'\n\n";
695  }
696 
699 
700  log.custom<Log::standard>("Cluster expansions");
701  for(auto it = m_clex.begin(); it != m_clex.end(); ++it) {
702 
703  const ClexDescription &desc = it->second;
704  bool is_default = (desc.name == m_default_clex);
705  int indent = 0;
706  desc.print(log, is_default, indent);
707  }
708  log << std::endl;
709 
710  const ClexDescription &default_desc = default_clex();
711 
712  std::vector<std::string> all = m_dir.all_bset();
713  log.custom<Log::standard>("Basis sets");
714  for(int i = 0; i < all.size(); i++) {
715  log << all[i];
716  if(all[i] == default_desc.bset) {
717  log << "*";
718  }
719  log << "\n";
720  }
721  log << std::endl;
722 
723  all = m_dir.all_calctype();
724  log.custom<Log::standard>("Training Data & References");
725  for(int i = 0; i < all.size(); i++) {
726  std::vector<std::string> all_ref = m_dir.all_ref(all[i]);
727  for(int j = 0; j < all_ref.size(); j++) {
728  log << all[i] << " / " << all_ref[j];
729  if(all[i] == default_desc.calctype && all_ref[j] == default_desc.ref) {
730  log << "*";
731  }
732  log << "\n";
733  }
734  log << std::endl;
735  }
736 
737  all = m_dir.all_eci(default_desc.property, default_desc.calctype, default_desc.ref, default_desc.bset);
738  log.custom<Log::standard>("ECI for current cluster expansion settings group");
739  for(int i = 0; i < all.size(); i++) {
740  log << all[i];
741  if(all[i] == default_desc.eci) {
742  log << "*";
743  }
744  log << "\n";
745  }
746  log << std::endl;
747 
748  log << "*: indicates the default settings used by CASM whenever particular \n"
749  "settings are not explicitly specified (i.e. the basis set to evaluate \n"
750  "for 'casm query -k corr')\n\n";
751 
753 
754  log.custom<Log::standard>("'casm view'");
755  log << "command: '" << view_command() << "'\n\n";
756 
757  }
758 
760  return set.to_json(json);
761  }
762 
763 }
pair_type eci
Definition: settings.cc:112
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
Definition: jsonParser.cc:430
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file"...
Definition: SafeOfstream.hh:81
ClexDescription & desc
Definition: settings.cc:104
static std::pair< std::string, std::string > default_cxxflags()
Default c++ compiler options.
Specifies a particular cluster expansion.
void commit() const
Save settings to project settings file.
Eigen::Matrix3l m_nlist_weight_matrix
std::pair< std::string, std::string > cxxflags() const
Get c++ compiler options.
void from_json(ClexDescription &desc, const jsonParser &json)
iterator end()
Returns iterator to end of JSON object or JSON array.
Definition: jsonParser.cc:465
static std::pair< fs::path, std::string > default_casm_includedir()
Return default includedir for CASM.
bool new_supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Add calculation settings directory path, for supercell specific settings.
Eigen::Matrix3l nlist_weight_matrix() const
Get neighbor list weight matrix.
Index size() const
Definition: Array.hh:145
bool set_casm_prefix(fs::path dir)
Set casm prefix (empty string to use default)
std::pair< fs::path, std::string > boost_includedir() const
Get boost includedir.
Specification of CASM project directory structure.
Structure specifies the lattice and atomic basis of a crystal.
Definition: Structure.hh:29
void print_compiler_settings_summary(Log &log) const
Print summary of compiler settings, as for 'casm settings -l'.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
std::string include_path(const fs::path &dir)
std::string m_depr_compile_options
std::pair< std::string, std::string > m_cxx
void _reset_clexulators()
Changing the neighbor list properties requires updating Clexulator source code.
std::string link_path(const fs::path &dir)
bool operator<(const ClexDescription &A, const ClexDescription &B)
Compare using name strings: A.name < B.name.
static std::pair< std::string, std::string > default_cxx()
Return default compiler.
std::string so_options() const
Get current shared library options string.
fs::path query_alias() const
Query aliases file.
fs::path calc_settings_dir(std::string calctype) const
Return calculation settings directory path, for global settings.
fs::path supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Return calculation settings directory path, for supercell specific settings.
fs::path configuration_calc_settings_dir(std::string configname, std::string calctype) const
Return calculation settings directory path, for configuration specific settings.
bool set_default_clex(const std::string &clex_name)
const std::set< int > & nlist_sublat_indices() const
Get set of sublattice indices to include in neighbor lists.
Main CASM namespace.
Definition: complete.cpp:8
Write to a temporary file to ensure a good write, then rename.
Definition: SafeOfstream.hh:28
bool new_eci_dir(std::string clex, std::string calctype, std::string ref, std::string bset, std::string eci) const
Add an eci directory.
const Lattice & lattice() const
Log & log
Definition: settings.cc:105
Eigen::Matrix3l _default_nlist_weight_matrix(const Structure &prim, double tol)
Default weight matrix for approximately spherical neighborhood in Cartesian coordinates.
fs::ofstream & ofstream()
Access underlying stream.
Definition: SafeOfstream.hh:76
const double TOL
fs::path prim() const
Return prim.json path.
std::pair< fs::path, std::string > m_boost_includedir
std::vector< std::string > all_eci(std::string property, std::string calctype, std::string ref, std::string bset) const
Check filesystem directory structure and return list of all eci names.
void print_summary(Log &log) const
Print summary of ProjectSettings, as for 'casm settings -l'.
iterator begin()
Returns const_iterator to beginning of JSON object or JSON array.
Definition: jsonParser.cc:440
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Definition: Lattice.hh:104
fs::path ref_dir(std::string calctype, std::string ref) const
Return calculation reference settings directory path, for global settings.
bool new_casm_dir() const
Create new project data directory.
bool new_ref_dir(std::string calctype, std::string ref) const
Add a ref directory.
bool set_view_command(std::string opt)
Set command used by 'casm view'.
std::vector< std::string > m_properties
ProjectSettings & set
Definition: settings.cc:103
bool set_cxx(std::string opt)
Set c++ compiler (empty string to use default)
T get(Args...args) const
Get data from json, using one of several alternatives.
Definition: jsonParser.hh:729
bool clex_exists(const DirectoryStructure &dir, const ClexDescription &desc)
BasicStructure< Site > read_prim(fs::path filename)
Definition: AppIO.cc:11
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
Definition: jsonParser.cc:185
pair_type ref
Definition: settings.cc:110
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
Definition: SafeOfstream.hh:62
std::map< std::string, ClexDescription > m_clex
double tol
void custom(const std::string &what)
Definition: Log.hh:96
std::string name() const
Get project name.
bool set_crystallography_tol(double _tol)
Set crystallography tolerance.
fs::path clex_dir(std::string property) const
Returns path to eci directory.
const std::vector< std::string > & properties() const
Get current properties.
const ClexDescription & clex(std::string name) const
static const int standard
Definition: Log.hh:15
std::pair< fs::path, std::string > m_casm_includedir
Read/modify settings of an already existing CASM project.
fs::path project_settings() const
Return project_settings.json path.
bool set_compile_options(std::string opt)
(deprecated) Set compile options to 'opt' (empty string to use default)
std::pair< fs::path, std::string > m_casm_libdir
fs::path clexulator_so(std::string project, std::string bset) const
Returns path to global clexulator so file.
static std::pair< fs::path, std::string > default_boost_libdir()
Return default libdir for boost.
pair_type property
Definition: settings.cc:108
std::pair< fs::path, std::string > casm_libdir() const
Get casm libdir.
std::pair< fs::path, std::string > casm_includedir() const
Get casm includedir.
std::set< int > m_nlist_sublat_indices
bool set_boost_prefix(fs::path dir)
Set boost prefix (empty string to use default)
fs::path clexulator_src(std::string project, std::string bset) const
Returns path to global clexulator source file.
static std::pair< fs::path, std::string > default_casm_libdir()
Return default libdir for CASM.
pair_type calctype
Definition: settings.cc:109
static std::pair< std::string, std::string > default_soflags()
Default c++ compiler options.
bool set_boost_libdir(fs::path dir)
Set boost libdir (empty string to use default)
bool new_symmetry_dir() const
Create new symmetry directory.
Array< CoordType > basis
Lattice vectors that specifies periodicity of the crystal.
bool has_clex(std::string name) const
bool new_configuration_calc_settings_dir(std::string configname, std::string calctype) const
Add calculation settings directory path, for configuration specific settings.
std::string compile_options() const
Get current compilation options string.
bool set_so_options(std::string opt)
(deprecated) Set shared library options to 'opt' (empty string to use default)
bool new_bset_dir(std::string bset) const
Add a basis set directory.
ProjectSettings()
Default constructor.
bool set_casm_libdir(fs::path dir)
Set casm libdir (empty string to use default)
bool new_clex_dir(std::string clex) const
Add a cluster expansion directory.
fs::path casm_dir() const
Return hidden .casm dir path.
std::pair< std::string, std::string > m_cxxflags
bool set_soflags(std::string opt)
Set shared object options (empty string to use default)
static Matrix3Type make_weight_matrix(const Eigen::Matrix3d lat_column_mat, Index max_element_value, double tol)
Returns a NeighborList weighting matrix appropriate for a particular lattice.
std::string clexulator() const
jsonParser & to_json(jsonParser &json) const
Output as JSON.
const std::map< std::string, ClexDescription > & cluster_expansions() const
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
Definition: ConfigIO.cc:340
bool set_lin_alg_tol(double _tol)
Set linear algebra tolerance.
std::set< int > _default_nlist_sublat_indices(const Structure &prim)
Default includes sublattices with >= 2 components.
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:276
DirectoryStructure & dir
Definition: settings.cc:102
bool set_casm_includedir(fs::path dir)
Set casm includedir (empty string to use default)
double crystallography_tol() const
Get current project crystallography tolerance.
bool new_calc_settings_dir(std::string calctype) const
Add calculation settings directory path.
bool erase_clex(const ClexDescription &desc)
fs::path bset_dir(std::string bset) const
Return path to directory contain basis set info.
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:500
fs::path clexulator_o(std::string project, std::string bset) const
Returns path to global clexulator o file.
fs::path symmetry_dir() const
Return symmetry directory path.
std::vector< std::string > all_calctype() const
Check filesystem directory structure and return list of all calctype names.
fs::path eci_dir(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci directory.
std::pair< fs::path, std::string > boost_libdir() const
Get boost libdir.
std::pair< std::string, std::string > m_soflags
static std::pair< fs::path, std::string > default_boost_includedir()
Return default includedir for boost.
Matrix< long int, 3, 3 > Matrix3l
Definition: Log.hh:9
void _load_default_options()
initialize default compiler options
std::pair< fs::path, std::string > m_boost_libdir
bool new_clex(const ClexDescription &desc)
std::string view_command() const
Get current command used by 'casm view'.
pair_type bset
Definition: settings.cc:111
ConfigIO::GenericConfigFormatter< std::string > scelname()
Definition: ConfigIO.cc:348
void print(std::ostream &sout, bool is_default, int indent=0) const
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value) ...
Definition: algorithm.hh:66
std::vector< std::string > all_bset() const
Check filesystem directory structure and return list of all basis set names.
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:329
std::pair< std::string, std::string > soflags() const
Get shared object options.
std::pair< std::string, std::string > cxx() const
Get c++ compiler.
const ClexDescription & default_clex() const
DirectoryStructure m_dir
std::vector< std::string > all_ref(std::string calctype) const
Check filesystem directory structure and return list of all ref names for a given calctype...
bool set_boost_includedir(fs::path dir)
Set boost includedir (empty string to use default)
bool set_cxxflags(std::string opt)
Set c++ compiler options (empty string to use default)
bool set_nlist_weight_matrix(Eigen::Matrix3l M)
Set neighbor list weight matrix (will delete existing Clexulator source and compiled code) ...
double lin_alg_tol() const
Get current project linear algebra tolerance.