Weakly Compressible SPH

Weakly compressible SPH as introduced by Monaghan (1994). This formulation relies on a stiff equation of state that generates large pressure changes for small density variations.

TrixiParticles.WeaklyCompressibleSPHSystemType
WeaklyCompressibleSPHSystem(initial_condition,
                            density_calculator, state_equation,
                            smoothing_kernel, smoothing_length;
                            viscosity=nothing, density_diffusion=nothing,
                            acceleration=ntuple(_ -> 0.0, NDIMS),
                            buffer_size=nothing,
                            correction=nothing, source_terms=nothing)

System for particles of a fluid. The weakly compressible SPH (WCSPH) scheme is used, wherein a stiff equation of state generates large pressure changes for small density variations. See Weakly Compressible SPH for more details on the method.

Arguments

Keyword Arguments

  • viscosity: Viscosity model for this system (default: no viscosity). See ArtificialViscosityMonaghan or ViscosityAdami.
  • density_diffusion: Density diffusion terms for this system. See DensityDiffusion.
  • acceleration: Acceleration vector for the system. (default: zero vector)
  • buffer_size: Number of buffer particles. This is needed when simulating with OpenBoundarySPHSystem.
  • correction: Correction method used for this system. (default: no correction, see Corrections)
  • source_terms: Additional source terms for this system. Has to be either nothing (by default), or a function of (coords, velocity, density, pressure, t) (which are the quantities of a single particle), returning a Tuple or SVector that is to be added to the acceleration of that particle. See, for example, SourceTermDamping. Note that these source terms will not be used in the calculation of the boundary pressure when using a boundary with BoundaryModelDummyParticles and AdamiPressureExtrapolation. The keyword argument acceleration should be used instead for gravity-like source terms.
  • surface_tension: Surface tension model used for this SPH system. (default: no surface tension)
source

Equation of State

The equation of state is used to relate fluid density to pressure and thus allow an explicit simulation of the WCSPH system. The equation in the following formulation was introduced by Cole (1948) (pp. 39 and 43). The pressure $p$ is calculated as

\[ p = B \left(\left(\frac{\rho}{\rho_0}\right)^\gamma - 1\right) + p_{\text{background}},\]

where $\rho$ denotes the density, $\rho_0$ the reference density, and $p_{\text{background}}$ the background pressure, which is set to zero when applied to free-surface flows (Adami et al., 2012).

The bulk modulus, $B = \frac{\rho_0 c^2}{\gamma}$, is calculated from the artificial speed of sound $c$ and the isentropic exponent $\gamma$.

An ideal gas equation of state with a linear relationship between pressure and density can be obtained by choosing exponent=1, i.e.

\[ p = B \left( \frac{\rho}{\rho_0} -1 \right) = c^2(\rho - \rho_0).\]

For higher Reynolds numbers, exponent=7 is recommended, whereas at lower Reynolds numbers exponent=1 yields more accurate pressure estimates since pressure and density are proportional (see Morris, 1997).

When using SummationDensity (or DensityReinitializationCallback) and free surfaces, initializing particles with equal spacing will cause underestimated density and therefore strong attractive forces between particles at the free surface. Setting clip_negative_pressure=true can avoid this.

TrixiParticles.StateEquationColeType
StateEquationCole(; sound_speed, reference_density, exponent,
                  background_pressure=0.0, clip_negative_pressure=false)

Equation of state to describe the relationship between pressure and density of water up to high pressures.

Keywords

  • sound_speed: Artificial speed of sound.
  • reference_density: Reference density of the fluid.
  • exponent: A value of 7 is usually used for most simulations.
  • background_pressure=0.0: Background pressure.
source

Viscosity

TODO: Explain viscosity.

TrixiParticles.ArtificialViscosityMonaghanType
ArtificialViscosityMonaghan(; alpha, beta=0.0, epsilon=0.01)

Artificial viscosity by Monaghan ([16], [17]), given by

\[\Pi_{ab} = \begin{cases} -(\alpha c \mu_{ab} + \beta \mu_{ab}^2) / \bar{\rho}_{ab} & \text{if } v_{ab} \cdot r_{ab} < 0, \\ 0 & \text{otherwise} \end{cases}\]

