19 if (json.find(
"chemical_reference") == json.end()) {
20 throw std::runtime_error(
21 "Error reading chemical reference states: Expected "
22 "\"chemical_reference\" entry");
26 err_log() <<
"Error reading chemical reference states from " << filename
40 outfile.
open(filename);
43 to_json(chem_ref, json[
"chemical_reference"]);
Write to a temporary file to ensure a good write, then rename.
void close()
Closes stream, and if not a failed write, removes "file" and renames "file.tmp" to "file".
void open(fs::path name, std::string tmp_ext="tmp")
Opens "file.tmp" for writing, with intended final target "file".
fs::ofstream & ofstream()
Access underlying stream.
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
BasicStructure specifies the lattice and atomic basis of a crystal.
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
void write_chemical_reference(const ChemicalReference &chem_ref, fs::path filename)
Write chemical reference states to JSON file.
ChemicalReference read_chemical_reference(fs::path filename, const xtal::BasicStructure &prim, double tol)
Read chemical reference states from JSON file.