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

Represents the force field used in simulations. More...

Collaboration diagram for ForceField:

Classes

struct  InsensitiveCompare
 Comparator for case-insensitive string comparison. More...
 

Public Types

enum class  ChargeMethod : int { Ewald = 0 , Coulomb = 1 , Wolf = 2 , ModifiedWolf = 3 }
 Enumeration of methods used for electrostatic interactions. More...
 
enum class  MixingRule : int { Lorentz_Berthelot = 0 , Jorgensen = 1 }
 Enumeration of mixing rules for cross interactions. More...
 
enum class  PotentialEnergySurfaceType : std::size_t {
  None = 0 , SecondOrderPolynomialTestFunction = 1 , ThirdOrderPolynomialTestFunction = 2 , FourthOrderPolynomialTestFunction = 3 ,
  FifthOrderPolynomialTestFunction = 4 , SixthOrderPolynomialTestFunction = 5 , ExponentialNonPolynomialTestFunction = 6 , MullerBrown = 7 ,
  Eckhardt = 8 , GonzalezSchlegel = 9
}
 
enum class  InterpolationGridType : std::size_t { LennardJones = 0 , LennardJonesRepulsion = 1 , LennardJonesAttraction = 2 , EwaldReal = 3 }
 
enum class  InterpolationScheme : std::size_t { Polynomial = 1 , Tricubic = 8 , Triquintic = 27 }
 

Public Member Functions

 ForceField () noexcept=default
 Default constructor for the ForceField struct.
 
 ForceField (std::vector< PseudoAtom > pseudoAtoms, std::vector< VDWParameters > parameters, MixingRule mixingRule, double cutOffFrameworkVDW, double cutOffMoleculeVDW, double cutOffCoulomb, bool shifted, bool tailCorrections, bool useCharge=true) noexcept(false)
 Constructs a ForceField with specified parameters.
 
 ForceField (std::string filePath) noexcept(false)
 Constructs a ForceField by reading parameters from a file.
 
VDWParametersoperator() (std::size_t row, std::size_t col)
 
const VDWParametersoperator[] (std::size_t row) const
 
const VDWParametersoperator() (std::size_t row, std::size_t col) const
 
bool operator== (const ForceField &other) const
 
void applyMixingRule ()
 Applies the mixing rule to compute cross-interaction parameters.
 
double cutOffVDW (std::size_t i, std::size_t j) const
 Returns the cut-off distance for van der Waals interactions between two pseudo-atoms.
 
void preComputePotentialShift ()
 Pre-computes the potential shift for interactions.
 
void preComputeTailCorrection ()
 Pre-computes the tail corrections for interactions.
 
std::string printPseudoAtomStatus () const
 Returns a string representation of the pseudo-atom status.
 
std::string printCutOffAutoStatus () const
 
std::string printForceFieldStatus () const
 Returns a string representation of the force field status.
 
std::vector< nlohmann::json > jsonPseudoAtomStatus () const
 Returns a JSON representation of the pseudo-atom status.
 
nlohmann::json jsonForceFieldStatus () const
 Returns a JSON representation of the force field status.
 
std::optional< std::size_t > findPseudoAtom (const std::string &name) const
 Finds the index of a pseudo-atom by name.
 
void initializeEwaldParameters (const SimulationBox &simulationBox)
 Initializes the Ewald parameters based on the simulation box.
 
void initializeAutomaticCutOff (const SimulationBox &simulationBox)
 
std::string repr () const
 Returns a string representation of the ForceField.
 
void validateInput (const nlohmann::basic_json< nlohmann::raspa_map > &parsed_data)
 

Static Public Member Functions

static std::optional< ForceFieldreadForceField (std::optional< std::string > directoryName, std::string forceFieldFileName) noexcept(false)
 Reads a ForceField from a file.
 
static std::optional< std::size_t > findPseudoAtom (const std::vector< PseudoAtom > pseudoAtoms, const std::string &name)
 Finds the index of a pseudo-atom by name in a given list.
 

Public Attributes

std::uint64_t versionNumber {1}
 Version number of the force field format.
 
std::vector< VDWParametersdata {}
 Interaction parameters between pseudo-atoms; size is numberOfPseudoAtoms squared.
 
std::vector< bool > shiftPotentials {}
 Indicates if potential shift is applied between pairs of atoms.
 
std::vector< bool > tailCorrections {}
 Indicates if tail corrections are applied between pairs of atoms.
 
MixingRule mixingRule {MixingRule::Lorentz_Berthelot}
 Mixing rule used for cross interactions.
 
bool cutOffFrameworkVDWAutomatic {false}
 
double cutOffFrameworkVDW {12.0}
 Cut-off distance for VDW interactions between framework and molecules.
 
bool cutOffMoleculeVDWAutomatic {false}
 
double cutOffMoleculeVDW {12.0}
 Cut-off distance for VDW interactions between molecules.
 
bool cutOffCoulombAutomatic {true}
 
