MDStressLab++
|
Represents a particle configuration including simulation box information. More...
#include <BoxConfiguration.h>
Public Member Functions | |
BoxConfiguration (int numberOfParticles, int referenceAndFinal) | |
Constructs a BoxConfiguration with a given number of particles. | |
Configuration * | getConfiguration (double padding) const |
This function returns a padded configuration by adding padding atoms originating due to pbcs. | |
void | read (std::string configFileName, int referenceAndFinal) |
A function to read the properties of atoms from a file in a MDStressLab format. | |
void | readLMP (const std::string &, const ConfigType &configType) |
Reads a configuration from an LAMMPS-style dump file. | |
void | readLMP (const std::string ¤tConfigFileName, const std::string &referenceConfigFileName) |
Reads both current and reference configurations from LAMMPS-style dump files. | |
void | lmpParser (std::ifstream &, const ConfigType &) |
Parses a LAMMPS dump file to populate configuration data. | |
virtual | ~BoxConfiguration () |
![]() | |
Configuration (int, int) | |
Constructs a Configuration object. | |
virtual | ~Configuration () |
Configuration * | getLocalConfiguration (const std::set< int > &localParticleList) const |
can be deleted | |
Public Attributes | |
Matrix3d | box |
The current and reference box vectors stored as columns of respective matrices. | |
Matrix3d | reference_box |
Vector3i | pbc |
Periodic boundary conditions. pbc=(1,0,1) implies periodicity along the \(x\) and \(z\)-directions. | |
![]() | |
int | numberOfParticles |
Total number of particles in the configuration. | |
std::vector< std::string > | species |
Species names for each particle (size equals numberOfParticles). | |
std::map< ConfigType, MatrixXd > | coordinates |
Map from configuration type (Reference or Current) to coordinate matrices. | |
MatrixXd | velocities |
Velocities of particles. | |
Represents a particle configuration including simulation box information.
This class extends the base Configuration class by adding storage for simulation box vectors (both Current and Reference) and periodic boundary conditions. It provides functionality to read configurations from MDStressLab and LAMMPS dump-style files, manage padding due to periodicity, and access box geometry details.
The box vectors are stored as columns in 3×3 matrices (box
and reference_box
), and periodic boundary conditions are represented as a 3D integer vector indicating periodicity along each Cartesian axis.
This class supports reading atomic configurations from two file formats:
It also allows extracting padded configurations to accommodate atoms near periodic boundaries, facilitating simulations requiring extended neighbor lists or replicas.
Definition at line 33 of file BoxConfiguration.h.
BoxConfiguration::BoxConfiguration | ( | int | numberOfParticles, |
int | referenceAndFinal | ||
) |
Constructs a BoxConfiguration with a given number of particles.
[in] | numberOfParticles | The number of particles in the configuration. |
[in] | referenceAndFinal | Flag indicating which configurations to allocate:
|
Definition at line 16 of file BoxConfiguration.cpp.
|
virtual |
Definition at line 322 of file BoxConfiguration.cpp.
Configuration * BoxConfiguration::getConfiguration | ( | double | padding | ) | const |
This function returns a padded configuration by adding padding atoms originating due to pbcs.
padding | - thickness of the padding region |
Definition at line 275 of file BoxConfiguration.cpp.
void BoxConfiguration::lmpParser | ( | std::ifstream & | file, |
const ConfigType & | configType | ||
) |
Parses a LAMMPS dump file to populate configuration data.
This function reads atomic configuration data, box dimensions, masses, and species information from a LAMMPS-style dump file stream, filling the relevant members of the BoxConfiguration object according to the specified configuration type.
The expected file format includes sections for:
Coordinates are adjusted for periodic boundary conditions using image flags. The function ensures species consistency between reference and current configurations.
[in,out] | file | Input file stream positioned at the beginning of the LAMMPS dump file. |
[in] | configType | The type of configuration to read (e.g., Current or Reference). |
MY_ERROR | If the number of atoms in the file does not match the expected number, or if coordinate parsing fails for any particle. |
Definition at line 125 of file BoxConfiguration.cpp.
void BoxConfiguration::read | ( | std::string | configFileName, |
int | referenceAndFinal | ||
) |
A function to read the properties of atoms from a file in a MDStressLab format.
configFileName | - Name of the configuration file to read |
referenceAndFinal | Flag indicating which data to read:
|
The MDStressLab format of the configuration file is described below
Ar
)2 52.9216036151419047 0.0 0.0 0.0 52.9216036151419047 0.0 0.0 0.0 52.9216036151419047 52.9216036151419047 0.0 0.0 0.0 53.4508196512933154 0.0 0.0 0.0 52.9216036151419047 1 1 1 Ar 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 Ar 0.0000000000000000 2.6725409825646658 2.6460801807570951 0.0000000000000000 0.0000000000000000 0.0000000000000000 0.0000000000000000 2.6460801807570951 2.6460801807570951 *
Definition at line 33 of file BoxConfiguration.cpp.
void BoxConfiguration::readLMP | ( | const std::string & | configFileName, |
const ConfigType & | configType | ||
) |
Reads a configuration from an LAMMPS-style dump file.
Opens the specified file and reads the atomic configuration data for the given configuration type (e.g., Reference or Current). This function supports only files with the .lmp
extension and delegates detailed parsing to the private method lmpParser
.
On failure to open the file or if the file extension is not .lmp
, this function prints an error message and terminates the program.
[in] | filename | The name of the LAMMPS dump file. |
[in] | configType | Specifies which configuration type to read (e.g., Reference or Current). |
The expected file format is a LAMMPS dump file with the following structure:
24480 atoms
)3 atom types
)xy xz yz
tilt factors (for triclinic cells)Masses
section listing: Atoms
section: ix
, iy
, iz
are image flags used to unwrap atom positions.Example snippet:
Definition at line 88 of file BoxConfiguration.cpp.
void BoxConfiguration::readLMP | ( | const std::string & | currentConfigFileName, |
const std::string & | referenceConfigFileName | ||
) |
Reads both current and reference configurations from LAMMPS-style dump files.
[in] | currentConfigFileName | The name of the file containing the current configuration. |
[in] | referenceConfigFileName | The name of the file containing the reference configuration. |
Definition at line 116 of file BoxConfiguration.cpp.
Matrix3d BoxConfiguration::box |
The current and reference box vectors stored as columns of respective matrices.
Definition at line 38 of file BoxConfiguration.h.
Vector3i BoxConfiguration::pbc |
Periodic boundary conditions. pbc=(1,0,1) implies periodicity along the \(x\) and \(z\)-directions.
Definition at line 43 of file BoxConfiguration.h.
Matrix3d BoxConfiguration::reference_box |
Definition at line 38 of file BoxConfiguration.h.