Loading...
Searching...
No Matches
eonc::Matter Class Reference

#include <Matter.h>

Classes

struct  Impl

Public Member Functions

 ~Matter ()
 Matter (std::shared_ptr< Potential > pot, const Parameters &params)
 Matter (const Matter &matter)
const Matter & operator= (const Matter &matter)
 Matter (Matter &&other) noexcept
 Move: transfers retained movie ConFrames (move-only).
Matter & operator= (Matter &&other) noexcept
bool compare (const Matter &matter, bool indistinguishable=false)
double distanceTo (const Matter &matter)
double perAtomNorm (const Matter &matter)
void setPotential (std::shared_ptr< Potential > pot)
std::shared_ptr< Potential > getPotential ()
void resize (long int nAtoms)
long int numberOfAtoms () const
Matrix3d getCell () const
void setCell (const Matrix3d &newCell)
double getPosition (long int atom, int axis) const
void setPosition (long int atom, int axis, double position)
void setVelocity (long int atom, int axis, double velocity)
bool relax (bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), bool retainMovieFrames=false)
const std::vector< readcon::ConFrame > & movieFrames () const
 In-memory minimization movie (same stamps as writeMovie CON).
void clearMovieFrames ()
std::vector< readcon::ConFrame > takeMovieFrames ()
 Take ownership of retained frames (leaves storage empty).
AtomMatrix pbc (const AtomMatrix &diff) const
VectorXd pbcV (const VectorXd &diff) const
size_t getPotentialCalls () const
const AtomMatrix & getPositions () const
AtomMatrix getPositionsCopy () const
VectorXd getPositionsV () const
AtomMatrix getPositionsFree () const
VectorXd getPositionsFreeV () const
void setPositions (const AtomMatrix &pos)
void setPositionsV (const VectorXd &pos)
void setPositionsFree (const AtomMatrix &pos)
void setPositionsFreeV (const VectorXd &pos)
AtomMatrix getVelocities () const
void setVelocities (const AtomMatrix &v)
void setBiasForces (const AtomMatrix &bf)
void setBiasPotential (BondBoost *bondBoost)
BondBoost * getBiasPotential () const
 The bias potential added to this Matter's forces, or nullptr.
void assignKeepingBias (const Matter &other)
 Copy another structure in and keep this Matter's own bias potential.
void setForces (const AtomMatrix &f)
AtomMatrix getAccelerations ()
const AtomMatrix & getForces () const
const AtomMatrix & getForcesRaw () const
AtomMatrix getBiasForces ()
VectorXd getForcesV () const
AtomMatrix getForcesFree () const
VectorXd getForcesFreeV () const
PbcConvention getPbcConvention () const
void setPbcConvention (PbcConvention convention)
double getMass (long int atom) const
void setMass (long int atom, double mass)
void setMasses (const VectorXd &massesIn)
long getAtomicNr (long int atom) const
void setAtomicNr (long int atom, long atomicNr)
VectorXi getAtomicNrs () const
VectorXi getAtomicNrsFree () const
void setAtomicNrs (const VectorXi &atmnrs)
int getFixed (long int atom) const
 1 if every Cartesian axis of the atom is fixed, else 0.
int getFixed (long int atom, int axis) const
 1 if this atom's axis is fixed, else 0. axis is 0=x, 1=y, 2=z.
std::array< bool, 3 > getFixedMask (long int atom) const
 Per-axis CON column-4 mask (bit0=x, bit1=y, bit2=z).
void setFixed (long int atom, int isFixed)
 Broadcast a whole-atom flag onto all three axes.
void setFixed (long int atom, int axis, int isFixed)
 Set one Cartesian axis. axis is 0=x, 1=y, 2=z.
void setFixedMask (long int atom, std::array< bool, 3 > mask)
double getEnergyVariance () const
double getPotentialEnergy () const
Matrix3d cauchyStress ()
 Cauchy stress in eV/Angstrom^3.
bool needsForceUpdate () const
 Whether forces need recomputation (positions changed since last eval).
double * forcesData ()
 Mutable access to force storage for batched potential evaluation.
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 held before, so no potential call follows.
void setComputedPotential (double energy, double variance)
 Set energy/variance from external batched evaluation and mark forces as up-to-date (recomputePotential = false).
double getKineticEnergy () const
double getMechanicalEnergy () const
double distance (long index1, long index2) const
double pdistance (long index1, long index2, int axis) const
double distance (const Matter &matter, long index) const
long int numberOfFreeAtoms () const
long int numberOfFixedAtoms () const
long getForceCalls () const
void resetForceCalls ()
double maxForce (void) const
double maxFreeAtomForce (const AtomMatrix &rows) const
 Max per-atom Euclidean norm of rows.
bool getWriteConForces () const noexcept
 Parameters.main_options().writeConForces for this Matter, if bound.
io::IoStatus writeTibble (std::string filename)
io::IoStatus con2matter (std::string filename)
io::IoStatus con2matter (const readcon::ConFrame &frame, io::ConFrameMetadata *out_metadata=nullptr)
io::IoStatus convel2matter (std::string filename)
io::IoStatus matter2con (std::string filename, bool append=false, const io::ConFrameMetadata *metadata=nullptr)
io::IoStatus matter2convel (std::string filename)
io::IoStatus matter2xyz (std::string filename, bool append=false)
AtomMatrix getFree () const
VectorXd getFreeV () const
Eigen::Matrix< double, Eigen::Dynamic, 1 > getMasses () const
std::int64_t getAtomIndex (long int atom) const
 .con column-5 index (pre-grouping); public for I/O / bindings.
void setAtomIndex (long int atom, std::int64_t index)
long mapFileRow (long file_row) const
 Map a CON file-order row onto the Matter row after matter_order.
void setFileToMatter (std::vector< long > map)
const std::array< std::string, 5 > & getHeaderCon () const
 CON header lines (indices 0..4); public for I/O / bindings.
void setHeaderCon (const std::array< std::string, 5 > &headers)
void setHeaderConLine (size_t i, std::string line)
bool getPeriodic () const noexcept
void setPeriodic (bool periodic)
void applyPeriodicBoundaryIfEnabled ()
 Apply MIC wrap when periodic boundaries are enabled (I/O path).

Private Member Functions

