CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ProjectSettings.cc
Go to the documentation of this file.
2 
3 #include <regex>
4 #include <tuple>
5 
9 #include "casm/casm_io/Log.hh"
14 
15 // template definitions
19 
20 namespace CASM {
21 
22 bool is_valid_project_name(std::string project_name) {
24  if (!std::regex_match(project_name, std::regex(R"([_a-zA-Z]\w*)"))) {
25  return false;
26  }
27  return true;
28 }
29 
30 void throw_if_project_name_is_not_valid(std::string project_name) {
32  if (!is_valid_project_name(project_name)) {
33  throw std::runtime_error(
34  std::string(" Invalid Project name: '") + project_name +
35  "'\n"
36  " Must be a valid C++ identifier: \n"
37  " - only alphanumeric characters and underscores allowed\n"
38  " - cannot start with a number");
39  }
40 }
41 
42 ProjectSettings::ProjectSettings(std::string project_name)
43  : m_project_name(project_name),
44  m_crystallography_tol(CASM::TOL),
45  m_lin_alg_tol(1e-10),
46  m_default_database_name("jsonDB") {
48 }
49 
50 ProjectSettings::ProjectSettings(std::string project_name, fs::path root)
51  : m_project_name(project_name),
52  m_dir(notstd::make_unique<DirectoryStructure>(root)),
53  m_crystallography_tol(CASM::TOL),
54  m_lin_alg_tol(1e-10),
55  m_default_database_name("jsonDB") {
57 }
58 
60 
61 std::string ProjectSettings::project_name() const { return m_project_name; }
62 
63 bool ProjectSettings::has_dir() const { return bool{m_dir}; }
64 
66  if (!m_dir) {
67  throw std::runtime_error(
68  "Error accessing DirectoryStructure from ProjectSettings: Does not "
69  "exist.");
70  }
71  return *m_dir;
72 }
73 
74 bool ProjectSettings::set_root_dir(fs::path root) {
75  m_dir = notstd::make_cloneable<DirectoryStructure>(root);
76  return bool{m_dir};
77 }
78 
79 fs::path ProjectSettings::root_dir() const { return dir().root_dir(); }
80 
83  return m_required_properties;
84 }
85 
87  required_properties_map_type const &_required_properties) {
88  m_required_properties = _required_properties;
89 }
90 
91 std::vector<std::string> const &ProjectSettings::required_properties(
92  std::string type_name, std::string calctype) const {
93  return m_required_properties.find(type_name)->second.find(calctype)->second;
94 }
95 
97  std::string type_name, std::string calctype,
98  std::vector<std::string> const &_required_properties) {
99  m_required_properties[type_name][calctype] = _required_properties;
100 }
101 
102 std::map<std::string, ClexDescription> const &
104  return m_clex;
105 }
106 
107 bool ProjectSettings::has_clex(std::string clex_name) const {
108  return m_clex.find(clex_name) != m_clex.end();
109 }
110 
111 ClexDescription const &ProjectSettings::clex(std::string clex_name) const {
112  return m_clex.find(clex_name)->second;
113 }
114 
116  if (m_clex.find(desc.name) != m_clex.end()) {
117  return false;
118  }
119  m_clex[desc.name] = desc;
120  return true;
121 }
122 
124  if (m_default_clex_name == desc.name) {
125  m_default_clex_name.clear();
126  }
127  return m_clex.erase(desc.name);
128 }
129 
131  return m_default_clex_name;
132 }
133 
134 bool ProjectSettings::set_default_clex_name(const std::string &clex_name) {
135  if (m_clex.find(clex_name) != m_clex.end()) {
136  m_default_clex_name = clex_name;
137  return true;
138  }
139  return false;
140 }
141 
143  return m_clex.find(m_default_clex_name)->second;
144 }
145 
147  m_clex[desc.name] = desc;
148  m_default_clex_name = desc.name;
149  return true;
150 }
151 
152 std::pair<std::string, std::string> ProjectSettings::cxx() const {
153  return m_cxx.first.empty() ? RuntimeLibrary::default_cxx() : m_cxx;
154 }
155 
156 std::pair<std::string, std::string> ProjectSettings::cxxflags() const {
157  return m_cxxflags.first.empty() ? RuntimeLibrary::default_cxxflags()
158  : m_cxxflags;
159 }
160 
161 std::pair<std::string, std::string> ProjectSettings::soflags() const {
162  return m_soflags.first.empty() ? RuntimeLibrary::default_soflags()
163  : m_soflags;
164 }
165 
166 std::pair<fs::path, std::string> ProjectSettings::casm_includedir() const {
167  return m_casm_includedir.first.empty()
170 }
171 
172 std::pair<fs::path, std::string> ProjectSettings::casm_libdir() const {
173  return m_casm_libdir.first.empty() ? RuntimeLibrary::default_casm_libdir()
174  : m_casm_libdir;
175 }
176 
177 std::pair<fs::path, std::string> ProjectSettings::boost_includedir() const {
178  return m_boost_includedir.first.empty()
181 }
182 
183 std::pair<fs::path, std::string> ProjectSettings::boost_libdir() const {
185  : m_boost_libdir;
186 }
187 
188 std::string ProjectSettings::compile_options() const {
189  // construct from pieces
190  return cxx().first + " " + cxxflags().first + " " +
191  include_path(casm_includedir().first) + " " +
193 }
194 
195 std::string ProjectSettings::so_options() const {
196  // construct from pieces
197  return cxx().first + " " + soflags().first + " " +
198  link_path(boost_libdir().first) + " " + link_path(casm_libdir().first);
199 }
200 
201 std::string ProjectSettings::view_command() const { return m_view_command; }
202 
204  return m_view_command_video;
205 }
206 
208  return m_crystallography_tol;
209 }
210 
211 double ProjectSettings::lin_alg_tol() const { return m_lin_alg_tol; }
212 
214  if (!m_enumerator_handler) {
215  m_enumerator_handler = notstd::make_cloneable<EnumeratorHandler>(*this);
216  }
217  return static_cast<EnumeratorHandler &>(*m_enumerator_handler);
218 }
219 
221  return const_cast<ProjectSettings &>(*this).enumerator_handler();
222 }
223 
225  std::string _default_database_name) {
226  m_default_database_name = _default_database_name;
227 }
228 
231 }
232 
234  const {
235  return m_query_alias;
236 }
237 
239  query_alias_map_type const &_query_alias) {
240  m_query_handler.clear();
241  m_query_alias = _query_alias;
242 }
243 
245  std::string alias_name,
246  std::string alias_value) {
247  m_query_handler.erase(type_name);
248  m_query_alias[type_name][alias_name] = alias_value;
249 }
250 
251 template <typename DataObject>
253  auto res = m_query_handler.find(traits<DataObject>::name);
254  if (res != m_query_handler.end()) {
255  return static_cast<QueryHandler<DataObject> &>(*res->second);
256  }
257 
258  res = m_query_handler
259  .insert(std::make_pair(traits<DataObject>::name,
261  new QueryHandler<DataObject>(*this))))
262  .first;
263 
265  static_cast<QueryHandler<DataObject> &>(*res->second);
266 
267  // if query aliases exist, add all for this type
268  auto type_it = m_query_alias.find(traits<DataObject>::name);
269  if (type_it != m_query_alias.end()) {
270  for (auto const &value : type_it->second) {
271  q.add_alias(value.first, value.second);
272  }
273  }
274  return q;
275 }
276 
277 template <typename DataObject>
279  return const_cast<ProjectSettings &>(*this).query_handler<DataObject>();
280 }
281 
283  if (!m_hamiltonian_modules) {
284  m_hamiltonian_modules = notstd::make_cloneable<HamiltonianModules>(this);
285  }
286  return static_cast<HamiltonianModules &>(*m_hamiltonian_modules);
287 }
288 
290  if (!m_hamiltonian_modules) {
291  m_hamiltonian_modules = notstd::make_cloneable<HamiltonianModules>(this);
292  }
293  return static_cast<HamiltonianModules const &>(*m_hamiltonian_modules);
294 }
295 
297  return project_name() + "_Clexulator";
298 }
299 
301  return bool{m_nlist_weight_matrix};
302 }
303 
305  return *m_nlist_weight_matrix;
306 }
307 
310  return bool{m_nlist_weight_matrix};
311 }
312 
314  return bool{m_nlist_sublat_indices};
315 }
316 
317 const std::set<int> &ProjectSettings::nlist_sublat_indices() const {
318  return *m_nlist_sublat_indices;
319 }
320 
321 bool ProjectSettings::set_nlist_sublat_indices(std::set<int> value) {
323  return bool{m_nlist_sublat_indices};
324 }
325 
326 bool ProjectSettings::set_cxx(std::string opt) {
327  m_cxx = std::make_pair(opt, "project_settings");
328  return true;
329 }
330 
331 bool ProjectSettings::set_cxxflags(std::string opt) {
332  m_cxxflags = std::make_pair(opt, "project_settings");
333  return true;
334 }
335 
336 bool ProjectSettings::set_soflags(std::string opt) {
337  m_soflags = std::make_pair(opt, "project_settings");
338  return true;
339 }
340 
341 bool ProjectSettings::set_casm_prefix(fs::path prefix) {
342  m_casm_includedir = std::make_pair(prefix / "include", "project_settings");
343  m_casm_libdir = std::make_pair(prefix / "lib", "project_settings");
344  return true;
345 }
346 
348  m_casm_includedir = std::make_pair(dir, "project_settings");
349  return true;
350 }
351 
353  m_casm_libdir = std::make_pair(dir, "project_settings");
354  return true;
355 }
356 
357 bool ProjectSettings::set_boost_prefix(fs::path prefix) {
358  m_boost_includedir = std::make_pair(prefix / "include", "project_settings");
359  m_boost_libdir = std::make_pair(prefix / "lib", "project_settings");
360  return true;
361 }
362 
364  m_boost_includedir = std::make_pair(dir, "project_settings");
365  return true;
366 }
367 
369  m_boost_libdir = std::make_pair(dir, "project_settings");
370  return true;
371 }
372 
373 bool ProjectSettings::set_view_command(std::string opt) {
374  m_view_command = opt;
375  return true;
376 }
377 
379  m_view_command_video = opt;
380  return true;
381 }
382 
384  m_crystallography_tol = _tol;
385  return true;
386 }
387 
389  m_lin_alg_tol = _tol;
390  return true;
391 }
392 
394  auto const &dir = set.dir();
395  auto const &cluster_expansions = set.cluster_expansions();
396 
397  bool result{true};
398  result &= dir.new_casm_dir();
399  result &= dir.new_symmetry_dir();
400  result &= dir.new_reports_dir();
401  for (auto const &pair : cluster_expansions) {
402  ClexDescription const &desc = pair.second;
403  result &= new_dir(dir, desc);
404  }
405  return result;
406 }
407 
408 namespace {
409 std::string _wdefaultval(std::string name,
410  std::pair<std::string, std::string> val) {
411  return name + ": '" + val.first + "' (" + val.second + ")\n";
412 }
413 
414 std::string _wdefaultval(std::string name,
415  std::pair<fs::path, std::string> val) {
416  return _wdefaultval(name, std::make_pair(val.first.string(), val.second));
417 }
418 } // namespace
419 
421  log.custom<Log::standard>("Compiler settings");
422  log << _wdefaultval("cxx", set.cxx())
423  << _wdefaultval("cxxflags", set.cxxflags())
424  << _wdefaultval("soflags", set.soflags())
425  << _wdefaultval("casm_includedir", set.casm_includedir())
426  << _wdefaultval("casm_libdir", set.casm_libdir())
427  << _wdefaultval("boost_includedir", set.boost_includedir())
428  << _wdefaultval("boost_libdir", set.boost_libdir()) << std::endl;
429  log << "compile command: '" << set.compile_options() << "'\n\n";
430  log << "so command: '" << set.so_options() << "'\n\n";
431 }
432 
434  log.custom<Log::standard>("Cluster expansions");
435  auto const &clex = set.cluster_expansions();
436  auto const &default_clex_name = set.default_clex_name();
437  for (auto it = clex.begin(); it != clex.end(); ++it) {
438  const ClexDescription &desc = it->second;
439  bool is_default = (desc.name == default_clex_name);
440  int indent = 0;
441  desc.print(log, is_default, indent);
442  }
443  log << std::endl;
444 
445  const ClexDescription &default_desc = set.default_clex();
446 
447  // print basis sets
448  std::vector<std::string> all_bset = set.dir().all_bset();
449  log.custom<Log::standard>("Basis sets");
450  for (int i = 0; i < all_bset.size(); i++) {
451  log << all_bset[i];
452  if (all_bset[i] == default_desc.bset) {
453  log << "*";
454  }
455  log << "\n";
456  }
457  log << std::endl;
458 
459  // print training data (calctype) & references
460  std::vector<std::string> all_calctype = set.dir().all_calctype();
461  log.custom<Log::standard>("Training Data & References");
462  for (int i = 0; i < all_calctype.size(); i++) {
463  std::vector<std::string> all_ref = set.dir().all_ref(all_calctype[i]);
464  for (int j = 0; j < all_ref.size(); j++) {
465  log << all_calctype[i] << " / " << all_ref[j];
466  if (all_calctype[i] == default_desc.calctype &&
467  all_ref[j] == default_desc.ref) {
468  log << "*";
469  }
470  log << "\n";
471  }
472  log << std::endl;
473  }
474 
475  // print training data (calctype) & references
476  std::vector<std::string> all_eci =
477  set.dir().all_eci(default_desc.property, default_desc.calctype,
478  default_desc.ref, default_desc.bset);
479  log.custom<Log::standard>("ECI for current cluster expansion settings group");
480  for (int i = 0; i < all_eci.size(); i++) {
481  log << all_eci[i];
482  if (all_eci[i] == default_desc.eci) {
483  log << "*";
484  }
485  log << "\n";
486  }
487  log << std::endl;
488 
489  log << "*: indicates the default settings used by CASM whenever particular \n"
490  "settings are not explicitly specified (i.e. the basis set to "
491  "evaluate \n"
492  "for 'casm query -k corr')\n\n";
493 
495 
496  log.custom<Log::standard>("'casm view'");
497  log << "command: '" << set.view_command() << "'\n\n";
498  log << "video command: '" << set.view_command_video() << "'\n\n";
499 }
500 
502  json = jsonParser::object();
503 
504  json["name"] = set.project_name();
505  json["cluster_expansions"] = set.cluster_expansions();
506  json["required_properties"] = set.required_properties();
507  json["default_clex"] = set.default_clex_name();
508  json["nlist_weight_matrix"] = set.nlist_weight_matrix();
509  json["nlist_sublat_indices"] = set.nlist_sublat_indices();
510 
511  // only write compiler & linker settings if stored in project settings, not if
512  // obtained from default values or environment variables
513 
514  auto _write_str_if =
515  [&](std::string name,
516  std::pair<std::string, std::string> value_and_source) {
517  if (value_and_source.second == "project_settings") {
518  json[name] = value_and_source.first;
519  };
520  };
521 
522  auto _write_path_if = [&](std::string name,
523  std::pair<fs::path, std::string> value_and_source) {
524  if (value_and_source.second == "project_settings") {
525  json[name] = value_and_source.first.string();
526  };
527  };
528 
529  _write_str_if("cxx", set.cxx());
530  _write_str_if("cxxflags", set.cxxflags());
531  _write_str_if("soflags", set.soflags());
532  _write_path_if("casm_includedir", set.casm_includedir());
533  _write_path_if("casm_libdir", set.casm_libdir());
534  _write_path_if("boost_includedir", set.boost_includedir());
535  _write_path_if("boost_libdir", set.boost_libdir());
536 
537  json["view_command"] = set.view_command();
538  json["view_command_video"] = set.view_command_video();
539  json["crystallography_tol"] = set.crystallography_tol();
540  json["crystallography_tol"].set_scientific();
541  json["lin_alg_tol"] = set.lin_alg_tol();
542  json["lin_alg_tol"].set_scientific();
543  json["query_alias"] = set.query_alias();
544 
545  return json;
546 }
547 
549  jsonParser const &json) {
550  try {
551  ProjectSettings settings{json["name"].get<std::string>()};
552 
553  // read required_properties map
554  if (json.contains("required_properties") &&
555  json["required_properties"].size()) {
556  auto it = json.find("required_properties");
558  CASM::from_json(tmp, *it);
559  settings.set_required_properties(tmp);
560  }
561 
562  // read cluster_expansions list and set default_clex
563  if (json.contains("cluster_expansions") &&
564  json["cluster_expansions"].size()) {
565  auto it = json.find("cluster_expansions");
566  auto clex_it = it->begin();
567  auto clex_end = it->end();
568  for (; clex_it != clex_end; ++clex_it) {
569  settings.insert_clex(clex_it->get<ClexDescription>());
570  }
571 
572  if (json.contains("default_clex")) {
573  settings.set_default_clex_name(json["default_clex"].get<std::string>());
574  } else {
575  if (settings.has_clex("formation_energy")) {
576  settings.set_default_clex_name("formation_energy");
577  } else {
578  settings.set_default_clex_name(
579  settings.cluster_expansions().begin()->first);
580  }
581  }
582  }
583  // if no cluster_expansions list, create with default_configuration_clex
584  else {
586  settings.insert_clex(desc);
587  settings.set_default_clex_name(desc.name);
588  }
589 
590  // read compiler & linker options
591 
592  std::string tmp_str;
593  if (json.get_if(tmp_str, "cxx")) {
594  settings.set_cxx(tmp_str);
595  }
596  if (json.get_if(tmp_str, "cxxflags")) {
597  settings.set_cxxflags(tmp_str);
598  }
599  if (json.get_if(tmp_str, "soflags")) {
600  settings.set_soflags(tmp_str);
601  }
602 
603  fs::path tmp_path;
604  if (json.get_if(tmp_path, "casm_prefix")) {
605  settings.set_casm_prefix(tmp_path); // deprecated
606  }
607  if (json.get_if(tmp_path, "boost_prefix")) {
608  settings.set_boost_prefix(tmp_path); // deprecated
609  }
610  if (json.get_if(tmp_path, "casm_includedir")) {
611  settings.set_casm_includedir(tmp_path);
612  }
613  if (json.get_if(tmp_path, "casm_libdir")) {
614  settings.set_casm_libdir(tmp_path);
615  }
616  if (json.get_if(tmp_path, "boost_includedir")) {
617  settings.set_boost_includedir(tmp_path);
618  }
619  if (json.get_if(tmp_path, "boost_libdir")) {
620  settings.set_boost_libdir(tmp_path);
621  }
622 
623  // other options
624  if (json.get_if(tmp_str, "view_command")) {
625  settings.set_view_command(tmp_str);
626  }
627  if (json.get_if(tmp_str, "view_command_video")) {
628  settings.set_view_command_video(tmp_str);
629  }
630 
631  // precision options -- always set
632  double tmp_double = TOL;
633  json.get_if(tmp_double, "crystallography_tol");
634  settings.set_crystallography_tol(tmp_double);
635 
636  json.get_else(tmp_double, "lin_alg_tol", 1e-10);
637  settings.set_lin_alg_tol(tmp_double);
638 
639  // read nlist json -- no longer generate defaults
640  if (json.contains("nlist_weight_matrix")) {
641  settings.set_nlist_weight_matrix(
642  json["nlist_weight_matrix"].get<Eigen::Matrix3l>());
643  }
644  if (json.contains("nlist_sublat_indices")) {
645  settings.set_nlist_sublat_indices(
646  json["nlist_sublat_indices"].get<std::set<int>>());
647  }
648 
649  // read query aliases
650  if (json.contains("query_alias") && json["query_alias"].size()) {
651  auto it = json.find("query_alias");
653  CASM::from_json(tmp, *it);
654  settings.set_query_alias(tmp);
655  }
656 
657  return settings;
658 
659  } catch (std::exception &e) {
660  err_log() << "Error reading ProjectSettings from JSON." << std::endl;
661  throw e;
662  }
663 }
664 
666  fs::path project_settings_path) {
667  jsonParser json;
668  to_json(set, json);
669 
670  SafeOfstream file;
671  file.open(project_settings_path);
672  json.print(file.ofstream(), 2, 18);
673  file.close();
674 }
675 
676 ProjectSettings read_project_settings(fs::path project_settings_path) {
677  try {
678  fs::ifstream file{project_settings_path};
679  jsonParser json{file};
681  } catch (std::exception &e) {
682  err_log() << "Error reading ProjectSettings from: '"
683  << project_settings_path << "'" << std::endl;
684  throw e;
685  }
686 }
687 
688 void commit(ProjectSettings const &set) {
690 }
691 
693  fs::path checkroot = find_casmroot(path);
694  if (checkroot.empty()) {
695  throw std::runtime_error(std::string("Error in open_project_settings:") +
696  " No CASM project includes path: '" +
697  path.string() + "'");
698  }
699  DirectoryStructure dir{checkroot};
701  result.set_root_dir(checkroot);
702  return result;
703 }
704 
705 } // namespace CASM
706 
707 // explicit instantiations
708 
709 #define INST_ProjectSettings_all(r, data, type) \
710  template QueryHandler<type> &ProjectSettings::query_handler<type>(); \
711  template const QueryHandler<type> &ProjectSettings::query_handler<type>() \
712  const;
713 
714 namespace CASM {
715 BOOST_PP_SEQ_FOR_EACH(INST_ProjectSettings_all, _, CASM_DB_TYPES)
716 }
#define CASM_DB_TYPES
#define INST_ProjectSettings_all(r, data, type)
Specification of CASM project directory structure.
fs::path root_dir() const
Return casm project directory path.
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.
fs::path project_settings() const
Return project_settings.json path.
std::vector< std::string > all_calctype() const
Check filesystem directory structure and return list of all calctype names.
bool new_casm_dir() const
Create new project data directory.
std::vector< std::string > all_bset() const
Check filesystem directory structure and return list of all basis set names.
bool new_reports_dir() const
Create new reports directory.
bool new_symmetry_dir() const
Create new symmetry directory.
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.
Definition: Log.hh:48
void custom(const std::string &what)
Definition: Log.hh:139
static const int standard
Definition: Log.hh:52
void set_query_alias(query_alias_map_type const &_query_alias)
notstd::cloneable_ptr< Eigen::Matrix3l > m_nlist_weight_matrix
std::pair< fs::path, std::string > boost_includedir() const
Get boost includedir (pair of value and source for the value)
double lin_alg_tol() const
Get current project linear algebra tolerance.
ClexDescription const & clex(std::string clex_name) const
Get a ClexDescription by name.
notstd::cloneable_ptr< std::set< int > > m_nlist_sublat_indices
std::pair< std::string, std::string > m_soflags
std::string view_command() const
Get current command used by 'casm view'.
bool set_crystallography_tol(double _tol)
Set crystallography tolerance.
bool set_view_command(std::string opt)
Set command used by 'casm view'.
bool has_dir() const
Check if DirectoryStructure exists.
std::pair< fs::path, std::string > casm_libdir() const
Get casm libdir (pair of value and source for the value)
bool insert_clex(ClexDescription const &desc)
notstd::cloneable_ptr< notstd::Cloneable > m_hamiltonian_modules
Eigen::Matrix3l nlist_weight_matrix() const
Get neighbor list weight matrix.
bool set_nlist_sublat_indices(std::set< int > value)
std::map< std::string, ClexDescription > const & cluster_expansions() const
Const access map of all ClexDescription.
notstd::cloneable_ptr< DirectoryStructure > m_dir
bool set_cxxflags(std::string opt)
Set c++ compiler options (empty string to use default)
std::map< std::string, notstd::cloneable_ptr< notstd::Cloneable > > m_query_handler
std::string default_clex_name() const
Get default ClexDescription name.
bool set_boost_libdir(fs::path dir)
Set boost libdir (empty string to use default)
bool has_m_nlist_weight_matrix() const
Check if neighbor list weight matrix exists.
std::string global_clexulator_name() const
Name to use for clexulator printing.
required_properties_map_type m_required_properties
DirectoryStructure const & dir() const
Access DirectoryStructure object. Throw if not set.
EnumeratorHandler & enumerator_handler()
std::pair< std::string, std::string > m_cxx
std::string compile_options() const
bool set_boost_prefix(fs::path dir)
Set boost prefix (empty string to use default)
HamiltonianModules & hamiltonian_modules()
query_alias_map_type const & query_alias() const
bool set_nlist_weight_matrix(Eigen::Matrix3l M)
std::pair< fs::path, std::string > casm_includedir() const
Get casm includedir (pair of value and source for the value)
std::string m_view_command_video
notstd::cloneable_ptr< notstd::Cloneable > m_enumerator_handler
bool set_default_clex_name(std::string const &clex_name)
Set default ClexDescription by name.
std::string m_default_clex_name
std::pair< fs::path, std::string > boost_libdir() const
Get boost libdir (pair of value and source for the value)
query_alias_map_type m_query_alias
bool set_casm_includedir(fs::path dir)
Set casm includedir (empty string to use default)
std::string m_default_database_name
std::map< ObjectTypeName, std::map< QueryAliasName, QueryAliasValue > > query_alias_map_type
std::map< ObjectTypeName, std::map< CalcTypeName, std::vector< std::string > > > required_properties_map_type
std::pair< fs::path, std::string > m_boost_includedir
std::string project_name() const
Get project name.
std::map< std::string, ClexDescription > m_clex
std::pair< fs::path, std::string > m_boost_libdir
bool set_casm_prefix(fs::path dir)
Set casm prefix (empty string to use default)
bool has_clex(std::string clex_name) const
Check if a ClexDescription exists.
ClexDescription const & default_clex() const
Get default ClexDescription.
fs::path root_dir() const
Access dir().root_dir(). Throw if not set.
QueryHandler< DataObject > & query_handler()
std::pair< std::string, std::string > soflags() const
Get shared object options (pair of value and source for the value)
std::pair< std::string, std::string > m_cxxflags
required_properties_map_type const & required_properties() const
bool has_nlist_sublat_indices() const
Check if set of sublattice indices to include in neighbor lists exists.
bool set_view_command_video(std::string opt)
Set video viewing command used by 'casm view'.
std::pair< fs::path, std::string > m_casm_includedir
bool set_lin_alg_tol(double _tol)
Set linear algebra tolerance.
std::string so_options() const
std::set< int > const & nlist_sublat_indices() const
Get set of sublattice indices to include in neighbor lists.
std::pair< std::string, std::string > cxx() const
Get c++ compiler (pair of value and source for the value)
bool set_default_clex(ClexDescription const &desc)
double crystallography_tol() const
Get current project crystallography tolerance.
bool set_soflags(std::string opt)
Set shared object options (empty string to use default)
void set_default_database_name(std::string _default_database_name)
Set default database type name (for future)
std::pair< fs::path, std::string > m_casm_libdir
void set_required_properties(required_properties_map_type const &_required_properties)
bool erase_clex(ClexDescription const &desc)
bool set_casm_libdir(fs::path dir)
Set casm libdir (empty string to use default)
bool set_boost_includedir(fs::path dir)
Set boost includedir (empty string to use default)
bool set_cxx(std::string opt)
Set c++ compiler (empty string to use default)
bool set_root_dir(fs::path root)
Set DirectoryStructure.
std::pair< std::string, std::string > cxxflags() const
Get c++ compiler options (pair of value and source for the value)
ProjectSettings(std::string project_name)
std::string view_command_video() const
Get current video viewing command used by 'casm view'.
std::string default_database_name() const
Get default database type name.
void add_alias(const std::string &alias_name, const std::string &alias_command)
Add user-defined query alias.
static std::pair< std::string, std::string > default_soflags()
Default c++ compiler options.
static std::pair< fs::path, std::string > default_boost_includedir()
Return default includedir for boost.
static std::pair< std::string, std::string > default_cxxflags()
Default c++ compiler options.
static std::pair< fs::path, std::string > default_casm_includedir()
Return default includedir for CASM.
static std::pair< fs::path, std::string > default_boost_libdir()
Return default libdir for boost.
static std::pair< std::string, std::string > default_cxx()
Return default compiler.
static std::pair< fs::path, std::string > default_casm_libdir()
Return default libdir for CASM.
Write to a temporary file to ensure a good write, then rename.
Definition: SafeOfstream.hh:31
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file".
Definition: SafeOfstream.hh:84
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
Definition: SafeOfstream.hh:65
fs::ofstream & ofstream()
Access underlying stream.
Definition: SafeOfstream.hh:80
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:395
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:601
size_type size() const
Definition: jsonParser.cc:487
iterator find(const std::string &name)
Return iterator to JSON object value with 'name'.
Definition: jsonParser.cc:543
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
Definition: jsonParser.cc:188
void commit(ProjectSettings const &set)
ProjectSettings open_project_settings(fs::path path_in_project)
void print_summary(ProjectSettings const &set, Log &log)
Print summary of ProjectSettings, as for 'casm settings -l'.
bool is_valid_project_name(std::string project_name)
bool create_all_directories(ProjectSettings const &set)
void throw_if_project_name_is_not_valid(std::string project_name)
Throw if project name is invalid.
void print_compiler_settings_summary(ProjectSettings const &set, Log &log)
Print summary of compiler settings, as for 'casm settings -l'.
void write_project_settings(ProjectSettings const &set, fs::path project_settings_path)
ProjectSettings read_project_settings(fs::path project_settings_path)
bool get_if(T &t, const std::string &key, Args &&... args) const
Definition: jsonParser.hh:740
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
Main CASM namespace.
Definition: APICommand.hh:8
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
std::string type_name()
Definition: TypeInfo.hh:19
std::string include_path(const fs::path &dir)
Log & log()
Definition: Log.hh:424
const double TOL
Definition: definitions.hh:30
DoFSpecsType const & get(DoFKey const &key, BasisFunctionSpecs const &basis_function_specs)
GenericDatumFormatter< std::string, DataObject > name()
fs::path find_casmroot(const fs::path &cwd)
std::string link_path(const fs::path &dir)
void from_json(ClexDescription &desc, const jsonParser &json)
bool new_dir(const DirectoryStructure &dir, ClexDescription const &desc)
ClexDescription default_configuration_clex()
Log & err_log()
Definition: Log.hh:426
Matrix< long int, 3, 3 > Matrix3l
Definition: eigen.hh:12
Non-std smart pointer classes and functions.
std::unique_ptr< T > clone(const T &obj)
std::unique_ptr< T > make_unique(Args &&... args)
c++17 does not include 'make_unique'
ClexDescription & desc
Definition: settings.cc:138
pair_type calctype
Definition: settings.cc:143
DirectoryStructure const & dir
Definition: settings.cc:136
ProjectSettings & set
Definition: settings.cc:137
Specifies a particular cluster expansion.
void print(std::ostream &sout, bool is_default, int indent=0) const
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:551