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);
32 return sublat_indices;
36 std::string in(indent,
' ');
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";
57 json[
"name"] = desc.
name;
60 json[
"ref"] = desc.
ref;
61 json[
"bset"] = desc.
bset;
62 json[
"eci"] = desc.
eci;
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() +
"'");
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());
130 if(settings.contains(
"cluster_expansions") && settings[
"cluster_expansions"].size()) {
144 ClexDescription desc(
"formation_energy",
"formation_energy",
"default",
"default",
"default",
"default");
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";
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";
161 _read_if(
m_cxx,
"cxx");
166 if(settings.get_if(tmp,
"casm_prefix")) {
172 if(settings.get_if(tmp,
"boost_prefix")) {
200 bool and_commit =
false;
201 if(!settings.contains(
"nlist_weight_matrix") || !settings.contains(
"nlist_sublat_indices")) {
207 if(settings.contains(
"nlist_weight_matrix")) {
214 if(settings.contains(
"nlist_sublat_indices")) {
222 jsonParser &alias_json = settings[
"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>();
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>());
246 catch(std::exception &e) {
247 std::cerr <<
"Error in ProjectSettings::ProjectSettings(const fs::path root).\n" <<
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() +
"'");
281 return m_clex.find(name)->second;
298 for(
auto it =
m_clex.begin(); it !=
m_clex.end(); ++it) {
299 if(it->first != desc.
name) {
381 return cxx().first +
" " +
cxxflags().first +
" " +
395 return cxx().first +
" " +
soflags().first +
" " +
420 return name() +
"_Clexulator";
465 return fs::create_directories(
m_dir.
ref_dir(calctype, ref));
470 return fs::create_directories(
m_dir.
eci_dir(property, calctype, ref, bset, eci));
497 m_cxx = std::make_pair(opt,
"project_settings");
503 m_cxxflags = std::make_pair(opt,
"project_settings");
509 m_soflags = std::make_pair(opt,
"project_settings");
516 m_casm_libdir = std::make_pair(prefix /
"lib",
"project_settings");
535 m_boost_libdir = std::make_pair(prefix /
"lib",
"project_settings");
593 std::cerr <<
"Uncaught exception in ProjectSettings::commit()" << std::endl;
604 for(
auto it = all_bset.begin(); it != all_bset.end(); ++it) {
625 json[
"name"] =
name();
633 auto _write_if = [&](std::string
name, std::string val) {
639 _write_if(
"cxx",
m_cxx.first);
651 json[
"crystallography_tol"].set_scientific();
653 json[
"lin_alg_tol"].set_scientific();
654 json[
"query_alias"] = query_handler<Configuration>().aliases();
660 std::string _wdefaultval(std::string name, std::pair<std::string, std::string> val) {
661 return name +
": '" + val.first +
"' (" + val.second +
")\n";
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));
671 log << _wdefaultval(
"cxx",
cxx())
672 << _wdefaultval(
"cxxflags",
cxxflags())
673 << _wdefaultval(
"soflags",
soflags())
677 << _wdefaultval(
"boost_libdir",
boost_libdir()) << std::endl;
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";
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";
694 log <<
"so command: '" <<
so_options() <<
"'\n\n";
701 for(
auto it =
m_clex.begin(); it !=
m_clex.end(); ++it) {
706 desc.
print(log, is_default, indent);
714 for(
int i = 0; i < all.size(); i++) {
716 if(all[i] == default_desc.
bset) {
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) {
739 for(
int i = 0; i < all.size(); i++) {
741 if(all[i] == default_desc.
eci) {
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";
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file"...
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.
double m_crystallography_tol
void from_json(ClexDescription &desc, const jsonParser &json)
iterator end()
Returns iterator to end of JSON object or JSON array.
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.
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.
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.
Write to a temporary file to ensure a good write, then rename.
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
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.
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.
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
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
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.
bool clex_exists(const DirectoryStructure &dir, const ClexDescription &desc)
BasicStructure< Site > read_prim(fs::path filename)
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
std::map< std::string, ClexDescription > m_clex
void custom(const std::string &what)
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
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.
std::string m_view_command
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.
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.
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.
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.
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'.
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
void _load_default_options()
initialize default compiler options
std::string m_default_clex
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'.
ConfigIO::GenericConfigFormatter< std::string > scelname()
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) ...
std::string m_depr_so_options
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.
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
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.