void assertIsolatedMoleculeLayoutSafe () const
 Throw if pot forbids PBC (isolated molecular QM backends, issue #188).
void computePotential () const
void applyPeriodicBoundary ()
void applyPeriodicBoundary (double &component, int axis)
void applyPeriodicBoundary (AtomMatrix &diff)
void restoreFileForces (const AtomMatrix &fileForces, bool trustEnergy, double energy)
 Write .con forces without the fixed-atom mask setForces applies.

Private Attributes

eonc::log::Scoped m_log
std::shared_ptr< Potential > potential
bool usePeriodicBoundaries
PbcConvention pbcConvention
bool recomputePotential
long forceCalls
std::array< std::string, 5 > headerCon
bool removeNetForce {true}
StructureComparisonOptions structComp
const Parameters * parameters
long nAtoms
std::unique_ptr< Impl > impl_
BondBoost * biasPotential {nullptr}
std::vector< long > fileToMatter
std::vector< int > freeIndices
bool recomputeFreeMask {true}
bool recomputeMaskedForces {true}
double energyVariance
std::vector< readcon::ConFrame > movie_frames_
double potentialEnergy

Friends

io::IoStatus io::con2matter (Matter &, const readcon::ConFrame &, io::ConFrameMetadata *)

Detailed Description

Definition at line 90 of file Matter.h.

Constructor & Destructor Documentation

◆ ~Matter()

eonc::Matter::~Matter ( )
default

◆ Matter() [1/3]

eonc::Matter::Matter ( std::shared_ptr< Potential > pot,
const Parameters & params )

Definition at line 49 of file Matter.cpp.

50 : potential{pot},
51 usePeriodicBoundaries{!(pot && pot->requiresIsolatedMoleculeLayout())},
54 forceCalls{0},
55 removeNetForce{params.main_options().removeNetForce},
56 structComp{params.structure_comparison_options()},
57 parameters{&params},
58 nAtoms{0},
59 impl_{std::make_unique<Impl>()},
60 biasPotential{nullptr},
61 energyVariance{0.0},
62 potentialEnergy{0.0} {}
double potentialEnergy
Definition Matter.h:376
PbcConvention pbcConvention
Definition Matter.h:342
const Parameters * parameters
Definition Matter.h:360
bool removeNetForce
Definition Matter.h:357
long nAtoms
Definition Matter.h:361
std::shared_ptr< Potential > potential
Definition Matter.h:337
BondBoost * biasPotential
Definition Matter.h:366
long forceCalls
Definition Matter.h:346
std::unique_ptr< Impl > impl_
Definition Matter.h:365
bool recomputePotential
Definition Matter.h:343
StructureComparisonOptions structComp
Definition Matter.h:358
bool usePeriodicBoundaries
Definition Matter.h:338
double energyVariance
Definition Matter.h:374

◆ Matter() [2/3]

eonc::Matter::Matter ( const Matter & matter)

Definition at line 81 of file Matter.cpp.

82 : impl_{std::make_unique<Impl>()} {
83 operator=(matter);
84}
const Matter & operator=(const Matter &matter)
Definition Matter.cpp:86

◆ Matter() [3/3]

eonc::Matter::Matter ( Matter && other)
noexcept

Move: transfers retained movie ConFrames (move-only).

User copy suppresses implicit move — without this, relax(inplace=False, retain_frames=True) loses frames when returning the working Matter.

Definition at line 136 of file Matter.cpp.

137 : impl_{std::make_unique<Impl>()} {
138 operator=(std::move(other));
139}

Member Function Documentation

◆ applyPeriodicBoundary() [1/3]

void eonc::Matter::applyPeriodicBoundary ( )
private

Definition at line 666 of file Matter.cpp.

666 {
668 // Unset / singular cell (default after Matter construct is Zero) — do not
669 // wipe coordinates; callers set the cell before wrapping makes sense.
670 if (std::abs(impl_->cell.determinant()) < 1e-30) {
671 return;
672 }
673 impl_->positions = eonc::pbc::applyPositions(
674 impl_->positions, impl_->cell, impl_->cellInverse, pbcConvention);
675}
void assertIsolatedMoleculeLayoutSafe() const
Throw if pot forbids PBC (isolated molecular QM backends, issue #188).
Definition Matter.cpp:594
AtomMatrix applyPositions(const AtomMatrix &coords, const Matrix3d &cell, const Matrix3d &cellInverse, PbcConvention convention)
Definition Matter.h:64

◆ applyPeriodicBoundary() [2/3]

void eonc::Matter::applyPeriodicBoundary ( AtomMatrix & diff)
private

◆ applyPeriodicBoundary() [3/3]

void eonc::Matter::applyPeriodicBoundary ( double & component,
int axis )
private

◆ applyPeriodicBoundaryIfEnabled()

void eonc::Matter::applyPeriodicBoundaryIfEnabled ( )
inline

Apply MIC wrap when periodic boundaries are enabled (I/O path).

Definition at line 322 of file Matter.h.

322 {
325 }
326 }
void applyPeriodicBoundary()
Definition Matter.cpp:666

◆ assertIsolatedMoleculeLayoutSafe()

void eonc::Matter::assertIsolatedMoleculeLayoutSafe ( ) const
private

Throw if pot forbids PBC (isolated molecular QM backends, issue #188).

Definition at line 594 of file Matter.cpp.

594 {
595 if (!potential || !potential->requiresIsolatedMoleculeLayout()) {
596 return;
597 }
599 throw std::runtime_error(
600 "Potential requires an isolated (non-periodic) molecular layout "
601 "(NWChem/ORCA-class). Disable periodic boundaries before optimizing; "
602 "PBC wraps can tear non-centered molecules (issue #188).");
603 }
604}

◆ assignKeepingBias()

void eonc::Matter::assignKeepingBias ( const Matter & other)

Copy another structure in and keep this Matter's own bias potential.

operator= clears the bias pointer, because it names the source's boost.

Definition at line 400 of file Matter.cpp.

400 {
401 BondBoost *keep = biasPotential;
402 *this = other;
403 biasPotential = keep;
404}

◆ cauchyStress()

Matrix3d eonc::Matter::cauchyStress ( )

Cauchy stress in eV/Angstrom^3.

Recomputes the potential so the tensor belongs to this image. The potential must report stress.

Definition at line 794 of file Matter.cpp.

794 {
795 if (!potential || !potential->computesStress()) {
796 throw std::logic_error(
797 "Matter::cauchyStress requires a potential that reports stress");
798 }
799 recomputePotential = true;
801 Matrix3d sigma = potential->cauchyStress();
802 if (!sigma.allFinite()) {
803 throw std::runtime_error("Potential returned a non-finite stress tensor");
804 }
805 return sigma;
806}
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Definition Eigen.h:35
void computePotential() const
Definition Matter.cpp:606

◆ clearMovieFrames()

void eonc::Matter::clearMovieFrames ( )
inline

Definition at line 132 of file Matter.h.

132{ movie_frames_.clear(); }
std::vector< readcon::ConFrame > movie_frames_
Definition Matter.h:375

◆ compare()

bool eonc::Matter::compare ( const Matter & matter,
bool indistinguishable = false )

Definition at line 184 of file Matter.cpp.

184 {
185 if (nAtoms != matter.numberOfAtoms())
186 return false;
187 if (structComp.check_rotation && indistinguishable) {
188 return eonc::geometry::sortedR(*this, matter,
189 structComp.distance_difference);
190 } else if (indistinguishable) {
191 if (this->numberOfFixedAtoms() == 0 and structComp.remove_translation)
193 return eonc::geometry::identical(*this, matter,
194 structComp.distance_difference);
195 } else if (structComp.check_rotation) {
196 return eonc::geometry::rotationMatch(*this, matter,
197 structComp.distance_difference);
198 } else {
199 if (this->numberOfFixedAtoms() == 0 and structComp.remove_translation)
201 return (structComp.distance_difference) > perAtomNorm(matter);
202 }
203}
double perAtomNorm(const Matter &matter)
Definition Matter.cpp:214
long int numberOfFixedAtoms() const
Definition Matter.cpp:573
bool rotationMatch(const Matter &m1, const Matter &m2, const double max_diff)
bool identical(const Matter &m1, const Matter &m2, const double distanceDifference)
bool sortedR(const Matter &m1, const Matter &m2, const double distanceDifference)
void translationRemove(Matter &m1, const AtomMatrix r1)

◆ computePotential()

void eonc::Matter::computePotential ( ) const
private

Definition at line 606 of file Matter.cpp.

606 {
607 if (recomputePotential) {
608 if (!potential) {
609 throw std::runtime_error(
610 "Matter::computePotential called without a potential");
611 }
613 if (potential->isSurrogate()) {
614 // Surrogate potential case: uses free-atom subset interface
615 auto surrogatePotential =
616 static_cast<SurrogatePotential *>(potential.get());
617 auto [freePE, freeForces, vari] = surrogatePotential->get_ef_var(
618 this->getPositionsFree(), this->getAtomicNrsFree(), impl_->cell);
619 this->potentialEnergy = freePE;
620 this->energyVariance = vari;
621 for (long idx{0}, jdx{0}; idx < nAtoms; idx++) {
622 if (!getFixed(idx)) {
623 impl_->forces.row(idx) = freeForces.row(jdx);
624 jdx++;
625 }
626 }
627 } else {
628 // Hot path: call force() directly into member storage.
629 // No intermediate allocation, no tuple, no copy.
630 double var{0};
631 potential->setFixedMask(nAtoms, impl_->isFixed.data());
632 const auto n = static_cast<size_t>(nAtoms);
633 // Isolated molecules still store a box for I/O. Pots that infer PBC
634 // from a non-zero cell (GFN2) must see a zero box here.
635 const Matrix3d force_cell =
636 usePeriodicBoundaries ? impl_->cell : Matrix3d::Zero();
637 potential->force(std::span<const double>(impl_->positions.data(), n * 3),
638 std::span<const int>(impl_->atomicNrs.data(), n),
639 std::span<double>(impl_->forces.data(), n * 3),
640 &potentialEnergy, &var,
641 std::span<const double>(force_cell.data(), 9));
642 potential->forceCallCounter++;
644 }
645 if (!std::isfinite(potentialEnergy) || !impl_->forces.allFinite()) {
646 throw std::runtime_error(
647 "Potential returned non-finite energy or forces");
648 }
650 recomputePotential = false;
651
652 // One free atom: subtracting the mean force is identically zero,
653 // and NEB would then report immediate GOOD.
654 if (impl_->isFixed.maxCoeff() < 0.5 && removeNetForce && nAtoms > 1) {
655 Vector3d tempForce = impl_->forces.colwise().sum() / nAtoms;
656 for (long int i = 0; i < nAtoms; i++) {
657 impl_->forces.row(i) -= tempForce.transpose();
658 }
659 }
660 }
661}
AtomMatrix getPositionsFree() const
Definition Matter.cpp:316
VectorXi getAtomicNrsFree() const
Definition Matter.cpp:325
int getFixed(long int atom) const
1 if every Cartesian axis of the atom is fixed, else 0.
Definition Matter.cpp:505
void on_force_call(PotType t) noexcept override
static PotRegistry & get() noexcept
Process-lifetime singleton.

◆ con2matter() [1/2]

io::IoStatus eonc::Matter::con2matter ( const readcon::ConFrame & frame,
io::ConFrameMetadata * out_metadata = nullptr )
inlinenodiscard

Definition at line 260 of file Matter.h.

261 {
262 return io::con2matter(*this, frame, out_metadata);
263 }
IoStatus con2matter(Matter &m, std::string filename)

◆ con2matter() [2/2]

io::IoStatus eonc::Matter::con2matter ( std::string filename)
inlinenodiscard

Definition at line 256 of file Matter.h.

256 {
257 return io::con2matter(*this, filename);
258 }

◆ convel2matter()

io::IoStatus eonc::Matter::convel2matter ( std::string filename)
inlinenodiscard

Definition at line 264 of file Matter.h.

264 {
265 return io::convel2matter(*this, filename);
266 }
IoStatus convel2matter(Matter &m, std::string filename)

◆ distance() [1/2]

double eonc::Matter::distance ( const Matter & matter,
long index ) const

Definition at line 471 of file Matter.cpp.

471 {
472 checkAtom(nAtoms, index, "Matter::distance");
473 checkAtom(matter.nAtoms, index, "Matter::distance");
474 return pbc(impl_->positions.row(index) - matter.getPositions().row(index))
475 .norm();
476}
AtomMatrix pbc(const AtomMatrix &diff) const
Definition Matter.cpp:810

◆ distance() [2/2]

double eonc::Matter::distance ( long index1,
long index2 ) const

Definition at line 448 of file Matter.cpp.

448 {
449 checkAtom(nAtoms, index1, "Matter::distance");
450 checkAtom(nAtoms, index2, "Matter::distance");
451 return pbc(impl_->positions.row(index1) - impl_->positions.row(index2))
452 .norm();
453}

◆ distanceTo()

double eonc::Matter::distanceTo ( const Matter & matter)

Definition at line 206 of file Matter.cpp.

206 {
207 if (matter.numberOfAtoms() != nAtoms) {
208 throw std::invalid_argument("Matter::distanceTo: size mismatch");
209 }
210 return pbc(impl_->positions - matter.impl_->positions).norm();
211}

◆ forcesData()

double * eonc::Matter::forcesData ( )

Mutable access to force storage for batched potential evaluation.

Caller must also call setComputedPotential() after writing forces.

Definition at line 824 of file Matter.cpp.

824{ return impl_->forces.data(); }

◆ getAccelerations()

AtomMatrix eonc::Matter::getAccelerations ( )

Definition at line 739 of file Matter.cpp.

739 {
741 AtomMatrix ret = totF.array() * getFree().array();
742 // Single reciprocal mass computation, replicated across 3 columns
743 auto invMass = impl_->masses.array().inverse();
744 ret.col(0).array() *= invMass;
745 ret.col(1).array() *= invMass;
746 ret.col(2).array() *= invMass;
747 return ret;
748}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
AtomMatrix getFree() const
Definition Matter.cpp:704
AtomMatrix getBiasForces()
Definition Matter.cpp:385
const AtomMatrix & getForces() const
Definition Matter.cpp:412

◆ getAtomicNr()

long eonc::Matter::getAtomicNr ( long int atom) const

Definition at line 495 of file Matter.cpp.

495 {
496 return (impl_->atomicNrs[indexAtom]);
497}

◆ getAtomicNrs()

VectorXi eonc::Matter::getAtomicNrs ( ) const

Definition at line 691 of file Matter.cpp.

691{ return this->impl_->atomicNrs; }

◆ getAtomicNrsFree()

VectorXi eonc::Matter::getAtomicNrsFree ( ) const

Definition at line 325 of file Matter.cpp.

325 {
326 getFree();
327 VectorXi ret(static_cast<Eigen::Index>(freeIndices.size()));
328 for (size_t j = 0; j < freeIndices.size(); j++) {
329 ret[static_cast<Eigen::Index>(j)] = impl_->atomicNrs[freeIndices[j]];
330 }
331 return ret;
332}
std::vector< int > freeIndices
Definition Matter.h:371

◆ getAtomIndex()

std::int64_t eonc::Matter::getAtomIndex ( long int atom) const
nodiscard

.con column-5 index (pre-grouping); public for I/O / bindings.

Held 64-bit wide: readcon carries the column as a uint64_t, and a 32-bit slot drops the high half of any id past 2^31.

Definition at line 826 of file Matter.cpp.

826 {
827 return impl_->atomIndex(atom);
828}

◆ getBiasForces()

AtomMatrix eonc::Matter::getBiasForces ( )

Definition at line 385 of file Matter.cpp.

385 {
386 if (biasPotential != nullptr) {
387 // Evaluate the current bias only. The MD job advances the bond-boost
388 // schedule once per step via BondBoost::advance().
389 biasPotential->boost();
390 }
391 return impl_->biasForces.array() * getFree().array();
392}

◆ getBiasPotential()

BondBoost * eonc::Matter::getBiasPotential ( ) const

The bias potential added to this Matter's forces, or nullptr.

Definition at line 398 of file Matter.cpp.

398{ return biasPotential; }

◆ getCell()

Matrix3d eonc::Matter::getCell ( ) const

Definition at line 275 of file Matter.cpp.

275{ return impl_->cell; }

◆ getEnergyVariance()

double eonc::Matter::getEnergyVariance ( ) const

Definition at line 792 of file Matter.cpp.

792{ return this->energyVariance; }

◆ getFixed() [1/2]

int eonc::Matter::getFixed ( long int atom) const

1 if every Cartesian axis of the atom is fixed, else 0.

Definition at line 505 of file Matter.cpp.

505 {
506 checkAtom(nAtoms, indexAtom, "Matter::getFixed");
507 return (impl_->isFixed(indexAtom, 0) > 0.5 &&
508 impl_->isFixed(indexAtom, 1) > 0.5 &&
509 impl_->isFixed(indexAtom, 2) > 0.5)
510 ? 1
511 : 0;
512}

◆ getFixed() [2/2]

int eonc::Matter::getFixed ( long int atom,
int axis ) const

1 if this atom's axis is fixed, else 0. axis is 0=x, 1=y, 2=z.

Definition at line 514 of file Matter.cpp.

514 {
515 checkAtom(nAtoms, indexAtom, "Matter::getFixed");
516 checkAxis(axis, "Matter::getFixed");
517 return impl_->isFixed(indexAtom, axis) > 0.5 ? 1 : 0;
518}

◆ getFixedMask()

std::array< bool, 3 > eonc::Matter::getFixedMask ( long int atom) const
nodiscard

Per-axis CON column-4 mask (bit0=x, bit1=y, bit2=z).

Definition at line 520 of file Matter.cpp.

520 {
521 checkAtom(nAtoms, indexAtom, "Matter::getFixedMask");
522 return {impl_->isFixed(indexAtom, 0) > 0.5,
523 impl_->isFixed(indexAtom, 1) > 0.5,
524 impl_->isFixed(indexAtom, 2) > 0.5};
525}

◆ getForceCalls()

long eonc::Matter::getForceCalls ( ) const

Definition at line 587 of file Matter.cpp.

587{ return (forceCalls); }

◆ getForces()

const AtomMatrix & eonc::Matter::getForces ( ) const

Definition at line 412 of file Matter.cpp.

412 {
415 // Use the cached freeMask (Nx3, 1.0 for free / 0.0 for fixed) to zero
416 // fixed-atom forces in a single vectorized Eigen operation.
417 impl_->maskedForces = impl_->forces.array() * getFree().array();
418 recomputeMaskedForces = false;
419 }
420 return impl_->maskedForces;
421}
bool recomputeMaskedForces
Definition Matter.h:373

