RASPA3 3.0.12
A molecular simulation code for computing adsorption and diffusion in nanoporous materials
|
Represents a simulation box used in simulations. More...
Public Types | |
enum class | Type : int { Rectangular = 0 , Triclinic = 1 } |
Enumeration for the type of the simulation box. | |
Public Member Functions | |
SimulationBox () | |
Default constructor for the SimulationBox class. | |
bool | operator== (SimulationBox const &) const =default |
SimulationBox (double a, double b, double c) | |
Constructs a rectangular SimulationBox with given lengths. | |
SimulationBox (double a, double b, double c, double alpha, double beta, double gamma) | |
Constructs a SimulationBox with given lengths and angles. | |
SimulationBox (double a, double b, double c, double alpha, double beta, double gamma, Type type) | |
Constructs a SimulationBox with given lengths, angles, and type. | |
SimulationBox (double3x3 m) | |
Constructs a SimulationBox with a given cell matrix. | |
SimulationBox (double3x3 m, Type type) | |
Constructs a SimulationBox with a given cell matrix and type. | |
ALWAYS_INLINE double3 | applyPeriodicBoundaryConditions (const double3 &dr) const |
Applies periodic boundary conditions to a displacement vector. | |
void | setBoxLengths (double3 lengths) |
Sets the lengths of the simulation box. | |
void | setBoxAngles (double3 angles) |
Sets the angles of the simulation box. | |
double3 | lengths () const |
Retrieves the lengths of the simulation box. | |
double3 | angles () const |
Retrieves the angles of the simulation box. | |
double3 | randomPosition (RandomNumber &random) const |
Generates a random position within the simulation box. | |
double3 | perpendicularWidths () const |
Calculates the perpendicular widths of the simulation box. | |
int3 | smallestNumberOfUnitCellsForMinimumImagesConvention (double cutOff) const |
std::string | printStatus () const |
Returns a string representation of the simulation box. | |
std::string | printStatus (const SimulationBox &average, const SimulationBox &error) const |
Returns a string representation of the simulation box with averages and errors. | |
nlohmann::json | jsonStatus () const |
Returns a JSON representation of the simulation box. | |
SimulationBox & | operator+= (const SimulationBox &b) |
void | scale (double scale) |
Scales the simulation box by a scalar factor. | |
void | scale (int3 scale) |
Scales the simulation box by integer factors along each axis. | |
SimulationBox | scaled (double scale) |
Returns a new SimulationBox scaled by a scalar factor. | |
SimulationBox | scaled (int3 scale) const |
Returns a new SimulationBox scaled by integer factors along each axis. | |
Public Attributes | |
std::uint64_t | versionNumber {1} |
double | lengthA |
double | lengthB |
double | lengthC |
double | angleAlpha |
double | angleBeta |
double | angleGamma |
double3x3 | cell |
double3x3 | inverseCell |
double | volume |
Type | type |
Friends | |
Archive< std::ofstream > & | operator<< (Archive< std::ofstream > &archive, const SimulationBox &box) |
Archive< std::ifstream > & | operator>> (Archive< std::ifstream > &archive, SimulationBox &box) |
void | to_json (nlohmann::json &, const SimulationBox &) |
void | from_json (const nlohmann::json &, SimulationBox &) |
Represents a simulation box used in simulations.
The SimulationBox struct defines the dimensions and angles of the simulation box. It supports different types, such as rectangular and triclinic, and contains information about the cell matrix and its inverse, as well as the volume of the box.
|
inline |
Default constructor for the SimulationBox class.
Initializes a SimulationBox with all lengths and angles set to zero, and sets the cell matrices to zero matrices.
|
explicit |
Constructs a rectangular SimulationBox with given lengths.
Initializes a rectangular SimulationBox with the specified lengths for the sides. Sets the angles to 90 degrees and computes the cell matrices and volume.
a | Length of side A. |
b | Length of side B. |
c | Length of side C. |
|
explicit |
Constructs a SimulationBox with given lengths and angles.
Initializes a SimulationBox with the specified lengths for the sides and angles. Computes the cell matrices and volume based on the provided dimensions.
a | Length of side A. |
b | Length of side B. |
c | Length of side C. |
alpha | Angle between sides B and C (in radians). |
beta | Angle between sides A and C (in radians). |
gamma | Angle between sides A and B (in radians). |
|
explicit |
Constructs a SimulationBox with given lengths, angles, and type.
Initializes a SimulationBox with the specified lengths, angles, and box type. Computes the cell matrices and volume based on the provided dimensions.
a | Length of side A. |
b | Length of side B. |
c | Length of side C. |
alpha | Angle between sides B and C (in radians). |
beta | Angle between sides A and C (in radians). |
gamma | Angle between sides A and B (in radians). |
type | The type of the simulation box (Rectangular or Triclinic). |
|
explicit |
Constructs a SimulationBox with a given cell matrix.
Initializes a SimulationBox with the specified cell matrix. Computes the lengths and angles from the cell matrix, as well as the inverse cell matrix and volume.
m | The cell matrix defining the box dimensions and angles. |
|
explicit |
Constructs a SimulationBox with a given cell matrix and type.
Initializes a SimulationBox with the specified cell matrix and box type. Computes the lengths and angles from the cell matrix, as well as the inverse cell matrix and volume.
m | The cell matrix defining the box dimensions and angles. |
type | The type of the simulation box (Rectangular or Triclinic). |
double3 SimulationBox::angles | ( | ) | const |
Retrieves the angles of the simulation box.
Returns the angles between the sides of the simulation box.
|
inline |
Applies periodic boundary conditions to a displacement vector.
Adjusts the displacement vector dr
to account for periodic boundary conditions, ensuring that it lies within the primary simulation cell. For rectangular boxes, the method is optimized for performance.
dr | The displacement vector to be adjusted. |
nlohmann::json SimulationBox::jsonStatus | ( | ) | const |
Returns a JSON representation of the simulation box.
Generates a JSON object containing the cell matrix, lengths, and angles of the box.
double3 SimulationBox::lengths | ( | ) | const |
Retrieves the lengths of the simulation box.
Returns the lengths of the sides of the simulation box.
double3 SimulationBox::perpendicularWidths | ( | ) | const |
Calculates the perpendicular widths of the simulation box.
Computes the perpendicular widths (shortest distances) along each axis of the box.
std::string SimulationBox::printStatus | ( | ) | const |
Returns a string representation of the simulation box.
Generates a string that includes the cell matrix, lengths, angles, and boundary conditions type.
std::string SimulationBox::printStatus | ( | const SimulationBox & | average, |
const SimulationBox & | error | ||
) | const |
Returns a string representation of the simulation box with averages and errors.
Generates a string that includes the cell matrix, lengths, angles, and boundary conditions type, along with average values and errors for comparison.
average | The average simulation box for comparison. |
error | The error simulation box for comparison. |
double3 SimulationBox::randomPosition | ( | RandomNumber & | random | ) | const |
Generates a random position within the simulation box.
Generates a random position within the simulation box using the provided random number generator.
random | A random number generator. |
|
inline |
Scales the simulation box by a scalar factor.
Multiplies the lengths of the box by the given scalar and recalculates the cell matrix, inverse cell matrix, and volume.
scale | The scalar factor to scale the box by. |
|
inline |
Scales the simulation box by integer factors along each axis.
Multiplies the lengths of the box by the given integer factors along x, y, and z axes, and recalculates the cell matrix, inverse cell matrix, and volume.
scale | An int3 containing the scaling factors along each axis. |
|
inline |
Returns a new SimulationBox scaled by a scalar factor.
Creates a new SimulationBox with lengths multiplied by the given scalar, and recalculates the cell matrix, inverse cell matrix, and volume.
scale | The scalar factor to scale the box by. |
|
inline |
Returns a new SimulationBox scaled by integer factors along each axis.
Creates a new SimulationBox with lengths multiplied by the given integer factors, and recalculates the cell matrix, inverse cell matrix, and volume.
scale | An int3 containing the scaling factors along each axis. |
void SimulationBox::setBoxAngles | ( | double3 | angles | ) |
Sets the angles of the simulation box.
Updates the angles of the box and recalculates the cell matrix, inverse cell matrix, and volume based on the new angles. Angles are provided in radians.
angles | A double3 containing the new angles (angleAlpha, angleBeta, angleGamma). |
void SimulationBox::setBoxLengths | ( | double3 | lengths | ) |
Sets the lengths of the simulation box.
Updates the lengths of the box and recalculates the cell matrix, inverse cell matrix, and volume based on the new lengths.
lengths | A double3 containing the new lengths (lengthA, lengthB, lengthC). |