MolSim
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Particle Class Reference

Particle class modeling a particle's position, velocity, force, mass and type. More...

#include <Particle.h>

Public Member Functions

 Particle (int type=0)
 Construct a new Particle object by optionally passing its type. Prevents implicit conversions.
 
 Particle (const Particle &other)
 Construct a new Particle object using another Particle's data.
 
 Particle (const std::array< double, 3 > &x, const std::array< double, 3 > &v, double m, int type=TYPE_DEFAULT, double eps=EPSILON_DEFAULT, double sigma=SIGMA_DEFAULT, double k=K_DEFAULT, double r_0=R0_DEFAULT, double fzup=FZUP_DEFAULT)
 Construct a new Particle object using explicit values for each new data field.
 
 Particle (const std::array< double, 3 > &x, const std::array< double, 3 > &v, const std::array< double, 3 > &f, const std::array< double, 3 > &old_f, double m, int type, double eps, double sigma, double k, double r_0, double fzup, int cellIndex)
 Construct a new Particle object using explicit values for every data field.
 
virtual ~Particle ()
 Destroys the Particle object.
 
std::array< double, 3 > & getX ()
 Gets the position \( x \) of this particle.
 
std::array< double, 3 > & getV ()
 Gets the velocity \( v \) of this particle.
 
std::array< double, 3 > & getF ()
 Gets the force \( F \) effective on this particle.
 
std::array< double, 3 > & getOldF ()
 Gets the force \( F_\text{old} \) previously effective on this particle.
 
std::vector< std::reference_wrapper< Particle > > & getDirectNeighbours ()
 Gets the direct neighbours of this particle.
 
const std::vector< std::reference_wrapper< Particle > > & getDirectNeighbours () const
 Gets the direct neighbours of this particle (const).
 
std::vector< std::reference_wrapper< Particle > > & getDiagonalNeighbours ()
 Gets the diagonal neighbours of this particle.
 
const std::vector< std::reference_wrapper< Particle > > & getDiagonalNeighbours () const
 Gets the diagonal neighbours of this particle (const).
 
const std::array< double, 3 > & getX () const
 Gets the position \( x \) of this particle (const).
 
const std::array< double, 3 > & getV () const
 Gets the velocity \( v \) of this particle (const).
 
const std::array< double, 3 > & getThermalMotion () const
 Gets the thermal motion \( \hat v \) of this particle (const).
 
const std::array< double, 3 > & getF () const
 Gets the force \( F \) effective on this particle (const).
 
const std::array< double, 3 > & getOldF () const
 Gets the force \( F_\text{old} \) previously effective on this particle (const).
 
double getM () const
 Gets the mass \( m \) of the particle.
 
int getType () const
 Gets the type of the particle.
 
double getEpsilon () const
 Gets the Lennard-Jones parameter \( \epsilon \) of the particle.
 
double getSigma () const
 Gets the Lennard-Jones parameter \( \sigma \) of the particle.
 
double getK () const
 Gets the stiffness constant \( k \).
 
double getR0 () const
 Gets the average bond length of a molecule pair \( r_0 \).
 
double getFZUP () const
 Gets the constant upward force \( F_{Z-UP} \).
 
int getCellIndex () const
 Get the index of the particle in a CellContainer.
 
bool isActive () const
 Checks if the particle is currently active.
 
int getId () const
 Get the ID of this particle.
 
omp_lock_tgetLock ()
 Get a reference to the Lock object.
 
void setX (const std::array< double, 3 > &new_x)
 Sets the new position \( x \) of the particle to a given value.
 
void setV (const std::array< double, 3 > &new_v)
 Sets the new velocity \( v \) of the particle to a given value.
 
void setDirectNeighbours (const std::vector< std::reference_wrapper< Particle > > &neighbours)
 Sets the direct neighbours of the particle.
 
void setDiagonalNeighbours (const std::vector< std::reference_wrapper< Particle > > &neighbours)
 Sets the diagonal neighbours of the particle.
 
void setThermalMotion (const std::array< double, 3 > &new_thermal_motion)
 Sets the new thermal motion \( \hat v \) of the particle to a given value.
 
void setF (const std::array< double, 3 > &new_f)
 Sets the new force effective on the particle \( F \) to a given value.
 