◆ getForcesFree()

AtomMatrix eonc::Matter::getForcesFree ( ) const

Definition at line 432 of file Matter.cpp.

432 {
433 AtomMatrix allForces = getForces();
434 getFree(); // ensure freeIndices is up to date (mutable cache)
435 AtomMatrix ret(static_cast<long>(freeIndices.size()), 3);
436 for (size_t j = 0; j < freeIndices.size(); j++) {
437 ret.row(static_cast<long>(j)) = allForces.row(freeIndices[j]);
438 }
439 return ret;
440}

◆ getForcesFreeV()

VectorXd eonc::Matter::getForcesFreeV ( ) const

Definition at line 442 of file Matter.cpp.

442 {
443 AtomMatrix freeForces = getForcesFree();
444 return VectorXd::Map(freeForces.data(), 3 * numberOfFreeAtoms());
445}
AtomMatrix getForcesFree() const
Definition Matter.cpp:432
long int numberOfFreeAtoms() const
Definition Matter.cpp:583

◆ getForcesRaw()

const AtomMatrix & eonc::Matter::getForcesRaw ( ) const

Definition at line 423 of file Matter.cpp.

423 {
425 return impl_->forces;
426}

◆ getForcesV()

VectorXd eonc::Matter::getForcesV ( ) const

