Loading...
Searching...
No Matches
Matter.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13#include "CancelToken.h"
14#include "ConFileIO.h"
15#include "ChemfilesIO.h"
16#include "Eigen.h"
17#include "EonLogger.h"
18#include "PbcSimd.h"
19#include "Potential.h"
21#include "SurrogatePotential.h"
22#include <array>
23#include <cstdint>
24#include <memory>
25#include <span>
26#include <string>
27#include <utility>
28#include <vector>
29
30// This is a forward declaration of BondBoost to avoid a circular dependency.
31namespace eonc {
32class BondBoost;
33class Parameters;
34
35// Absolute positions use either fractional [0,1) or centered [-0.5,0.5)
36// representatives. Euclidean closest-image differences are independent of
37// this position convention.
38enum class PbcConvention {
39 Legacy = 0,
41};
42
43namespace pbc {
44
45// Euclidean closest image of each Cartesian difference.
46inline AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell,
47 const Matrix3d &cellInverse) {
48 static_cast<void>(cellInverse);
49 AtomMatrix image = diff;
50 closestDisplacements(image.data(), static_cast<size_t>(image.size()),
51 cell.data());
52 return image;
53}
54
55// Legacy position wrap: fractional coords into [0, 1) via fmod (historical
56// Matter).
57inline AtomMatrix applyLegacy(const AtomMatrix &coords, const Matrix3d &cell,
58 const Matrix3d &cellInverse) {
59 AtomMatrix frac = coords * cellInverse;
60 // Same values as fmod(x + 1, 1): (x + 1) - trunc(x + 1).
61 wrapLegacyUnit(frac.data(), static_cast<size_t>(frac.size()));
62 return frac * cell;
63}
64
65// Position wrap selecting convention (Legacy vs MinimumImage centering).
66inline AtomMatrix applyPositions(const AtomMatrix &coords, const Matrix3d &cell,
67 const Matrix3d &cellInverse,
68 PbcConvention convention) {
69 if (convention == PbcConvention::MinimumImage) {
70 AtomMatrix frac = coords * cellInverse;
71 wrapMinimumImage(frac.data(), static_cast<size_t>(frac.size()));
72 return frac * cell;
73 }
74 return applyLegacy(coords, cell, cellInverse);
75}
76
77inline VectorXd applyV(const VectorXd &diffVector, const Matrix3d &cell,
78 const Matrix3d &cellInverse) {
79 AtomMatrix pbcMatrix =
80 apply(AtomMatrix::Map(diffVector.data(), diffVector.size() / 3, 3), cell,
81 cellInverse);
82 return VectorXd(VectorXd::Map(pbcMatrix.data(), diffVector.size()));
83}
84
85} // namespace pbc
86
87/* Data describing an atomic structure. This class has been devised to handle
88 * information about an atomic structure such as positions, velocities, masses,
89 * etc. It also allow to associate a forcefield for the structure through a
90 * pointer to function (potential()). The class can read and save data to a .con
91 * file (atom2con() and con2atom()). It can also save to a .xyz file
92 * (atom2xyz()).*/
93
94class Matter {
95public:
97 Matter(std::shared_ptr<Potential> pot, const Parameters &params);
100 Matter(std::unique_ptr<Potential> pot, const Parameters &params);
102 [[nodiscard]] bool holdsExclusivePotential() const;
103 Matter(const Matter &matter); // create a copy of matter
104 const Matter &operator=(const Matter &matter); // copy the matter object
108 Matter(Matter &&other) noexcept;
109 Matter &operator=(Matter &&other) noexcept;
110 bool compare(const Matter &matter, bool indistinguishable = false);
111
112 double
113 distanceTo(const Matter &matter); // the distance to the given matter object
114 double perAtomNorm(const Matter &matter); // the maximum distance between two
115 // atoms in the Matter objects
116 void
117 setPotential(std::shared_ptr<Potential> pot); // set potential function to use
118 std::shared_ptr<Potential> getPotential(); // get potential function to use
119 void resize(long int nAtoms); // set or reset the number of atoms
120 long int numberOfAtoms() const; // return the number of atoms
121 Matrix3d getCell() const;
122 void setCell(const Matrix3d &newCell);
123 double getPosition(long int atom, int axis)
124 const; // return the position of an atom along one of the axis
125 void setPosition(
126 long int atom, int axis,
127 double position); // set the position of atom along axis to position
128 void setVelocity(
129 long int atom, int axis,
130 double velocity); // set the velocity of atom along axis to velocity
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);
135
138 [[nodiscard]] const std::vector<readcon::ConFrame> &movieFrames() const {
139 return movie_frames_;
140 }
141 void clearMovieFrames() { movie_frames_.clear(); }
143 [[nodiscard]] std::vector<readcon::ConFrame> takeMovieFrames() {
144 return std::move(movie_frames_);
145 }
146
147 AtomMatrix pbc(const AtomMatrix &diff) const;
148 VectorXd pbcV(const VectorXd &diff) const;
149
150 size_t getPotentialCalls() const;
151 const AtomMatrix &getPositions() const; // return coordinates of atoms
152 AtomMatrix getPositionsCopy() const; // return a modifiable copy
153 VectorXd getPositionsV() const;
155 getPositionsFree() const; // return coordinates of free atoms in array pos
156 VectorXd getPositionsFreeV() const;
157 void
158 setPositions(const AtomMatrix &pos); // update Matter with the new positions
159 // of the free atoms given in array pos
160 void setPositionsV(const VectorXd &pos);
161 void setPositionsFree(
162 const AtomMatrix &pos); // update Matter with the new positions of the
163 // free atoms given in array pos
164 void setPositionsFreeV(const VectorXd &pos);
165
167 void setVelocities(const AtomMatrix &v);
168 void setBiasForces(const AtomMatrix &bf);
169 void setBiasPotential(BondBoost *bondBoost);
174 void assignKeepingBias(const Matter &other);
175 void setForces(const AtomMatrix &f);
177
178 const AtomMatrix &getForces() const;
179 const AtomMatrix &getForcesRaw() const;
181 VectorXd getForcesV() const;
182 // Const so callers can read free-atom forces without mutating Matter (#171).
184 VectorXd getForcesFreeV() const;
185
188 pbcConvention = convention;
189 }
190
191 double getMass(long int atom) const; // return the mass of the atom specified
192 void setMass(long int atom, double mass); // set the mass of an atom
193 void setMasses(const VectorXd &massesIn); // set the mass of an atom
194 long getAtomicNr(
195 long int atom) const; // return the atomic number of the atom specified
196 void setAtomicNr(long int atom,
197 long atomicNr); // set the atomic number of an atom
198 VectorXi getAtomicNrs() const; // Get the vector of atomic numbers
199 VectorXi getAtomicNrsFree() const; // Get the vector of atomic numbers
200 void setAtomicNrs(const VectorXi &atmnrs); // set the vector of atomic numbers
201
203 int getFixed(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);
213 double getEnergyVariance() const;
214 double getPotentialEnergy() const;
218
220 [[nodiscard]] bool needsForceUpdate() const {
221 return recomputePotential || epochDirty();
222 }
223
227 void setSurfaceEpoch(unsigned long long epoch);
228 [[nodiscard]] unsigned long long getSurfaceEpoch() const noexcept {
229 return surfaceEpoch_;
230 }
231
234 double *forcesData();
238 void setEvaluation(const AtomMatrix &forces, double energy) {
239 restoreFileForces(forces, true, energy);
240 }
241
244 void setComputedPotential(double energy, double variance);
245 double getKineticEnergy() const;
246 double getMechanicalEnergy() const;
247
248 double distance(long index1, long index2)
249 const; // return the distance between two atoms in same configuration
250 double pdistance(long index1, long index2, int axis) const;
251 double distance(const Matter &matter, long index)
252 const; // the distance between the same atom in two cofigurations
253
254 long int
255 numberOfFreeAtoms() const; // return the number of free (or movable) atoms
256 long int numberOfFixedAtoms() const; // return the number of fixed atoms
257
258 long
259 getForceCalls() const; // return how many force calls that have been performed
260 void resetForceCalls(); // zeroing the value of force calls
261
262 double maxForce(void) const;
263
266 [[nodiscard]] double maxFreeAtomForce(const AtomMatrix &rows) const;
267
271 [[nodiscard]] bool getWriteConForces() const noexcept;
272
273 // I/O delegates to eonc::io free functions (IoStatus for bindings).
274 [[nodiscard]] io::IoStatus writeTibble(std::string filename) {
275 return io::writeTibble(*this, filename);
276 }
277
278 [[nodiscard]] io::IoStatus inp2matter(const std::string &filename) {
279 return io::inp2matter(*this, filename);
280 }
281 [[nodiscard]] io::IoStatus con2matter(std::string filename) {
282 return io::con2matter(*this, filename);
283 }
284 [[nodiscard]] io::IoStatus
285 con2matter(const readcon::ConFrame &frame,
286 io::ConFrameMetadata *out_metadata = nullptr) {
287 return io::con2matter(*this, frame, out_metadata);
288 }
289 [[nodiscard]] io::IoStatus convel2matter(std::string filename) {
290 return io::convel2matter(*this, filename);
291 }
292 [[nodiscard]] io::IoStatus
293 matter2con(std::string filename, bool append = false,
294 const io::ConFrameMetadata *metadata = nullptr) {
295 return io::matter2con(*this, filename, append, metadata);
296 }
297 [[nodiscard]] io::IoStatus matter2convel(std::string filename) {
298 return io::matter2convel(*this, filename);
299 }
300 [[nodiscard]] io::IoStatus matter2xyz(std::string filename,
301 bool append = false) {
302 return io::matter2xyz(*this, filename, append);
303 }
304
305 AtomMatrix getFree() const;
306 VectorXd getFreeV() const;
307 Eigen::Matrix<double, Eigen::Dynamic, 1> getMasses() const;
308
312 [[nodiscard]] std::int64_t getAtomIndex(long int atom) const;
313 void setAtomIndex(long int atom, std::int64_t index);
314
318 [[nodiscard]] long mapFileRow(long file_row) const {
319 if (file_row < 0 || file_row >= nAtoms ||
320 fileToMatter.size() != static_cast<size_t>(nAtoms)) {
321 return file_row;
322 }
323 return fileToMatter[static_cast<size_t>(file_row)];
324 }
325 void setFileToMatter(std::vector<long> map) { fileToMatter = std::move(map); }
326
328 [[nodiscard]] const std::array<std::string, 5> &getHeaderCon() const {
329 return headerCon;
330 }
331 void setHeaderCon(const std::array<std::string, 5> &headers) {
332 headerCon = headers;
333 }
334 void setHeaderConLine(size_t i, std::string line) {
335 headerCon.at(i) = std::move(line);
336 }
337
338 [[nodiscard]] bool getPeriodic() const noexcept {
340 }
341 void setPeriodic(bool periodic) {
342 usePeriodicBoundaries = periodic;
343 recomputePotential = true;
345 }
346
347 void setCancelToken(CancelToken token) { cancel_token_ = std::move(token); }
348 [[nodiscard]] const CancelToken &cancelToken() const { return cancel_token_; }
349 void pollCancel(const char *site) const { cancel_token_.poll(site); }
356
357private:
358 // Friend declarations for eonc::io free functions that need private access
359 // con2matter still needs private headerCon + recompute flags for faithful
360 // force/energy restore without an extra potential evaluation.
361 friend io::IoStatus io::con2matter(Matter &, const readcon::ConFrame &,
363
365 Potential *livePotential() const;
366 void shareOwnedPotential() const;
367 mutable std::unique_ptr<Potential> ownedPotential;
368 mutable std::shared_ptr<Potential>
369 potential; // shared once a second Matter needs the same instance
370 bool usePeriodicBoundaries; // boolean telling periodic boundaries are used
371
374 PbcConvention pbcConvention; // position-wrap MIC convention (issue #176)
375 mutable bool recomputePotential; // boolean indicating if the potential energy
376 // and forces need to be recalculated
377 mutable long
378 forceCalls; // keep track of how many force calls have been performed
379
380 // CON file header lines (indices 0-4 map to old headerCon1,2,4,5,6)
381 std::array<std::string, 5> headerCon;
382
383 [[nodiscard]] bool epochDirty() const;
384 void stampSurfaceEpoch() const;
385 void computePotential() const;
386 void captureStress() const;
388 void applyPeriodicBoundary(double &component, int axis);
390
391 // Narrowed from Parameters: only fields Matter actually reads
392 bool removeNetForce{true};
394 // Same cell as Parameters::main_options().writeConForces. relax() and
395 // captureStress() still borrow `parameters`; a write does not.
396 std::shared_ptr<bool> writeConForces_;
397 // Full Parameters pointer retained for relax() and the parallel flag.
398 const Parameters *parameters{nullptr};
399 long nAtoms;
402 struct Impl;
403 std::unique_ptr<Impl> impl_;
405 std::vector<long> fileToMatter; // CON file row -> Matter row
407 void restoreFileForces(const AtomMatrix &fileForces, bool trustEnergy,
408 double energy);
409 mutable std::vector<int> freeIndices; // cached indices of free atoms
410 mutable bool recomputeFreeMask{true};
411 mutable bool recomputeMaskedForces{true};
412 mutable double energyVariance;
413 std::vector<readcon::ConFrame> movie_frames_;
414 mutable double potentialEnergy;
415 unsigned long long surfaceEpoch_{0};
416 mutable unsigned long long cachedHostEpoch_{0};
417 mutable unsigned long long cachedPotEpoch_{0};
419};
420
435void evaluateTogether(Potential &pot, std::span<Matter *const> systems,
436 bool threads = false, std::span<const long> owners = {});
437
440[[nodiscard]] bool canComputeConcurrently(std::span<Matter *const> systems);
441
442} // namespace eonc
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Definition Eigen.h:35
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
Functionality relying on the conjugate gradients algorithm.
Definition BondBoost.h:25
Shared flag. Copies observe the same request.
Definition CancelToken.h:30
double potentialEnergy
Definition Matter.h:414
void pollCancel(const char *site) const
Definition Matter.h:349
void applyPeriodicBoundary()
Definition Matter.cpp:761
void setBiasPotential(BondBoost *bondBoost)
Definition Matter.cpp:464
double getKineticEnergy() const
Definition Matter.cpp:632
io::IoStatus writeTibble(std::string filename)
Definition Matter.h:274
void resetForceCalls()
Definition Matter.cpp:659
bool getWriteConForces() const noexcept
Parameters.main_options().writeConForces for this Matter.
Definition Matter.cpp:117
VectorXi getAtomicNrs() const
Definition Matter.cpp:786
bool recomputeFreeMask
Definition Matter.h:410
void setComputedPotential(double energy, double variance)
Set energy/variance from external batched evaluation and mark forces as up-to-date (recomputePotentia...
Definition Matter.cpp:869
io::IoStatus convel2matter(std::string filename)
Definition Matter.h:289
void setForces(const AtomMatrix &f)
Definition Matter.cpp:827
void setFixed(long int atom, int isFixed)
Broadcast a whole-atom flag onto all three axes.
Definition Matter.cpp:597
std::shared_ptr< Potential > getPotential()
Definition Matter.cpp:938
BondBoost * getBiasPotential() const
The bias potential added to this Matter's forces, or nullptr.
Definition Matter.cpp:468
double maxFreeAtomForce(const AtomMatrix &rows) const
Max per-atom Euclidean norm of rows.
Definition Matter.cpp:772
void setFixedMask(long int atom, std::array< bool, 3 > mask)
Definition Matter.cpp:615
void setPosition(long int atom, int axis, double position)
Definition Matter.cpp:360
PbcConvention pbcConvention
Definition Matter.h:374
const AtomMatrix & getPositions() const
Definition Matter.cpp:378
bool relax(bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), bool retainMovieFrames=false)
Definition Matter.cpp:404
double distanceTo(const Matter &matter)
Definition Matter.cpp:276
VectorXd getForcesFreeV() const
Definition Matter.cpp:512
void setPositions(const AtomMatrix &pos)
Definition Matter.cpp:420
void setAtomicNr(long int atom, long atomicNr)
Definition Matter.cpp:569
double pdistance(long index1, long index2, int axis) const
Definition Matter.cpp:527
unsigned long long getSurfaceEpoch() const noexcept
Definition Matter.h:228
AtomMatrix getForcesFree() const
Definition Matter.cpp:502
const Matter & operator=(const Matter &matter)
Definition Matter.cpp:139
std::vector< readcon::ConFrame > movie_frames_
Definition Matter.h:413
eonc::log::Scoped m_log
Definition Matter.h:364
bool compare(const Matter &matter, bool indistinguishable=false)
Definition Matter.cpp:254
void setHeaderConLine(size_t i, std::string line)
Definition Matter.h:334
io::IoStatus matter2convel(std::string filename)
Definition Matter.h:297
void setPositionsV(const VectorXd &pos)
Definition Matter.cpp:433
void setCell(const Matrix3d &newCell)
Definition Matter.cpp:347
std::vector< int > freeIndices
Definition Matter.h:409
AtomMatrix getFree() const
Definition Matter.cpp:799
bool getPeriodic() const noexcept
Definition Matter.h:338
void setVelocity(long int atom, int axis, double velocity)
Definition Matter.cpp:371
void computePotential() const
Definition Matter.cpp:695
void setPbcConvention(PbcConvention convention)
Definition Matter.h:187
void setPotential(std::shared_ptr< Potential > pot)
Definition Matter.cpp:850
void setPositionsFreeV(const VectorXd &pos)
Definition Matter.cpp:451
bool recomputeMaskedForces
Definition Matter.h:411
void setPeriodic(bool periodic)
Definition Matter.h:341
Matrix3d getCell() const
Definition Matter.cpp:345
void applyPeriodicBoundaryIfEnabled()
Apply MIC wrap when periodic boundaries are enabled (I/O path).
Definition Matter.h:351
std::unique_ptr< Potential > ownedPotential
Definition Matter.h:367
const Parameters * parameters
Definition Matter.h:398
bool removeNetForce
Definition Matter.h:392
const CancelToken & cancelToken() const
Definition Matter.h:348
long nAtoms
Definition Matter.h:399
long int numberOfAtoms() const
Definition Matter.cpp:343
Matrix3d cauchyStress()
Cauchy stress in eV/Angstrom^3.
Definition Matter.cpp:920
std::shared_ptr< Potential > potential
Definition Matter.h:369
long getForceCalls() const
Definition Matter.cpp:657
VectorXd getPositionsFreeV() const
Definition Matter.cpp:415
BondBoost * biasPotential
Definition Matter.h:404
void setAtomicNrs(const VectorXi &atmnrs)
Definition Matter.cpp:788
AtomMatrix getVelocities() const
Definition Matter.cpp:819
void setVelocities(const AtomMatrix &v)
Definition Matter.cpp:823
double getMechanicalEnergy() const
Definition Matter.cpp:639
void setAtomIndex(long int atom, std::int64_t index)
Definition Matter.cpp:963
PbcConvention getPbcConvention() const
Definition Matter.h:186
double perAtomNorm(const Matter &matter)
Definition Matter.cpp:284
const AtomMatrix & getForcesRaw() const
Definition Matter.cpp:493
long forceCalls
Definition Matter.h:378
io::IoStatus inp2matter(const std::string &filename)
Any structure file: .con/.convel via readcon, the rest via chemfiles.
Definition Matter.h:278
void resize(long int nAtoms)
Definition Matter.cpp:297
VectorXd pbcV(const VectorXd &diff) const
Definition Matter.cpp:950
AtomMatrix getPositionsFree() const
Definition Matter.cpp:386
double getPosition(long int atom, int axis) const
Definition Matter.cpp:354
void applyPeriodicBoundary(double &component, int axis)
size_t getPotentialCalls() const
Definition Matter.cpp:888
unsigned long long cachedHostEpoch_
Definition Matter.h:416
std::shared_ptr< bool > writeConForces_
Definition Matter.h:396
VectorXi getAtomicNrsFree() const
Definition Matter.cpp:395
const std::vector< readcon::ConFrame > & movieFrames() const
In-memory minimization movie (same stamps as writeMovie CON).
Definition Matter.h:138
void restoreFileForces(const AtomMatrix &fileForces, bool trustEnergy, double energy)
Write .con forces without the fixed-atom mask setForces applies.
Definition Matter.cpp:967
Eigen::Matrix< double, Eigen::Dynamic, 1 > getMasses() const
Definition Matter.cpp:846
long int numberOfFixedAtoms() const
Definition Matter.cpp:643
std::unique_ptr< Impl > impl_
Definition Matter.h:403
unsigned long long cachedPotEpoch_
Definition Matter.h:417
double distance(long index1, long index2) const
Definition Matter.cpp:518
double getMass(long int atom) const
Definition Matter.cpp:548
bool recomputePotential
Definition Matter.h:375
unsigned long long surfaceEpoch_
Definition Matter.h:415
void setMasses(const VectorXd &massesIn)
Definition Matter.cpp:558
void setMass(long int atom, double mass)
Definition Matter.cpp:553
io::IoStatus con2matter(const readcon::ConFrame &frame, io::ConFrameMetadata *out_metadata=nullptr)
Definition Matter.h:285
double getPotentialEnergy() const
Definition Matter.cpp:624
AtomMatrix getAccelerations()
Definition Matter.cpp:835
void stampSurfaceEpoch() const
Definition Matter.cpp:682
double * forcesData()
Mutable access to force storage for batched potential evaluation.
Definition Matter.cpp:957
bool needsForceUpdate() const
Whether forces need recomputation (positions or surface epoch changed).
Definition Matter.h:220
AtomMatrix getBiasForces()
Definition Matter.cpp:455
long mapFileRow(long file_row) const
Map a CON file-order row onto the Matter row after matter_order.
Definition Matter.h:318
std::array< std::string, 5 > headerCon
Definition Matter.h:381
void clearMovieFrames()
Definition Matter.h:141
void setHeaderCon(const std::array< std::string, 5 > &headers)
Definition Matter.h:331
bool holdsExclusivePotential() const
True while no copy has shared the Potential from an exclusive handoff.
Definition Matter.cpp:113
StructureComparisonOptions structComp
Definition Matter.h:393
bool usePeriodicBoundaries
Definition Matter.h:370
long int numberOfFreeAtoms() const
Definition Matter.cpp:653
VectorXd getFreeV() const
Definition Matter.cpp:815
Matter(std::shared_ptr< Potential > pot, const Parameters &params)
Definition Matter.cpp:76
CancelToken cancel_token_
Definition Matter.h:418
long getAtomicNr(long int atom) const
Definition Matter.cpp:565
double getEnergyVariance() const
Definition Matter.cpp:892
AtomMatrix getPositionsCopy() const
Definition Matter.cpp:380
void shareOwnedPotential() const
Definition Matter.cpp:107
void setCancelToken(CancelToken token)
Definition Matter.h:347
std::array< bool, 3 > getFixedMask(long int atom) const
Per-axis CON column-4 mask (bit0=x, bit1=y, bit2=z).
Definition Matter.cpp:590
io::IoStatus matter2xyz(std::string filename, bool append=false)
Definition Matter.h:300
void setBiasForces(const AtomMatrix &bf)
Definition Matter.cpp:476
void setPositionsFree(const AtomMatrix &pos)
Definition Matter.cpp:437
std::vector< long > fileToMatter
Definition Matter.h:405
const std::array< std::string, 5 > & getHeaderCon() const
CON header lines (indices 0..4); public for I/O / bindings.
Definition Matter.h:328
std::int64_t getAtomIndex(long int atom) const
.con column-5 index (pre-grouping); public for I/O / bindings.
Definition Matter.cpp:959
void assertIsolatedMoleculeLayoutSafe() const
Throw if pot forbids PBC (isolated molecular QM backends, issue #188).
Definition Matter.cpp:664
VectorXd getPositionsV() const
Definition Matter.cpp:382
void assignKeepingBias(const Matter &other)
Copy another structure in and keep this Matter's own bias potential.
Definition Matter.cpp:470
const AtomMatrix & getForces() const
Definition Matter.cpp:482
double energyVariance
Definition Matter.h:412
bool epochDirty() const
Definition Matter.cpp:676
void setFileToMatter(std::vector< long > map)
Definition Matter.h:325
io::IoStatus matter2con(std::string filename, bool append=false, const io::ConFrameMetadata *metadata=nullptr)
Definition Matter.h:293
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 ...
Definition Matter.h:238
int getFixed(long int atom) const
1 if every Cartesian axis of the atom is fixed, else 0.
Definition Matter.cpp:575
Potential * livePotential() const
Definition Matter.cpp:103
io::IoStatus con2matter(std::string filename)
Definition Matter.h:281
void setSurfaceEpoch(unsigned long long epoch)
Host surface generation.
Definition Matter.cpp:687
std::vector< readcon::ConFrame > takeMovieFrames()
Take ownership of retained frames (leaves storage empty).
Definition Matter.h:143
VectorXd getForcesV() const
Definition Matter.cpp:498
void applyPeriodicBoundary(AtomMatrix &diff)
void captureStress() const
Definition Matter.cpp:899
double maxForce(void) const
Definition Matter.cpp:780
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).
Definition ConFileIO.h:29
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)
Definition PbcSimd.cpp:110
AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:46
void wrapLegacyUnit(double *data, size_t n)
Definition PbcSimd.cpp:114
AtomMatrix applyLegacy(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:57
AtomMatrix applyPositions(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse, PbcConvention convention)
Definition Matter.h:66
VectorXd applyV(const VectorXd &diffVector, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:77
RAII resource manager for the ARTn C library with global synchronization.
PbcConvention
Definition Matter.h:38
void evaluateTogether(Potential &pot, std::span< Matter *const > systems, bool threads, std::span< const long > owners)
Evaluates every system that needs a force update.
Definition Matter.cpp:998
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...
Definition Matter.cpp:981
Options for Matter::compare / distance.
RAII helper for class-scoped logging.
Definition EonLogger.h:238