void setOldF (const std::array< double, 3 > &new_old_f)
 Sets the new previously effective force on the particle \( F_\text{old} \) to a given value.
 
void setFToZero ()
 Resets the force of the particle \( F \) to 0,0,0.
 
void setM (double new_m)
 Sets the new mass \( m \) of the particle to a given value.
 
void setType (double new_type)
 Sets the new type of the particle to a given value.
 
void setEpsilon (double new_eps)
 Sets the new Lennard-Jones parameter \( \epsilon \) of the particle to a given value.
 
void setSigma (double new_sigma)
 Sets the new Lennard-Jones parameter \( \sigma \) of the particle to a given value.
 
void setK (double new_k)
 Sets the new stiffness constant \( k \) to a given value.
 
void setFZUP (double new_fzup)
 Sets the new upward force \( F_{Z-UP} \) to a given value.
 
void setR0 (double new_r_0)
 Sets the new average bond length \( r_0 \) to a given value.
 
void setCellIndex (int new_index)
 Sets the new index in a CellContainer.
 
void markInactive ()
 Sets the Particle's active status to "inactive".
 
std::string toString () const
 Returns a string representation of this particle.
 
bool operator== (const Particle &other) const
 Overload of the equality operator for Particle objects.
 
bool operator!= (const Particle &other) const
 Overload of the inequality operator for Particle objects.
 

Private Attributes

std::array< double, 3 > x
 Position \( x \) of the particle.
 
std::array< double, 3 > v
 Velocity \( v \) of the particle.
 
std::array< double, 3 > thermal_motion
 Thermal motion \( \hat v \) of the particle.
 
std::array< double, 3 > f
 Force \( F \) effective on this particle.
 
std::array< double, 3 > old_f
 Force \( F_\text{old} \) which was effective on this particle.
 
std::vector< std::reference_wrapper< Particle > > direct_neighbours
 Direct (up-down, left-right) neighbours of the particle (for membranes).
 
std::vector< std::reference_wrapper< Particle > > diagonal_neighbours
 Diagonal neighbours of the particle (for membranes).
 
double m
 Mass \( m \) of this particle.
 
int type
 Type of the particle. 1 if wall, 0 otherwise.
 
double epsilon
 Depth \( \epsilon \) of the potential well. Lennard-Jones parameter.
 
double sigma
 Distance \( \sigma \) where the Lennard-Jones potential reaches zero. Lennard-Jones parameter.
 
double k
 The stiffness constant \( k \) for membrane simulations.
 
double r_0
 The average bond length \( r_0 \) for membrane simulations.
 
double fzup
 The constant upward force \( F_{Z-UP} \) for membrane simulations.
 
int cellIndex
 The cell index of the particle, to be used with the linked cell method.
 
omp_lock_t lock
 A mutual exclusion lock, used alongside parallelization.
 
bool active {true}
 The status of the particle.
 
int id
 A unique ID for this particle. Currently only used for debug purposes.
 

Detailed Description

Particle class modeling a particle's position, velocity, force, mass and type.

Constructor & Destructor Documentation

◆ Particle() [1/4]

Particle::Particle ( int  type = 0)
explicit

Construct a new Particle object by optionally passing its type. Prevents implicit conversions.

Given that the current simulations make use of the particle mass as the divisor in some formulas, the mass may not be negative or 0.

Parameters
typeThe type of the Particle object to be constructed.

◆ Particle() [2/4]

Particle::Particle ( const Particle other)

Construct a new Particle object using another Particle's data.

Parameters
otherA reference to the Particle object to copy the data from.

◆ Particle() [3/4]

Particle::Particle ( const std::array< double, 3 > &  x,
const std::array< double, 3 > &  v,
double  m,
int  type = TYPE_DEFAULT,
double  eps = EPSILON_DEFAULT,
double  sigma = SIGMA_DEFAULT,
double  k = K_DEFAULT,
double  r_0 = R0_DEFAULT,
double  fzup = FZUP_DEFAULT 
)

Construct a new Particle object using explicit values for each new data field.

Given that the current simulations make use of the particle mass as the divisor in some formulas, the mass may not be negative or 0.