Definition at line 428 of file Matter.cpp.

428 {
429 return VectorXd::Map(getForces().data(), 3 * numberOfAtoms());
430}
long int numberOfAtoms() const
Definition Matter.cpp:273

◆ getFree()

AtomMatrix eonc::Matter::getFree ( ) const

Definition at line 704 of file Matter.cpp.

704 {
705 if (recomputeFreeMask) {
706 impl_->freeMask.resize(nAtoms, 3);
707 impl_->freeMask = 1.0 - impl_->isFixed.array();
708 freeIndices.clear();
709 freeIndices.reserve(static_cast<size_t>(nAtoms));
710 for (long i = 0; i < nAtoms; i++) {
711 if (impl_->freeMask.row(i).sum() > 0.5) {
712 freeIndices.push_back(static_cast<int>(i));
713 }
714 }
715 recomputeFreeMask = false;
716 }
717 return impl_->freeMask;
718}
bool recomputeFreeMask
Definition Matter.h:372

◆ getFreeV()

VectorXd eonc::Matter::getFreeV ( ) const

Definition at line 720 of file Matter.cpp.

720 {
721 return VectorXd::Map(getFree().data(), 3 * numberOfAtoms());
722}

◆ getHeaderCon()

const std::array< std::string, 5 > & eonc::Matter::getHeaderCon ( ) const
inlinenodiscard

CON header lines (indices 0..4); public for I/O / bindings.

Definition at line 303 of file Matter.h.

303 {
304 return headerCon;
305 }
std::array< std::string, 5 > headerCon
Definition Matter.h:349

◆ getKineticEnergy()

double eonc::Matter::getKineticEnergy ( ) const

Definition at line 562 of file Matter.cpp.

562 {
563 // 0.5 * sum(mass_i * |v_i,free|^2); a constrained axis does not contribute.
564 AtomMatrix vfree = impl_->velocities.array() * getFree().array();
565 Eigen::VectorXd speed2 = vfree.rowwise().squaredNorm();
566 return 0.5 * (impl_->masses.array() * speed2.array()).sum();
567}

◆ getMass()

double eonc::Matter::getMass ( long int atom) const

Definition at line 478 of file Matter.cpp.

478 {
479 checkAtom(nAtoms, indexAtom, "Matter::getMass");
480 return (impl_->masses[indexAtom]);
481}

◆ getMasses()

Matrix< double, Eigen::Dynamic, 1 > eonc::Matter::getMasses ( ) const

Definition at line 750 of file Matter.cpp.

750 {
751 return impl_->masses;
752}

◆ getMechanicalEnergy()

double eonc::Matter::getMechanicalEnergy ( ) const

Definition at line 569 of file Matter.cpp.

569 {
571}
double getKineticEnergy() const
Definition Matter.cpp:562
double getPotentialEnergy() const
Definition Matter.cpp:554

◆ getPbcConvention()

PbcConvention eonc::Matter::getPbcConvention ( ) const
inline

Definition at line 177 of file Matter.h.

177{ return pbcConvention; }

◆ getPeriodic()

bool eonc::Matter::getPeriodic ( ) const
inlinenodiscardnoexcept

Definition at line 313 of file Matter.h.

313 {
315 }

◆ getPosition()

double eonc::Matter::getPosition ( long int atom,
int axis ) const

Definition at line 284 of file Matter.cpp.

284 {
285 checkAtom(nAtoms, indexAtom, "Matter::getPosition");
286 checkAxis(axis, "Matter::getPosition");
287 return impl_->positions(indexAtom, axis);
288}

