SSAGES  0.8.5
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | Private Attributes | List of all members
SSAGES::Snapshot Class Reference

Class containing a snapshot of the current simulation in time. More...

#include <Snapshot.h>

Public Member Functions

 Snapshot (const MPI_Comm &comm, unsigned int wid)
 Constructor. More...
 
size_t GetIteration () const
 Get the current iteration. More...
 
size_t GetTargetIterations () const
 Get target iterations. More...
 
double GetTemperature () const
 Get current temperature. More...
 
double GetEnergy () const
 Get per-particle energy. More...
 
const Matrix3GetHMatrix () const
 Get system H-matrix. More...
 
const Matrix3GetVirial () const
 Get box virial. More...
 
Matrix3GetVirial ()
 Get box virial. More...
 
const Vector3GetOrigin () const
 Get origin of the system. More...
 
const Bool3IsPeriodic () const
 Get periodicity of three dimensions. More...
 
double GetVolume () const
 Get system volume. More...
 
double GetKb () const
 Get system Kb. More...
 
double GetDielectric () const
 Get dielectric constant. More...
 
double Getqqrd2e () const
 Get qqrd2e value. More...
 
const mxx::comm & GetCommunicator () const
 Get communicator for walker. More...
 
unsigned GetWalkerID () const
 Get walker ID. More...
 
unsigned GetNumAtoms () const
 Get number of atoms in this snapshot. More...
 
void SetIteration (size_t iteration)
 Set the iteration. More...
 
void SetTargetIterations (int target)
 Set target iterations. More...
 
void SetTemperature (double temperature)
 Change the temperature. More...
 
void SetEnergy (double energy)
 Change the energy. More...
 
void SetHMatrix (const Matrix3 &hmat)
 Change the Box H-matrix. More...
 
void SetVirial (const Matrix3 &virial)
 Change the box virial. More...
 
void SetOrigin (const Vector3 &origin)
 Change the box origin. More...
 
void SetPeriodicity (const Bool3 &isperiodic)
 Change the periodicity of the system. More...
 
void SetKb (double kb)
 Change the kb. More...
 
void SetDielectric (double dielectric)
 Set the dielectric constant. More...
 
void Setqqrd2e (double qqrd2e)
 Set the value for qqrd2e. More...
 
void SetNumAtoms (unsigned int natoms)
 Set number of atoms in this snapshot. More...
 
const std::vector< Vector3 > & GetPositions () const
 Access the particle positions. More...
 
std::vector< Vector3 > & GetPositions ()
 Access the particle positions. More...
 
const std::vector< Integer3 > & GetImageFlags () const
 Access the particles image flags. More...
 
std::vector< Integer3 > & GetImageFlags ()
 Access the particles image flags. More...
 
const std::vector< Vector3 > & GetVelocities () const
 Access the particle velocities. More...
 
std::vector< Vector3 > & GetVelocities ()
 Access the particle velocities. More...
 
const std::vector< Vector3 > & GetForces () const
 Access the per-particle forces. More...
 
std::vector< Vector3 > & GetForces ()
 Access the per-particle forces. More...
 
const std::vector< double > & GetMasses () const
 Const access to the particle masses. More...
 
std::vector< double > & GetMasses ()
 Const access to the particle masses. More...
 
Vector3 ScaleVector (const Vector3 &v) const
 Scale a vector into fractional coordinates. More...
 
Vector3 UnwrapVector (const Vector3 &v, const Integer3 &image) const
 Unwrap a vector's real coordinates according to its image replica count. More...
 
void ApplyMinimumImage (Vector3 *v) const
 Apply minimum image to a vector. More...
 
Vector3 ApplyMinimumImage (const Vector3 &v) const
 Apply minimum image to a vector. More...
 
double TotalMass (const Label &indices) const
 Compute the total mass of a group of particles based on index. More...
 
Vector3 CenterOfMass (const Label &indices) const
 
Vector3 CenterOfMass (const Label &indices, double mtot) const
 
std::vector< Vector3UnwrapPositions (const Label &indices) const
 Unwrap the particle positions, based on first position. More...
 
const LabelGetAtomIDs () const
 Access the atom IDs. More...
 
LabelGetAtomIDs ()
 Access the atom IDs. More...
 
int GetLocalIndex (int id) const
 Gets the local atom index corresponding to an atom ID. More...
 
void GetLocalIndices (const Label &ids, Label *indices) const
 
const std::vector< double > & GetCharges () const
 Access the atom charges. More...
 
std::vector< double > & GetCharges ()
 Access the atom charges. More...
 
const LabelGetAtomTypes () const
 Access the atom types. More...
 
LabelGetAtomTypes ()
 Access the atom types. More...
 
const std::vector< std::vector< double > > & GetSigmas () const
 Access the atom sigmas. More...
 
std::vector< std::vector< double > > & GetSigmas ()
 Access the atom sigmas. More...
 
const std::string & GetSnapshotID () const
 Access the snapshot ID. More...
 
std::string & GetSnapshotID ()
 Access the snapshot ID. More...
 
bool HasChanged () const
 Query if Snapshot was modified. More...
 
void Changed (bool state)
 Set the "changed" flag of the Snapshot. More...
 
std::vector< double > SerializePositions ()
 Return the serialized positions across all local cores. More...
 
std::vector< double > SerializeVelocities ()
 Return the serialized velocities across all local cores. More...
 
std::vector< int > SerializeIDs ()
 Return the serialized IDs across all local cores. More...
 
 ~Snapshot ()
 Destructor.
 

Private Attributes

mxx::comm comm_
 Local snapshot (walker) communicator.
 
unsigned int wid_
 Walker ID.
 
unsigned int nlocal_
 Number of atoms located on this snapshot.
 
std::string ID_
 ID string.
 
Matrix3 H_
 Parrinello-Rahman box H-matrix.
 
Matrix3 Hinv_
 Parinello-Rahman box inverse.
 
Matrix3 virial_
 Virial tensor.
 