with

\[\mu_{ab} = \frac{h v_{ab} \cdot r_{ab}}{\Vert r_{ab} \Vert^2 + \epsilon h^2},\]

where $\alpha, \beta, \epsilon$ are parameters, $c$ is the speed of sound, $h$ is the smoothing length, $r_{ab} = r_a - r_b$ is the difference of the coordinates of particles $a$ and $b$, $v_{ab} = v_a - v_b$ is the difference of their velocities, and $\bar{\rho}_{ab}$ is the arithmetic mean of their densities.

Note that $\alpha$ needs to adjusted for different resolutions to maintain a specific Reynolds Number. To do so, Monaghan (2005) defined an equivalent effective physical kinematic viscosity $\nu$ by

\[ \nu = \frac{\alpha h c }{2d + 4},\]

where $d$ is the dimension.

Keywords

  • alpha: A value of 0.02 is usually used for most simulations. For a relation with the kinematic viscosity, see description above.
  • beta=0.0: A value of 0.0 works well for most fluid simulations and simulations with shocks of moderate strength. In simulations where the Mach number can be very high, eg. astrophysical calculation, good results can be obtained by choosing a value of beta=2.0 and alpha=1.0.
  • epsilon=0.01: Parameter to prevent singularities.
source
TrixiParticles.ViscosityAdamiType
ViscosityAdami(; nu, epsilon=0.01)

Viscosity by Adami (2012). The viscous interaction is calculated with the shear force for incompressible flows given by

\[f_{ab} = \sum_w \bar{\eta}_{ab} \left( V_a^2 + V_b^2 \right) \frac{v_{ab}}{||r_{ab}||^2+\epsilon h_{ab}^2} \nabla W_{ab} \cdot r_{ab},\]

where $r_{ab} = r_a - r_b$ is the difference of the coordinates of particles $a$ and $b$, $v_{ab} = v_a - v_b$ is the difference of their velocities, $h$ is the smoothing length and $V$ is the particle volume. The parameter $\epsilon$ prevents singularities (see Ramachandran (2019)). The inter-particle-averaged shear stress is

\[ \bar{\eta}_{ab} =\frac{2 \eta_a \eta_b}{\eta_a + \eta_b},\]

where $\eta_a = \rho_a \nu_a$ with $\nu$ as the kinematic viscosity.

Keywords

  • nu: Kinematic viscosity
  • epsilon=0.01: Parameter to prevent singularities
source
TrixiParticles.ViscosityMorrisType
ViscosityMorris(; nu, epsilon=0.01)

Viscosity by Morris (1997) also used by Fourtakas (2019).

To the force $f_{ab}$ between two particles $a$ and $b$ due to pressure gradients, an additional force term $\tilde{f}_{ab}$ is added with

\[\tilde{f}_{ab} = m_a m_b \frac{(\mu_a + \mu_b) r_{ab} \cdot \nabla W_{ab}}{\rho_a \rho_b (\Vert r_{ab} \Vert^2 + \epsilon h^2)} v_{ab},\]

where $\mu_a = \rho_a \nu$ and $\mu_b = \rho_b \nu$ denote the dynamic viscosity of particle $a$ and $b$ respectively, and $\nu$ is the kinematic viscosity.

Keywords

  • nu: Kinematic viscosity
  • epsilon=0.01: Parameter to prevent singularities
source

Density Diffusion

Density diffusion can be used with ContinuityDensity to remove the noise in the pressure field. It is highly recommended to use density diffusion when using WCSPH.

Formulation

All density diffusion terms extend the continuity equation (see ContinuityDensity) by an additional term

\[\frac{\mathrm{d}\rho_a}{\mathrm{d}t} = \sum_{b} m_b v_{ab} \cdot \nabla_{r_a} W(\Vert r_{ab} \Vert, h) + \delta h c \sum_{b} V_b \psi_{ab} \cdot \nabla_{r_a} W(\Vert r_{ab} \Vert, h),\]