◆ getPositions()

const AtomMatrix & eonc::Matter::getPositions ( ) const

Definition at line 308 of file Matter.cpp.

308{ return impl_->positions; }

◆ getPositionsCopy()

AtomMatrix eonc::Matter::getPositionsCopy ( ) const

Definition at line 310 of file Matter.cpp.

310{ return impl_->positions; }

◆ getPositionsFree()

AtomMatrix eonc::Matter::getPositionsFree ( ) const

Definition at line 316 of file Matter.cpp.

316 {
317 getFree(); // ensure freeIndices is up to date
318 AtomMatrix ret(static_cast<long>(freeIndices.size()), 3);
319 for (size_t j = 0; j < freeIndices.size(); j++) {
320 ret.row(static_cast<long>(j)) = impl_->positions.row(freeIndices[j]);
321 }
322 return ret;
323}

◆ getPositionsFreeV()

VectorXd eonc::Matter::getPositionsFreeV ( ) const

Definition at line 345 of file Matter.cpp.

345 {
346 return VectorXd::Map(getPositionsFree().data(), 3 * numberOfFreeAtoms());
347}

◆ getPositionsV()

VectorXd eonc::Matter::getPositionsV ( ) const

Definition at line 312 of file Matter.cpp.

312 {
313 return VectorXd::Map(impl_->positions.data(), 3 * numberOfAtoms());
314}

◆ getPotential()

std::shared_ptr< Potential > eonc::Matter::getPotential ( )

Definition at line 808 of file Matter.cpp.

808{ return this->potential; }

◆ getPotentialCalls()

size_t eonc::Matter::getPotentialCalls ( ) const

Definition at line 788 of file Matter.cpp.

788 {
789 return this->potential->forceCallCounter;
790}

◆ getPotentialEnergy()

double eonc::Matter::getPotentialEnergy ( ) const

Definition at line 554 of file Matter.cpp.

554 {
555 if (nAtoms > 0) {
557 return potentialEnergy;
558 } else
559 return 0.0;
560}

◆ getVelocities()

AtomMatrix eonc::Matter::getVelocities ( ) const

Definition at line 724 of file Matter.cpp.

724 {
725 return impl_->velocities.array() * getFree().array();
726}

◆ getWriteConForces()

bool eonc::Matter::getWriteConForces ( ) const
nodiscardnoexcept

Parameters.main_options().writeConForces for this Matter, if bound.

Definition at line 64 of file Matter.cpp.

64 {
65 return parameters != nullptr && parameters->main_options().writeConForces;
66}

◆ mapFileRow()

long eonc::Matter::mapFileRow ( long file_row) const
inlinenodiscard

Map a CON file-order row onto the Matter row after matter_order.

Identity when the Matter was not loaded from a .con, or the ids were already ascending.

Definition at line 293 of file Matter.h.

293 {
294 if (file_row < 0 || file_row >= nAtoms ||
295 fileToMatter.size() != static_cast<size_t>(nAtoms)) {
296 return file_row;
297 }
298 return fileToMatter[static_cast<size_t>(file_row)];
299 }
std::vector< long > fileToMatter
Definition Matter.h:367

◆ matter2con()

io::IoStatus eonc::Matter::matter2con ( std::string filename,
bool append = false,
const io::ConFrameMetadata * metadata = nullptr )
inlinenodiscard

Definition at line 268 of file Matter.h.

269 {
270 return io::matter2con(*this, filename, append, metadata);
271 }
IoStatus matter2con(Matter &m, std::string filename, bool append, const ConFrameMetadata *metadata)
Append a frame to a .con, or truncate and write one frame.

◆ matter2convel()

io::IoStatus eonc::Matter::matter2convel ( std::string filename)
inlinenodiscard

Definition at line 272 of file Matter.h.

272 {
273 return io::matter2convel(*this, filename);
274 }
IoStatus matter2convel(Matter &m, std::string filename)

◆ matter2xyz()

io::IoStatus eonc::Matter::matter2xyz ( std::string filename,
bool append = false )
inlinenodiscard

Definition at line 275 of file Matter.h.

276 {
277 return io::matter2xyz(*this, filename, append);
278 }
IoStatus matter2xyz(Matter &m, std::string filename, bool append)
Write one extended-XYZ frame: Lattice= cell and 17-digit coordinates.

◆ maxForce()

double eonc::Matter::maxForce ( void ) const

Definition at line 685 of file Matter.cpp.

685 {
686 // Ensures that the forces are up to date
688 return maxFreeAtomForce(getForces());
689}
double maxFreeAtomForce(const AtomMatrix &rows) const
Max per-atom Euclidean norm of rows.
Definition Matter.cpp:677

◆ maxFreeAtomForce()

double eonc::Matter::maxFreeAtomForce ( const AtomMatrix & rows) const
nodiscard

Max per-atom Euclidean norm of rows.

Atoms fixed on every axis are ignored. rows must have one row per atom.

Definition at line 677 of file Matter.cpp.

677 {
678 if (rows.rows() != nAtoms) {
679 throw std::invalid_argument(
680 "Matter::maxFreeAtomForce: row count does not match atom count");
681 }
682 return maxFreeAtomForceNorm(rows.data(), impl_->isFixed.data(), nAtoms);
683}
double maxFreeAtomForceNorm(const double *forces, const double *fixed, long nAtoms)
Max Euclidean norm over N x 3 row-major force rows.

◆ movieFrames()

const std::vector< readcon::ConFrame > & eonc::Matter::movieFrames ( ) const
inlinenodiscard

In-memory minimization movie (same stamps as writeMovie CON).

Cleared when retainMovieFrames=false on the next relax, or via clearMovieFrames().

Definition at line 129 of file Matter.h.

129 {
130 return movie_frames_;
131 }

◆ needsForceUpdate()

bool eonc::Matter::needsForceUpdate ( ) const
inlinenodiscard

Whether forces need recomputation (positions changed since last eval).

Definition at line 211 of file Matter.h.

211{ return recomputePotential; }

◆ numberOfAtoms()

long int eonc::Matter::numberOfAtoms ( ) const

Definition at line 273 of file Matter.cpp.

273{ return (nAtoms); }

◆ numberOfFixedAtoms()

long int eonc::Matter::numberOfFixedAtoms ( ) const

Definition at line 573 of file Matter.cpp.

573 {
574 long n = 0;
575 for (long i = 0; i < nAtoms; ++i) {
576 if (getFixed(i)) {
577 ++n;
578 }
579 }
580 return n;
581}

◆ numberOfFreeAtoms()

long int eonc::Matter::numberOfFreeAtoms ( ) const

Definition at line 583 of file Matter.cpp.

583 {
584 return nAtoms - numberOfFixedAtoms();
585}

◆ operator=() [1/2]

const Matter & eonc::Matter::operator= ( const Matter & matter)

Definition at line 86 of file Matter.cpp.

