48 frac.array() -= (frac.array() + 0.5).floor();
57 for (
int i = 0; i < frac.rows(); i++) {
58 for (
int j = 0; j < 3; j++) {
59 frac(i, j) = std::fmod(frac(i, j) + 1.0, 1.0);
70 return apply(coords, cell, cellInverse);
78 apply(AtomMatrix::Map(diffVector.data(), diffVector.size() / 3, 3), cell,
80 return VectorXd(VectorXd::Map(pbcMatrix.data(), diffVector.size()));
103 structComp{params.structure_comparison_options},
111 masses{Eigen::VectorXd::Zero(0)},
126 bool compare(
const Matter &matter,
bool indistinguishable =
false);
142 long int atom,
int axis,
145 long int atom,
int axis,
147 bool relax(
bool quiet =
false,
bool writeMovie =
false,
148 bool checkpoint =
false, std::string prefixMovie = std::string(),
149 std::string prefixCheckpoint = std::string(),
150 bool retainMovieFrames =
false);
154 [[nodiscard]]
const std::vector<readcon::ConFrame> &
movieFrames()
const {
166 VectorXd
pbcV(
const VectorXd &diff)
const {
206 double getMass(
long int atom)
const;
207 void setMass(
long int atom,
double mass);
208 void setMasses(
const VectorXd &massesIn);
210 long int atom)
const;
220 int getFixed(
long int atom,
int axis)
const;
222 [[nodiscard]] std::array<bool, 3>
getFixedMask(
long int atom)
const;
227 void setFixedMask(
long int atom, std::array<bool, 3> mask);
244 double distance(
long index1,
long index2)
246 double pdistance(
long index1,
long index2,
int axis)
const;
289 bool append =
false) {
295 Eigen::Matrix<double, Eigen::Dynamic, 1>
getMasses()
const;
341 std::shared_ptr<Potential>
375 Eigen::Matrix<std::int64_t, Eigen::Dynamic, 1>
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, eOnStorageOrder > MatrixXd
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Functionality relying on the conjugate gradients algorithm.
io::IoStatus writeTibble(std::string filename)
Parameters::structure_comparison_options_t structComp
double getPotentialEnergy() const
bool getWriteConForces() const noexcept
Parameters.main_options.writeConForces for this Matter, if bound.
VectorXd getFreeV() const
long int numberOfFixedAtoms() const
void setComputedPotential(double energy, double variance)
Set energy/variance from external batched evaluation and mark forces as up-to-date (recomputePotentia...
void setForces(const AtomMatrix &f)
Eigen::Matrix< std::int64_t, Eigen::Dynamic, 1 > atomIndex
void setPositionsFreeV(const VectorXd &pos)
io::IoStatus convel2matter(std::string filename)
PbcConvention pbcConvention
void setAtomicNrs(const VectorXi &atmnrs)
VectorXd getPositionsV() const
std::vector< readcon::ConFrame > movie_frames_
long getForceCalls() const
void setMasses(const VectorXd &massesIn)
void setHeaderConLine(size_t i, std::string line)
void setPosition(long int atom, int axis, double position)
io::IoStatus matter2convel(std::string filename)
void computePotential() const
std::vector< int > freeIndices
double distance(long index1, long index2) const
AtomMatrix getFree() const
bool getPeriodic() const noexcept
void setBiasPotential(BondBoost *bondBoost)
const AtomMatrix & getForces() const
double maxForce(void) const
void setPbcConvention(PbcConvention convention)
bool recomputeMaskedForces
void setPeriodic(bool periodic)
void setVelocities(const AtomMatrix &v)
VectorXi getAtomicNrs() const
void applyPeriodicBoundaryIfEnabled()
Apply MIC wrap when periodic boundaries are enabled (I/O path).
const Parameters * parameters
void setBiasForces(const AtomMatrix &bf)
AtomMatrix pbc(const AtomMatrix &diff) const
VectorXd getForcesV() const
std::shared_ptr< Potential > potential
double getEnergyVariance() const
AtomMatrix getPositionsCopy() const
BondBoost * biasPotential
long int numberOfAtoms() const
void setAtomIndex(long int atom, std::int64_t index)
Eigen::Matrix< double, Eigen::Dynamic, 1 > getMasses() const
PbcConvention getPbcConvention() const
AtomMatrix getPositionsFree() const
std::shared_ptr< Potential > getPotential()
VectorXd pbcV(const VectorXd &diff) const
void setPositionsFree(const AtomMatrix &pos)
double getPosition(long int atom, int axis) const
void applyPeriodicBoundary(double &component, int axis)
void resize(long int nAtoms)
void applyPeriodicBoundary()
const std::vector< readcon::ConFrame > & movieFrames() const
In-memory minimization movie (same stamps as writeMovie CON).
const AtomMatrix & getForcesRaw() const
void setMass(long int atom, double mass)
io::IoStatus con2matter(const readcon::ConFrame &frame, io::ConFrameMetadata *out_metadata=nullptr)
void setPositionsV(const VectorXd &pos)
void setCell(const Matrix3d &newCell)
bool relax(bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), bool retainMovieFrames=false)
double * forcesData()
Mutable access to force storage for batched potential evaluation.
bool needsForceUpdate() const
Whether forces need recomputation (positions changed since last eval).
std::array< std::string, 5 > headerCon
void assertIsolatedMoleculeLayoutSafe() const
Throw if pot forbids PBC (isolated molecular QM backends, issue #188).
void setHeaderCon(const std::array< std::string, 5 > &headers)
bool usePeriodicBoundaries
std::array< bool, 3 > getFixedMask(long int atom) const
Per-axis CON column-4 mask (bit0=x, bit1=y, bit2=z).
VectorXd getForcesFreeV() const
Matter(std::shared_ptr< Potential > pot, const Parameters ¶ms)
VectorXd getPositionsFreeV() const
VectorXi getAtomicNrsFree() const
double getMechanicalEnergy() const
const Matter & operator=(const Matter &matter)
io::IoStatus matter2xyz(std::string filename, bool append=false)
long int numberOfFreeAtoms() const
const std::array< std::string, 5 > & getHeaderCon() const
CON header lines (indices 0..4); public for I/O / bindings.
std::int64_t getAtomIndex(long int atom) const
.con column-5 index (pre-grouping); public for I/O / bindings.
bool compare(const Matter &matter, bool indistinguishable=false)
void setFixed(long int atom, int isFixed)
Broadcast a whole-atom flag onto all three axes.
long getAtomicNr(long int atom) const
void setFixedMask(long int atom, std::array< bool, 3 > mask)
AtomMatrix getVelocities() const
double perAtomNorm(const Matter &matter)
AtomMatrix getForcesFree() const
void setPositions(const AtomMatrix &pos)
io::IoStatus matter2con(std::string filename, bool append=false, const io::ConFrameMetadata *metadata=nullptr)
double getKineticEnergy() const
double getMass(long int atom) const
double distanceTo(const Matter &matter)
size_t getPotentialCalls() const
void setVelocity(long int atom, int axis, double velocity)
io::IoStatus con2matter(std::string filename)
std::vector< readcon::ConFrame > takeMovieFrames()
Take ownership of retained frames (leaves storage empty).
const AtomMatrix & getPositions() const
AtomMatrix getAccelerations()
void applyPeriodicBoundary(AtomMatrix &diff)
AtomMatrix getBiasForces()
double pdistance(long index1, long index2, int axis) const
void setAtomicNr(long int atom, long atomicNr)
void setPotential(std::shared_ptr< Potential > pot)
int getFixed(long int atom) const
1 if every Cartesian axis of the atom is fixed, else 0.
IoStatus convel2matter(Matter &m, std::string filename)
IoStatus matter2convel(Matter &m, std::string filename)
IoStatus matter2con(Matter &m, std::string filename, bool append, const ConFrameMetadata *metadata)
Append a frame to a .con, or truncate and write one frame.
IoStatus con2matter(Matter &m, std::string filename)
IoStatus matter2xyz(Matter &m, std::string filename, bool append)
Write one extended-XYZ frame: Lattice= cell and 17-digit coordinates.
IoStatus
Structured I/O result for the client surface (nanobind-friendly).
IoStatus writeTibble(Matter &m, std::string fname)
Debug table (positions, optional cached forces). Not a structure format.
AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
AtomMatrix applyLegacy(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse)
AtomMatrix applyPositions(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse, PbcConvention convention)
VectorXd applyV(const VectorXd &diffVector, const Matrix3d &cell, const Matrix3d &cellInverse)
RAII resource manager for the ARTn C library with global synchronization.
RAII helper for class-scoped logging.