19 (
"force,f",
"Force using a non-reduced, non-primitive, or left-handed PRIM");
37 po::store(po::parse_command_line(args.
argc, args.
argv, init_opt.
desc()), vm);
41 if(vm.count(
"help")) {
43 args.
log << init_opt.
desc() << std::endl;
48 if(vm.count(
"desc")) {
50 args.
log << init_opt.
desc() << std::endl;
52 args.
log <<
"DESCRIPTION \n" <<
53 " Initialize a new CASM project in the current directory.\n" <<
54 " - Expects a prim.json file in the current directory \n" <<
55 " - If not found, looks for a PRIM file in the current \n" <<
56 " directory and creates prim.json. \n\n";
65 args.
err_log <<
"ERROR: " << e.what() << std::endl << std::endl;
69 catch(std::exception &e) {
70 args.
err_log <<
"Unhandled Exception reached the top of main: "
71 << e.what() <<
", application will now exit" << std::endl;
77 args.
log <<
"Already in a casm project." << std::endl;
81 args.
log <<
"\n***************************\n" << std::endl;
90 if(!fs::is_regular_file(dir.
prim())) {
92 if(!fs::is_regular_file(dir.
PRIM())) {
93 args.
log <<
"Error in 'casm init': Neither 'prim.json' nor 'PRIM' found.\n\n";
95 args.
log <<
"Run 'casm format --prim' for the format of the 'prim.json' file.\n\n";
97 args.
log <<
"For step by step help use: 'casm status -n'\n\n";
103 fs::ifstream poscar_prim;
104 poscar_prim.open(dir.
PRIM());
105 prim.
read(poscar_prim);
108 catch(std::runtime_error &e) {
110 args.
err_log <<
"ERROR: No prim.json exists. PRIM exists, but it could not be read.\n";
111 args.
err_log << e.what() << std::endl;
116 std::string poscar_prim_title = prim.
title;
117 args.
log <<
"Converting 'PRIM' to 'prim.json'.\n\n" << std::endl;
119 args.
log <<
"Please enter a short title for this project.\n";
120 args.
log <<
" Use something suitable as a prefix for files specific to this project, such as 'ZrO' or 'TiAl'.\n\n";
122 args.
log <<
"Title: ";
123 std::cin >> prim.
title;
128 json[
"description"] = poscar_prim_title;
129 fs::ofstream primfile(dir.
prim());
130 json.
print(primfile);
143 catch(std::runtime_error &e) {
144 args.
err_log << e.what() << std::endl;
153 if(!vm.count(
"force")) {
154 args.
err_log <<
"ERROR: The structure in the prim.json file is not primitive. Writing the most \n"
155 <<
" primitive structure to file 'prim.true.json'.\n\n";
161 fs::ofstream primfile(root /
"prim.true.json");
164 json[
"description"] = prim_json[
"description"];
165 json.
print(primfile);
168 args.
err_log <<
"If you want to use the current prim.json anyway, re-run with the --force option. Some\n"
169 <<
"CASM features cannot be used with a non-primitive starting structure.\n";
173 args.
err_log <<
"WARNING: The structure in the prim.json file is not primitive. Continuing anyway \n"
174 <<
" because the --force option is on.\n\n";
183 if(!is_standard_niggli) {
184 if(!vm.count(
"force")) {
185 if(!is_standard_niggli) {
186 args.
err_log <<
"ERROR: The structure in the prim.json file is not the niggli cell in the CASM standard\n"
187 <<
" orientation. Writing the suggested structure to 'prim.niggli.json'.\n\n"
188 <<
" If you want to use the current prim.json anyway, re-run with the --force option.\n";
195 fs::ofstream primfile(root /
"prim.niggli.json");
198 json[
"description"] = prim_json[
"description"];
199 json.
print(primfile);
205 args.
err_log <<
"WARNING: The structure in the prim.json file is not the standard orientation Niggli\n"
206 <<
" cell. Continuing anyway because the --force option is on.\n\n";
214 if(!vm.count(
"force")) {
215 args.
err_log <<
"ERROR: The structure in prim.json is not right-handed. Some electronic-"
216 <<
"structure codes will not accept this input. If you would like to "
217 <<
"keep this PRIM, re-run with the --force option. Writing the "
218 <<
"right-handed structure to PRIM.right_handed.json" << std::endl;
223 fs::ofstream primfile(root /
"prim.right_handed.json");
226 json[
"description"] = prim_json[
"description"];
227 json.
print(primfile);
232 args.
err_log <<
"WARNING: The structure in the prim.json file is not right-handed. Continuing anyway \n"
233 <<
" because the --force option is on.\n\n";
238 args.
log <<
"Initializing CASM project '" << prim.
title <<
"'" << std::endl;
242 catch(std::runtime_error &e) {
243 args.
err_log <<
"ERROR: Could not build CASM project.\n";
244 args.
err_log << e.what() << std::endl;
248 args.
log <<
" DONE" << std::endl;
249 args.
log << std::endl;
Data structure holding basic CASM command info.
Specification of CASM project directory structure.
const SymGroup & point_group() const
void initialize() override
Fill in the options descriptions accordingly.
Structure specifies the lattice and atomic basis of a crystal.
bool is_primitive(double prim_tol=TOL) const
void add_help_suboption()
Add a plain –help suboption.
void write_prim(const BasicStructure< Site > &prim, fs::path filename, COORD_TYPE mode)
Write prim.json to file.
const Lattice & lattice() const
int init_command(const CommandArgs &args)
fs::path prim() const
Return prim.json path.
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
fs::path find_casmroot(const fs::path &cwd)
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.
const po::options_description & desc()
Get the program options, filled with the initialized values.
Sets up directories and files for a new CASM project.
Lattice canonical_equivalent_lattice(const Lattice &in_lat, const SymGroup &point_grp, double compare_tol)
Find the niggli, most standard oriented version of the given orbit (defined by the given SymGroup) of...
fs::path PRIM() const
Return PRIM path.
po::options_description m_desc
Boost program options. All the derived classes have them, but will fill them up themselves.
void set_lattice(const Lattice &lattice, COORD_TYPE mode)
std::string title
User-specified name of this Structure.
void build() const
Builds a new CASM project.
virtual void read(std::istream &stream)
Print intpolated images in seperate directries.
bool is_right_handed() const
Check if the lattice is right handed.
void within()
Translate all basis sites so that they are inside the unit cell.
#define ERR_MISSING_INPUT_FILE
bool almost_equal(const GenericCluster< CoordType > &LHS, const GenericCluster< CoordType > &RHS, double tol)
#define ERR_INVALID_INPUT_FILE