Vector3 origin_
 Box origin.
 
Bool3 isperiodic_
 Periodicity of box.
 
std::vector< Vector3positions_
 Positions.
 
std::vector< Integer3images_
 Unwrapped positions.
 
std::vector< Vector3velocities_
 Velocities.
 
std::vector< Vector3forces_
 Forces.
 
std::vector< double > masses_
 Masses.
 
std::vector< double > charges_
 Charges.
 
Label atomids_
 List of Atom IDs.
 
Label types_
 List of Atom types.
 
std::vector< std::vector< double > > sigma_
 Sigma.
 
size_t iteration_
 Iteration of Simulation.
 
size_t targetiter_
 Iteration target of simulation.
 
double temperature_
 Current temperature.
 
double energy_
 Average per-particle energy.
 
double kb_
 Kb from the MD driver.
 
double dielectric_
 Dielectric.
 
double qqrd2e_
 qqrd2e
 
bool changed_
 TRUE is Simulation state changed
 

Detailed Description

Class containing a snapshot of the current simulation in time.

This contains information on the particle positions, velocities, etc... and additional information on the state of the system.

Definition at line 47 of file Snapshot.h.

Constructor & Destructor Documentation

SSAGES::Snapshot::Snapshot ( const MPI_Comm &  comm,
unsigned int  wid 
)
inline

Constructor.

Parameters
commMPI communicator
widWalker ID

Initialize a snapshot with MPI communicator and a correpsonding walker ID.

Definition at line 96 of file Snapshot.h.

References atomids_, energy_, forces_, images_, isperiodic_, iteration_, kb_, masses_, positions_, temperature_, types_, and velocities_.

96  :
97  comm_(comm), wid_(wid), H_(), Hinv_(), virial_(Matrix3::Zero()),
98  origin_({0,0,0}), isperiodic_({true, true, true}), positions_(0),
99  images_(0), velocities_(0), forces_(0), masses_(0), atomids_(0),
100  types_(0), iteration_(0), temperature_(0), energy_(0), kb_(0)
101  {}
std::vector< Integer3 > images_
Unwrapped positions.
Definition: Snapshot.h:68
std::vector< Vector3 > forces_
Forces.
Definition: Snapshot.h:70
size_t iteration_
Iteration of Simulation.
Definition: Snapshot.h:77
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58
double kb_
Kb from the MD driver.
Definition: Snapshot.h:81
std::vector< Vector3 > positions_
Positions.
Definition: Snapshot.h:67
Matrix3 Hinv_
Parinello-Rahman box inverse.
Definition: Snapshot.h:59
double energy_
Average per-particle energy.
Definition: Snapshot.h:80
double temperature_
Current temperature.
Definition: Snapshot.h:79
Matrix3 virial_
Virial tensor.
Definition: Snapshot.h:61
Bool3 isperiodic_
Periodicity of box.
Definition: Snapshot.h:65
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
std::vector< double > masses_
Masses.
Definition: Snapshot.h:71
Label types_
List of Atom types.
Definition: Snapshot.h:74
std::vector< Vector3 > velocities_
Velocities.
Definition: Snapshot.h:69
unsigned int wid_
Walker ID.
Definition: Snapshot.h:53
Vector3 origin_
Box origin.
Definition: Snapshot.h:63
Label atomids_
List of Atom IDs.
Definition: Snapshot.h:73

Member Function Documentation

void SSAGES::Snapshot::ApplyMinimumImage ( Vector3 v) const
inline

Apply minimum image to a vector.

Parameters
vVector of interest

Definition at line 422 of file Snapshot.h.

References SSAGES::roundf().

Referenced by CenterOfMass(), SSAGES::AngleCV::Evaluate(), SSAGES::TorsionalCV::Evaluate(), SSAGES::PairwiseCV::Evaluate(), SSAGES::ParticlePositionCV::Evaluate(), SSAGES::RouseModeCV::Evaluate(), SSAGES::GyrationTensorCV::Evaluate(), SSAGES::ParticleSeparationCV::Evaluate(), and UnwrapPositions().

423  {
424  Vector3 scaled = Hinv_*(*v);
425 
426  for(int i = 0; i < 3; ++i)
427  scaled[i] -= isperiodic_[i]*roundf(scaled[i]);
428 
429  *v = H_*scaled;
430  }
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58
Matrix3 Hinv_
Parinello-Rahman box inverse.
Definition: Snapshot.h:59
Bool3 isperiodic_
Periodicity of box.
Definition: Snapshot.h:65
double roundf(double x)
Quick helper function to round a double.
Definition: Snapshot.h:35
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33

Here is the call graph for this function:

Here is the caller graph for this function:

Vector3 SSAGES::Snapshot::ApplyMinimumImage ( const Vector3 v) const
inline

Apply minimum image to a vector.

Parameters
vVector of interest
Returns
Return new vector.

Definition at line 437 of file Snapshot.h.

References SSAGES::roundf().

438  {
439  Vector3 scaled = Hinv_*v;
440 
441  for(int i = 0; i < 3; ++i)
442  scaled[i] -= isperiodic_[i]*roundf(scaled[i]);
443 
444  return H_*scaled;
445  }
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58
Matrix3 Hinv_
Parinello-Rahman box inverse.
Definition: Snapshot.h:59
Bool3 isperiodic_
Periodicity of box.
Definition: Snapshot.h:65
double roundf(double x)
Quick helper function to round a double.
Definition: Snapshot.h:35
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33

Here is the call graph for this function:

Vector3 SSAGES::Snapshot::CenterOfMass ( const Label indices) const
inline

Compute center of mass of a group of atoms based on idex with provided Total mass.

Parameters
indicesIDs of particles of interest.
Returns
Vector3 Center of mass of particles.

Definition at line 470 of file Snapshot.h.

References TotalMass().

Referenced by SSAGES::ParticleCoordinateCV::Evaluate(), SSAGES::ParticlePositionCV::Evaluate(), SSAGES::RouseModeCV::Evaluate(), SSAGES::GyrationTensorCV::Evaluate(), and SSAGES::ParticleSeparationCV::Evaluate().

