Fluid Models
Currently available fluid methods are the weakly compressible SPH method and the entropically damped artificial compressibility for SPH. This page lists models and techniques that apply to both of these methods.
Viscosity
Viscosity is a critical physical property governing momentum diffusion within a fluid. In the context of SPH, viscosity determines how rapidly velocity gradients are smoothed out, influencing key flow characteristics such as boundary layer formation, vorticity diffusion, and dissipation of kinetic energy. It also helps determine whether a flow is laminar or turbulent under a given set of conditions.
Implementing viscosity correctly in SPH is essential for producing physically accurate results, and different methods exist to capture both numerical stabilization and true viscous effects.
Artificial (numerical) viscosity
Artificial (numerical) viscosity is a technique used to stabilize simulations of inviscid flows, which would otherwise show unphysical particle movement due to numerical instability. To achieve this, a dissipative term is added to the momentum equations in a way that it does not significantly alter the physical behavior of the flow. This approach is especially useful in simulations such as high-speed flows with strong shocks or astrophysical scenarios, where other approaches are insufficient to stabilize the simulation.
Physical (real) viscosity
Physical viscosity is essential for accurately modeling the true viscous stresses within a fluid. It ensures that simulations align with a target Reynolds number or adhere to experimentally measured fluid properties. This is achieved by incorporating forces that replicate the viscous stress term found in the Navier–Stokes equations. As a result, the method is particularly effective for simulating low-speed, incompressible, or weakly compressible flows, where it is crucial to capture the actual behavior of the fluid.
Model comparison
ArtificialViscosityMonaghan
ArtificialViscosityMonaghan
by Monaghan ([9], [10]) should be mainly used for inviscid flows (Euler), artificial stabilization or shock-capturing, for which Monaghan [10] originally designed this term to provide smoothing across shocks, intentionally overestimating the physical viscosity. The implementation includes a dissipation term that becomes more significant as particles approach one another. This helps suppress tensile instabilities, which can lead to particle clumping and effectively smooths out high-frequency pressure fluctuations. This increase in dissipation is triggered by the relative motion between particles: as particles come closer and compress the local flow, the artificial viscosity term becomes stronger to damp out rapid changes and prevent unphysical clustering. This ensures that while the simulation remains stable in challenging flow regimes with large density or pressure variations, the physical behavior is not overly altered. Several extensions have been proposed to limit the dissipation effect for example by Balsara ([11]) or Morris ([12]).
Mathematical Formulation
The force exerted by particle b
on particle a
due to artificial viscosity is given by:
\[\mathbf{F}_{ab}^{\text{AV}} = - m_a m_b \Pi_{ab} \nabla W_{ab}\]
where:
\Pi_{ab}
is the artificial viscosity term defined as:```math \Pi{ab} = \begin{cases} -\frac{\alpha c \mu{ab} + \beta \mu{ab}^2}{\bar{\rho}{ab}} & \text{if } \mathbf{v}{ab} \cdot \mathbf{r}{ab} < 0, \ 0 & \text{otherwise} \end{cases} ```
$\alpha$ and $\beta$ are viscosity parameters,
$c$ is the local speed of sound,
$\bar{\rho}_{ab}$ is the arithmetic mean of the densities of particles $a$ and $b$.
The term $\mu_{ab}$ is defined as:
\[\mu_{ab} = \frac{h \, v_{ab} \cdot r_{ab}}{\Vert r_{ab} \Vert^2 + \epsilon h^2},\]
with:
- $h$ being the smoothing length,
- $\epsilon$ a small parameter to prevent singularities,
- $r_{ab} = r_a - r_b$ representing the difference of the coordinate vectors,
- $v_{ab} = v_a - v_b$ representing the relative velocity between particles.
Resolution Dependency and Effective Viscosity
To ensure that the simulation maintains a consistent Reynolds number when the resolution changes, the parameter $\alpha$ must be adjusted accordingly. Monaghan (2005) introduced an effective physical kinematic viscosity $\nu$ defined as:
\[\nu = \frac{\alpha h c}{2d + 4},\]
where $d$ is the number of spatial dimensions. This relation allows the calibration of $\alpha$ to achieve the desired viscous behavior as the resolution or simulation conditions vary.
ViscosityMorris
ViscosityMorris
is ideal for moderate to low Mach number flows where accurately modeling physical viscous behavior is essential. Developed by Morris (1997) and later applied by Fourtakas (2019), this method directly simulates the viscous stresses found in fluids rather than relying on artificial viscosity. By approximating momentum diffusion based on local fluid properties, the method captures the actual viscous forces without excessive damping. This results in a more realistic representation of flow dynamics in weakly compressible scenarios.
Mathematical Formulation
An additional force term $\tilde{f}_{ab}$ is introduced to the pressure gradient force $f_{ab}$ between particles $a$ and $b$:
\[\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$ represent the dynamic viscosities of particles $a$and $b$ (with $\nu$ being the kinematic viscosity),
- $r_{ab} = r_a - r_b$ represents the difference of the coordinate vectors,
- $v_{ab} = v_a - v_b$ represents the relative velocity between particles.
- $h$ is the smoothing length,
- $\nabla W_{ab}$ is the gradient of the smoothing kernel,
- $\epsilon$ is a small parameter to prevent singularities.
ViscosityAdami
ViscosityAdami
, introduced by Adami (2012), is optimized for incompressible or weakly compressible flows where precise modeling of shear stress is critical. It enhances boundary layer representation by better resolving shear gradients, increasing dissipation in regions with steep velocity differences (e.g., near solid boundaries) while minimizing compressibility effects. This results in accurate laminar flow simulations and accurate physical shear stresses.
Mathematical Formulation
The viscous interaction is modeled through a shear force for incompressible flows:
\[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 coordinate vectors,
- $v_{ab} = v_a - v_b$ is their relative velocity,
- $V_a = m_a / \rho_a$ and $V_b = m_b / \rho_b$ are the particle volumes,
- $h_{ab}$ is the smoothing length,
- $\nabla W_{ab}$ is the gradient of the smoothing kernel,
- $\epsilon$ is a small parameter that prevents singularities (see Ramachandran (2019)).
The inter-particle-averaged shear stress is defined as:
\[\bar{\eta}_{ab} = \frac{2 \eta_a \eta_b}{\eta_a + \eta_b},\]
with the dynamic viscosity of each particle given by $\eta_a = \rho_a \nu_a$, where $\nu_a$ is the kinematic viscosity.
TrixiParticles.ArtificialViscosityMonaghan
— TypeArtificialViscosityMonaghan(; alpha, beta=0.0, epsilon=0.01)
Artificial viscosity by Monaghan ([9], [10]).
See Viscosity
for an overview and comparison of implemented viscosity models.
Keywords
alpha
: A value of0.02
is usually used for most simulations. For a relation with the kinematic viscosity, see description above.beta=0.0
: A value of0.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 ofbeta=2.0
andalpha=1.0
.epsilon=0.01
: Parameter to prevent singularities.
TrixiParticles.ViscosityAdami
— TypeViscosityAdami(; nu, epsilon=0.01)
Viscosity by Adami (2012).
See Viscosity
for an overview and comparison of implemented viscosity models.
Keywords
nu
: Kinematic viscosityepsilon=0.01
: Parameter to prevent singularities
TrixiParticles.ViscosityMorris
— TypeViscosityMorris(; nu, epsilon=0.01)
Viscosity by Morris (1997) also used by Fourtakas (2019).
See Viscosity
for an overview and comparison of implemented viscosity models.
Keywords
nu
: Kinematic viscosityepsilon=0.01
: Parameter to prevent singularities
Corrections
TrixiParticles.AkinciFreeSurfaceCorrection
— TypeAkinciFreeSurfaceCorrection(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.
TrixiParticles.BlendedGradientCorrection
— TypeBlendedGradientCorrection()
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.
TrixiParticles.GradientCorrection
— TypeGradientCorrection()
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}.\]
- 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
orWendlandC6Kernel
. - Set
dt_max =< 1e-3
for stability.
TrixiParticles.KernelCorrection
— TypeKernelCorrection()
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.
- 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.
TrixiParticles.MixedKernelGradientCorrection
— TypeMixedKernelGradientCorrection()
Combines GradientCorrection
and KernelCorrection
, which results in a 1st-order-accurate SPH method (see Bonet, 1999).
Notes:
- Stability issues, especially when particles separate into small clusters.
- Doubles the computational effort.
TrixiParticles.ShepardKernelCorrection
— TypeShepardKernelCorrection()
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.
Surface Normals
Overview of surface normal calculation in SPH
Surface normals are essential for modeling surface tension as they provide the directionality of forces acting at the fluid interface. They are calculated based on the particle properties and their spatial distribution.
Color field and gradient-based surface normals
The surface normal at a particle is derived from the color field, a scalar field assigned to particles to distinguish between different fluid phases or between fluid and air. The color field gradients point towards the interface, and the normalized gradient defines the surface normal direction.
The simplest SPH formulation for a surface normal, $n_a$ is given as
\[n_a = \sum_b m_b \frac{c_b}{\rho_b} \nabla_a W_{ab},\]
where:
- $c_b$ is the color field value for particle $b$,
- $m_b$ is the mass of particle $b$,
- $\rho_b$ is the density of particle $b$,
- $\nabla_a W_{ab}$ is the gradient of the smoothing kernel $W_{ab}$ with respect to particle $a$.
Normalization of surface normals
The calculated normals are normalized to unit vectors:
\[\hat{n}_a = \frac{n_a}{\Vert n_a \Vert}.\]
Normalization ensures that the magnitude of the normals does not bias the curvature calculations or the resulting surface tension forces.
Handling noise and errors in normal calculation
In regions distant from the interface, the calculated normals may be small or inaccurate due to the smoothing kernel's support radius. To mitigate this:
- Normals below a threshold are excluded from further calculations.
- Curvature calculations use a corrected formulation to reduce errors near interface fringes.
TrixiParticles.ColorfieldSurfaceNormal
— TypeColorfieldSurfaceNormal(; boundary_contact_threshold=0.1, interface_threshold=0.01,
ideal_density_threshold=0.0)
Color field based computation of the interface normals.
Keyword Arguments
boundary_contact_threshold=0.1
: If this threshold is reached the fluid is assumed to be in contact with the boundary.interface_threshold=0.01
: Threshold for normals to be removed as being invalid.ideal_density_threshold=0.0
: Assume particles are inside if they are above this threshold, which is relative to theideal_neighbor_count
.
Surface Tension
Surface tension is a key phenomenon in fluid dynamics, influencing the behavior of droplets, bubbles, and fluid interfaces. In SPH, surface tension is modeled as forces arising due to surface curvature and relative particle movement, ensuring realistic simulation of capillary effects, droplet coalescence, and fragmentation.
The surface tension coefficient $\sigma$ is a physical parameter that quantifies the energy required to increase the surface area of a fluid by a unit amount. A higher value of $\sigma$ indicates that the fluid resists changes to its surface area more strongly, causing droplets or bubbles to assume shapes (often spherical) that minimize their surface. In practice, $\sigma$ can be measured experimentally through techniques such as the pendant drop method, the Wilhelmy plate method, or the du Noüy ring method, each of which relates a measurable force or change in shape to the fluid’s surface tension. For pure substances, tabulated reference values of $\sigma$ at given temperatures are commonly used, while for mixtures or complex fluids, direct experimental measurements or values can be estimated from empirical equation (see Poling or Lange). In the following table some values are shown for reference. The values marked with a '~' are complex mixtures that are estimated by an empirical equation (see Poling).
Fluid | Surface Tension ($\sigma$) [N/m at 20°C] |
---|---|
Gasoline | ~0.022 Poling |
Ethanol | 0.022386 Lange |
Acetone | 0.02402 Lange |
Mineral Oil | ~0.030 Poling |
Olive Oil | 0.03303 Hui, MeloEspinosa |
Glycerol | 0.06314 Lange |
Water | 0.07288 Lange |
Mercury | 0.486502 Lange |
Akinci-based intra-particle force surface tension and wall adhesion model
The Akinci model divides surface tension into distinct force components:
Cohesion force
The cohesion force captures the attraction between particles at the fluid interface, creating the effect of surface tension. It is defined by the distance between particles and the support radius $h_c$, using a kernel-based formulation.
Key features:
- Particles within half the support radius experience a repulsive force to prevent clustering.
- Particles beyond half the radius but within the support radius experience an attractive force to simulate cohesion.
Mathematically:
\[F_{\text{cohesion}} = -\sigma m_b C(r) \frac{r}{\Vert r \Vert},\]
where $C(r)$, the cohesion kernel, 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
The surface area minimization force models the curvature reduction effects, aligning particle motion to reduce the interface's total area. It acts based on the difference in surface normals:
\[F_{\text{curvature}} = -\sigma (n_a - n_b),\]
where $n_a$ and $n_b$ are the surface normals of the interacting particles.
Wall adhesion force
This force models the interaction between fluid and solid boundaries, simulating adhesion effects at walls. It uses a custom kernel with a peak at 0.75 times the support radius:
\[F_{\text{adhesion}} = -\beta m_b A(r) \frac{r}{\Vert r \Vert},\]
where $A(r)$ is the adhesion kernel:
\[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}\]
Morris surface tension model
The method described by Morris estimates curvature by combining particle color gradients (see surface_normal
) and smoothing functions to derive surface normals. The computed curvature is then used to determine forces acting perpendicular to the interface. While this method provides accurate surface tension forces, it does not explicitly conserve momentum.
In the Morris model, surface tension is computed based on local interface curvature $\kappa$ and the unit surface normal $\hat{n}.$ By estimating $\hat{n}$ and $\kappa$ at each particle near the interface, the surface tension force for particle a can be written as:
\[F_{\text{surface tension}} = - \sigma \frac{\kappa_a}{\rho_a}\hat{n}_a\]
This formulation focuses directly on geometric properties of the interface, making it relatively straightforward to implement when a reliable interface detection (e.g., a color function) is available. However, accurately estimating $\kappa$ and $n$ may require fine resolutions.
Morris-based momentum-conserving surface tension model
In addition to the simpler curvature-based formulation, Morris introduced a momentum-conserving approach. This method treats surface tension forces as arising from the divergence of a stress tensor, ensuring exact conservation of linear momentum and offering more robust behavior for high-resolution or long-duration simulations where accumulated numerical error can be significant.
Stress tensor formulation
The surface tension force can be seen as a divergence of a stress tensor $S$
\[F_{\text{surface tension}} = \nabla \cdot S,\]
with $S$ defined as
\[S = \sigma \delta_s (I - \hat{n} \otimes \hat{n}),\]
with:
- $\delta_s$: Surface delta function,
- $\hat{n}$: Unit normal vector,
- $I$: Identity matrix.
This divergence can be computed numerically in the SPH framework as
\[\sum_b \frac{m_b}{\rho_a \rho_b} (S_a + S_b) \nabla W_{ab} \]
Advantages and limitations
While momentum conservation makes this model attractive, it requires additional computational effort and stabilization techniques to address instabilities in high-density regions.
API
TrixiParticles.CohesionForceAkinci
— TypeCohesionForceAkinci(surface_tension_coefficient=1.0)
This model only implements the cohesion force of the Akinci [16] surface tension model.
See surface_tension
for more details.
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.
TrixiParticles.SurfaceTensionAkinci
— TypeSurfaceTensionAkinci(surface_tension_coefficient=1.0)
Implements a model for surface tension and adhesion effects drawing upon the principles outlined by Akinci [16]. 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.
See surface_tension
for more details.
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.
TrixiParticles.SurfaceTensionMomentumMorris
— TypeSurfaceTensionMomentumMorris(surface_tension_coefficient=1.0)
This model implements the momentum-conserving surface tension approach outlined by Morris [24]. It calculates surface tension forces using the divergence of a stress tensor, ensuring exact conservation of linear momentum. This method is particularly useful for simulations where momentum conservation is critical, though it may require numerical adjustments at higher resolutions.
See surface_tension
for more details.
Keywords
surface_tension_coefficient=1.0
: A parameter to adjust the strength of surface tension forces, allowing fine-tuning to replicate physical behavior.
TrixiParticles.SurfaceTensionMorris
— TypeSurfaceTensionMorris(surface_tension_coefficient=1.0)
This model implements the surface tension approach described by Morris [24]. It calculates surface tension forces based on the curvature of the fluid interface using particle normals and their divergence, making it suitable for simulating phenomena like droplet formation and capillary wave dynamics.
See surface_tension
for more details.
Keywords
surface_tension_coefficient=1.0
: Adjusts the magnitude of the surface tension forces, enabling tuning of fluid surface behaviors in simulations.