double cutOffCoulomb {12.0}
 Cut-off distance for Coulomb interactions.
 
double dualCutOff {6.0}
 Inner cut-off distance when using dual cut-off scheme.
 
std::size_t numberOfPseudoAtoms {0}
 Number of pseudo-atoms defined in the force field.
 
std::vector< PseudoAtompseudoAtoms {}
 List of pseudo-atoms in the force field.
 
ChargeMethod chargeMethod {ChargeMethod::Ewald}
 Method used for calculating electrostatic interactions.
 
double EwaldPrecision {1e-6}
 Desired precision for Ewald summation.
 
double EwaldAlpha {0.265058}
 Ewald convergence parameter alpha.
 
int3 numberOfWaveVectors {8, 8, 8}
 Number of wave vectors in each direction for Ewald summation.
 
std::size_t reciprocalIntegerCutOffSquared
 Squared integer cut-off in reciprocal space.
 
double reciprocalCutOffSquared
 Squared cut-off distance in reciprocal space.
 
bool automaticEwald {true}
 Indicates if Ewald parameters are computed automatically.
 
bool useCharge {true}
 Indicates if charges are used in calculations.
 
bool omitEwaldFourier {false}
 If true, omits the Fourier component in Ewald summation.
 
double energyOverlapCriteria {1e6}
 Energy criteria for considering overlaps.
 
std::size_t numberOfTrialDirections { 10 }
 
std::size_t numberOfTorsionTrialDirections { 100 }
 
std::size_t numberOfFirstBeadPositions { 10 }
 
double minimumRosenbluthFactor {1e-150}
 Minimum allowed Rosenbluth factor.
 
bool useDualCutOff {false}
 Indicates if dual cut-off scheme is used.
 
bool omitInterInteractions {false}
 If true, omits interactions between molecules.
 
bool computePolarization {false}
 Indicates if polarization effects are computed.
 
bool omitInterPolarization {true}
 If true, omits polarization between molecules.
 
bool hasExternalField {false}
 
PotentialEnergySurfaceType potentialEnergySurfaceType {PotentialEnergySurfaceType::SecondOrderPolynomialTestFunction}
 
double3 potentialEnergySurfaceOrigin {0.0, 0.0, 0.0}
 
std::vector< std::size_t > gridPseudoAtomIndices
 
double spacingVDWGrid {0.15}
 
double spacingCoulombGrid {0.15}
 
std::optional< int3 > numberOfVDWGridPoints {}
 
std::optional< int3 > numberOfCoulombGridPoints {}
 
std::size_t numberOfGridTestPoints {100000}
 
bool interpolationSchemeAuto {true}
 
InterpolationScheme interpolationScheme {InterpolationScheme::Polynomial}
 

Static Public Attributes

static const std::set< std::string, InsensitiveCompareoptions
 Set of general option keys accepted in the input data.
 

Friends

Archive< std::ofstream > & operator<< (Archive< std::ofstream > &archive, const ForceField &f)
 
Archive< std::ifstream > & operator>> (Archive< std::ifstream > &archive, ForceField &f)
 

Detailed Description

Represents the force field used in simulations.

The ForceField struct contains all parameters and methods related to force field calculations, including van der Waals interactions, electrostatics, Ewald summation parameters, mixing rules, and methods to initialize and compute these parameters.

Member Enumeration Documentation

◆ ChargeMethod

enum class ForceField::ChargeMethod : int
strong

Enumeration of methods used for electrostatic interactions.

Enumerator
Ewald 

Ewald summation method.

Coulomb 

Direct Coulomb interactions.

Wolf 

Wolf summation method.

ModifiedWolf 

Modified Wolf method.

◆ MixingRule

enum class ForceField::MixingRule : int
strong

Enumeration of mixing rules for cross interactions.

Enumerator
Lorentz_Berthelot 

Lorentz-Berthelot mixing rule.

Constructor & Destructor Documentation

◆ ForceField() [1/2]

ForceField::ForceField ( std::vector< PseudoAtom pseudoAtoms,
std::vector< VDWParameters parameters,
MixingRule  mixingRule,
double  cutOffFrameworkVDW,
double  cutOffMoleculeVDW,
double  cutOffCoulomb,
bool  shifted,
bool  tailCorrections,
bool  useCharge = true 
)

Constructs a ForceField with specified parameters.

Initializes the force field using the provided pseudo-atoms, van der Waals parameters, mixing rule, cut-off distances, and flags for shifting potentials and tail corrections.

Parameters
pseudoAtomsVector of pseudo-atoms.
parametersVector of van der Waals self-interaction parameters.
mixingRuleThe mixing rule to use for cross interactions.
cutOffFrameworkVDWCut-off distance for VDW interactions between framework and molecules.
cutOffMoleculeVDWCut-off distance for VDW interactions between molecules.
cutOffCoulombCut-off distance for Coulomb interactions.
shiftedIf true, applies potential shift to interactions.
tailCorrectionsIf true, applies tail corrections to interactions.
useChargeIf true, includes electrostatic interactions.