86 {
87 if (this == &matter) {
88 return *this;
89 }
90 nAtoms = matter.nAtoms;
92
93 impl_->positions = matter.impl_->positions;
94 impl_->forces = matter.impl_->forces;
95 impl_->masses = matter.impl_->masses;
96 impl_->atomicNrs = matter.impl_->atomicNrs;
97 impl_->isFixed = matter.impl_->isFixed;
98 impl_->atomIndex = matter.impl_->atomIndex;
99 fileToMatter = matter.fileToMatter;
100 impl_->cell = matter.impl_->cell;
101 impl_->cellInverse = matter.impl_->cellInverse;
102 impl_->velocities = matter.impl_->velocities;
103
104 removeNetForce = matter.removeNetForce;
105 structComp = matter.structComp;
106 parameters = matter.parameters;
107
108 usePeriodicBoundaries = matter.usePeriodicBoundaries;
109 pbcConvention = matter.pbcConvention;
110
111 potential = matter.potential;
112 potentialEnergy = matter.potentialEnergy;
113 energyVariance = matter.energyVariance;
114 forceCalls = matter.forceCalls;
115 recomputePotential = matter.recomputePotential;
116 // Both caches describe the forces this object held before the assignment.
117 // resize() above already raises them; state it here alongside the members
118 // this function owns.
119 recomputeFreeMask = true;
121
122 // A BondBoost binds to one Matter (BondBoost.h:32 takes a Matter *), so a
123 // copy cannot share the source's: boosting through it would drive the
124 // original. The copy starts without one and re-establishes it through
125 // setBiasPotential. biasForces is zeroed by the resize above, which is the
126 // state that matches having no bias potential.
127 biasPotential = nullptr;
128
129 headerCon = matter.headerCon;
130 // ConFrame is move-only; copy does not retain movie trajectory.
131 movie_frames_.clear();
132
133 return *this;
134}
void resize(long int nAtoms)
Definition Matter.cpp:227

◆ operator=() [2/2]

Matter & eonc::Matter::operator= ( Matter && other)
noexcept

Definition at line 141 of file Matter.cpp.

141 {
142 if (this == &other) {
143 return *this;
144 }
145 potential = std::move(other.potential);
146 usePeriodicBoundaries = other.usePeriodicBoundaries;
147 pbcConvention = other.pbcConvention;
148 recomputePotential = other.recomputePotential;
149 forceCalls = other.forceCalls;
150 headerCon = std::move(other.headerCon);
151 removeNetForce = other.removeNetForce;
152 structComp = other.structComp;
153 parameters = other.parameters;
154 nAtoms = other.nAtoms;
155 impl_->positions = std::move(other.impl_->positions);
156 impl_->velocities = std::move(other.impl_->velocities);
157 impl_->forces = std::move(other.impl_->forces);
158 impl_->biasForces = std::move(other.impl_->biasForces);
159 biasPotential = other.biasPotential;
160 other.biasPotential = nullptr;
161 impl_->masses = std::move(other.impl_->masses);
162 impl_->atomicNrs = std::move(other.impl_->atomicNrs);
163 impl_->isFixed = std::move(other.impl_->isFixed);
164 impl_->atomIndex = std::move(other.impl_->atomIndex);
165 fileToMatter = std::move(other.fileToMatter);
166 impl_->freeMask = std::move(other.impl_->freeMask);
167 impl_->maskedForces = std::move(other.impl_->maskedForces);
168 freeIndices = std::move(other.freeIndices);
169 recomputeFreeMask = other.recomputeFreeMask;
170 recomputeMaskedForces = other.recomputeMaskedForces;
171 impl_->cell = std::move(other.impl_->cell);
172 impl_->cellInverse = std::move(other.impl_->cellInverse);
173 energyVariance = other.energyVariance;
174 movie_frames_ = std::move(other.movie_frames_);
175 potentialEnergy = other.potentialEnergy;
176
177 other.nAtoms = 0;
178 other.recomputePotential = true;
179 other.recomputeFreeMask = true;
180 other.recomputeMaskedForces = true;
181 return *this;
182}

◆ pbc()

AtomMatrix eonc::Matter::pbc ( const AtomMatrix & diff) const

Definition at line 810 of file Matter.cpp.

810 {
812 return diff;
813 }
814 return eonc::pbc::apply(diff, impl_->cell, impl_->cellInverse);
815}
AtomMatrix apply(const AtomMatrix &diff, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:44

◆ pbcV()

VectorXd eonc::Matter::pbcV ( const VectorXd & diff) const

Definition at line 817 of file Matter.cpp.

817 {
819 return diff;
820 }
821 return eonc::pbc::applyV(diff, impl_->cell, impl_->cellInverse);
822}
VectorXd applyV(const VectorXd &diffVector, const Matrix3d &cell, const Matrix3d &cellInverse)
Definition Matter.h:73

◆ pdistance()

double eonc::Matter::pdistance ( long index1,
long index2,
int axis ) const

Definition at line 457 of file Matter.cpp.

457 {
458 checkAtom(nAtoms, index1, "Matter::pdistance");
459 checkAtom(nAtoms, index2, "Matter::pdistance");
460 checkAxis(axis, "Matter::pdistance");
461 Matrix<double, 1, 3> ret;
462 ret.setZero();
463 ret(0, axis) =
464 impl_->positions(index1, axis) - impl_->positions(index2, axis);
465 ret = pbc(ret);
466 return ret(0, axis);
467}

◆ perAtomNorm()

double eonc::Matter::perAtomNorm ( const Matter & matter)

Definition at line 214 of file Matter.cpp.

214 {
215 long i = 0;
216 double max_distance = 0.0;
217
218 if (matter.numberOfAtoms() == nAtoms) {
219 AtomMatrix diff = pbc(impl_->positions - matter.impl_->positions);
220 for (i = 0; i < nAtoms; i++) {
221 max_distance = std::max(diff.row(i).norm(), max_distance);
222 }
223 }
224 return max_distance;
225}

◆ relax()

bool eonc::Matter::relax ( bool quiet = false,
bool writeMovie = false,
bool checkpoint = false,
std::string prefixMovie = std::string(),
std::string prefixCheckpoint = std::string(),
bool retainMovieFrames = false )

Definition at line 334 of file Matter.cpp.

336 {
337 if (retainMovieFrames) {
338 movie_frames_.clear();
339 }
341 *this, *parameters, quiet, writeMovie, checkpoint, prefixMovie,
342 prefixCheckpoint, retainMovieFrames ? &movie_frames_ : nullptr);
343}
bool relaxMatter(Matter &matter, const Parameters &params, bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), std::vector< readcon::ConFrame > *outFrames=nullptr)

◆ resetForceCalls()

void eonc::Matter::resetForceCalls ( )

Definition at line 589 of file Matter.cpp.

589 {
590 forceCalls = 0;
591 return;
592}

◆ resize()

void eonc::Matter::resize ( long int nAtoms)

Definition at line 227 of file Matter.cpp.

227 {
228 if (length < 0) {
229 throw std::invalid_argument("Matter::resize: negative atom count");
230 }
231 // Same-N resize still zeros coordinates. Keep .con column-5 ids and
232 // the file-order map so a later matter2con does not stamp 1..N.
233 const bool keepAtomIds =
234 (length == nAtoms && impl_->atomIndex.size() == length &&
235 fileToMatter.size() == static_cast<size_t>(length));
236 // Zero is a real size: leaving nAtoms at the old value there sends
237 // setMasses and every other nAtoms loop off the end of an empty array.
238 nAtoms = length;
239 impl_->positions.resize(length, 3);
240 impl_->positions.setZero();
241
242 impl_->velocities.resize(length, 3);
243 impl_->velocities.setZero();
244
245 impl_->biasForces.resize(length, 3);
246 impl_->biasForces.setZero();
247
248 impl_->forces.resize(length, 3);
249 impl_->forces.setZero();
250
251 impl_->masses.resize(length);
252 impl_->masses.setZero();
253
254 impl_->atomicNrs.resize(length);
255 impl_->atomicNrs.setZero();
256
257 impl_->isFixed.resize(length, 3);
258 impl_->isFixed.setZero();
259
260 if (!keepAtomIds) {
261 impl_->atomIndex.resize(length);
262 fileToMatter.resize(static_cast<size_t>(length));
263 for (long i = 0; i < length; i++) {
264 impl_->atomIndex(i) = static_cast<std::int64_t>(i); // default: sequential
265 fileToMatter[static_cast<size_t>(i)] = i;
266 }
267 }
268 recomputePotential = true;
270 recomputeFreeMask = true;
271}

