45 formatter.
push_back(MonteCarloTFormatter<GrandCanonical>());
47 std::set<std::string> exclude;
52 formatter.
push_back(MonteCarloBetaFormatter<GrandCanonical>());
53 name =
"potential_energy";
58 name =
"formation_energy";
66 i < mc.
primclex().composition_axes().independent_compositions(); ++i) {
67 formatter.
push_back(MonteCarloParamChemPotFormatter<GrandCanonical>(mc, i));
71 i < mc.
primclex().composition_axes().independent_compositions(); i++) {
81 for (
int i = 0; i < struc_mol_name.size(); ++i) {
82 name = std::string(
"comp_n(") + struc_mol_name[i] +
")";
90 if (exclude.find(it->first) == exclude.end()) {
97 formatter.
push_back(MonteCarloHeatCapacityFormatter<GrandCanonical>());
101 i < mc.
primclex().composition_axes().independent_compositions(); i++) {
103 j < mc.
primclex().composition_axes().independent_compositions(); j++) {
107 MonteCarloSuscXFormatter<GrandCanonical>(comp_var_i, comp_var_j));
113 i < mc.
primclex().composition_axes().independent_compositions(); i++) {
116 MonteCarloThermoChemSuscXFormatter<GrandCanonical>(comp_var_i));
120 for (
int i = 0; i < struc_mol_name.size(); ++i) {
121 for (
int j = i; j < struc_mol_name.size(); ++j) {
122 auto species_i = struc_mol_name[i];
123 auto species_j = struc_mol_name[j];
125 MonteCarloSuscNFormatter<GrandCanonical>(species_i, species_j));
130 for (
int i = 0; i < struc_mol_name.size(); ++i) {
131 auto species_i = struc_mol_name[i];
133 MonteCarloThermoChemSuscNFormatter<GrandCanonical>(species_i));
162 bool print_json =
true;
165 formatter.
push_back(MonteCarloTFormatter<GrandCanonical>());
167 std::set<std::string> exclude;
172 formatter.
push_back(MonteCarloBetaFormatter<GrandCanonical>());
173 name =
"gs_potential_energy";
175 return static_cast<const GrandCanonical *
>(ptr)->potential_energy();
179 exclude.insert(
name);
183 name =
"gs_formation_energy";
189 exclude.insert(
name);
195 formatter.
push_back(MonteCarloParamChemPotFormatter<GrandCanonical>(mc, i));
200 name = std::string(
"gs_comp(") +
209 exclude.insert(
name);
214 for (
int i = 0; i < struc_mol_name.size(); ++i) {
215 name = std::string(
"gs_comp_n(") + struc_mol_name[i] +
")";
221 exclude.insert(
name);
243 for (
int i = 0; i < param_chem_pot.size(); i++) {
247 json[
"tolerance"] = conditions.
tolerance();
264 double temp = json[
"temperature"].
get<
double>();
265 double tol = json[
"tolerance"].
get<
double>();
267 int Nparam =
primclex.composition_axes().independent_compositions();
270 for (
int i = 0; i < Nparam; i++) {
280 const double &phi_LTE1) {
289 const double &phi_LTE1,
const std::string &
configname,
298 fs::path file =
dir.results_csv();
299 _log <<
"write: " <<
dir.results_csv() <<
"\n";
302 if (!fs::exists(file)) {
304 formatter.print_header(&mc, sout);
306 sout.open(file, std::ios::app);
309 formatter.print(&mc, sout);
316 fs::path file =
dir.results_json();
317 _log <<
"write: " <<
dir.results_json() <<
"\n";
320 if (fs::exists(file)) {
326 formatter.to_json_arrays(&mc, results);
330 std::cerr <<
"ERROR writing results" << std::endl;
Eigen::VectorXd param_composition(const Eigen::VectorXd &n) const
Convert number of mol per prim, 'n' to parametric composition 'x'.
static std::string comp_var(size_type i)
Composition variable names: "a", "b", ...
size_type independent_compositions() const
The dimensionality of the composition space.
double temperature() const
Eigen::VectorXd param_chem_pot() const
parametric chemical potential: dg/dcomp_x
const Eigen::VectorXd & comp_n() const
Number of atoms of each type, normalized per primitive cell.
Interface base class for all types of Monte Carlo simulations (not meant to be used polymorphically)
const PrimClex & primclex() const
const Access the PrimClex that *this is based on
const SamplerMap & samplers() const
const Access sampler map
Settings for Monte Carlo calculations.
const fs::path output_directory() const
Directory where output should go.
bool write_csv() const
Write csv versions of files? (csv is the default format if no 'output_format' given)
bool write_json() const
Write json versions of files?
PrimClex is the top-level data structure for a CASM project.
static jsonParser object()
Returns an empty json object.
bool read(std::istream &stream)
Reads json from the stream.
jsonParser & put_obj()
Puts new empty JSON object.
void write(const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
Write json to file.
double formation_energy(const Configuration &config)
Returns the formation energy, normalized per unit cell.
Eigen::VectorXd comp_n(const Configuration &config)
Returns the composition, as number of each species per unit cell.
const CompositionConverter & composition_axes() const
const Access CompositionConverter object
const PrimType & prim() const
const Access to primitive Structure
std::vector< std::string > struc_molecule_name(BasicStructure const &_struc)
Returns an Array of each possible Molecule in this Structure.
T get(Args &&... args) const
Get data from json, using one of several alternatives.
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
GenericDatumFormatter< double, ConstMonteCarloPtr > MonteCarloPrecFormatter(std::string prop_name)
Print calculated precision of property values: prec(<prop_name>)
void from_json(CanonicalConditions &conditions, const PrimClex &primclex, const jsonParser &json)
Read CanonicalConditions from JSON format.
GenericDatumFormatter< double, ConstMonteCarloPtr > MonteCarloMeanFormatter(std::string prop_name)
Print mean property values: <prop_name>
GenericDatumFormatter< size_type, ConstMonteCarloPtr > MonteCarloNAvgSamplesFormatter()
Print number of samples used in calculating means.
GenericDatumFormatter< bool, ConstMonteCarloPtr > MonteCarloIsConvergedFormatter()
Print if converged.
DataFormatter< ConstMonteCarloPtr > make_lte_results_formatter(const GrandCanonical &mc, const double &phi_LTE1, const std::string &configname)
Make a results formatter.
jsonParser & to_json(const CanonicalConditions &conditions, jsonParser &json)
Store CanonicalConditions in JSON format.
void write_lte_results(const MonteSettings &settings, const GrandCanonical &mc, const double &phi_LTE1, const std::string &configname, Log &_log)
Will create new file or append to existing results file the results of the latest run.
GenericDatumFormatter< bool, ConstMonteCarloPtr > MonteCarloIsEquilibratedFormatter()
Print if equilibrated (not counting explicitly requested equilibration)
GenericDatumFormatter< size_type, ConstMonteCarloPtr > MonteCarloNEquilSamplesFormatter()
Print number of samples used for equilibration (not counting explicitly requested equilibration)
DataFormatter< ConstMonteCarloPtr > make_results_formatter(const Canonical &mc)
Make a LTE results formatter.
GenericDatumFormatter< double, ConstMonteCarloPtr > GrandCanonicalLTEFormatter(const double &phi_LTE1)
Print single spin flip LTE.
GenericDatumFormatter< std::string, DataObject > name()
DirectoryStructure const & dir