◆ ForceField() [2/2]

ForceField::ForceField ( std::string  filePath)

Constructs a ForceField by reading parameters from a file.

Initializes the force field by parsing a force field file specified by the file path.

Parameters
filePathPath to the force field file.

Member Function Documentation

◆ applyMixingRule()

void ForceField::applyMixingRule ( )

Applies the mixing rule to compute cross-interaction parameters.

Calculates the interaction parameters between different pseudo-atoms using the specified mixing rule.

◆ cutOffVDW()

double ForceField::cutOffVDW ( std::size_t  i,
std::size_t  j 
) const

Returns the cut-off distance for van der Waals interactions between two pseudo-atoms.

Parameters
iIndex of the first pseudo-atom.
jIndex of the second pseudo-atom.
Returns
The cut-off distance for VDW interactions.

◆ findPseudoAtom() [1/2]

std::optional< std::size_t > ForceField::findPseudoAtom ( const std::string &  name) const

Finds the index of a pseudo-atom by name.

Searches for a pseudo-atom with the given name and returns its index if found.

Parameters
nameName of the pseudo-atom.
Returns
Optional index of the pseudo-atom.

◆ findPseudoAtom() [2/2]

static std::optional< std::size_t > ForceField::findPseudoAtom ( const std::vector< PseudoAtom pseudoAtoms,
const std::string &  name 
)
static

Finds the index of a pseudo-atom by name in a given list.

Searches for a pseudo-atom with the given name in the provided vector and returns its index if found.

Parameters
pseudoAtomsVector of pseudo-atoms to search.
nameName of the pseudo-atom.
Returns
Optional index of the pseudo-atom.

◆ initializeEwaldParameters()

void ForceField::initializeEwaldParameters ( const SimulationBox simulationBox)

Initializes the Ewald parameters based on the simulation box.

Calculates the Ewald alpha parameter and the number of wave vectors required for the desired precision.

Parameters
simulationBoxThe simulation box to use for initialization.

◆ jsonForceFieldStatus()

nlohmann::json ForceField::jsonForceFieldStatus ( ) const

Returns a JSON representation of the force field status.

Generates a JSON object containing information about the force field parameters.

Returns
A JSON object representing the force field status.

◆ jsonPseudoAtomStatus()

std::vector< nlohmann::json > ForceField::jsonPseudoAtomStatus ( ) const

Returns a JSON representation of the pseudo-atom status.

Generates a JSON array containing information about the pseudo-atoms.

Returns
A vector of JSON objects representing the pseudo-atoms.

◆ preComputePotentialShift()

void ForceField::preComputePotentialShift ( )

Pre-computes the potential shift for interactions.

Calculates the potential shift for each pair of pseudo-atoms if shifting is enabled.

◆ preComputeTailCorrection()

void ForceField::preComputeTailCorrection ( )

Pre-computes the tail corrections for interactions.

Calculates the tail correction energy for each pair of pseudo-atoms if tail corrections are enabled.

◆ printForceFieldStatus()

std::string ForceField::printForceFieldStatus ( ) const

Returns a string representation of the force field status.

Generates a detailed string containing information about the force field parameters.

Returns
A string representing the force field status.
Here is the caller graph for this function:

◆ printPseudoAtomStatus()

std::string ForceField::printPseudoAtomStatus ( ) const

Returns a string representation of the pseudo-atom status.

Generates a detailed string containing information about the pseudo-atoms.

Returns
A string representing the pseudo-atom status.
Here is the caller graph for this function:

◆ readForceField()

static std::optional< ForceField > ForceField::readForceField ( std::optional< std::string >  directoryName,
std::string  forceFieldFileName 
)
static

Reads a ForceField from a file.

Attempts to read the force field parameters from the specified file.

Parameters
directoryNameOptional directory name where the file is located.
forceFieldFileNameName of the force field file.
Returns
An optional ForceField object if successful.

◆ repr()

std::string ForceField::repr ( ) const
inline

Returns a string representation of the ForceField.

Combines the pseudo-atom status and force field status into a single string.

Returns
A string representing the ForceField.
Here is the call graph for this function:

Member Data Documentation

◆ options

const std::set<std::string, InsensitiveCompare> ForceField::options
static

Set of general option keys accepted in the input data.

This set contains all the general configuration keys that are recognized at the top level of the input JSON. It is used to validate the presence of only known keys.

◆ reciprocalCutOffSquared

double ForceField::reciprocalCutOffSquared
Initial value:
{
std::numeric_limits<double>::max()}

Squared cut-off distance in reciprocal space.

◆ reciprocalIntegerCutOffSquared

std::size_t ForceField::reciprocalIntegerCutOffSquared
Initial value:
{
std::numeric_limits<std::size_t>::max()}

Squared integer cut-off in reciprocal space.


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