CASM  1.1.0
A Clusters Approach to Statistical Mechanics
clex_io.cc
Go to the documentation of this file.
1 #ifndef CASM_app_clex_file_io
2 #define CASM_app_clex_file_io
3 
4 #include <boost/filesystem.hpp>
5 #include <boost/filesystem/fstream.hpp>
6 
11 #include "casm/clex/Supercell.hh"
17 
18 namespace CASM {
19 
22 void write_lat(Supercell const &supercell, DirectoryStructure const &dir) {
23  fs::create_directories(dir.configuration_dir(supercell.name()));
24  fs::ofstream outfile{dir.LAT(supercell.name())};
25  outfile << supercell.lattice().lat_column_mat() << std::endl;
26 }
27 
29 void write_pos(Configuration const &configuration,
30  DirectoryStructure const &dir) {
31  fs::create_directories(dir.configuration_dir(configuration.name()));
32  fs::ofstream outfile{dir.POS(configuration.name())};
33  print_poscar(configuration, outfile);
34 }
35 
38 void write_structure_json(Configuration const &configuration,
39  DirectoryStructure const &dir) {
40  fs::create_directories(dir.configuration_dir(configuration.name()));
41  fs::ofstream outfile{dir.structure_json(configuration.name())};
42  jsonParser json;
43  to_json(make_simple_structure(configuration), json);
44  json.print(outfile);
45 }
46 
49 void write_config_json(Configuration const &configuration,
50  DirectoryStructure const &dir) {
51  fs::create_directories(dir.configuration_dir(configuration.name()));
52  fs::ofstream outfile{dir.config_json(configuration.name())};
53  jsonParser json;
54  to_json(configuration, json);
55  json.print(outfile);
56 }
57 
58 } // namespace CASM
59 
60 #endif
std::string name() const
Definition: Named_impl.hh:14
Specification of CASM project directory structure.
fs::path LAT(std::string scelname) const
Return supercell LAT file path.
fs::path structure_json(std::string configname) const
Return path to standard structure.json file location.
fs::path config_json(std::string configname) const
Return path to standard config.json file location.
fs::path configuration_dir(std::string configname) const
Return configuration directory path.
fs::path POS(std::string configname) const
Return path to standard POS file location.
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
const Lattice & lattice() const
The super lattice.
Definition: Supercell.cc:239
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
Definition: jsonParser.cc:188
const Eigen::Matrix3d & lat_column_mat() const
3x3 matrix with lattice vectors as its columne
Definition: Lattice.hh:110
Main CASM namespace.
Definition: APICommand.hh:8
xtal::SimpleStructure make_simple_structure(Supercell const &_scel, ConfigDoF const &_dof, std::vector< DoFKey > const &_which_dofs={})
Construct from ConfigDoF _dof belonging to provided Supercell _scel.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void write_config_json(Configuration const &configuration, DirectoryStructure const &dir)
Definition: clex_io.cc:49
void write_structure_json(Configuration const &configuration, DirectoryStructure const &dir)
Definition: clex_io.cc:38
void write_pos(Configuration const &configuration, DirectoryStructure const &dir)
Write configuration "POS" file (VASP POSCAR) to standard location.
Definition: clex_io.cc:29
void write_lat(Supercell const &supercell, DirectoryStructure const &dir)
Definition: clex_io.cc:22
void print_poscar(Configuration const &configuration, std::ostream &sout)
DirectoryStructure const & dir
Definition: settings.cc:136