CASM  1.1.0
A Clusters Approach to Statistical Mechanics
sym.cc
Go to the documentation of this file.
1 #include "casm/app/sym.hh"
2 
8 #include "casm/casm_io/Log.hh"
9 #include "casm/clex/PrimClex.hh"
10 
11 namespace CASM {
12 
13 namespace Completer {
15 
17  bool required = false;
18 
23  // add_scelnames_suboption();
25  add_settings_suboption(required);
26  add_input_suboption(required);
27 
28  m_desc.add_options()(
29 
30  "lattice-point-group", "Pretty print prim lattice point group")(
31 
32  "factor-group", "Pretty print prim factor group")(
33 
34  "crystal-point-group", "Pretty print prim crystal point group")(
35 
36  "brief", "Print brief descriptions of symmetry operations")(
37 
38  "calc-wedge",
39  "Perform calculation of irreducible wedge (may significantly slow down "
40  "analysis). Used for --dof-space-analysis.")(
41 
42  "tol", po::value<double>(&m_tol)->default_value(1.0e-5),
43  "Tolerance in Angstr. Used for --symmetrize (default 1e-5)")(
44 
45  "dof-space-analysis", "Print DoF Space analysis files")(
46  "symmetrize",
47  po::value<fs::path>(&m_poscar_path)->value_name(ArgHandler::path()),
48  "symmetrize a POSCAR specified by path to a given tolerance");
49 
50  return;
51 }
52 } // namespace Completer
53 } // namespace CASM
54 
55 namespace CASM {
56 // ///////////////////////////////////////
57 // 'sym' function for casm
58 // (add an 'if-else' statement in casm.cpp to call this)
59 
60 const std::string SymCommand::name = "sym";
61 
63  : APICommand<Completer::SymOption>(_args, _opt) {}
64 
66  if (!vm().count("symmetrize") && !in_project()) {
67  help();
68  err_log().error("No casm project found");
69  err_log() << std::endl;
70  return ERR_NO_PROJ;
71  }
72 
73  if (vm().count("settings") + vm().count("input") == 2) {
74  help();
75  err_log() << "Error in 'casm sym'. The options --settings or --input may "
76  "not both be chosen."
77  << std::endl;
78  return ERR_INVALID_ARG;
79  }
80 
81  return 0;
82 }
83 
84 int SymCommand::help() const {
85  log() << "\n";
86  log() << opt().desc() << std::endl;
87 
88  return 0;
89 }
90 
91 int SymCommand::desc() const {
92  log() << "\n";
93  log() << opt().desc() << std::endl;
94  log() << "DESCRIPTION" << std::endl << std::endl;
95 
97  log() << symmetrize_desc();
99  return 0;
100 }
101 
102 int SymCommand::run() const {
103  jsonParser json_options =
104  make_json_input(opt()); // JSON from --input string or --settings file
105  jsonParser cli_options_as_json{opt()}; // All CLI options as JSON object
106 
107  if (vm().count("symmetrize")) {
108  symmetrize(primclex(), json_options, cli_options_as_json);
109  } else if (vm().count("dof-space-analysis")) {
110  dof_space_analysis(primclex(), json_options, cli_options_as_json);
111  } else {
112  write_prim_symmetry(primclex(), json_options, cli_options_as_json);
113  }
114 
115  return 0;
116 }
117 
118 } // namespace CASM
#define ERR_NO_PROJ
Definition: errors.hh:13
#define ERR_INVALID_ARG
Definition: errors.hh:7
PrimClex & primclex() const
Definition: APICommand.cc:17
bool in_project() const
Definition: APICommand.cc:15
const OptionType & opt() const
Definition: APICommand.hh:61
const po::variables_map & vm() const
Definition: APICommand.hh:59
int count(std::string s) const
Definition: APICommand.hh:57
static std::string path()
Get value_type string for path completion.
Definition: Handlers.cc:56
void add_input_suboption(bool required=true)
Definition: Handlers.cc:610
void add_confignames_suboption()
Add a –confignames suboption.
Definition: Handlers.cc:691
const po::options_description & desc()
Get the program options, filled with the initialized values.
Definition: Handlers.cc:321
void add_settings_suboption(bool required=true)
Definition: Handlers.cc:588
void add_help_suboption()
Add a plain –help and –desc suboptions.
Definition: Handlers.cc:561
po::options_description m_desc
Definition: Handlers.hh:260
void add_selection_no_default_suboption()
Add –selection suboption (no default)
Definition: Handlers.cc:420
void add_coordtype_suboption()
Add a –coord suboption to specify FRAC or CART.
Definition: Handlers.cc:725
void add_dofs_suboption()
Add a –dofs suboption to specify DoF Types.
Definition: Handlers.cc:737
void initialize() override
Fill in the options descriptions accordingly.
Definition: sym.cc:16
void error(const std::string &what)
Definition: Log.hh:129
int run() const override
Definition: sym.cc:102
int help() const override
Definition: sym.cc:84
int vm_count_check() const override
Definition: sym.cc:65
int desc() const override
Definition: sym.cc:91
SymCommand(const CommandArgs &_args, Completer::SymOption &_opt)
Definition: sym.cc:62
static const std::string name
Definition: sym.hh:18
Main CASM namespace.
Definition: APICommand.hh:8
std::string write_prim_symmetry_desc()
Describe the default casm sym option.
Log & log()
Definition: Log.hh:424
void dof_space_analysis(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Perform DoF space analysis.
std::string dof_space_analysis_desc()
Describe DoF space analysis input.
jsonParser make_json_input(const OptionType &opt)
Definition: json_io_impl.hh:11
void write_prim_symmetry(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Write/print prim symmetry.
std::string symmetrize_desc()
Describe the symmetrize method.
Definition: symmetrize.cc:245
void symmetrize(PrimClex &primclex, jsonParser const &json_options, jsonParser const &cli_options_as_json)
Adjust a structure's lattice and basis to increase factor group symmetry.
Definition: symmetrize.cc:292
Log & err_log()
Definition: Log.hh:426
Data structure holding basic CASM command info.