where $V_b = m_b / \rho_b$ is the volume of particle $b$ and $\psi_{ab}$ depends on the density diffusion method (see DensityDiffusion for available terms). Also, $\rho_a$ denotes the density of particle $a$ and $r_{ab} = r_a - r_b$ is the difference of the coordinates, $v_{ab} = v_a - v_b$ of the velocities of particles $a$ and $b$.

Numerical Results

All density diffusion terms remove numerical noise in the pressure field and produce more accurate results than weakly commpressible SPH without density diffusion. This can be demonstrated with dam break examples in 2D and 3D. Here, $δ = 0.1$ has been used for all terms. Note that, due to added stability, the adaptive time integration method that was used here can choose higher time steps in the simulations with density diffusion. For the cheap DensityDiffusionMolteniColagrossi, this results in reduced runtime.

density_diffusion_2d
Dam break in 2D with different density diffusion terms
density_diffusion_3d
Dam break in 3D with different density diffusion terms

The simpler terms DensityDiffusionMolteniColagrossi and DensityDiffusionFerrari do not solve the hydrostatic problem and lead to incorrect solutions in long-running steady-state hydrostatic simulations with free surfaces (Antuono et al., 2012). This can be seen when running the simple rectangular tank example until $t = 40$ (again using $δ = 0.1$):

density_diffusion_tank
Tank in rest under gravity in 3D with different density diffusion terms

DensityDiffusionAntuono adds a correction term to solve this problem, but this term is very expensive and adds about 40–50% of computational cost.

API

TrixiParticles.DensityDiffusionAntuonoType
DensityDiffusionAntuono(initial_condition; delta)

The commonly used density diffusion terms by Antuono (2010), also referred to as δ-SPH. The density diffusion term by Molteni (2009) is extended by a second term, which is nicely written down by Antuono (2012).

The term $\psi_{ab}$ in the continuity equation in DensityDiffusion is defined by

\[\psi_{ab} = 2\left(\rho_a - \rho_b - \frac{1}{2}\big(\nabla\rho^L_a + \nabla\rho^L_b\big) \cdot r_{ab}\right) \frac{r_{ab}}{\Vert r_{ab} \Vert^2},\]

where $\rho_a$ and $\rho_b$ denote the densities of particles $a$ and $b$ respectively and $r_{ab} = r_a - r_b$ is the difference of the coordinates of particles $a$ and $b$. The symbol $\nabla\rho^L_a$ denotes the renormalized density gradient defined as

\[\nabla\rho^L_a = -\sum_b (\rho_a - \rho_b) V_b L_a \nabla_{r_a} W(\Vert r_{ab} \Vert, h)\]

with

\[L_a := \left( -\sum_{b} V_b r_{ab} \otimes \nabla_{r_a} W(\Vert r_{ab} \Vert, h) \right)^{-1} \in \R^{d \times d},\]

where $d$ is the number of dimensions.

See DensityDiffusion for an overview and comparison of implemented density diffusion terms.

source
TrixiParticles.DensityDiffusionFerrariType
DensityDiffusionFerrari()

A density diffusion term by Ferrari (2009).

The term $\psi_{ab}$ in the continuity equation in DensityDiffusion is defined by

\[\psi_{ab} = \frac{\rho_a - \rho_b}{2h} \frac{r_{ab}}{\Vert r_{ab} \Vert},\]

where $\rho_a$ and $\rho_b$ denote the densities of particles $a$ and $b$ respectively, $r_{ab} = r_a - r_b$ is the difference of the coordinates of particles $a$ and $b$ and $h$ is the smoothing length.

See DensityDiffusion for an overview and comparison of implemented density diffusion terms.

source
TrixiParticles.DensityDiffusionMolteniColagrossiType
DensityDiffusionMolteniColagrossi(; delta)

The commonly used density diffusion term by Molteni (2009).

The term $\psi_{ab}$ in the continuity equation in DensityDiffusion is defined by

\[\psi_{ab} = 2(\rho_a - \rho_b) \frac{r_{ab}}{\Vert r_{ab} \Vert^2},\]

where $\rho_a$ and $\rho_b$ denote the densities of particles $a$ and $b$ respectively and $r_{ab} = r_a - r_b$ is the difference of the coordinates of particles $a$ and $b$.