◆ restoreFileForces()

void eonc::Matter::restoreFileForces ( const AtomMatrix & fileForces,
bool trustEnergy,
double energy )
private

Write .con forces without the fixed-atom mask setForces applies.

Definition at line 834 of file Matter.cpp.

835 {
836 impl_->forces = fileForces;
838 if (trustEnergy) {
839 potentialEnergy = energy;
840 energyVariance = 0.0;
841 recomputePotential = false;
842 } else {
843 recomputePotential = true;
844 }
845}

◆ setAtomicNr()

void eonc::Matter::setAtomicNr ( long int atom,
long atomicNr )

Definition at line 499 of file Matter.cpp.

499 {
500 impl_->atomicNrs[indexAtom] = atomicNr;
501 recomputePotential = true;
503}

◆ setAtomicNrs()

void eonc::Matter::setAtomicNrs ( const VectorXi & atmnrs)

Definition at line 693 of file Matter.cpp.

693 {
694 if (atmnrs.size() != this->nAtoms) {
695 throw std::invalid_argument(
696 "Vector of atomic numbers not equal to the number of atoms");
697 } else {
698 this->impl_->atomicNrs = atmnrs;
699 recomputePotential = true;
701 }
702}

◆ setAtomIndex()

void eonc::Matter::setAtomIndex ( long int atom,
std::int64_t index )

Definition at line 830 of file Matter.cpp.

830 {
831 impl_->atomIndex(atom) = index;
832}

◆ setBiasForces()

void eonc::Matter::setBiasForces ( const AtomMatrix & bf)

Definition at line 406 of file Matter.cpp.

406 {
407 impl_->biasForces = bf.array() * getFree().array();
408}

◆ setBiasPotential()

void eonc::Matter::setBiasPotential ( BondBoost * bondBoost)

Definition at line 394 of file Matter.cpp.

394 {
395 biasPotential = bondBoost;
396}

◆ setCell()

void eonc::Matter::setCell ( const Matrix3d & newCell)

Definition at line 277 of file Matter.cpp.

277 {
278 impl_->cell = newCell;
279 impl_->cellInverse = impl_->cell.inverse();
280 recomputePotential = true;
282}

◆ setComputedPotential()

void eonc::Matter::setComputedPotential ( double energy,
double variance )

Set energy/variance from external batched evaluation and mark forces as up-to-date (recomputePotential = false).

Definition at line 772 of file Matter.cpp.

772 {
773 potentialEnergy = energy;
774 energyVariance = variance;
775 recomputePotential = false;
777 forceCalls++;
778
779 // Apply the same net force removal as computePotential()
780 if (impl_->isFixed.maxCoeff() < 0.5 && removeNetForce && nAtoms > 1) {
781 Vector3d tempForce = impl_->forces.colwise().sum() / nAtoms;
782 for (long int i = 0; i < nAtoms; i++) {
783 impl_->forces.row(i) -= tempForce.transpose();
784 }
785 }
786}

◆ setEvaluation()

void eonc::Matter::setEvaluation ( const AtomMatrix & forces,
double energy )
inline

Puts a known evaluation back after a position reset: the forces and energy of a geometry this object held before, so no potential call follows.

Fixed-atom masking applies on read as for any evaluation.

Definition at line 219 of file Matter.h.

219 {
220 restoreFileForces(forces, true, energy);
221 }
void restoreFileForces(const AtomMatrix &fileForces, bool trustEnergy, double energy)
Write .con forces without the fixed-atom mask setForces applies.
Definition Matter.cpp:834

◆ setFileToMatter()

void eonc::Matter::setFileToMatter ( std::vector< long > map)
inline

Definition at line 300 of file Matter.h.

300{ fileToMatter = std::move(map); }

◆ setFixed() [1/2]

void eonc::Matter::setFixed ( long int atom,
int axis,
int isFixed )

Set one Cartesian axis. axis is 0=x, 1=y, 2=z.

Definition at line 537 of file Matter.cpp.

537 {
538 checkAtom(nAtoms, indexAtom, "Matter::setFixed");
539 checkAxis(axis, "Matter::setFixed");
540 impl_->isFixed(indexAtom, axis) = isFixed_passed ? 1.0 : 0.0;
541 recomputeFreeMask = true;
543}

◆ setFixed() [2/2]

void eonc::Matter::setFixed ( long int atom,
int isFixed )

Broadcast a whole-atom flag onto all three axes.

Definition at line 527 of file Matter.cpp.

527 {
528 checkAtom(nAtoms, indexAtom, "Matter::setFixed");
529 const double v = isFixed_passed ? 1.0 : 0.0;
530 impl_->isFixed(indexAtom, 0) = v;
531 impl_->isFixed(indexAtom, 1) = v;
532 impl_->isFixed(indexAtom, 2) = v;
533 recomputeFreeMask = true;
535}

◆ setFixedMask()

void eonc::Matter::setFixedMask ( long int atom,
std::array< bool, 3 > mask )

Definition at line 545 of file Matter.cpp.

545 {
546 checkAtom(nAtoms, indexAtom, "Matter::setFixedMask");
547 impl_->isFixed(indexAtom, 0) = mask[0] ? 1.0 : 0.0;
548 impl_->isFixed(indexAtom, 1) = mask[1] ? 1.0 : 0.0;
549 impl_->isFixed(indexAtom, 2) = mask[2] ? 1.0 : 0.0;
550 recomputeFreeMask = true;
552}

◆ setForces()

void eonc::Matter::setForces ( const AtomMatrix & f)

Definition at line 732 of file Matter.cpp.

732 {
733 impl_->forces = f.array() * getFree().array();
734 impl_->maskedForces = impl_->forces;
735 recomputeMaskedForces = false;
736 recomputePotential = false;
737}

◆ setHeaderCon()

void eonc::Matter::setHeaderCon ( const std::array< std::string, 5 > & headers)
inline

Definition at line 306 of file Matter.h.

306 {
307 headerCon = headers;
308 }

◆ setHeaderConLine()

void eonc::Matter::setHeaderConLine ( size_t i,
std::string line )
inline

Definition at line 309 of file Matter.h.

309 {
310 headerCon.at(i) = std::move(line);
311 }

◆ setMass()

void eonc::Matter::setMass ( long int atom,
double mass )

Definition at line 483 of file Matter.cpp.

483 {
484 checkAtom(nAtoms, indexAtom, "Matter::setMass");
485 impl_->masses[indexAtom] = mass;
486}

◆ setMasses()

void eonc::Matter::setMasses ( const VectorXd & massesIn)

Definition at line 488 of file Matter.cpp.

488 {
489 if (massesIn.size() != nAtoms) {
490 throw std::invalid_argument("Matter::setMasses: size mismatch");
491 }
492 impl_->masses = massesIn;
493}

◆ setPbcConvention()

void eonc::Matter::setPbcConvention ( PbcConvention convention)
inline

Definition at line 178 of file Matter.h.