471  {
472  // Get total mass.
473  auto mtot = TotalMass(indices);
474 
475  return CenterOfMass(indices, mtot);
476  }
double TotalMass(const Label &indices) const
Compute the total mass of a group of particles based on index.
Definition: Snapshot.h:455
Vector3 CenterOfMass(const Label &indices) const
Definition: Snapshot.h:470

Here is the call graph for this function:

Here is the caller graph for this function:

Vector3 SSAGES::Snapshot::CenterOfMass ( const Label indices,
double  mtot 
) const
inline

Compute center of mass of a group of atoms based on idex with provided Total mass.

Parameters
indicesIDs of particles of interest.
mtotTotal mass of particle group.
Returns
Vector3 Center of mass of particles.
Note
Each processor passes in the local indices of the atoms of interest and this function will collect the data and compute the center of mass.

Definition at line 487 of file Snapshot.h.

References ApplyMinimumImage(), and comm_.

488  {
489  // Store coorinates and masses in vectors to gather.
490  std::vector<double> pos, mass, gpos, gmass;
491  std::vector<int> pcounts(comm_.size(), 0), mcounts(comm_.size(), 0);
492  std::vector<int> pdispls(comm_.size()+1, 0), mdispls(comm_.size()+1, 0);
493 
494  pcounts[comm_.rank()] = 3*indices.size();
495  mcounts[comm_.rank()] = indices.size();
496 
497  // Reduce counts.
498  MPI_Allreduce(MPI_IN_PLACE, pcounts.data(), pcounts.size(), MPI_INT, MPI_SUM, comm_);
499  MPI_Allreduce(MPI_IN_PLACE, mcounts.data(), mcounts.size(), MPI_INT, MPI_SUM, comm_);
500 
501  // Compute displacements.
502  std::partial_sum(pcounts.begin(), pcounts.end(), pdispls.begin() + 1);
503  std::partial_sum(mcounts.begin(), mcounts.end(), mdispls.begin() + 1);
504 
505  // Fill up mass and position vectors.
506  for(auto& idx : indices)
507  {
508  auto& p = positions_[idx];
509  pos.push_back(p[0]);
510  pos.push_back(p[1]);
511  pos.push_back(p[2]);
512  mass.push_back(masses_[idx]);
513  }
514 
515  // Re-size receiving vectors.
516  gpos.resize(pdispls.back(), 0);
517  gmass.resize(mdispls.back(), 0);
518 
519  // All-gather data.
520  MPI_Allgatherv(pos.data(), pos.size(), MPI_DOUBLE, gpos.data(), pcounts.data(), pdispls.data(), MPI_DOUBLE, comm_);
521  MPI_Allgatherv(mass.data(), mass.size(), MPI_DOUBLE, gmass.data(), mcounts.data(), mdispls.data(), MPI_DOUBLE, comm_);
522 
523  // Loop through atoms and compute mass weighted sum.
524  // We march linearly through list and find nearest image
525  // to each successive particle to properly unwrap object.
526  Vector3 ppos = {gpos[0], gpos[1], gpos[2]}; // Previous unwrapped position.
527  Vector3 cpos = ppos;
528  Vector3 xcm = gmass[0]*cpos;
529 
530  for(size_t i = 1, j = 3; i < gmass.size(); ++i, j += 3)
531  {
532  cpos = {gpos[j], gpos[j+1], gpos[j+2]};
533  cpos = ApplyMinimumImage(cpos - ppos) + ppos;
534  xcm += gmass[i]*cpos;
535  ppos = cpos;
536  }
537 
538  return xcm/mtot;
539  }
std::vector< Vector3 > positions_
Positions.
Definition: Snapshot.h:67
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
std::vector< double > masses_
Masses.
Definition: Snapshot.h:71
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33
void ApplyMinimumImage(Vector3 *v) const
Apply minimum image to a vector.
Definition: Snapshot.h:422

Here is the call graph for this function:

void SSAGES::Snapshot::Changed ( bool  state)
inline

Set the "changed" flag of the Snapshot.

Parameters
stateState to which the "changed" flag is set

Definition at line 706 of file Snapshot.h.

Referenced by SSAGES::Hook::PostIntegrationHook(), SSAGES::Hook::PostSimulationHook(), and SSAGES::Hook::PreSimulationHook().

706 { changed_ = state; }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85

Here is the caller graph for this function:

const Label& SSAGES::Snapshot::GetAtomIDs ( ) const
inline

Access the atom IDs.

Returns
List of atom IDs

Definition at line 602 of file Snapshot.h.

References atomids_.

Referenced by SSAGES::ForwardFlux::AppendTrajectoryFile(), SSAGES::PairwiseCV::Evaluate(), SSAGES::RMSDCV::Evaluate(), SSAGES::RMSDCV::Initialize(), SSAGES::ForwardFlux::ReadFFSConfiguration(), and SSAGES::ForwardFlux::WriteFFSConfiguration().

602 { return atomids_; }
Label atomids_
List of Atom IDs.
Definition: Snapshot.h:73

Here is the caller graph for this function:

Label& SSAGES::Snapshot::GetAtomIDs ( )
inline

Access the atom IDs.

Returns
List of atom IDs

Definition at line 605 of file Snapshot.h.

References atomids_.