See DensityDiffusion for an overview and comparison of implemented density diffusion terms.

source

Corrections

TrixiParticles.AkinciFreeSurfaceCorrectionType
AkinciFreeSurfaceCorrection(rho0)

Free surface correction according to Akinci et al. (2013). At a free surface, the mean density is typically lower than the reference density, resulting in reduced surface tension and viscosity forces. The free surface correction adjusts the viscosity, pressure, and surface tension forces near free surfaces to counter this effect. It's important to note that this correlation is unphysical and serves as an approximation. The computation time added by this method is about 2–3%.

Mathematically the idea is quite simple. If we have an SPH particle in the middle of a volume at rest, its density will be identical to the rest density $\rho_0$. If we now consider an SPH particle at a free surface at rest, it will have neighbors missing in the direction normal to the surface, which will result in a lower density. If we calculate the correction factor

\[k = \rho_0/\rho_\text{mean},\]

this value will be about ~1.5 for particles at the free surface and can then be used to increase the pressure and viscosity accordingly.

Arguments

  • rho0: Rest density.
source
TrixiParticles.BlendedGradientCorrectionType
BlendedGradientCorrection()

Calculate a blended gradient to reduce the stability issues of the GradientCorrection as explained by Bonet (1999).

This calculates the following,

\[\tilde\nabla A_i = (1-\lambda) \nabla A_i + \lambda L_i \nabla A_i\]

with $0 \leq \lambda \leq 1$ being the blending factor.

Arguments

  • blending_factor: Blending factor between corrected and regular SPH gradient.
source
TrixiParticles.GradientCorrectionType
GradientCorrection()

Compute the corrected gradient of particle interactions based on their relative positions (see Bonet, 1999).

Mathematical Details

Given the standard SPH representation, the gradient of a field $A$ at particle $a$ is given by

\[\nabla A_a = \sum_b m_b \frac{A_b - A_a}{\rho_b} \nabla_{r_a} W(\Vert r_a - r_b \Vert, h),\]

where $m_b$ is the mass of particle $b$ and $\rho_b$ is the density of particle $b$.

The gradient correction, as commonly proposed, involves multiplying this gradient with a correction matrix $L$:

\[\tilde{\nabla} A_a = \bm{L}_a \nabla A_a\]

The correction matrix $\bm{L}_a$ is computed based on the provided particle configuration, aiming to make the corrected gradient more accurate, especially near domain boundaries.

To satisfy

\[\sum_b V_b r_{ba} \otimes \tilde{\nabla}W_b(r_a) = \left( \sum_b V_b r_{ba} \otimes \nabla W_b(r_a) \right) \bm{L}_a^T = \bm{I}\]

the correction matrix $\bm{L}_a$ is evaluated explicitly as

\[\bm{L}_a = \left( \sum_b V_b \nabla W_b(r_{a}) \otimes r_{ba} \right)^{-1}.\]

Note
  • Stability issues arise, especially when particles separate into small clusters.
  • Doubles the computational effort.
  • Better stability with smoother smoothing Kernels with larger support, e.g. SchoenbergQuinticSplineKernel or WendlandC6Kernel.
  • Set dt_max =< 1e-3 for stability.
source
TrixiParticles.KernelCorrectionType
KernelCorrection()

Kernel correction, as explained by Bonet (1999), uses Shepard interpolation to obtain a 0-th order accurate result, which was first proposed by Li et al. This can be further extended to obtain a kernel corrected gradient as shown by Basa et al. (2008).

The kernel correction coefficient is determined by

\[c(x) = \sum_{b=1} V_b W_b(x)\]

The gradient of corrected kernel is determined by

\[\nabla \tilde{W}_{b}(r) =\frac{\nabla W_{b}(r) - W_b(r) \gamma(r)}{\sum_{b=1} V_b W_b(r)} , \quad \text{where} \quad \gamma(r) = \frac{\sum_{b=1} V_b \nabla W_b(r)}{\sum_{b=1} V_b W_b(r)}.\]

