RASPA3 3.0.12
A molecular simulation code for computing adsorption and diffusion in nanoporous materials
Loading...
Searching...
No Matches
SimulationBox Struct Referenceexport

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.
 
SimulationBoxoperator+= (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 &)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SimulationBox() [1/6]

SimulationBox::SimulationBox ( )
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.

◆ SimulationBox() [2/6]

SimulationBox::SimulationBox ( double  a,
double  b,
double  c 
)
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.

Parameters
aLength of side A.
bLength of side B.
cLength of side C.

◆ SimulationBox() [3/6]

SimulationBox::SimulationBox ( double  a,
double  b,
double  c,
double  alpha,
double  beta,
double  gamma 
)
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.

Parameters
aLength of side A.
bLength of side B.
cLength of side C.
alphaAngle between sides B and C (in radians).
betaAngle between sides A and C (in radians).
gammaAngle between sides A and B (in radians).

◆ SimulationBox() [4/6]

SimulationBox::SimulationBox ( double  a,
double  b,
double  c,
double  alpha,
double  beta,
double  gamma,
Type  type 
)
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.

Parameters
aLength of side A.
bLength of side B.
cLength of side C.
alphaAngle between sides B and C (in radians).
betaAngle between sides A and C (in radians).
gammaAngle between sides A and B (in radians).
typeThe type of the simulation box (Rectangular or Triclinic).

◆ SimulationBox() [5/6]

SimulationBox::SimulationBox ( double3x3  m)
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.

Parameters
mThe cell matrix defining the box dimensions and angles.

◆ SimulationBox() [6/6]

SimulationBox::SimulationBox ( double3x3  m,
Type  type 
)
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.

Parameters
mThe cell matrix defining the box dimensions and angles.
typeThe type of the simulation box (Rectangular or Triclinic).

Member Function Documentation

◆ angles()

double3 SimulationBox::angles ( ) const

Retrieves the angles of the simulation box.

Returns the angles between the sides of the simulation box.

Returns
A double3 containing the angles (angleAlpha, angleBeta, angleGamma) in radians.

◆ applyPeriodicBoundaryConditions()

ALWAYS_INLINE double3 SimulationBox::applyPeriodicBoundaryConditions ( const double3 &  dr) const
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.

Parameters
drThe displacement vector to be adjusted.
Returns
The adjusted displacement vector within the primary simulation cell.

◆ jsonStatus()

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.

Returns
A JSON object representing the simulation box.

◆ lengths()

double3 SimulationBox::lengths ( ) const

Retrieves the lengths of the simulation box.

Returns the lengths of the sides of the simulation box.

Returns
A double3 containing the lengths (lengthA, lengthB, lengthC).

◆ perpendicularWidths()

double3 SimulationBox::perpendicularWidths ( ) const

Calculates the perpendicular widths of the simulation box.

Computes the perpendicular widths (shortest distances) along each axis of the box.

Returns
A double3 containing the perpendicular widths along x, y, and z axes.

◆ printStatus() [1/2]

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.

Returns
A string representing the simulation box.

◆ printStatus() [2/2]

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.

Parameters
averageThe average simulation box for comparison.
errorThe error simulation box for comparison.
Returns
A string representing the simulation box with averages and errors.

◆ randomPosition()

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.

Parameters
randomA random number generator.
Returns
A double3 representing a random position within the box.

◆ scale() [1/2]

void SimulationBox::scale ( double  scale)
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.

Parameters
scaleThe scalar factor to scale the box by.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale() [2/2]

void SimulationBox::scale ( int3  scale)
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.

Parameters
scaleAn int3 containing the scaling factors along each axis.
Here is the call graph for this function:

◆ scaled() [1/2]

SimulationBox SimulationBox::scaled ( double  scale)
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.

Parameters
scaleThe scalar factor to scale the box by.
Returns
A new scaled SimulationBox.
Here is the call graph for this function:

◆ scaled() [2/2]

SimulationBox SimulationBox::scaled ( int3  scale) const
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.

Parameters
scaleAn int3 containing the scaling factors along each axis.
Returns
A new scaled SimulationBox.
Here is the call graph for this function:

◆ setBoxAngles()

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.

Parameters
anglesA double3 containing the new angles (angleAlpha, angleBeta, angleGamma).

◆ setBoxLengths()

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.

Parameters
lengthsA double3 containing the new lengths (lengthA, lengthB, lengthC).

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