Parameters
xA reference to the array containing data for the position \( x \).
vA reference to the array containing data for the velocity \( v \).
mThe mass \( m \) of the particle.
typeThe type of the particle. (optional)
epsThe Lennard-Jones parameter \( \epsilon \) of the particle. (optional)
sigmaThe Lennard-Jones parameter \( \sigma \) of the particle. (optional)
kThe stiffness constant \( k \), used for membrane simulations. (optional)
r_0The average bond length \( r_0 \), used for membrane simulations. (optional)
fzupThe constant upward force \( F_{Z-UP} \), used for membrane simulations. (optional)

◆ Particle() [4/4]

Particle::Particle ( const std::array< double, 3 > &  x,
const std::array< double, 3 > &  v,
const std::array< double, 3 > &  f,
const std::array< double, 3 > &  old_f,
double  m,
int  type,
double  eps,
double  sigma,
double  k,
double  r_0,
double  fzup,
int  cellIndex 
)

Construct a new Particle object using explicit values for every data field.

There are no default parameters here; every value must be initialized.

Parameters
xA reference to the array containing data for the position \( x \).
vA reference to the array containing data for the velocity \( v \).
fA reference to the array containing data for the force \( F \) effective on this particle.
old_fA reference to the array containing data for the old force \( F \) effective on this particle.
mThe mass \( m \) of the particle.
typeThe type of the particle.
epsThe Lennard-Jones parameter \( \epsilon \) of the particle.
sigmaThe Lennard-Jones parameter \( \sigma \) of the particle.
kThe stiffness constant \( k \), used for membrane simulations.
r_0The average bond length \( r_0 \), used for membrane simulations.
fzupThe constant upward force \( F_{Z-UP} \), used for membrane simulations.
cellIndexThe index of this particle inside a cell. For use with the linked cell method.

◆ ~Particle()

virtual Particle::~Particle ( )
virtual

Destroys the Particle object.

Member Function Documentation

◆ getCellIndex()

int Particle::getCellIndex ( ) const
inline

Get the index of the particle in a CellContainer.

For use with the linked cell method.

Returns
The index of the particle in a grid of cells.

◆ getDiagonalNeighbours() [1/2]

std::vector< std::reference_wrapper< Particle > > & Particle::getDiagonalNeighbours ( )
inline

Gets the diagonal neighbours of this particle.

Returns
A reference to the vector of diagonal neighbour particle references of this particle.

◆ getDiagonalNeighbours() [2/2]

const std::vector< std::reference_wrapper< Particle > > & Particle::getDiagonalNeighbours ( ) const
inline

Gets the diagonal neighbours of this particle (const).

Returns
A const reference to the vector of diagonal neighbour particle references of this particle.

◆ getDirectNeighbours() [1/2]

std::vector< std::reference_wrapper< Particle > > & Particle::getDirectNeighbours ( )
inline

Gets the direct neighbours of this particle.

Returns
A reference to the vector of direct neighbour particle references of this particle.

◆ getDirectNeighbours() [2/2]

const std::vector< std::reference_wrapper< Particle > > & Particle::getDirectNeighbours ( ) const
inline

Gets the direct neighbours of this particle (const).

Returns
A const reference to the vector of direct neighbour particle references of this particle.

◆ getEpsilon()

double Particle::getEpsilon ( ) const
inline

Gets the Lennard-Jones parameter \( \epsilon \) of the particle.

Returns
The Lennard-Jones parameter \( \epsilon \) of the particle.

◆ getF() [1/2]

std::array< double, 3 > & Particle::getF ( )
inline

Gets the force \( F \) effective on this particle.

Returns
A reference to the force array of this particle.

◆ getF() [2/2]

const std::array< double, 3 > & Particle::getF ( ) const
inline

Gets the force \( F \) effective on this particle (const).

Returns
A const reference to the force array of this particle.

◆ getFZUP()

double Particle::getFZUP ( ) const
inline

Gets the constant upward force \( F_{Z-UP} \).

Returns
The constant upward force \( F_{Z-UP} \).

◆ getId()

int Particle::getId ( ) const
inline

Get the ID of this particle.

Currently only used for debugging purposes.

Returns
The ID of this particle.

◆ getK()

double Particle::getK ( ) const
inline

Gets the stiffness constant \( k \).

Returns
The stiffness constant \( k \).

◆ getLock()

omp_lock_t & Particle::getLock ( )
inline

Get a reference to the Lock object.

Returns
A reference to the Lock object.

◆ getM()

double Particle::getM ( ) const
inline

