|
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 a LAMMPS data 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 data file to populate configuration data. | |
| virtual | ~BoxConfiguration () |
Public Member Functions inherited from Configuration | |
| 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, and their origins. | |
| Matrix3d | reference_box |
| Vector3d | box_origin |
| Vector3d | reference_box_origin |
| Vector3i | pbc |
Periodic boundary conditions. pbc=(1,0,1) implies periodicity along the \(x\) and \(z\)-directions. | |
Public Attributes inherited from Configuration | |
| int | numberOfParticles |
| Total number of particles in the configuration. | |
| std::vector< std::string > | species |
| Species names for each particle (size equals numberOfParticles). | |
| VectorXd | masses |
| Mass of each particle. | |
| 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), with separate origins (box_origin and reference_box_origin). Periodic boundary conditions are represented as a 3D integer vector indicating periodicity along the box-vector directions.
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. Padding creates periodic images as needed but does not fold the original atoms or grid points back into the primary cell; preserving the supplied atom identity and reference/current correspondence is the caller's responsibility.
Definition at line 37 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 19 of file BoxConfiguration.cpp.
|
virtual |
Definition at line 457 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 396 of file BoxConfiguration.cpp.
| void BoxConfiguration::lmpParser | ( | std::ifstream & | file, |
| const ConfigType & | configType | ||
| ) |
Parses a LAMMPS data 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:
xy xz yz) for triclinic cellsCoordinates are adjusted for periodic boundary conditions using image flags. Atoms are not folded into the primary MDStressLab box after reading. 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 195 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
origin ox oy oz. If absent, both reference and current origins default to (0,0,0).* <species_1> <mass_1> <species_2> <mass_2> ... *
Ar)2 origin 0.0 0.0 0.0 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 39.948 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 38 of file BoxConfiguration.cpp.
| void BoxConfiguration::readLMP | ( | const std::string & | configFileName, |
| const ConfigType & | configType | ||
| ) |
Reads a configuration from a LAMMPS data 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] | configFileName | The name of the LAMMPS data file. |
| [in] | configType | Specifies which configuration type to read (e.g., Reference or Current). |
The expected file format is a LAMMPS data file with the following structure:
24480 atoms)3 atom types)xy xz yz tilt factors for triclinic cells. The parser stores the corresponding lower corner as the box origin and builds the box vectors from the LAMMPS bounds and tilt factors.Masses section listing: Atoms section: ix, iy, iz are image flags used to unwrap atom positions.Example snippet:
Definition at line 158 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 186 of file BoxConfiguration.cpp.
| Matrix3d BoxConfiguration::box |
The current and reference box vectors stored as columns of respective matrices, and their origins.
Definition at line 42 of file BoxConfiguration.h.
| Vector3d BoxConfiguration::box_origin |
Definition at line 43 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 48 of file BoxConfiguration.h.
| Matrix3d BoxConfiguration::reference_box |
Definition at line 42 of file BoxConfiguration.h.
| Vector3d BoxConfiguration::reference_box_origin |
Definition at line 43 of file BoxConfiguration.h.