3 #include <boost/filesystem.hpp>
31 "update,u",
"Update basis set")(
33 "orbits",
"Pretty-print orbit prototypes")(
35 "functions",
"Pretty-print prototype cluster functions for each orbit")(
37 "clusters",
"Pretty-print all clusters")(
40 "Select a non-default basis set to print by specifying the name of a "
41 "cluster expansion using the basis set")(
43 "print-invariant-group",
44 "Use with --orbits or --clusters to print the group that leaves clusters "
47 "print-equivalence-map",
48 "Use with --clusters to print the orbit equivalence map (sets of "
49 "symmetry operations that map the prototype cluster onto an equivalent "
50 "cluster / cosets of the invariant group).")(
53 "Use with --functions to print aligned functions ready to copy and paste "
54 "into a latex document")(
57 "Use with --update to generate basis.json, clust.json, and "
58 "the basis function source code but not compile it.")(
61 "Use with --update to keep the existing basis.json, clust.json, and "
62 "basis function source code but to re-compile it if the .so and .o files "
65 "force,f",
"Force overwrite");
73 template <
typename CommandType>
75 const auto &vm = cmd.vm();
76 const auto &
primclex = cmd.primclex();
78 if (!vm.count(
"clex")) {
79 return primclex.settings().default_clex();
83 set.cluster_expansions().find(vm[
"clex"].
template as<std::string>());
84 if (it ==
set.cluster_expansions().end()) {
85 throw std::runtime_error{
"Invalid --clex value: " +
86 vm[
"clex"].template as<std::string>()};
97 bool _any_existing_files =
false;
98 for (
const auto &p :
dir.bset_data(
set.project_name(),
bset)) {
100 if (!_any_existing_files) {
102 _any_existing_files =
true;
104 log() <<
"found: " << p <<
"\n";
107 return _any_existing_files;
111 const auto &vm = cmd.
vm();
115 if (vm.count(
"force")) {
116 log() <<
"Using --force. Will overwrite existing files.\n" << std::endl;
119 "Exiting due to existing files. Use --force to force overwrite.",
127 const auto &vm = cmd.
vm();
134 if (vm.count(
"only-compile")) {
135 auto clexulator =
primclex.clexulator(basis_set_name);
139 if (!
primclex.has_basis_set_specs(basis_set_name)) {
140 auto bspecs_path =
primclex.dir().bspecs(basis_set_name);
142 "'bspecs.json' file not found at: " + bspecs_path.string(),
152 }
catch (std::exception &e) {
157 if (!vm.count(
"no-compile")) {
158 auto clexulator =
primclex.clexulator(basis_set_name);
164 template <
typename Pr
interType>
169 template <
typename OrbitVecType>
170 void operator()(OrbitVecType
const &orbits)
const;
180 auto const &vm = cmd.
vm();
186 auto const &basis_set_specs =
primclex.basis_set_specs(basis_set_name);
187 auto const &cluster_specs = *basis_set_specs.cluster_specs;
189 std::vector<IntegralCluster> prototypes;
197 orbit_printer_options.
delim = 0;
199 if (vm.count(
"print-invariant-group")) {
202 if (vm.count(
"print-equivalence-map")) {
206 if (vm.count(
"orbits")) {
210 if (vm.count(
"clusters")) {
214 if (vm.count(
"functions")) {
215 bool align = vm.count(
"align");
220 orbit_printer_options};
246 err_log() <<
"Error in 'casm bset'. Choose --update or one or more of "
247 "--orbits, --clusters, ----functions."
264 log().
indent() <<
"DESCRIPTION\n" << std::endl;
266 log().
indent() <<
"Generate and inspect cluster basis functions. A "
267 "bspecs.json file should be available at\n";
270 log().
indent() <<
"$ROOT/basis_set/$current_bset/bspecs.json\n";
274 log().
indent() <<
"For a description of the bspecs.json file use one of:"
277 log() <<
"'casm format --bpsecs'" << std::endl;
278 log() <<
"'casm format --local_bpsecs'" << std::endl;
288 const auto &
vm = this->
vm();
291 if (
vm.count(
"update")) {
293 }
else if (
vm.count(
"orbits") ||
vm.count(
"clusters") ||
294 vm.count(
"functions")) {
297 err_log() <<
"Error in 'casm bset'. Choose --update or one or more of "
298 "--orbits, --clusters, ----functions."
303 err_log() << e.what() << std::endl;
305 }
catch (std::exception &e) {
306 err_log() << e.what() << std::endl;
313 namespace bset_impl {
315 template <
typename Pr
interType>
318 : m_log(_log), m_printer(_opt) {}
320 template <
typename Pr
interType>
321 template <
typename OrbitVecType>
323 OrbitVecType
const &orbits)
const {
324 print_clust(orbits.begin(), orbits.end(), m_log, m_printer);
std::shared_ptr< Structure const > shared_prim
#define ERR_MISSING_INPUT_FILE
#define ERR_EXISTING_FILE
#define ERR_INVALID_INPUT_FILE
PrimClex & primclex() const
const OptionType & opt() const
const po::variables_map & vm() const
int count(std::string s) const
'casm enum' implementation
int help() const override
BsetCommand(const CommandArgs &_args, Completer::BsetOption &_opt)
int vm_count_check() const override
static const std::string name
int desc() const override
static std::string clex()
Get value_type string for clex mode completion.
COORD_TYPE coordtype_enum() const
Return the coordinate type recasted as the CASM defined enum.
void initialize() override
Fill in the options descriptions accordingly.
const po::options_description & desc()
Get the program options, filled with the initialized values.
void add_help_suboption()
Add a plain –help and –desc suboptions.
po::options_description m_desc
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
Specification of CASM project directory structure.
void custom(const std::string &what)
void error(const std::string &what)
void operator()(OrbitVecType const &orbits) const
OrbitPrinterAdapter(Log &_log, OrbitPrinterOptions _opt)
ProjectSettings & settings()
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
void write_basis_set_data(std::shared_ptr< Structure const > shared_prim, ProjectSettings const &settings, std::string const &basis_set_name, ClexBasisSpecs const &basis_set_specs, PrimNeighborList &prim_neighbor_list)
void update_bset(const BsetCommand &cmd)
Implements casm bset --update
void check_force(const std::string &bset, const BsetCommand &cmd)
bool any_existing_files(const std::string &bset, const BsetCommand &cmd)
Check for generated bset files, print messages when found to CASM::log()
void print_bset(const BsetCommand &cmd)
ClexDescription get_clex_description(const CommandType &cmd)
void for_all_orbits(ClusterSpecs const &cluster_specs, std::vector< IntegralCluster > const &generating_elements, FunctorType const &f)
void print_clust(ClusterOrbitIterator begin, ClusterOrbitIterator end, Log &out, OrbitPrinter printer)
Print IntegralCluster orbits.
const COORD_TYPE INTEGRAL
ClusterOutputIterator read_clust(ClusterOutputIterator result, const jsonParser &json, const Structure &prim, const SymGroup &generating_grp, const SymCompareType &sym_compare)
Read JSON containing Orbit<SymCompareType> prototypes.
DirectoryStructure const & dir
Specifies a particular cluster expansion.
Data structure holding basic CASM command info.
bool print_equivalence_map
bool print_invariant_group