Gets the mass \( m \) of the particle.

Returns
The mass of the particle.

◆ getOldF() [1/2]

std::array< double, 3 > & Particle::getOldF ( )
inline

Gets the force \( F_\text{old} \) previously effective on this particle.

Returns
A reference to the old force array of this particle.

◆ getOldF() [2/2]

const std::array< double, 3 > & Particle::getOldF ( ) const
inline

Gets the force \( F_\text{old} \) previously effective on this particle (const).

Returns
A const reference to the old force array of this particle.

◆ getR0()

double Particle::getR0 ( ) const
inline

Gets the average bond length of a molecule pair \( r_0 \).

Returns
The average bond length \( r_0 \).

◆ getSigma()

double Particle::getSigma ( ) const
inline

Gets the Lennard-Jones parameter \( \sigma \) of the particle.

Returns
The Lennard-Jones parameter \( \sigma \) of the particle.

◆ getThermalMotion()

const std::array< double, 3 > & Particle::getThermalMotion ( ) const
inline

Gets the thermal motion \( \hat v \) of this particle (const).

Returns
A const reference to the thermal motion array of this particle.

◆ getType()

int Particle::getType ( ) const
inline

Gets the type of the particle.

Returns
The type of the particle.

◆ getV() [1/2]

std::array< double, 3 > & Particle::getV ( )
inline

Gets the velocity \( v \) of this particle.

Returns
A reference to the velocity array of this particle.

◆ getV() [2/2]

const std::array< double, 3 > & Particle::getV ( ) const
inline

Gets the velocity \( v \) of this particle (const).

Returns
A const reference to the velocity array of this particle.

◆ getX() [1/2]

std::array< double, 3 > & Particle::getX ( )
inline

Gets the position \( x \) of this particle.

Returns
A reference to the position array of this particle.

◆ getX() [2/2]

const std::array< double, 3 > & Particle::getX ( ) const
inline

Gets the position \( x \) of this particle (const).

Returns
A const reference to the position array of this particle.

◆ isActive()

bool Particle::isActive ( ) const
inline

Checks if the particle is currently active.

Returns
true if the particle is currently active.
false if the particle is currently inactive.

◆ markInactive()

void Particle::markInactive ( )

Sets the Particle's active status to "inactive".

◆ operator!=()

bool Particle::operator!= ( const Particle other) const

Overload of the inequality operator for Particle objects.

Parameters
otherA reference to the Particle object to compare the current object with.
Returns
true if both particles have at least one differing attribute.
false if both particles' data (attributes) contain the same values.

◆ operator==()

bool Particle::operator== ( const Particle other) const

Overload of the equality operator for Particle objects.

Parameters
otherA reference to the Particle object to compare the current object with.
Returns
true if both particles' data (attributes) contain the same values.
false if both particles have at least one differing attribute.

◆ setCellIndex()

void Particle::setCellIndex ( int  new_index)

Sets the new index in a CellContainer.

For use with the linked cell method.

Parameters
new_indexThe new index in a grid of cells.

◆ setDiagonalNeighbours()

void Particle::setDiagonalNeighbours ( const std::vector< std::reference_wrapper< Particle > > &  neighbours)

Sets the diagonal neighbours of the particle.

Parameters
neighboursA reference to the vector of references to the neighbours.

◆ setDirectNeighbours()

void Particle::setDirectNeighbours ( const std::vector< std::reference_wrapper< Particle > > &  neighbours)

Sets the direct neighbours of the particle.

Parameters
neighboursA reference to the vector of references to the neighbours.

◆ setEpsilon()

void Particle::setEpsilon ( double  new_eps)

Sets the new Lennard-Jones parameter \( \epsilon \) of the particle to a given value.

Parameters
new_epsThe new Lennard-Jones parameter \( \epsilon \) of this particle.

◆ setF()

void Particle::setF ( const std::array< double, 3 > &  new_f)

Sets the new force effective on the particle \( F \) to a given value.

Parameters
new_fA reference to the array containing the new force effective on this particle.

◆ setFToZero()

void Particle::setFToZero ( )

Resets the force of the particle \( F \) to 0,0,0.

◆ setFZUP()

void Particle::setFZUP ( double  new_fzup)

Sets the new upward force \( F_{Z-UP} \) to a given value.

