3 #include <boost/filesystem.hpp>
22 sout <<
"Possible composition axes:\n\n";
28 sout <<
"Currently selected composition axes: " << comp_axes.
curr_key
32 sout <<
"Parametric composition:\n";
36 sout <<
"Composition:\n";
40 sout <<
"Parametric chemical potentials:\n";
51 m_desc.add_options()(
"display,d",
"Display composition axes file")(
52 "calc,c",
"Calculate the standard composition axes")(
54 "Select composition axes");
77 po::store(po::parse_command_line(args.
argc(), args.
argv(), comp_opt.
desc()),
80 bool call_help =
false;
83 if (!vm.count(
"help") && !vm.count(
"desc")) {
84 if (vm.count(
"calc") + vm.count(
"select") + vm.count(
"display") +
87 log() <<
"Error in 'casm composition'. You need to use either --calc, "
88 "--select, --display, or --update."
96 if (vm.count(
"help") || call_help) {
98 log() << comp_opt.
desc() << std::endl;
103 if (vm.count(
"desc")) {
105 log() << comp_opt.
desc() << std::endl;
107 log() <<
"DESCRIPTION" << std::endl;
108 log() <<
" Setup the composition axes.\n";
109 log() <<
" - expects a PRIM file in the project root directory \n";
110 log() <<
" - custom composition axes can be added to the "
111 "'composition_axes.json' file \n";
112 log() <<
" and then compositions and references updated with 'casm "
113 "composition --update'\n";
114 log() <<
" (word of caution: compatibility with PRIM is currently "
115 "not checked for.)\n";
117 log() <<
" Examples:\n";
118 log() <<
" casm composition --calc \n";
119 log() <<
" - Calculate standard composition axes, but does not "
122 log() <<
" casm composition --display \n";
123 log() <<
" - Display the possible composition axes\n";
124 log() <<
" - Possible axes are stored in the "
125 "'composition_axes.json' file.\n";
127 log() <<
" casm composition --select 0 \n";
128 log() <<
" - Select the composition axes by key name.\n";
129 log() <<
" - Updates and writes compositions and reference "
143 }
catch (po::error &e) {
144 err_log() <<
"ERROR: " << e.what() << std::endl << std::endl;
147 }
catch (std::exception &e) {
148 err_log() <<
"Unhandled Exception reached the top of main: " << e.what()
149 <<
", application will now exit" << std::endl;
153 const fs::path &root = args.
root;
162 std::unique_ptr<PrimClex> uniq_primclex;
169 if (fs::exists(comp_axes_path)) {
173 if (vm.count(
"display")) {
174 log() <<
"\n***************************\n\n";
183 log() <<
"Please use 'casm composition --select' to choose your "
184 "composition axes.\n\n";
185 }
else if (!comp_axes.
all_axes.size()) {
186 log() <<
"Please use 'casm composition --calc' to calculate standard "
187 "composition axes.\n\n";
192 if (vm.count(
"calc")) {
193 log() <<
"\n***************************\n\n";
195 log() <<
"Using the PRIM to enumerate standard composition axes for this "
199 log() <<
"Overwriting existing standard composition axes.\n\n";
204 std::vector<CompositionConverter> v;
206 std::back_inserter(v));
215 log() <<
"Wrote: " << comp_axes_path <<
"\n\n";
218 log() <<
"Please use 'casm composition --select' to choose your "
219 "composition axes.\n\n";
223 if (vm.count(
"select")) {
224 log() <<
"\n***************************\n\n";
227 log() <<
"Error: No composition axes found.\n\n";
229 log() <<
"Please use 'casm composition --calc' to calculate standard "
230 "composition axes,\n"
231 <<
"or add custom composition axes to " << comp_axes_path
238 log() <<
"Error: The selected composition axes '"
240 <<
"be found in either the standard or custom compostion axes. "
242 <<
"re-select composition axes. "
256 log() <<
"Wrote: " << comp_axes_path <<
"\n\n";
#define ERR_MISSING_DEPENDS
#define ERR_INVALID_INPUT_FILE
void initialize() override
Fill in the options descriptions accordingly.
std::string m_axis_choice_str
const std::string & axis_choice_str() const
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
Specification of CASM project directory structure.
fs::path composition_axes() const
Return composition axes file path.
void error(const std::string &what)
PrimClex is the top-level data structure for a CASM project.
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...
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
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.
const PrimType & prim() const
const Access to primitive Structure
std::vector< std::vector< std::string > > allowed_molecule_names(BasicStructure const &_struc)
Returns a vector with a list of allowed molecule names at each site.
void display_comp_n(std::ostream &stream, const CompositionConverter &f, int indent=0)
Pretty-print comp_n in terms of comp.
void write_composition_axes(fs::path _filename, CompositionAxes const &composition_axes)
Write CompositionAxes to file.
void display(std::ostream &sout, const CompositionAxes &comp_axes)
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 display_composition_axes(std::ostream &stream, const std::map< std::string, CompositionConverter > &map)
Pretty-print map of name/CompositionConverter pairs.
CompositionAxes read_composition_axes(fs::path _filename)
void display_comp(std::ostream &stream, const CompositionConverter &f, int indent=0)
Pretty-print comp in terms of comp_n.
OutputIterator standard_composition_axes(ParamComposition::AllowedOccupants _allowed_occs, OutputIterator result)
Generate CompositionConverter specifying standard composition axes for a prim Structure.
int composition_command(const CommandArgs &args)
DirectoryStructure const & dir
Data structure holding basic CASM command info.
bool has_current_axes() const
True if curr_key is set.
std::set< std::string > enumerated
void select(std::string key)
Set this->curr using key.
CompositionConverter curr
std::map< std::string, CompositionConverter > all_axes
void insert_enumerated(IterType begin, IterType end)
Iterate over list of CompositionConverter and insert each one as an enumerated axes set with a unique...
void erase_enumerated()
Erase all enumerated axes and clear this->enumerated.