15 sout <<
"Standard composition axes:\n\n";
20 sout <<
"Custom composition axes:\n\n";
26 sout <<
"Currently selected composition axes: " << opt.
curr_key <<
"\n";
29 sout <<
"Parametric composition:\n";
33 sout <<
"Composition:\n";
37 sout <<
"Parametric chemical potentials:\n";
51 (
"display,d",
"Display composition axes file")
52 (
"calc,c",
"Calculate the standard composition axes")
53 (
"select,s", po::value<std::string>(&
m_axis_choice_str),
"Select composition axes");
76 po::store(po::parse_command_line(args.
argc, args.
argv, comp_opt.
desc()), vm);
78 bool call_help =
false;
81 if(!vm.count(
"help") && !vm.count(
"desc")) {
82 if(vm.count(
"calc") + vm.count(
"select") + vm.count(
"display") + vm.count(
"update") != 1) {
83 args.
log <<
"Error in 'casm composition'. You need to use either --calc, --select, --display, or --update." << std::endl;
90 if(vm.count(
"help") || call_help) {
91 args.
log << std::endl;
92 args.
log << comp_opt.
desc() << std::endl;
97 if(vm.count(
"desc")) {
98 args.
log << std::endl;
99 args.
log << comp_opt.
desc() << std::endl;
101 args.
log <<
"DESCRIPTION" << std::endl;
102 args.
log <<
" Setup the composition axes.\n";
103 args.
log <<
" - expects a PRIM file in the project root directory \n";
104 args.
log <<
" - custom composition axes can be added to the 'composition_axes.json' file \n";
105 args.
log <<
" and then compositions and references updated with 'casm composition --update'\n";
106 args.
log <<
" (word of caution: compatibility with PRIM is currently not checked for.)\n";
108 args.
log <<
" Examples:\n";
109 args.
log <<
" casm composition --calc \n";
110 args.
log <<
" - Calculate standard composition axes, but does not select any. \n";
112 args.
log <<
" casm composition --display \n";
113 args.
log <<
" - Display the possible composition axes\n";
114 args.
log <<
" - Possible axes are stored in the 'composition_axes.json' file.\n";
116 args.
log <<
" casm composition --select 0 \n";
117 args.
log <<
" - Select the composition axes by key name.\n";
118 args.
log <<
" - Updates and writes compositions and reference properties.\n";
134 catch(po::error &e) {
135 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
139 catch(std::exception &e) {
140 args.
err_log <<
"Unhandled Exception reached the top of main: "
141 << e.what() <<
", application will now exit" << std::endl;
155 std::unique_ptr<PrimClex> uniq_primclex;
162 if(fs::exists(comp_axes)) {
166 if(vm.count(
"display")) {
168 args.
log <<
"\n***************************\n\n";
178 args.
log <<
"Please use 'casm composition --select' to choose your composition axes.\n\n";
181 args.
log <<
"Please use 'casm composition --calc' to calculate standard composition axes.\n\n";
188 if(vm.count(
"calc")) {
190 args.
log <<
"\n***************************\n\n";
192 args.
log <<
"Using the PRIM to enumerate standard composition axes for this space.\n\n";
195 args.
log <<
"Overwriting existing standard composition axes.\n\n";
199 std::vector<CompositionConverter> v;
201 for(
int i = 0; i < v.size(); i++) {
210 opt.
write(comp_axes);
212 args.
log <<
"Wrote: " << comp_axes <<
"\n\n";
215 args.
log <<
"Please use 'casm composition --select' to choose your composition axes.\n\n";
219 if(vm.count(
"select")) {
221 args.
log <<
"\n***************************\n\n";
225 args.
log <<
"Error: No composition axes found.\n\n";
227 args.
log <<
"Please use 'casm composition --calc' to calculate standard composition axes,\n" <<
228 "or add custom composition axes to " << comp_axes <<
"\n\n";
237 args.
log <<
"Error: The selected composition axes '" << comp_opt.
axis_choice_str() <<
"' can be \n" <<
238 "found in both the standard and custom compostion axes. Please \n" <<
239 "edit the custom composition axes to remove this ambiguity. \n\n" <<
241 "File: " << comp_axes <<
"\n\n";
249 args.
log <<
"Error: The selected composition axes '" << comp_opt.
axis_choice_str() <<
"' can not \n" <<
250 "be found in either the standard or custom compostion axes. Please\n" <<
251 "re-select composition axes. \n\n";
263 opt.
write(comp_axes);
265 args.
log <<
"Wrote: " << comp_axes <<
"\n\n";
Data structure holding basic CASM command info.
void display_comp_n(std::ostream &stream, const CompositionConverter &f, int indent=0)
Pretty-print comp_n in terms of comp.
CompositionConverter curr
void display_composition_axes(std::ostream &stream, const std::map< std::string, CompositionConverter > &map)
Pretty-print map of name/CompositionConverter pairs.
std::map< std::string, CompositionConverter > standard
fs::path composition_axes() const
Return composition axes file path.
const std::string & axis_choice_str() const
Specification of CASM project directory structure.
const DirectoryStructure & dir() const
void select(std::string key)
Set this->curr using key.
void add_help_suboption()
Add a plain –help suboption.
void refresh(bool read_settings=false, bool read_composition=false, bool read_chem_ref=false, bool read_configs=false, bool clear_clex=false)
Reload PrimClex data from settings.
void display_param_chem_pot(std::ostream &stream, const CompositionConverter &f, int indent=0)
Pretty-print param_chem_pot in terms of chem_pot.
void initialize() override
Fill in the options descriptions accordingly.
std::string to_string(ENUM val)
Return string representation of enum class.
void display(std::ostream &sout, const CompositionAxes &opt)
const po::options_description & desc()
Get the program options, filled with the initialized values.
void read(fs::path _filename)
Read CompositionAxes from file.
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
PrimClex is the top-level data structure for a CASM project.
OutputIterator standard_composition_axes(const Structure &prim, OutputIterator result)
Generate CompositionConverter specifying standard composition axes for a prim Structure.
PrimClex & make_primclex_if_not(const CommandArgs &args, std::unique_ptr< PrimClex > &uniq_primclex)
If !_primclex, construct new PrimClex stored in uniq_primclex, then return reference to existing or c...
void display_comp(std::ostream &stream, const CompositionConverter &f, int indent=0)
Pretty-print comp in terms of comp_n.
void error(const std::string &what)
void write(fs::path _filename)
Write CompositionAxes to file.
std::string m_axis_choice_str
std::map< std::string, CompositionConverter > custom
const Structure & get_prim() const
const Access to primitive Structure
#define ERR_MISSING_DEPENDS
#define ERR_INVALID_INPUT_FILE
int composition_command(const CommandArgs &args)