Parameters
new_fzupThe new upward force \( F_{Z-UP} \).

◆ setK()

void Particle::setK ( double  new_k)

Sets the new stiffness constant \( k \) to a given value.

Parameters
new_kThe new stiffness constant \( k \).

◆ setM()

void Particle::setM ( double  new_m)

Sets the new mass \( m \) of the particle to a given value.

Given that the current simulations make use of the particle mass as the divisor in some formulas, the mass may not be negative or 0.

Parameters
new_mThe new mass of this particle.

◆ setOldF()

void Particle::setOldF ( const std::array< double, 3 > &  new_old_f)

Sets the new previously effective force on the particle \( F_\text{old} \) to a given value.

Parameters
new_old_fA reference to the array containing the new previously effective force on this particle.

◆ setR0()

void Particle::setR0 ( double  new_r_0)

Sets the new average bond length \( r_0 \) to a given value.

Parameters
new_r_0The new average bond length \( r_0 \).

◆ setSigma()

void Particle::setSigma ( double  new_sigma)

Sets the new Lennard-Jones parameter \( \sigma \) of the particle to a given value.

Parameters
new_sigmaThe new Lennard-Jones parameter \( \sigma \) of this particle.

◆ setThermalMotion()

void Particle::setThermalMotion ( const std::array< double, 3 > &  new_thermal_motion)

Sets the new thermal motion \( \hat v \) of the particle to a given value.

Parameters
new_thermal_motionA reference to the array containing the new thermal motion of this particle.

◆ setType()

void Particle::setType ( double  new_type)

Sets the new type of the particle to a given value.

Parameters
new_typeThe new type of this particle.

◆ setV()

void Particle::setV ( const std::array< double, 3 > &  new_v)

Sets the new velocity \( v \) of the particle to a given value.

Parameters
new_vA reference to the array containing the new velocity of this particle.

◆ setX()

void Particle::setX ( const std::array< double, 3 > &  new_x)

Sets the new position \( x \) of the particle to a given value.

Parameters
new_xA reference to the array containing the new position of this particle.

◆ toString()

std::string Particle::toString ( ) const

Returns a string representation of this particle.

Returns
The formatted particle data as a std::string.

Member Data Documentation

◆ active

bool Particle::active {true}
private

The status of the particle.

If the particle is marked "active", it will be considered in the time integration calculation. Otherwise, it is ignored.

◆ cellIndex

int Particle::cellIndex
private

The cell index of the particle, to be used with the linked cell method.

◆ diagonal_neighbours

std::vector<std::reference_wrapper<Particle> > Particle::diagonal_neighbours
private

Diagonal neighbours of the particle (for membranes).

◆ direct_neighbours

std::vector<std::reference_wrapper<Particle> > Particle::direct_neighbours
private

Direct (up-down, left-right) neighbours of the particle (for membranes).

◆ epsilon

double Particle::epsilon
private

Depth \( \epsilon \) of the potential well. Lennard-Jones parameter.

◆ f

std::array<double, 3> Particle::f
private

Force \( F \) effective on this particle.

◆ fzup

double Particle::fzup
private

The constant upward force \( F_{Z-UP} \) for membrane simulations.

◆ id

int Particle::id
private

A unique ID for this particle. Currently only used for debug purposes.

◆ k

double Particle::k
private

The stiffness constant \( k \) for membrane simulations.

◆ lock

omp_lock_t Particle::lock
private

A mutual exclusion lock, used alongside parallelization.

◆ m

double Particle::m
private

Mass \( m \) of this particle.

◆ old_f

std::array<double, 3> Particle::old_f
private

Force \( F_\text{old} \) which was effective on this particle.

◆ r_0

double Particle::r_0
private

The average bond length \( r_0 \) for membrane simulations.

◆ sigma

double Particle::sigma
private

Distance \( \sigma \) where the Lennard-Jones potential reaches zero. Lennard-Jones parameter.

◆ thermal_motion

std::array<double, 3> Particle::thermal_motion
private

Thermal motion \( \hat v \) of the particle.

◆ type

int Particle::type
private

Type of the particle. 1 if wall, 0 otherwise.

◆ v

std::array<double, 3> Particle::v
private

Velocity \( v \) of the particle.

◆ x

std::array<double, 3> Particle::x
private

Position \( x \) of the particle.


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