178 {
179 pbcConvention = convention;
180 }

◆ setPeriodic()

void eonc::Matter::setPeriodic ( bool periodic)
inline

Definition at line 316 of file Matter.h.

316 {
317 usePeriodicBoundaries = periodic;
318 recomputePotential = true;
320 }

◆ setPosition()

void eonc::Matter::setPosition ( long int atom,
int axis,
double position )

Definition at line 290 of file Matter.cpp.

290 {
291 checkAtom(nAtoms, indexAtom, "Matter::setPosition");
292 checkAxis(axis, "Matter::setPosition");
293 impl_->positions(indexAtom, axis) = position;
296 }
297 recomputePotential = true;
299}

◆ setPositions()

void eonc::Matter::setPositions ( const AtomMatrix & pos)

Definition at line 350 of file Matter.cpp.

350 {
351 if (pos.rows() != nAtoms) {
352 throw std::invalid_argument("Matter::setPositions: row count mismatch");
353 }
354 impl_->positions = pos;
357 }
358 recomputePotential = true;
360}

◆ setPositionsFree()

void eonc::Matter::setPositionsFree ( const AtomMatrix & pos)

Definition at line 367 of file Matter.cpp.

367 {
368 getFree(); // ensure freeIndices is up to date
369 for (size_t j = 0; j < freeIndices.size(); j++) {
370 impl_->positions.row(freeIndices[j]) = pos.row(static_cast<long>(j));
371 }
372 // Optimizers write free-atom coords only (TIP4P/SPCE and any PBC pot).
373 // Match setPositions: wrap the full configuration when PBC is on (#171).
376 }
377 recomputePotential = true;
379}

◆ setPositionsFreeV()

void eonc::Matter::setPositionsFreeV ( const VectorXd & pos)

Definition at line 381 of file Matter.cpp.

381 {
382 setPositionsFree(AtomMatrix::Map(pos.data(), numberOfFreeAtoms(), 3));
383}
void setPositionsFree(const AtomMatrix &pos)
Definition Matter.cpp:367

◆ setPositionsV()

void eonc::Matter::setPositionsV ( const VectorXd & pos)

Definition at line 363 of file Matter.cpp.

363 {
364 setPositions(AtomMatrix::Map(pos.data(), numberOfAtoms(), 3));
365}
void setPositions(const AtomMatrix &pos)
Definition Matter.cpp:350

◆ setPotential()

void eonc::Matter::setPotential ( std::shared_ptr< Potential > pot)

Definition at line 754 of file Matter.cpp.

754 {
755 this->potential = pot;
756 // Molecular QM backends (NWChem/ORCA) must not use PBC wraps (#188). Auto-off
757 // with a hard fail if code later forces PBC while this pot is attached.
758 if (potential && potential->requiresIsolatedMoleculeLayout() &&
760 usePeriodicBoundaries = false;
761 // Use EONC_LOG_* (not bare QUILL_LOG_* with eonc::log::get() as arg): the
762 // quill macros expand logger->… and choke on a call expression as the first
763 // macro argument on some GCC versions (CI: expected primary-expression).
765 "Disabled PBC for isolated-molecule potential (NWChem/ORCA-class); "
766 "re-enabling PBC will throw (issue #188)");
767 }
768 recomputePotential = true;
770}
#define EONC_LOG_WARNING(...)
Definition EonLogger.h:255

◆ setVelocities()

void eonc::Matter::setVelocities ( const AtomMatrix & v)

Definition at line 728 of file Matter.cpp.

728 {
729 impl_->velocities = v.array() * getFree().array();
730}

◆ setVelocity()

void eonc::Matter::setVelocity ( long int atom,
int axis,
double velocity )

Definition at line 301 of file Matter.cpp.

301 {
302 checkAtom(nAtoms, indexAtom, "Matter::setVelocity");
303 checkAxis(axis, "Matter::setVelocity");
304 impl_->velocities(indexAtom, axis) = vel;
305}

◆ takeMovieFrames()

std::vector< readcon::ConFrame > eonc::Matter::takeMovieFrames ( )
inlinenodiscard

Take ownership of retained frames (leaves storage empty).

Definition at line 134 of file Matter.h.

134 {
135 return std::move(movie_frames_);
136 }

◆ writeTibble()

io::IoStatus eonc::Matter::writeTibble ( std::string filename)
inlinenodiscard

Definition at line 253 of file Matter.h.

253 {
254 return io::writeTibble(*this, filename);
255 }
IoStatus writeTibble(Matter &m, std::string fname)
Debug table (positions, optional cached forces). Not a structure format.

◆ io::con2matter

io::IoStatus io::con2matter ( Matter & ,
const readcon::ConFrame & ,
io::ConFrameMetadata *  )
friend

Member Data Documentation

◆ biasPotential

BondBoost* eonc::Matter::biasPotential {nullptr}
private

Definition at line 366 of file Matter.h.

366{nullptr};

◆ energyVariance

double eonc::Matter::energyVariance
mutableprivate

Definition at line 374 of file Matter.h.

◆ fileToMatter

std::vector<long> eonc::Matter::fileToMatter
private

Definition at line 367 of file Matter.h.

◆ forceCalls

long eonc::Matter::forceCalls
mutableprivate

Definition at line 346 of file Matter.h.

◆ freeIndices

std::vector<int> eonc::Matter::freeIndices
mutableprivate

Definition at line 371 of file Matter.h.

◆ headerCon

std::array<std::string, 5> eonc::Matter::headerCon
private

Definition at line 349 of file Matter.h.

◆ impl_

std::unique_ptr<Impl> eonc::Matter::impl_
private

Definition at line 365 of file Matter.h.

◆ m_log

eonc::log::Scoped eonc::Matter::m_log
private

Definition at line 335 of file Matter.h.

◆ movie_frames_

std::vector<readcon::ConFrame> eonc::Matter::movie_frames_
private

Definition at line 375 of file Matter.h.

◆ nAtoms

long eonc::Matter::nAtoms
private

Definition at line 361 of file Matter.h.

◆ parameters

const Parameters* eonc::Matter::parameters
private

Definition at line 360 of file Matter.h.

◆ pbcConvention

PbcConvention eonc::Matter::pbcConvention
private

Definition at line 342 of file Matter.h.

◆ potential

std::shared_ptr<Potential> eonc::Matter::potential
private

Definition at line 337 of file Matter.h.

◆ potentialEnergy

double eonc::Matter::potentialEnergy
mutableprivate

Definition at line 376 of file Matter.h.

◆ recomputeFreeMask

bool eonc::Matter::recomputeFreeMask {true}
mutableprivate

Definition at line 372 of file Matter.h.

372{true};

◆ recomputeMaskedForces

bool eonc::Matter::recomputeMaskedForces {true}
mutableprivate

Definition at line 373 of file Matter.h.

373{true};

◆ recomputePotential

bool eonc::Matter::recomputePotential
mutableprivate

Definition at line 343 of file Matter.h.

◆ removeNetForce

bool eonc::Matter::removeNetForce {true}
private

Definition at line 357 of file Matter.h.

357{true};

◆ structComp

StructureComparisonOptions eonc::Matter::structComp
private

Definition at line 358 of file Matter.h.

◆ usePeriodicBoundaries

bool eonc::Matter::usePeriodicBoundaries
private

Definition at line 338 of file Matter.h.


The documentation for this class was generated from the following files:
  • /home/runner/work/eOn/eOn/include/eon/Matter.h
  • /home/runner/work/eOn/eOn/client/Matter.cpp