606  {
607  changed_ = true;
608  return atomids_;
609  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Label atomids_
List of Atom IDs.
Definition: Snapshot.h:73
const Label& SSAGES::Snapshot::GetAtomTypes ( ) const
inline

Access the atom types.

Returns
List of atom types

Definition at line 661 of file Snapshot.h.

References types_.

661 { return types_; }
Label types_
List of Atom types.
Definition: Snapshot.h:74
Label& SSAGES::Snapshot::GetAtomTypes ( )
inline

Access the atom types.

Returns
List of atom types

Definition at line 664 of file Snapshot.h.

References types_.

665  {
666  changed_ = true;
667  return types_;
668  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Label types_
List of Atom types.
Definition: Snapshot.h:74
const std::vector<double>& SSAGES::Snapshot::GetCharges ( ) const
inline

Access the atom charges.

Returns
List of atom charges

Definition at line 648 of file Snapshot.h.

References charges_.

648 { return charges_; }
std::vector< double > charges_
Charges.
Definition: Snapshot.h:72
std::vector<double>& SSAGES::Snapshot::GetCharges ( )
inline

Access the atom charges.

Returns
List of atom charges

Definition at line 651 of file Snapshot.h.

References charges_.

652  {
653  changed_ = true;
654  return charges_;
655  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< double > charges_
Charges.
Definition: Snapshot.h:72
const mxx::comm& SSAGES::Snapshot::GetCommunicator ( ) const
inline
double SSAGES::Snapshot::GetDielectric ( ) const
inline

Get dielectric constant.

Returns
dielectric constant.

Definition at line 173 of file Snapshot.h.

References dielectric_.

173 { return dielectric_; }
double dielectric_
Dielectric.
Definition: Snapshot.h:83
double SSAGES::Snapshot::GetEnergy ( ) const
inline

Get per-particle energy.

Returns
Current average per-particle energy

Definition at line 125 of file Snapshot.h.

References energy_.

125 { return energy_; }
double energy_
Average per-particle energy.
Definition: Snapshot.h:80
const std::vector<Vector3>& SSAGES::Snapshot::GetForces ( ) const
inline

Access the per-particle forces.

Returns
List of per-particle forces

Definition at line 366 of file Snapshot.h.

References forces_.

Referenced by SSAGES::ElasticBand::PostIntegration(), SSAGES::FiniteTempString::PostIntegration(), SSAGES::Swarm::PostIntegration(), SSAGES::ANN::PostIntegration(), SSAGES::Umbrella::PostIntegration(), SSAGES::Meta::PostIntegration(), SSAGES::BFS::PostIntegration(), SSAGES::ABF::PostIntegration(), and SSAGES::ForwardFlux::ReadFFSConfiguration().

366 { return forces_; }
std::vector< Vector3 > forces_
Forces.
Definition: Snapshot.h:70

Here is the caller graph for this function:

std::vector<Vector3>& SSAGES::Snapshot::GetForces ( )
inline

Access the per-particle forces.

Returns
List of per-particle forces

Definition at line 369 of file Snapshot.h.

References forces_.

370  {
371  changed_ = true;
372  return forces_;
373  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< Vector3 > forces_
Forces.
Definition: Snapshot.h:70
const Matrix3& SSAGES::Snapshot::GetHMatrix ( ) const
inline

Get system H-matrix.

Returns
Parrinello-Rahman H-matrix of simulation box

Definition at line 131 of file Snapshot.h.

References H_.

131 { return H_; }
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58
const std::vector<Integer3>& SSAGES::Snapshot::GetImageFlags ( ) const
inline

Access the particles image flags.

Returns
List of particle image flags

Definition at line 340 of file Snapshot.h.

References images_.

Referenced by SSAGES::RMSDCV::Evaluate().

340 { return images_; }
std::vector< Integer3 > images_
Unwrapped positions.
Definition: Snapshot.h:68

Here is the caller graph for this function:

std::vector<Integer3>& SSAGES::Snapshot::GetImageFlags ( )
inline

Access the particles image flags.

Returns
List of particle image flags

Definition at line 343 of file Snapshot.h.

References images_.

344  {
345  changed_ = true;
346  return images_;
347  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< Integer3 > images_
Unwrapped positions.
Definition: Snapshot.h:68
size_t SSAGES::Snapshot::GetIteration ( ) const
inline

Get the current iteration.

Returns
Current Iteration

Definition at line 107 of file Snapshot.h.

References iteration_.

Referenced by SSAGES::Logger::PostIntegration(), SSAGES::ANN::PostIntegration(), SSAGES::Umbrella::PostIntegration(), SSAGES::Meta::PostIntegration(), SSAGES::BFS::PostIntegration(), and SSAGES::Hook::PostIntegrationHook().

107 {return iteration_; }
size_t iteration_
Iteration of Simulation.
Definition: Snapshot.h:77

Here is the caller graph for this function:

double SSAGES::Snapshot::GetKb ( ) const
inline

Get system Kb.

Returns
Kb of the current simulation box

Definition at line 167 of file Snapshot.h.

References kb_.

Referenced by SSAGES::BFS::PostIntegration(), and SSAGES::ANN::PreSimulation().

167 { return kb_; }
double kb_
Kb from the MD driver.
Definition: Snapshot.h:81

Here is the caller graph for this function:

int SSAGES::Snapshot::GetLocalIndex ( int  id) const
inline

Gets the local atom index corresponding to an atom ID.

Parameters
idAtom ID.
Returns
Local atom index or -1 if not found.

Definition at line 616 of file Snapshot.h.

Referenced by SSAGES::AngleCV::Evaluate(), SSAGES::TorsionalCV::Evaluate(), SSAGES::PairwiseCV::Evaluate(), SSAGES::AlphaRMSDCV::Evaluate(), SSAGES::AntiBetaRMSDCV::Evaluate(), SSAGES::ParallelBetaRMSDCV::Evaluate(), GetLocalIndices(), SSAGES::PairwiseCV::Initialize(), SSAGES::ParticleCoordinateCV::Initialize(), SSAGES::RouseModeCV::Initialize(), SSAGES::ParticleSeparationCV::Initialize(), SSAGES::ParticlePositionCV::Initialize(), SSAGES::GyrationTensorCV::Initialize(), SSAGES::FiniteTempString::PostIntegration(), and SSAGES::Swarm::PostIntegration().

617  {
618 
619  auto s = std::find(atomids_.begin(), atomids_.end(), id);
620  if(s == atomids_.end())
621  return -1;
622  else
623  return s - atomids_.begin();
624  }
Label atomids_
List of Atom IDs.
Definition: Snapshot.h:73

Here is the caller graph for this function:

void SSAGES::Snapshot::GetLocalIndices ( const Label ids,
Label indices 
) const
inline

Gets the local atom indices corresponding to atom IDs in the vector.

Parameters
idsVector of atom ID's.
indicesPointer to container for local atom indices.
Note
If atom does not exist on processor, it will be ignored.

Definition at line 634 of file Snapshot.h.

References GetLocalIndex().

Referenced by SSAGES::ParticleCoordinateCV::Evaluate(), SSAGES::PairwiseCV::Evaluate(), SSAGES::ParticlePositionCV::Evaluate(), SSAGES::RouseModeCV::Evaluate(), SSAGES::GyrationTensorCV::Evaluate(), SSAGES::ParticleSeparationCV::Evaluate(), SSAGES::AngleCV::Initialize(), SSAGES::TorsionalCV::Initialize(), SSAGES::AlphaRMSDCV::Initialize(), SSAGES::AntiBetaRMSDCV::Initialize(), SSAGES::ParallelBetaRMSDCV::Initialize(), and SSAGES::RouseModeCV::setMasses().

635  {
636  for(auto& id : ids)
637  {
638  auto idx = GetLocalIndex(id);
639  if(idx != -1)
640  indices->push_back(idx);
641  }
642  }
int GetLocalIndex(int id) const
Gets the local atom index corresponding to an atom ID.
Definition: Snapshot.h:616

Here is the call graph for this function:

Here is the caller graph for this function:

const std::vector<double>& SSAGES::Snapshot::GetMasses ( ) const
inline

Const access to the particle masses.

Returns
List of Masses

Note that the Masses can be either stored as per-atom or per-type depending on the Lammps Atom type used.

Definition at line 382 of file Snapshot.h.

References masses_.

Referenced by SSAGES::ParticleCoordinateCV::Evaluate(), SSAGES::ParticlePositionCV::Evaluate(), SSAGES::RouseModeCV::Evaluate(), SSAGES::GyrationTensorCV::Evaluate(), SSAGES::ParticleSeparationCV::Evaluate(), SSAGES::RMSDCV::Evaluate(), SSAGES::RMSDCV::Initialize(), and SSAGES::ABF::PostIntegration().

382 { return masses_; }
std::vector< double > masses_
Masses.
Definition: Snapshot.h:71

Here is the caller graph for this function:

std::vector<double>& SSAGES::Snapshot::GetMasses ( )
inline

Const access to the particle masses.

Returns
List of Masses

Note that the Masses can be either stored as per-atom or per-type depending on the Lammps Atom type used.

Definition at line 385 of file Snapshot.h.

References masses_.

386  {
387  changed_ = true;
388  return masses_;
389  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< double > masses_
Masses.
Definition: Snapshot.h:71
unsigned SSAGES::Snapshot::GetNumAtoms ( ) const
inline
const Vector3& SSAGES::Snapshot::GetOrigin ( ) const
inline

Get origin of the system.

Returns
Vector containing coordinates of box origin.

Definition at line 149 of file Snapshot.h.

References origin_.

149 { return origin_; }
Vector3 origin_
Box origin.
Definition: Snapshot.h:63
const std::vector<Vector3>& SSAGES::Snapshot::GetPositions ( ) const
inline
std::vector<Vector3>& SSAGES::Snapshot::GetPositions ( )
inline

Access the particle positions.

Returns
List of particle positions

Definition at line 330 of file Snapshot.h.

References positions_.

331  {
332  changed_ = true;
333  return positions_;
334  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< Vector3 > positions_
Positions.
Definition: Snapshot.h:67
double SSAGES::Snapshot::Getqqrd2e ( ) const
inline

Get qqrd2e value.

Returns
Value of qqrd2e.

Definition at line 179 of file Snapshot.h.

References qqrd2e_.

179 { return qqrd2e_; }
double qqrd2e_
qqrd2e
Definition: Snapshot.h:84
const std::vector<std::vector<double> >& SSAGES::Snapshot::GetSigmas ( ) const
inline

Access the atom sigmas.

Returns
List of atom sigmas

Definition at line 674 of file Snapshot.h.

References sigma_.

674 { return sigma_; }
std::vector< std::vector< double > > sigma_
Sigma.
Definition: Snapshot.h:75
std::vector<std::vector<double> >& SSAGES::Snapshot::GetSigmas ( )
inline

Access the atom sigmas.

Returns
List of atom sigmas

Definition at line 677 of file Snapshot.h.

References sigma_.

678  {
679  changed_ = true;
680  return sigma_;
681  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< std::vector< double > > sigma_
Sigma.
Definition: Snapshot.h:75
const std::string& SSAGES::Snapshot::GetSnapshotID ( ) const
inline

Access the snapshot ID.

Returns
Snapshot ID

Definition at line 687 of file Snapshot.h.

References ID_.

687 { return ID_; }
std::string ID_
ID string.
Definition: Snapshot.h:56
std::string& SSAGES::Snapshot::GetSnapshotID ( )
inline

Access the snapshot ID.

Returns
Snapshot ID

Definition at line 690 of file Snapshot.h.

References ID_.

691  {
692  changed_ = true;
693  return ID_;
694  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::string ID_
ID string.
Definition: Snapshot.h:56
size_t SSAGES::Snapshot::GetTargetIterations ( ) const
inline

Get target iterations.

Returns
Target Iterations

Definition at line 113 of file Snapshot.h.

References targetiter_.

Referenced by SSAGES::Meta::PreSimulation().

113 {return targetiter_; }
size_t targetiter_
Iteration target of simulation.
Definition: Snapshot.h:78

Here is the caller graph for this function:

double SSAGES::Snapshot::GetTemperature ( ) const
inline

Get current temperature.

Returns
System temperature

Definition at line 119 of file Snapshot.h.

References temperature_.

119 {return temperature_; }
double temperature_
Current temperature.
Definition: Snapshot.h:79
const std::vector<Vector3>& SSAGES::Snapshot::GetVelocities ( ) const
inline

Access the particle velocities.

Returns
List of particle velocities

Definition at line 353 of file Snapshot.h.

References velocities_.

Referenced by SSAGES::ForwardFlux::AppendTrajectoryFile(), SSAGES::Swarm::PostIntegration(), SSAGES::ABF::PostIntegration(), SSAGES::ForwardFlux::ReadFFSConfiguration(), and SSAGES::ForwardFlux::WriteFFSConfiguration().

353 { return velocities_; }
std::vector< Vector3 > velocities_
Velocities.
Definition: Snapshot.h:69

Here is the caller graph for this function:

std::vector<Vector3>& SSAGES::Snapshot::GetVelocities ( )
inline

Access the particle velocities.

Returns
List of particle velocities

Definition at line 356 of file Snapshot.h.

References velocities_.

357  {
358  changed_ = true;
359  return velocities_;
360  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
std::vector< Vector3 > velocities_
Velocities.
Definition: Snapshot.h:69
const Matrix3& SSAGES::Snapshot::GetVirial ( ) const
inline

Get box virial.

Returns
Virial tensor of the simulation box.

Definition at line 137 of file Snapshot.h.

References virial_.

Referenced by SSAGES::ANN::PostIntegration(), SSAGES::Umbrella::PostIntegration(), SSAGES::Meta::PostIntegration(), and SSAGES::BFS::PostIntegration().

137 { return virial_; }
Matrix3 virial_
Virial tensor.
Definition: Snapshot.h:61

Here is the caller graph for this function:

Matrix3& SSAGES::Snapshot::GetVirial ( )
inline

Get box virial.

Returns
Virial tensor of the simulation box.

Definition at line 143 of file Snapshot.h.

References virial_.

143 { return virial_; }
Matrix3 virial_
Virial tensor.
Definition: Snapshot.h:61
double SSAGES::Snapshot::GetVolume ( ) const
inline

Get system volume.

Returns
Volume of the current simulation box

Definition at line 161 of file Snapshot.h.

Referenced by SSAGES::BoxVolumeCV::Evaluate().

161 { return H_.determinant(); }
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58

Here is the caller graph for this function:

unsigned SSAGES::Snapshot::GetWalkerID ( ) const
inline

Get walker ID.

Returns
ID of the Walker

Definition at line 197 of file Snapshot.h.

References wid_.

Referenced by SSAGES::StringMethod::PreSimulation(), and SSAGES::BFS::PreSimulation().

197 { return wid_; }
unsigned int wid_
Walker ID.
Definition: Snapshot.h:53

Here is the caller graph for this function:

bool SSAGES::Snapshot::HasChanged ( ) const
inline

Query if Snapshot was modified.

Returns
True if Snapshot was modified, else return False

Definition at line 700 of file Snapshot.h.

References changed_.

Referenced by SSAGES::Hook::PostIntegrationHook(), SSAGES::Hook::PostSimulationHook(), and SSAGES::Hook::PreSimulationHook().

700 { return changed_; }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85

Here is the caller graph for this function:

const Bool3& SSAGES::Snapshot::IsPeriodic ( ) const
inline

Get periodicity of three dimensions.

Returns
Three dimensional boolean containing periodicity of each dimension.

Definition at line 155 of file Snapshot.h.

References isperiodic_.

155 {return isperiodic_; }
Bool3 isperiodic_
Periodicity of box.
Definition: Snapshot.h:65
Vector3 SSAGES::Snapshot::ScaleVector ( const Vector3 v) const
inline

Scale a vector into fractional coordinates.

Parameters
vVector of interest
Returns
Scaled vector in fractional coordinates

Definition at line 396 of file Snapshot.h.

References origin_.

397  {
398  return Hinv_*(v-origin_);
399  }
Matrix3 Hinv_
Parinello-Rahman box inverse.
Definition: Snapshot.h:59
Vector3 origin_
Box origin.
Definition: Snapshot.h:63
std::vector<int> SSAGES::Snapshot::SerializeIDs ( )
inline

Return the serialized IDs across all local cores.

Returns
IDs across all local cores.

Definition at line 783 of file Snapshot.h.

References comm_, and nlocal_.

Referenced by SSAGES::FiniteTempString::PostIntegration(), and SSAGES::Swarm::PostIntegration().

784  {
785  std::vector<int> mcounts(comm_.size(), 0);
786  std::vector<int> mdispls(comm_.size()+1, 0);
787 
788  mcounts[comm_.rank()] = nlocal_;
789 
790  // Reduce counts.
791  MPI_Allreduce(MPI_IN_PLACE, mcounts.data(), mcounts.size(), MPI_INT, MPI_SUM, comm_);
792 
793  // Compute displacements.
794  std::partial_sum(mcounts.begin(), mcounts.end(), mdispls.begin() + 1);
795 
796  // Re-size receiving vectors.
797  std::vector<int> IDs;
798  IDs.resize(mdispls.back(), 0);
799 
800  // All-gather data.
801  MPI_Allgatherv(atomids_.data(), atomids_.size(), MPI_INT, IDs.data(), mcounts.data(), mdispls.data(), MPI_INT, comm_);
802  return IDs;
803  }
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
Label atomids_
List of Atom IDs.
Definition: Snapshot.h:73
unsigned int nlocal_
Number of atoms located on this snapshot.
Definition: Snapshot.h:54

Here is the caller graph for this function:

std::vector<double> SSAGES::Snapshot::SerializePositions ( )
inline

Return the serialized positions across all local cores.

Returns
Positions across all local cores.

Definition at line 712 of file Snapshot.h.

References comm_, and nlocal_.

Referenced by SSAGES::FiniteTempString::PostIntegration(), and SSAGES::Swarm::PostIntegration().

713  {
714 
715  std::vector<int> pcounts(comm_.size(), 0);
716  std::vector<int> pdispls(comm_.size()+1, 0);
717 
718  pcounts[comm_.rank()] = 3*nlocal_;
719 
720  // Reduce counts.
721  MPI_Allreduce(MPI_IN_PLACE, pcounts.data(), pcounts.size(), MPI_INT, MPI_SUM, comm_);
722 
723  // Compute displacements.
724  std::partial_sum(pcounts.begin(), pcounts.end(), pdispls.begin() + 1);
725 
726  // Re-size receiving vectors.
727  std::vector<double> positions;
728  positions.resize(pdispls.back(), 0);
729 
730  std::vector<double> ptemp;
731 
732  for(auto& p : positions_)
733  {
734  ptemp.push_back(p[0]);
735  ptemp.push_back(p[1]);
736  ptemp.push_back(p[2]);
737  }
738 
739  // All-gather data.
740  MPI_Allgatherv(ptemp.data(), ptemp.size(), MPI_DOUBLE, positions.data(), pcounts.data(), pdispls.data(), MPI_DOUBLE, comm_);
741  return positions;
742  }
std::vector< Vector3 > positions_
Positions.
Definition: Snapshot.h:67
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
unsigned int nlocal_
Number of atoms located on this snapshot.
Definition: Snapshot.h:54

Here is the caller graph for this function:

std::vector<double> SSAGES::Snapshot::SerializeVelocities ( )
inline

Return the serialized velocities across all local cores.

Returns
Velocities across all local cores.

Definition at line 748 of file Snapshot.h.

References comm_, and nlocal_.

Referenced by SSAGES::Swarm::PostIntegration().

749  {
750  std::vector<int> vcounts(comm_.size(), 0);
751  std::vector<int> vdispls(comm_.size()+1, 0);
752 
753  vcounts[comm_.rank()] = 3*nlocal_;
754 
755  // Reduce counts.
756  MPI_Allreduce(MPI_IN_PLACE, vcounts.data(), vcounts.size(), MPI_INT, MPI_SUM, comm_);
757 
758  // Compute displacements.
759  std::partial_sum(vcounts.begin(), vcounts.end(), vdispls.begin() + 1);
760 
761  // Re-size receiving vectors.
762  std::vector<double> velocities;
763  velocities.resize(vdispls.back(), 0);
764 
765  std::vector<double> vtemp;
766 
767  for(auto& v : velocities_)
768  {
769  vtemp.push_back(v[0]);
770  vtemp.push_back(v[1]);
771  vtemp.push_back(v[2]);
772  }
773 
774  // All-gather data.
775  MPI_Allgatherv(vtemp.data(), vtemp.size(), MPI_DOUBLE, velocities.data(), vcounts.data(), vdispls.data(), MPI_DOUBLE, comm_);
776  return velocities;
777  }
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
std::vector< Vector3 > velocities_
Velocities.
Definition: Snapshot.h:69
unsigned int nlocal_
Number of atoms located on this snapshot.
Definition: Snapshot.h:54

Here is the caller graph for this function:

void SSAGES::Snapshot::SetDielectric ( double  dielectric)
inline

Set the dielectric constant.

Parameters
dielectricValue for the dielectric constant.

Definition at line 301 of file Snapshot.h.

302  {
303  dielectric_ = dielectric;
304  changed_ = true;
305  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
double dielectric_
Dielectric.
Definition: Snapshot.h:83
void SSAGES::Snapshot::SetEnergy ( double  energy)
inline

Change the energy.

Parameters
energyNew value for the energy

Definition at line 240 of file Snapshot.h.

241  {
242  energy_ = energy;
243  changed_ = true;
244  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
double energy_
Average per-particle energy.
Definition: Snapshot.h:80
void SSAGES::Snapshot::SetHMatrix ( const Matrix3 hmat)
inline

Change the Box H-matrix.

Parameters
hmatNew H-matrix for the system

Definition at line 250 of file Snapshot.h.

251  {
252  H_ = hmat;
253  Hinv_ = hmat.inverse();
254  changed_ = true;
255  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58
Matrix3 Hinv_
Parinello-Rahman box inverse.
Definition: Snapshot.h:59
void SSAGES::Snapshot::SetIteration ( size_t  iteration)
inline

Set the iteration.

Parameters
iterationNew value for the iteration

Definition at line 210 of file Snapshot.h.

211  {
212  iteration_ = iteration;
213  changed_ = true;
214  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
size_t iteration_
Iteration of Simulation.
Definition: Snapshot.h:77
void SSAGES::Snapshot::SetKb ( double  kb)
inline

Change the kb.

Parameters
kbNew value for the kb

Definition at line 291 of file Snapshot.h.

292  {
293  kb_ = kb;
294  changed_ = true;
295  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
double kb_
Kb from the MD driver.
Definition: Snapshot.h:81
void SSAGES::Snapshot::SetNumAtoms ( unsigned int  natoms)
inline

Set number of atoms in this snapshot.

Parameters
natomsNumber of atoms in this snapshot

Definition at line 321 of file Snapshot.h.

321 { nlocal_ = natoms; }
unsigned int nlocal_
Number of atoms located on this snapshot.
Definition: Snapshot.h:54
void SSAGES::Snapshot::SetOrigin ( const Vector3 origin)
inline

Change the box origin.

Parameters
originNew origin for the system

Definition at line 271 of file Snapshot.h.

272  {
273  origin_ = origin;
274  changed_ = true;
275  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Vector3 origin_
Box origin.
Definition: Snapshot.h:63
void SSAGES::Snapshot::SetPeriodicity ( const Bool3 isperiodic)
inline

Change the periodicity of the system.

Parameters
isperiodicPeriodicity of three dimensions

Definition at line 281 of file Snapshot.h.

282  {
283  isperiodic_ = isperiodic;
284  changed_ = true;
285  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Bool3 isperiodic_
Periodicity of box.
Definition: Snapshot.h:65
void SSAGES::Snapshot::Setqqrd2e ( double  qqrd2e)
inline

Set the value for qqrd2e.

Parameters
qqrd2eValue for qqrd2e.

Definition at line 311 of file Snapshot.h.

312  {
313  qqrd2e_ = qqrd2e;
314  changed_ = true;
315  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
double qqrd2e_
qqrd2e
Definition: Snapshot.h:84
void SSAGES::Snapshot::SetTargetIterations ( int  target)
inline

Set target iterations.

Parameters
targetNew value for target iterations

Definition at line 220 of file Snapshot.h.

221  {
222  targetiter_ = target;
223  changed_ = true;
224  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
size_t targetiter_
Iteration target of simulation.
Definition: Snapshot.h:78
void SSAGES::Snapshot::SetTemperature ( double  temperature)
inline

Change the temperature.

Parameters
temperatureNew value for the temperature

Definition at line 230 of file Snapshot.h.

231  {
232  temperature_ = temperature;
233  changed_ = true;
234  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
double temperature_
Current temperature.
Definition: Snapshot.h:79
void SSAGES::Snapshot::SetVirial ( const Matrix3 virial)
inline

Change the box virial.

Parameters
virialNew virial tensor for the system.

Definition at line 261 of file Snapshot.h.

262  {
263  virial_ = virial;
264  changed_ = true;
265  }
bool changed_
TRUE is Simulation state changed
Definition: Snapshot.h:85
Matrix3 virial_
Virial tensor.
Definition: Snapshot.h:61
double SSAGES::Snapshot::TotalMass ( const Label indices) const
inline

Compute the total mass of a group of particles based on index.

Parameters
indicesIDs of particles of interest.
Returns
double Total mass of particles.
Note
This function reduces the mass across the communicator associated with the snapshot.

Definition at line 455 of file Snapshot.h.

Referenced by CenterOfMass(), SSAGES::ParticleCoordinateCV::Evaluate(), SSAGES::ParticlePositionCV::Evaluate(), SSAGES::ParticleSeparationCV::Evaluate(), SSAGES::GyrationTensorCV::Evaluate(), and SSAGES::RouseModeCV::setMasses().

456  {
457  auto mtot = 0.;
458  for(auto& i : indices)
459  mtot += masses_[i];
460  MPI_Allreduce(MPI_IN_PLACE, &mtot, 1, MPI_DOUBLE, MPI_SUM, comm_);
461  return mtot;
462  }
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
std::vector< double > masses_
Masses.
Definition: Snapshot.h:71

Here is the caller graph for this function:

std::vector<Vector3> SSAGES::Snapshot::UnwrapPositions ( const Label indices) const
inline

Unwrap the particle positions, based on first position.

Parameters
indicesIDs of particles of interest.
Returns
Unwrapped particle positions.
Note
This function unwraps positions in reference to the first position.
Each processor passes in the local indices of the atoms of interest and this function will collect the data and return unwrapped coordinates.

Definition at line 549 of file Snapshot.h.

References ApplyMinimumImage(), and comm_.

550  {
551  // Store coordinates in vectors to gather.
552  std::vector<Vector3> upos;
553  std::vector<double> pos, gpos;
554  std::vector<int> pcounts(comm_.size(), 0);
555  std::vector<int> pdispls(comm_.size()+1, 0);
556 
557  pcounts[comm_.rank()] = 3*indices.size();
558 
559  // Reduce counts.
560  MPI_Allreduce(MPI_IN_PLACE, pcounts.data(), pcounts.size(), MPI_INT, MPI_SUM, comm_);
561 
562  // Compute displacements.
563  std::partial_sum(pcounts.begin(), pcounts.end(), pdispls.begin() + 1);
564 
565  // Fill up position vectors.
566  for(auto& idx : indices)
567  {
568  auto& p = positions_[idx];
569  pos.push_back(p[0]);
570  pos.push_back(p[1]);
571  pos.push_back(p[2]);
572  }
573 
574  // Re-size receiving vectors.
575  gpos.resize(pdispls.back(), 0);
576 
577  // All-gather data.
578  MPI_Allgatherv(pos.data(), pos.size(), MPI_DOUBLE, gpos.data(), pcounts.data(), pdispls.data(), MPI_DOUBLE, comm_);
579 
580  // Loop through atoms and unwrap positions.
581  // We march linearly through list and find nearest image
582  // to each successive particle to properly unwrap object.
583  Vector3 ppos = {gpos[0], gpos[1], gpos[2]}; // Previous unwrapped position.
584  Vector3 cpos = ppos;
585  upos.push_back(cpos); // Used as reference position.
586 
587  for(size_t i = 1; i < gpos.size(); ++i)
588  {
589  cpos = {gpos[3*i], gpos[3*i+1], gpos[3*i+2]};
590  cpos = ApplyMinimumImage(cpos - ppos) + ppos;
591  upos.push_back(cpos);
592  ppos = cpos;
593  }
594 
595  return upos;
596  }
std::vector< Vector3 > positions_
Positions.
Definition: Snapshot.h:67
mxx::comm comm_
Local snapshot (walker) communicator.
Definition: Snapshot.h:51
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33
void ApplyMinimumImage(Vector3 *v) const
Apply minimum image to a vector.
Definition: Snapshot.h:422

Here is the call graph for this function:

Vector3 SSAGES::Snapshot::UnwrapVector ( const Vector3 v,
const Integer3 image 
) const
inline

Unwrap a vector's real coordinates according to its image replica count.

Parameters
vVector of interest
imageInteger vector representing mirror images in the three dimensions.
Returns
Vector3 Unwrapped vector in real coordinates. This function takes a set of (wrapped) coordinates and returns the unwrapped coordinates.
Note
This function does not require the initial coordinates to be within the simulation box.

Definition at line 413 of file Snapshot.h.

Referenced by SSAGES::RMSDCV::Evaluate().

414  {
415  return H_*image.cast<double>()+v;
416  }
Matrix3 H_
Parrinello-Rahman box H-matrix.
Definition: Snapshot.h:58

Here is the caller graph for this function:


The documentation for this class was generated from the following file: