MolSim
Loading...
Searching...
No Matches
Functions
PositionCalculation.h File Reference

Strategy functions for calculating the position of one or more particles. More...

#include "objects/CellContainer.h"
#include "objects/ParticleContainer.h"

Go to the source code of this file.

Functions

void calculateX (ParticleContainer &particles, double delta_t, double g_grav, CellContainer *lc=nullptr, bool membrane=false)
 Calculates the position \( x \) for all Particle objects in a given ParticleContainer.
 
void calculateX_LC (ParticleContainer &particles, double delta_t, double g_grav, CellContainer *lc, bool membrane=false)
 Calculates the position \( x \) for all Particle objects in a given ParticleContainer when using the linked cells method.
 

Detailed Description

Strategy functions for calculating the position of one or more particles.

Date
2024-11-11

Function Documentation

◆ calculateX()

void calculateX ( ParticleContainer particles,
double  delta_t,
double  g_grav,
CellContainer lc = nullptr,
bool  membrane = false 
)

Calculates the position \( x \) for all Particle objects in a given ParticleContainer.

The position \( x_i \) of a given particle \( i \) at the next unit of time \( t_{n+1} \) is calculated using the formula

\[ x_i(t_{n+1}) = x_i(t_n) + \Delta t \cdot v_i(t_n) + (\Delta t)^2 \frac{F_i(t_n)}{2m_i}. \]

As an optimization, in order to prevent looping through all particles once more to reset the existing force and potentially apply gravity in the upcoming force calculation step of the time integration, this is done at the end of this function instead. If the gravity is set to 0, the force applied to all active particles will be zeroed instead.

Parameters
particlesThe ParticleContainer containing the Particle objects to iterate over.
delta_tThe timestep \( \Delta t \).
g_gravThe gravitational force \( g_{grav} \).
lcUnused. Present to allow calling function without last argument.
membraneUnused. Present to allow calling function without last argument.

◆ calculateX_LC()

void calculateX_LC ( ParticleContainer particles,
double  delta_t,
double  g_grav,
CellContainer lc,
bool  membrane = false 
)

Calculates the position \( x \) for all Particle objects in a given ParticleContainer when using the linked cells method.

The position update occurs analogously to the default, non-linked-cell function.

After each update, the particle may need to be moved to a different cell. The algorithm checks this and updates the cell correspondence accordingly. If the particle enters a halo cell, the appropriate boundary condition will be applied.

If a particle enters a corner halo cell where one side has a different boundary condition to the other, the condition is chosen based on which boundary the particle will hit first. See the report and presentation for more details.

As an optimization, in order to prevent looping through all particles once more to reset the existing force and potentially apply gravity in the upcoming force calculation step of the time integration, this is done at the end of this function instead. If the gravity is set to 0, the force applied to all active particles will be zeroed instead.

Parameters
particlesThe ParticleContainer containing the Particle objects to iterate over.
delta_tThe timestep \( \Delta t \).
g_gravThe gravitational force \( g_{grav} \).
lcThe CellContainer for the linked cells method.
membraneDetermines, whether gravity should be applied along the z-axis (true) or y-axis (false).