5#ifndef MANAGERS_IO_READCONLOADER_H_
6#define MANAGERS_IO_READCONLOADER_H_
16#include <unordered_map>
20#include "readcon-core.h"
29 gpr::AtomsConfiguration& atoms_config,
30 const gpr::InputParameters& parameters);
32 gpr::AtomsConfiguration& atoms_config,
33 const gpr::InputParameters& parameters);
36 const gpr::Coord& R_init,
const gpr::InputParameters& parameters,
37 const std::unordered_map<std::string, gpr::Index_t>& atomtypes,
38 gpr::AtomsConfiguration& atoms_config);
42template <
typename Type,
typename AtomicNr>
46 std::vector<AtomicNr> elements;
47 std::vector<Type> types(n_atoms);
48 for (std::size_t i = 0; i < n_atoms; ++i) {
50 std::find(elements.begin(), elements.end(), atomic_nrs[i]);
51 types[i] =
static_cast<Type
>(seen - elements.begin());
52 if (seen == elements.end()) elements.push_back(atomic_nrs[i]);
61 const std::array<double, 3>& cell,
const std::array<double, 3>& angles);
64 const std::array<double, 3>& angles,
78 const readcon::CFrame* product =
nullptr,
79 std::vector<int>* reactive_atoms =
nullptr);
83 std::size_t n_atoms)
noexcept
85 if (forces ==
nullptr)
return std::numeric_limits<double>::quiet_NaN();
87 for (std::size_t atom = 0; atom < n_atoms; ++atom) {
88 const double x = forces[3 * atom];
89 const double y = forces[3 * atom + 1];
90 const double z = forces[3 * atom + 2];
91 if (!std::isfinite(
x) || !std::isfinite(
y) || !std::isfinite(
z))
92 return std::numeric_limits<double>::quiet_NaN();
93 fmax = std::max(fmax, std::sqrt(
x *
x +
y *
y +
z *
z));
100 const char* symbol,
double x,
double y,
101 double z,
bool fixed, std::uint64_t atom_id,
102 double mass,
const double* force)
104 return readcon::rkr_frame_add_atom_full(builder, symbol,
x,
y,
z, fixed,
105 fixed, fixed, atom_id, mass,
112 double energy = std::numeric_limits<double>::quiet_NaN();
118 const readcon::RKRConFrame* frame,
const readcon::CFrame& parsed)
121 const auto n = parsed.num_atoms;
122 if (frame ==
nullptr || n == 0 || !parsed.has_forces)
return out;
123 out.forces.assign(3 * n, 0.0);
124 for (std::size_t atom = 0; atom < n; ++atom) {
125 const auto& site = parsed.atoms[atom];
127 out.forces[3 * atom] = site.fx;
128 out.forces[3 * atom + 1] = site.fy;
129 out.forces[3 * atom + 2] = site.fz;
131 out.energy = readcon::rkr_frame_energy(frame);
132 out.complete = std::isfinite(
out.energy) &&
141std::size_t ingestConDirectory(
const std::string& corpus_dir,
142 const std::string& tree);
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
void setCellDimensionsFromLengthsAndAngles(const std::array< double, 3 > &cell, const std::array< double, 3 > &angles, gpr::InputParameters ¶meters)
void loadEnvironmentAtomTypes(std::istream &input, gpr::AtomsConfiguration &atoms_config, const gpr::InputParameters ¶meters)
void loadAtomsConfigurationFromFrame(const readcon::CFrame &frame, gpr::AtomsConfiguration &atoms_config, gpr::Coord &R_init, gpr::InputParameters ¶meters, const readcon::CFrame *product, std::vector< int > *reactive_atoms)
FrameEnergyForces frameEnergyForces(const readcon::RKRConFrame *frame, const readcon::CFrame &parsed)
int addAtomWithOptionalForce(readcon::RKRConFrameBuilder *builder, const char *symbol, double x, double y, double z, bool fixed, std::uint64_t atom_id, double mass, const double *force)
Add one atom. force is three doubles, or null when the atom has none.
std::array< double, 9 > cellMatrixFromLengthsAndAngles(const std::array< double, 3 > &cell, const std::array< double, 3 > &angles)
double maxAtomicForce(const double *forces, std::size_t n_atoms) noexcept
Largest atomic force norm. NaN when any component is non-finite.
std::vector< Type > elementAtomTypes(const AtomicNr *atomic_nrs, std::size_t n_atoms)
void initializeAtomsConfiguration(const gpr::Coord &R_init, const gpr::InputParameters ¶meters, const std::unordered_map< std::string, gpr::Index_t > &atomtypes, gpr::AtomsConfiguration &atoms_config)
Stores configurations of all atoms in the system.
std::vector< double > forces