48 static_cast<void>(cellInverse);
80 apply(AtomMatrix::Map(diffVector.data(), diffVector.size() / 3, 3), cell,
82 return VectorXd(VectorXd::Map(pbcMatrix.data(), diffVector.size()));
110 bool compare(
const Matter &matter,
bool indistinguishable =
false);
126 long int atom,
int axis,
129 long int atom,
int axis,
131 bool relax(
bool quiet =
false,
bool writeMovie =
false,
132 bool checkpoint =
false, std::string prefixMovie = std::string(),
133 std::string prefixCheckpoint = std::string(),
134 bool retainMovieFrames =
false);
138 [[nodiscard]]
const std::vector<readcon::ConFrame> &
movieFrames()
const {
148 VectorXd
pbcV(
const VectorXd &diff)
const;
191 double getMass(
long int atom)
const;
192 void setMass(
long int atom,
double mass);
193 void setMasses(
const VectorXd &massesIn);
195 long int atom)
const;
205 int getFixed(
long int atom,
int axis)
const;
207 [[nodiscard]] std::array<bool, 3>
getFixedMask(
long int atom)
const;
209 void setFixed(
long int atom,
int isFixed);
211 void setFixed(
long int atom,
int axis,
int isFixed);
212 void setFixedMask(
long int atom, std::array<bool, 3> mask);
248 double distance(
long index1,
long index2)
250 double pdistance(
long index1,
long index2,
int axis)
const;
301 bool append =
false) {
307 Eigen::Matrix<double, Eigen::Dynamic, 1>
getMasses()
const;
312 [[nodiscard]] std::int64_t
getAtomIndex(
long int atom)
const;
319 if (file_row < 0 || file_row >=
nAtoms ||
368 mutable std::shared_ptr<Potential>
436 bool threads =
false, std::span<const long> owners = {});
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Functionality relying on the conjugate gradients algorithm.
Shared flag. Copies observe the same request.
void pollCancel(const char *site) const
void applyPeriodicBoundary()
void setBiasPotential(BondBoost *bondBoost)
double getKineticEnergy() const
io::IoStatus writeTibble(std::string filename)
bool getWriteConForces() const noexcept
Parameters.main_options().writeConForces for this Matter.
VectorXi getAtomicNrs() const
void setComputedPotential(double energy, double variance)
Set energy/variance from external batched evaluation and mark forces as up-to-date (recomputePotentia...
io::IoStatus convel2matter(std::string filename)
void setForces(const AtomMatrix &f)
void setFixed(long int atom, int isFixed)
Broadcast a whole-atom flag onto all three axes.
std::shared_ptr< Potential > getPotential()
BondBoost * getBiasPotential() const
The bias potential added to this Matter's forces, or nullptr.
double maxFreeAtomForce(const AtomMatrix &rows) const
Max per-atom Euclidean norm of rows.
void setFixedMask(long int atom, std::array< bool, 3 > mask)
void setPosition(long int atom, int axis, double position)
PbcConvention pbcConvention
const AtomMatrix & getPositions() const
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 distanceTo(const Matter &matter)
VectorXd getForcesFreeV() const
void setPositions(const AtomMatrix &pos)
void setAtomicNr(long int atom, long atomicNr)
double pdistance(long index1, long index2, int axis) const
unsigned long long getSurfaceEpoch() const noexcept
AtomMatrix getForcesFree() const
const Matter & operator=(const Matter &matter)
std::vector< readcon::ConFrame > movie_frames_
bool compare(const Matter &matter, bool indistinguishable=false)
void setHeaderConLine(size_t i, std::string line)
io::IoStatus matter2convel(std::string filename)
void setPositionsV(const VectorXd &pos)
void setCell(const Matrix3d &newCell)
std::vector< int > freeIndices
AtomMatrix getFree() const
bool getPeriodic() const noexcept
void setVelocity(long int atom, int axis, double velocity)
void computePotential() const
void setPbcConvention(PbcConvention convention)
void setPotential(std::shared_ptr< Potential > pot)
void setPositionsFreeV(const VectorXd &pos)
bool recomputeMaskedForces
void setPeriodic(bool periodic)
void applyPeriodicBoundaryIfEnabled()
Apply MIC wrap when periodic boundaries are enabled (I/O path).
std::unique_ptr< Potential > ownedPotential
const Parameters * parameters
const CancelToken & cancelToken() const
long int numberOfAtoms() const
Matrix3d cauchyStress()
Cauchy stress in eV/Angstrom^3.
std::shared_ptr< Potential > potential
long getForceCalls() const
VectorXd getPositionsFreeV() const
BondBoost * biasPotential
void setAtomicNrs(const VectorXi &atmnrs)
AtomMatrix getVelocities() const
void setVelocities(const AtomMatrix &v)
double getMechanicalEnergy() const
void setAtomIndex(long int atom, std::int64_t index)
PbcConvention getPbcConvention() const
double perAtomNorm(const Matter &matter)
const AtomMatrix & getForcesRaw() const
io::IoStatus inp2matter(const std::string &filename)
Any structure file: .con/.convel via readcon, the rest via chemfiles.
void resize(long int nAtoms)
VectorXd pbcV(const VectorXd &diff) const
AtomMatrix getPositionsFree() const
double getPosition(long int atom, int axis) const
void applyPeriodicBoundary(double &component, int axis)
size_t getPotentialCalls() const
unsigned long long cachedHostEpoch_
std::shared_ptr< bool > writeConForces_
VectorXi getAtomicNrsFree() const
const std::vector< readcon::ConFrame > & movieFrames() const
In-memory minimization movie (same stamps as writeMovie CON).
void restoreFileForces(const AtomMatrix &fileForces, bool trustEnergy, double energy)
Write .con forces without the fixed-atom mask setForces applies.
Eigen::Matrix< double, Eigen::Dynamic, 1 > getMasses() const
long int numberOfFixedAtoms() const
std::unique_ptr< Impl > impl_
unsigned long long cachedPotEpoch_
double distance(long index1, long index2) const
double getMass(long int atom) const
unsigned long long surfaceEpoch_
void setMasses(const VectorXd &massesIn)
void setMass(long int atom, double mass)
io::IoStatus con2matter(const readcon::ConFrame &frame, io::ConFrameMetadata *out_metadata=nullptr)
double getPotentialEnergy() const
AtomMatrix getAccelerations()
void stampSurfaceEpoch() const
double * forcesData()
Mutable access to force storage for batched potential evaluation.
bool needsForceUpdate() const
Whether forces need recomputation (positions or surface epoch changed).
AtomMatrix getBiasForces()
long mapFileRow(long file_row) const
Map a CON file-order row onto the Matter row after matter_order.
std::array< std::string, 5 > headerCon
void setHeaderCon(const std::array< std::string, 5 > &headers)
bool holdsExclusivePotential() const
True while no copy has shared the Potential from an exclusive handoff.
StructureComparisonOptions structComp
bool usePeriodicBoundaries
long int numberOfFreeAtoms() const
VectorXd getFreeV() const
Matter(std::shared_ptr< Potential > pot, const Parameters ¶ms)
CancelToken cancel_token_
long getAtomicNr(long int atom) const
double getEnergyVariance() const
AtomMatrix getPositionsCopy() const
void shareOwnedPotential() const
void setCancelToken(CancelToken token)
std::array< bool, 3 > getFixedMask(long int atom) const
Per-axis CON column-4 mask (bit0=x, bit1=y, bit2=z).
io::IoStatus matter2xyz(std::string filename, bool append=false)
void setBiasForces(const AtomMatrix &bf)
void setPositionsFree(const AtomMatrix &pos)
std::vector< long > fileToMatter
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.
void assertIsolatedMoleculeLayoutSafe() const
Throw if pot forbids PBC (isolated molecular QM backends, issue #188).
VectorXd getPositionsV() const
void assignKeepingBias(const Matter &other)
Copy another structure in and keep this Matter's own bias potential.
const AtomMatrix & getForces() const
void setFileToMatter(std::vector< long > map)
io::IoStatus matter2con(std::string filename, bool append=false, const io::ConFrameMetadata *metadata=nullptr)
void setEvaluation(const AtomMatrix &forces, double energy)
Puts a known evaluation back after a position reset: the forces and energy of a geometry this object ...
int getFixed(long int atom) const
1 if every Cartesian axis of the atom is fixed, else 0.
Potential * livePotential() const
io::IoStatus con2matter(std::string filename)
void setSurfaceEpoch(unsigned long long epoch)
Host surface generation.
std::vector< readcon::ConFrame > takeMovieFrames()
Take ownership of retained frames (leaves storage empty).
VectorXd getForcesV() const
void applyPeriodicBoundary(AtomMatrix &diff)
void captureStress() const
double maxForce(void) const
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 inp2matter(Matter &m, const std::string &filename)
Input entry point: .con/.convel (and .gz/.zst) go to readcon, everything else goes to chemfiles.
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.
void closestDisplacements(double *data, size_t coordinates, const double *rowMajorCell)
void wrapMinimumImage(double *data, size_t n)
AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
void wrapLegacyUnit(double *data, size_t n)
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.
void evaluateTogether(Potential &pot, std::span< Matter *const > systems, bool threads, std::span< const long > owners)
Evaluates every system that needs a force update.
bool canComputeConcurrently(std::span< Matter *const > systems)
True when the systems can compute on separate threads at once: every potential instance that two of t...
Options for Matter::compare / distance.
RAII helper for class-scoped logging.