diff --git a/docs/_docs/analysis.md b/docs/_docs/analysis.md index 34fd0d8bb..441224776 100644 --- a/docs/_docs/analysis.md +++ b/docs/_docs/analysis.md @@ -645,7 +645,7 @@ All units in $k\_BT$. `file` | Output filename (`.dat`, `.csv`, `.dat.gz`) `nstep` | Interval between samples `nskip=0` | Number of initial steps excluded from the analysis -`save_min_conf=false` | Dump minimum energy configuration to `PQR` file +`save_min_conf=false` | Dump minimum energy configuration to a `PQR` and state file ### Penalty function diff --git a/docs/schema.yml b/docs/schema.yml index 74d2c7173..bd0bedc55 100644 --- a/docs/schema.yml +++ b/docs/schema.yml @@ -1203,7 +1203,7 @@ properties: systemenergy: properties: - file: {type: string} + file: {type: string, pattern: "(.*?)\\.(dat|dat.gz|csv)$", description: "Output filename (.dat|.dat.gz|.csv)"} nstep: {type: integer} nskip: {type: integer, default: 0, description: Initial steps to skip} save_min_conf: diff --git a/src/analysis.cpp b/src/analysis.cpp index 7807a6013..d5a67b6f7 100644 --- a/src/analysis.cpp +++ b/src/analysis.cpp @@ -245,7 +245,8 @@ void SystemEnergy::normalize() { /** * @brief Checks if the current energy is the lowest so far and saves the configuration if so. * - * The output is hardcoded to PQR format, tagged with the step number and energy. + * The output is hardcoded to PQR format, tagged with the step number and energy. In addition, + * we dump Space to a state file that can be used to restart a simulation. * * @return True if a new minimum energy was encountered */ @@ -254,9 +255,18 @@ bool SystemEnergy::updateMinimumEnergy(const double current_energy) { return false; } minimum_energy = current_energy; - const auto filename = MPI::prefix + "mininum_energy.pqr"; + + auto filename = MPI::prefix + "mininum_energy.pqr"; faunus_logger->debug("{}: saving {} ({:.2f} kT) at step {}", name, filename, minimum_energy, getNumberOfSteps()); PQRWriter(PQRWriter::Style::PQR).save(filename, spc.groups, spc.geometry.getLength()); + + filename = MPI::prefix + "mininum_energy.state"; + if (std::ofstream file(filename); file) { + faunus_logger->debug("{}: saving {} ({:.2f} kT) at step {}", name, filename, minimum_energy, getNumberOfSteps()); + json j; + Faunus::to_json(j, spc); + file << std::setw(1) << j; + } return true; }