This correction can be applied with SummationDensity and ContinuityDensity, which leads to an improvement, especially at free surfaces.

Note
  • This only works when the boundary model uses SummationDensity (yet).
  • It is also referred to as "0th order correction".
  • In 2D, we can expect an increase of about 10–15% in computation time.
source
TrixiParticles.ShepardKernelCorrectionType
ShepardKernelCorrection()

Kernel correction, as explained by Bonet (1999), uses Shepard interpolation to obtain a 0-th order accurate result, which was first proposed by Li et al. (1996).

The kernel correction coefficient is determined by

\[c(x) = \sum_{b=1} V_b W_b(x),\]

where $V_b = m_b / \rho_b$ is the volume of particle $b$.

This correction is applied with SummationDensity to correct the density and leads to an improvement, especially at free surfaces.

Note
  • It is also referred to as "0th order correction".
  • In 2D, we can expect an increase of about 5–6% in computation time.
source

Surface Tension

Akinci-based intra-particle force surface tension and wall adhesion model

The work by Akinci proposes three forces:

  • a cohesion force
  • a surface area minimization force
  • a wall adhesion force

The classical model is composed of the curvature minimization and cohesion force.

Cohesion force

The model calculates the cohesion force based on the distance between particles and the support radius $h_c$. This force is determined using two distinct regimes within the support radius:

  • For particles closer than half the support radius, a repulsive force is calculated to prevent particle clustering too tightly, enhancing the simulation's stability and realism.
  • Beyond half the support radius and within the full support radius, an attractive force is computed, simulating the effects of surface tension that draw particles together.

The cohesion force, $F_{\text{cohesion}}$, for a pair of particles is given by:

\[F_{\text{cohesion}} = -\sigma m_b C(r) \frac{r}{\Vert r \Vert},\]

where:

  • $\sigma$ represents the surface tension coefficient, adjusting the overall strength of the cohesion effect.
  • $C$ is a scalar function of the distance between particles.

The cohesion kernel $C$ is defined as

\[C(r)=\frac{32}{\pi h_c^9} \begin{cases} (h_c-r)^3 r^3, & \text{if } 2r > h_c \\ 2(h_c-r)^3 r^3 - \frac{h^6}{64}, & \text{if } r > 0 \text{ and } 2r \leq h_c \\ 0, & \text{otherwise} \end{cases}\]

Surface area minimization force

To model the minimization of the surface area and curvature of the fluid, a curvature force is used, which is calculated as

\[F_{\text{curvature}} = -\sigma (n_a - n_b)\]

Wall adhesion force

The wall adhesion model proposed by Akinci et al. is based on a kernel function which is 0 from 0.0 to 0.5 support radiia with a maximum at 0.75. With the force calculated with an adhesion coefficient $\beta$ as

\[F_{\text{adhesion}} = -\beta m_b A(r) \frac{r}{\Vert r \Vert},\]

with $A$ being the adhesion kernel defined as

\[A(r)= \frac{0.007}{h_c^{3.25}} \begin{cases} \sqrt[4]{- \frac{4r^2}{h_c} + 6r - 2h_c}, & \text{if } 2r > h_c \text{ and } r \leq h_c \\ 0, & \text{otherwise.} \end{cases}\]

TrixiParticles.CohesionForceAkinciType
CohesionForceAkinci(surface_tension_coefficient=1.0)

This model only implements the cohesion force of the [25] surface tension model.

Keywords

  • surface_tension_coefficient=1.0: Modifies the intensity of the surface tension-induced force, enabling the tuning of the fluid's surface tension properties within the simulation.
source
TrixiParticles.SurfaceTensionAkinciType
SurfaceTensionAkinci(surface_tension_coefficient=1.0)

Implements a model for surface tension and adhesion effects drawing upon the principles outlined by [25]. This model is instrumental in capturing the nuanced behaviors of fluid surfaces, such as droplet formation and the dynamics of merging or separation, by utilizing intra-particle forces.

Keywords

  • surface_tension_coefficient=1.0: A parameter to adjust the magnitude of surface tension forces, facilitating the fine-tuning of how surface tension phenomena are represented in the simulation.
source