Skip to content

Commit aa110a6

Browse files
svchbefaulhaberLasNikas
authored
Implement Morris surface tension model (#584)
* review comments * format * fix test * fix test * fix test * fix * remove some allocations * format * fix docs * some fixes * Update src/schemes/fluid/weakly_compressible_sph/state_equations.jl Co-authored-by: Erik Faulhaber <[email protected]> * add docs * review fixes * remove independent setting of smoothing_kernel and smoothing_length * remove calls to surface_normal method smoothing kernel * format * update news * typo * forgot to edit the other doc * format * Update NEWS.md * forgot some renames * fix doc tests * fix docs * fix tests * format * cleanup * format * Update NEWS.md * fix tests * Update NEWS.md * fixers * fix * fix * fix * fix * improve documentation * fixes * format * adding this again * review fixes * review comments * fix test * update * format * fix test * merge * typo * merge error * typo * update * update * review updates * review update * add boundary system * update * update * format * format * fix merge * format * another merge error * format * reset to original version * remove color since it is unused in this PR * readd color since it is used here * review comment * format * merge error * review comment * format * fix * format * fix * remove surface_normal_method() * readd surface_normal_method() * merge error * function was renamed in PN * format * fix test * fix error * fix * review comments * review comments * review comments * format * merge * format * add comment * remove ideal_neighbor() * format * format * typo * fix tests * format * add missing docs * cleanup * only initialize necessary values * fix test * fix examples * format * fix tests * typo * remove validation case * rectangular test * update * format * typo * move stress calculation * fix test * format * update * format * update * update * more line breaks * remove fluff * doc fixes * define sigma * improve docs * more doc improvements * fix docs * remove unnecessary example * fix allocations * add descriptions * reduce example runtime * move fluid examples to separate file * format * add missing comment * fix stress_tensor() * fix docs * improve coverage * reduce example run time * further reduce runtime * format * fix merge error * now for real * fix * fix test * update viscosity * update format * remove viscosity docs * update * review * fix docs * review * fix tests * Update examples_fluid.jl * add citations for table * clarification * review * review * merge * format * fix merge * suppress typo * move ideal_neighbor_count to cache * move to cache * format * some lost changes * more lost changes * format * fix test * fix * remove packing changes * remove packing changes * forgot one * remove ideal_neighbor_count from local values * part 2 * review * format * update news * review * rename * format * remove typo * update * fix comment --------- Co-authored-by: Erik Faulhaber <[email protected]> Co-authored-by: Niklas Neher <[email protected]>
1 parent 9d62c33 commit aa110a6

34 files changed

+1769
-723
lines changed

Diff for: .typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Strack = "Strack"
99
Lok = "Lok"
1010
PN = "PN"
1111
Typ = "Typ"
12+
Yiu = "Yiu"

Diff for: NEWS.md

+23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
TrixiParticles.jl follows the interpretation of [semantic versioning (semver)](https://julialang.github.io/Pkg.jl/dev/compatibility/#Version-specifier-format-1)
44
used in the Julia ecosystem. Notable changes will be documented in this file for human readability.
55

6+
## Version 0.2.7
7+
8+
### Features
9+
10+
- Adds the classic **Continuum Surface Force (CSF)** model based on Morris 2000 (#584), which computes
11+
surface tension as a **body force** proportional to curvature and directed along the interface normal.
12+
This method is efficient and accurate for capillary effects but does not explicitly conserve momentum.
13+
14+
- Added the classic **Continuum Surface Stress (CSS)** model based on Morris 2000 (#584), which is
15+
a **momentum-conserving** approach that formulates surface tension as the **divergence of a stress tensor**.
16+
However, it requires additional computation and stabilization to handle **high-density interfaces** and reduce numerical instabilities.
17+
18+
- Implement `BoundaryZone` to allow for bidirectional flow (#623)
19+
20+
21+
### Testing
22+
23+
- Run CI tests on GPUs via Buildkite CI (#723)
24+
25+
### Bugs
26+
27+
- Fix GPU computations (#689)
28+
629
## Version 0.2.6
730

831
### Features

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TrixiParticles"
22
uuid = "66699cd8-9c01-4e9d-a059-b96c86d16b3a"
33
authors = ["erik.faulhaber <[email protected]>"]
4-
version = "0.2.7-dev"
4+
version = "0.2.7"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

Diff for: docs/src/refs.bib

+48
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,19 @@ @Article{Morris1997
491491
publisher = {Elsevier BV},
492492
}
493493

494+
@article{Morris2000,
495+
author = {Morris, Joseph P.},
496+
title = {Simulating surface tension with smoothed particle hydrodynamics},
497+
journal = {International Journal for Numerical Methods in Fluids},
498+
volume = {33},
499+
number = {3},
500+
pages = {333-353},
501+
keywords = {interfacial flow, meshless methods, surface tension},
502+
doi = {https://doi.org/10.1002/1097-0363(20000615)33:3<333::AID-FLD11>3.0.CO;2-7},
503+
year = {2000}
504+
}
505+
506+
494507
@InProceedings{Mueller2003,
495508
author = {M{\"u}ller, Matthias and Charypar, David and Gross, Markus},
496509
booktitle = {Proceedings of the 2003 ACM SIGGRAPH/Eurographics Symposium on Computer Animation},
@@ -622,3 +635,38 @@ @Article{Wendland1995
622635
}
623636

624637
@Comment{jabref-meta: databaseType:bibtex;}
638+
639+
@book{Lange2005,
640+
author = {{Lange's Handbook of Chemistry}},
641+
title = {Lange's Handbook of Chemistry},
642+
edition = {16th},
643+
publisher = {McGraw-Hill},
644+
year = {2005}
645+
}
646+
647+
@article{MeloEspinosa2014,
648+
author = {Melo-Espinosa, Eliezer A. and S{\'a}nchez-Borroto, Yisel and Errasti, Michel and Hansen, Alan C.},
649+
title = {Surface Tension Prediction of Vegetable Oils Using Artificial Neural Networks and Multiple Linear Regression},
650+
journal = {Energy Conversion and Management},
651+
volume = {84},
652+
pages = {50--60},
653+
doi = {https://doi.org/10.1016/j.enconman.2014.08.004},
654+
year = {2014}
655+
}
656+
657+
@book{Hui1992,
658+
author = {Hui, Yiu H.},
659+
title = {Encyclopedia of Food Science and Technology},
660+
year = {1992},
661+
publisher = {Academic Press},
662+
address = {London},
663+
isbn = {9780122774308}
664+
}
665+
666+
@book{Poling2001,
667+
title = {The Properties of Gases and Liquids},
668+
author = {Poling, Bruce E. and Prausnitz, John M. and O'Connell, John P.},
669+
year = {2001},
670+
publisher = {McGraw-Hill},
671+
address = {New York}
672+
}

Diff for: docs/src/systems/fluid.md

+180-32
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
12
# [Fluid Models](@id fluid_models)
2-
Currently available fluid methods are the [weakly compressible SPH method](@ref wcsph) and the [entropically damped artificial compressibility for SPH](@ref edac).
3+
4+
Currently available fluid methods are the [weakly compressible SPH method](@ref wcsph) and the
5+
[entropically damped artificial compressibility for SPH](@ref edac).
36
This page lists models and techniques that apply to both of these methods.
47

58
## [Viscosity](@id viscosity_wcsph)
69

7-
TODO: Explain viscosity.
10+
Viscosity is a critical physical property governing momentum diffusion within a fluid.
11+
In the context of SPH, viscosity determines how rapidly velocity gradients are smoothed out,
12+
influencing key flow characteristics such as boundary layer formation, vorticity diffusion,
13+
and dissipation of kinetic energy. It also helps determine whether a flow is laminar or turbulent
14+
under a given set of conditions.
15+
16+
Implementing viscosity correctly in SPH is essential for producing physically accurate results,
17+
and different methods exist to capture both numerical stabilization and true viscous effects.
18+
19+
### API
820

921
```@autodocs
1022
Modules = [TrixiParticles]
@@ -18,71 +30,207 @@ Modules = [TrixiParticles]
1830
Pages = [joinpath("general", "corrections.jl")]
1931
```
2032

21-
33+
---
2234

2335
## [Surface Normals](@id surface_normal)
36+
37+
### Overview of surface normal calculation in SPH
38+
39+
Surface normals are essential for modeling surface tension as they provide the directionality
40+
of forces acting at the fluid interface. They are calculated based on the particle properties and
41+
their spatial distribution.
42+
43+
#### Color field and gradient-based surface normals
44+
45+
The surface normal at a particle is derived from the color field, a scalar field assigned to particles
46+
to distinguish between different fluid phases or between fluid and air. The color field gradients point
47+
towards the interface, and the normalized gradient defines the surface normal direction.
48+
49+
The simplest SPH formulation for a surface normal, ``n_a`` is given as
50+
51+
```math
52+
n_a = \sum_b m_b \frac{c_b}{\rho_b} \nabla_a W_{ab},
53+
```
54+
55+
where:
56+
57+
- ``c_b`` is the color field value for particle ``b``,
58+
- ``m_b`` is the mass of particle ``b``,
59+
- ``\rho_b`` is the density of particle ``b``,
60+
- ``\nabla_a W_{ab}`` is the gradient of the smoothing kernel ``W_{ab}`` with respect to particle ``a``.
61+
62+
#### Normalization of surface normals
63+
64+
The calculated normals are normalized to unit vectors:
65+
66+
```math
67+
\hat{n}_a = \frac{n_a}{\Vert n_a \Vert}.
68+
```
69+
70+
Normalization ensures that the magnitude of the normals does not bias the curvature calculations or the resulting surface tension forces.
71+
72+
#### Handling noise and errors in normal calculation
73+
74+
In regions distant from the interface, the calculated normals may be small or inaccurate due to the
75+
smoothing kernel's support radius. To mitigate this:
76+
77+
1. Normals below a threshold are excluded from further calculations.
78+
2. Curvature calculations use a corrected formulation to reduce errors near interface fringes.
79+
2480
```@autodocs
2581
Modules = [TrixiParticles]
2682
Pages = [joinpath("schemes", "fluid", "surface_normal_sph.jl")]
2783
```
2884

29-
## [Surface Tension](@id surface_tension)
85+
---
3086

31-
### Akinci-based intra-particle force surface tension and wall adhesion model
32-
The work by Akinci proposes three forces:
33-
- a cohesion force
34-
- a surface area minimization force
35-
- a wall adhesion force
87+
## [Surface Tension](@id surface_tension)
3688

37-
The classical model is composed of the curvature minimization and cohesion force.
89+
Surface tension is a key phenomenon in fluid dynamics, influencing the behavior of droplets, bubbles, and fluid interfaces.
90+
In SPH, surface tension is modeled as forces arising due to surface curvature and relative particle movement, ensuring realistic
91+
simulation of capillary effects, droplet coalescence, and fragmentation.
92+
93+
The surface tension coefficient ``\sigma`` is a physical parameter that quantifies the energy required to increase the surface area
94+
of a fluid by a unit amount. A higher value of ``\sigma`` indicates that the fluid resists changes to its surface area more strongly,
95+
causing droplets or bubbles to assume shapes (often spherical) that minimize their surface. In practice, ``\sigma`` can be measured
96+
experimentally through techniques such as the pendant drop method, the Wilhelmy plate method, or the du Noüy ring method,
97+
each of which relates a measurable force or change in shape to the fluid’s surface tension. For pure substances,
98+
tabulated reference values of ``\sigma`` at given temperatures are commonly used, while for mixtures or complex fluids,
99+
direct experimental measurements or values can be estimated from empirical equation (see [Poling](@cite Poling2001) or [Lange](@cite Lange2005)).
100+
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](@cite Poling2001)).
101+
102+
| **Fluid** | **Surface Tension (``\sigma``) [N/m at 20°C]** |
103+
|--------------|----------------------------------------------:|
104+
| **Gasoline** | ~0.022 [Poling](@cite Poling2001) |
105+
| **Ethanol** | 0.022386 [Lange](@cite Lange2005) |
106+
| **Acetone** | 0.02402 [Lange](@cite Lange2005) |
107+
| **Mineral Oil** | ~0.030 [Poling](@cite Poling2001) |
108+
| **Olive Oil** | 0.03303 [Hui](@cite Hui1992), [MeloEspinosa](@cite MeloEspinosa2014) |
109+
| **Glycerol** | 0.06314 [Lange](@cite Lange2005) |
110+
| **Water** | 0.07288 [Lange](@cite Lange2005) |
111+
| **Mercury** | 0.486502 [Lange](@cite Lange2005) |
112+
113+
### [Akinci-based intra-particle force surface tension and wall adhesion model](@id akinci_ipf)
114+
115+
The [Akinci](@cite Akinci2013) model divides surface tension into distinct force components:
38116

39117
#### Cohesion force
40-
The model calculates the cohesion force based on the support radius ``h_c`` and the distance between particles.
41-
This force is determined using two distinct regimes within the support radius:
42-
- For particles closer than half the support radius,
43-
a repulsive force is calculated to prevent particles from clustering too tightly,
44-
enhancing the simulation's stability and realism.
45-
- Beyond half the support radius and within the full support radius,
46-
an attractive force is computed, simulating the effects of surface tension that draw particles together.
47-
The cohesion force, ``F_{\text{cohesion}}``, for a pair of particles is given by:
118+
119+
The cohesion force captures the attraction between particles at the fluid interface, creating the effect of surface tension.
120+
It is defined by the distance between particles and the support radius ``h_c``, using a kernel-based formulation.
121+
122+
**Key features:**
123+
124+
- Particles within half the support radius experience a repulsive force to prevent clustering.
125+
- Particles beyond half the radius but within the support radius experience an attractive force to simulate cohesion.
126+
127+
Mathematically:
128+
48129
```math
49130
F_{\text{cohesion}} = -\sigma m_b C(r) \frac{r}{\Vert r \Vert},
50131
```
51-
where:
52-
- ``\sigma`` represents the surface tension coefficient, adjusting the overall strength of the cohesion effect.
53-
- ``C`` is a scalar function of the distance between particles.
54132

55-
The cohesion kernel ``C`` is defined as
133+
where ``C(r)``, the cohesion kernel, is defined as:
134+
56135
```math
57136
C(r)=\frac{32}{\pi h_c^9}
58137
\begin{cases}
59-
(h_c-r)^3 r^3, & \text{if } 2r > h_c \\
60-
2(h_c-r)^3 r^3 - \frac{h^6}{64}, & \text{if } r > 0 \text{ and } 2r \leq h_c \\
61-
0, & \text{otherwise}
138+
(h_c-r)^3 r^3, & \text{if } 2r > h_c, \\
139+
2(h_c-r)^3 r^3 - \frac{h^6}{64}, & \text{if } r > 0 \text{ and } 2r \leq h_c, \\
140+
0, & \text{otherwise.}
62141
\end{cases}
63142
```
64143

65144
#### Surface area minimization force
66-
To model the minimization of the surface area and curvature of the fluid, a curvature force is used, which is calculated as
145+
146+
The surface area minimization force models the curvature reduction effects, aligning particle motion to reduce the interface's total area.
147+
It acts based on the difference in surface normals:
148+
67149
```math
68-
F_{\text{curvature}} = -\sigma (n_a - n_b)
150+
F_{\text{curvature}} = -\sigma (n_a - n_b),
69151
```
70152

153+
where ``n_a`` and ``n_b`` are the surface normals of the interacting particles.
154+
71155
#### Wall adhesion force
72-
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.
73-
With the force calculated with an adhesion coefficient ``\beta`` as
156+
157+
This force models the interaction between fluid and solid boundaries, simulating adhesion effects at walls.
158+
It uses a custom kernel with a peak at 0.75 times the support radius:
159+
74160
```math
75161
F_{\text{adhesion}} = -\beta m_b A(r) \frac{r}{\Vert r \Vert},
76162
```
77-
with ``A`` being the adhesion kernel defined as
163+
164+
where ``A(r)`` is the adhesion kernel:
165+
78166
```math
79-
A(r)= \frac{0.007}{h_c^{3.25}}
167+
A(r) = \frac{0.007}{h_c^{3.25}}
80168
\begin{cases}
81-
\sqrt[4]{- \frac{4r^2}{h_c} + 6r - 2h_c}, & \text{if } 2r > h_c \text{ and } r \leq h_c \\
169+
\sqrt[4]{-\frac{4r^2}{h_c} + 6r - 2h_c}, & \text{if } 2r > h_c \text{ and } r \leq h_c, \\
82170
0, & \text{otherwise.}
83171
\end{cases}
84172
```
85173

174+
---
175+
176+
### [Morris surface tension model](@id morris_csf)
177+
178+
The method described by [Morris](@cite Morris2000) estimates curvature by combining particle color gradients (see [`surface_normal`](@ref)) and smoothing functions to derive surface normals.
179+
The computed curvature is then used to determine forces acting perpendicular to the interface.
180+
While this method provides accurate surface tension forces, it does not explicitly conserve momentum.
181+
182+
In the Morris model, surface tension is computed based on local interface curvature ``\kappa`` and the unit surface normal ``\hat{n}.``
183+
By estimating ``\hat{n}`` and ``\kappa`` at each particle near the interface, the surface tension force for particle a can be written as:
184+
185+
```math
186+
F_{\text{surface tension}} = - \sigma \frac{\kappa_a}{\rho_a}\hat{n}_a
187+
```
188+
189+
This formulation focuses directly on geometric properties of the interface, making it relatively straightforward to implement when a reliable interface detection
190+
(e.g., a color function) is available. However, accurately estimating ``\kappa`` and ``n`` may require fine resolutions.
191+
192+
---
193+
194+
### [Morris-based momentum-conserving surface tension model](@id moriss_css)
195+
196+
In addition to the simpler curvature-based formulation, [Morris](@cite Morris2000) introduced a momentum-conserving approach.
197+
This method treats surface tension forces as arising from the divergence of a stress tensor, ensuring exact conservation
198+
of linear momentum and offering more robust behavior for high-resolution or long-duration simulations
199+
where accumulated numerical error can be significant.
200+
201+
#### Stress tensor formulation
202+
203+
The surface tension force can be seen as a divergence of a stress tensor ``S``
204+
205+
```math
206+
F_{\text{surface tension}} = \nabla \cdot S,
207+
```
208+
209+
with ``S`` defined as
210+
211+
```math
212+
S = \sigma \delta_s (I - \hat{n} \otimes \hat{n}),
213+
```
214+
215+
with:
216+
217+
- ``\delta_s``: Surface delta function,
218+
- ``\hat{n}``: Unit normal vector,
219+
- ``I``: Identity matrix.
220+
221+
This divergence can be computed numerically in the SPH framework as
222+
223+
```math
224+
\sum_b \frac{m_b}{\rho_a \rho_b} (S_a + S_b) \nabla W_{ab}
225+
```
226+
227+
#### Advantages and limitations
228+
229+
While momentum conservation makes this model attractive, it requires additional computational effort and stabilization
230+
techniques to address instabilities in high-density regions.
231+
232+
### API
233+
86234
```@autodocs
87235
Modules = [TrixiParticles]
88236
Pages = [joinpath("schemes", "fluid", "surface_tension.jl")]

Diff for: examples/fluid/dam_break_oil_film_2d.jl

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ smoothing_length = 3.5 * fluid_particle_spacing
1818
sound_speed = 20 * sqrt(gravity * H)
1919

2020
# Physical values
21-
nu_water = 8.9E-7
22-
nu_oil = 6E-5
21+
nu_water = 8.9e-7
22+
nu_oil = 6e-5
2323
nu_ratio = nu_water / nu_oil
2424

2525
nu_sim_oil = max(0.01 * smoothing_length * sound_speed, nu_oil)
2626
nu_sim_water = nu_ratio * nu_sim_oil
2727

2828
oil_viscosity = ViscosityMorris(nu=nu_sim_oil)
2929

30+
# TODO: broken if both systems use surface tension
3031
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
3132
sol=nothing, fluid_particle_spacing=fluid_particle_spacing,
3233
viscosity=ViscosityMorris(nu=nu_sim_water), smoothing_length=smoothing_length,
@@ -60,6 +61,13 @@ oil_system = WeaklyCompressibleSPHSystem(oil, fluid_density_calculator,
6061
correction=AkinciFreeSurfaceCorrection(oil_density),
6162
reference_particle_spacing=fluid_particle_spacing)
6263

64+
# oil_system = WeaklyCompressibleSPHSystem(oil, fluid_density_calculator,
65+
# oil_eos, smoothing_kernel,
66+
# smoothing_length, viscosity=oil_viscosity,
67+
# acceleration=(0.0, -gravity),
68+
# surface_tension=SurfaceTensionMorris(surface_tension_coefficient=0.03),
69+
# reference_particle_spacing=fluid_particle_spacing)
70+
6371
# ==========================================================================================
6472
# ==== Simulation
6573
semi = Semidiscretization(fluid_system, oil_system, boundary_system,

0 commit comments

Comments
 (0)