forked from trixi-framework/TrixiParticles.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:svchb/TrixiParticles.jlOpen
- Loading branch information
Showing
33 changed files
with
919 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "TrixiParticles" | ||
uuid = "66699cd8-9c01-4e9d-a059-b96c86d16b3a" | ||
authors = ["erik.faulhaber <[email protected]>"] | ||
version = "0.1.2-dev" | ||
version = "0.1.3-dev" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This example shows how surface tension can be applied to existing cases | ||
# and which parameters have to be changed! | ||
using TrixiParticles | ||
|
||
fluid_density = 1000.0 | ||
|
||
H = 0.6 | ||
fluid_particle_spacing = H / 60 | ||
|
||
# Set the surface tension to a value that is accurate in your case. | ||
# Note: This usually requires calibration to be physically accurate! | ||
surface_tension = SurfaceTensionAkinci(surface_tension_coefficient=0.025) | ||
|
||
# `density_diffusion` is deactivated since the interaction with the surface tension model can | ||
# cause stability problems. | ||
# `adhesion_coefficient` needs to be set to a value so that the fluid doesn't separate | ||
# from the boundary. | ||
# Note: The surface tension model leads to an increase in compressibility of the fluid, | ||
# which needs to be rectified by an increase of the `sound_speed`. | ||
# Note: The Wendland Kernels don't work very well here since the `SurfaceTensionAkinci` | ||
# model is optimized for a compact support of `2 * particle_spacing`, which would result | ||
# in a too small `smoothing_length` for the Wendland Kernel functions. | ||
# Note: Adhesion will result in additional friction at the boundary. | ||
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), | ||
surface_tension=surface_tension, | ||
fluid_particle_spacing=fluid_particle_spacing, | ||
smoothing_kernel=SchoenbergCubicSplineKernel{2}(), | ||
smoothing_length=1.0 * fluid_particle_spacing, | ||
correction=AkinciFreeSurfaceCorrection(fluid_density), | ||
density_diffusion=nothing, adhesion_coefficient=0.05, | ||
sound_speed=100.0, tspan=(0.0, 2.0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# In this example two circles of water drop to the floor demonstrating the difference | ||
# between the behavior with and without surface tension modelling. | ||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
# ========================================================================================== | ||
# ==== Resolution | ||
fluid_particle_spacing = 0.005 | ||
|
||
boundary_layers = 3 | ||
spacing_ratio = 1 | ||
|
||
# ========================================================================================== | ||
# ==== Experiment Setup | ||
gravity = 9.81 | ||
tspan = (0.0, 0.3) | ||
|
||
# Boundary geometry and initial fluid particle positions | ||
initial_fluid_size = (0.0, 0.0) | ||
tank_size = (2.0, 0.5) | ||
|
||
fluid_density = 1000.0 | ||
sound_speed = 100 | ||
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, | ||
exponent=1) | ||
|
||
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density, | ||
n_layers=boundary_layers, spacing_ratio=spacing_ratio, | ||
faces=(true, true, true, false), | ||
acceleration=(0.0, -gravity), state_equation=state_equation) | ||
|
||
sphere_radius = 0.05 | ||
|
||
sphere1_center = (0.5, 0.2) | ||
sphere2_center = (1.5, 0.2) | ||
sphere1 = SphereShape(fluid_particle_spacing, sphere_radius, sphere1_center, | ||
fluid_density, sphere_type=VoxelSphere(), velocity=(0.0, -3.0)) | ||
sphere2 = SphereShape(fluid_particle_spacing, sphere_radius, sphere2_center, | ||
fluid_density, sphere_type=VoxelSphere(), velocity=(0.0, -3.0)) | ||
|
||
# ========================================================================================== | ||
# ==== Fluid | ||
fluid_smoothing_length = 1.0 * fluid_particle_spacing | ||
fluid_smoothing_kernel = SchoenbergCubicSplineKernel{2}() | ||
|
||
fluid_density_calculator = ContinuityDensity() | ||
|
||
nu = 0.005 | ||
alpha = 8 * nu / (fluid_smoothing_length * sound_speed) | ||
viscosity = ArtificialViscosityMonaghan(alpha=alpha, beta=0.0) | ||
density_diffusion = DensityDiffusionAntuono(sphere2, delta=0.1) | ||
|
||
sphere_surface_tension = WeaklyCompressibleSPHSystem(sphere1, fluid_density_calculator, | ||
state_equation, fluid_smoothing_kernel, | ||
fluid_smoothing_length, | ||
viscosity=viscosity, | ||
acceleration=(0.0, -gravity), | ||
surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.05), | ||
correction=AkinciFreeSurfaceCorrection(fluid_density)) | ||
|
||
sphere = WeaklyCompressibleSPHSystem(sphere2, fluid_density_calculator, | ||
state_equation, fluid_smoothing_kernel, | ||
fluid_smoothing_length, viscosity=viscosity, | ||
density_diffusion=density_diffusion, | ||
acceleration=(0.0, -gravity)) | ||
|
||
# ========================================================================================== | ||
# ==== Boundary | ||
boundary_density_calculator = AdamiPressureExtrapolation() | ||
wall_viscosity = nu | ||
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass, | ||
state_equation=state_equation, | ||
boundary_density_calculator, | ||
fluid_smoothing_kernel, fluid_smoothing_length, | ||
viscosity=ViscosityAdami(nu=wall_viscosity)) | ||
|
||
boundary_system = BoundarySPHSystem(tank.boundary, boundary_model, | ||
adhesion_coefficient=0.001) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
semi = Semidiscretization(boundary_system, sphere_surface_tension, sphere) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=50) | ||
saving_callback = SolutionSavingCallback(dt=0.01, output_directory="out", prefix="", | ||
write_meta_data=true) | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback) | ||
|
||
# Use a Runge-Kutta method with automatic (error based) time step size control. | ||
sol = solve(ode, RDPK3SpFSAL35(), | ||
abstol=1e-6, # Default abstol is 1e-6 | ||
reltol=1e-4, # Default reltol is 1e-3 | ||
save_everystep=false, callback=callbacks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
# ========================================================================================== | ||
# ==== Resolution | ||
fluid_particle_spacing = 0.008 | ||
|
||
# ========================================================================================== | ||
# ==== Experiment Setup | ||
gravity = 9.81 | ||
nu = 0.01 | ||
fluid_density = 1000.0 | ||
sound_speed = 50 | ||
|
||
sphere1_radius = 0.05 | ||
|
||
sphere1_center = (0.5, 0.5, 0.2) | ||
sphere2_center = (1.5, 0.5, 0.2) | ||
sphere1 = SphereShape(fluid_particle_spacing, sphere1_radius, sphere1_center, | ||
fluid_density, sphere_type=VoxelSphere(), velocity=(0.0, 0.0, -2.0)) | ||
sphere2 = SphereShape(fluid_particle_spacing, sphere1_radius, sphere2_center, | ||
fluid_density, sphere_type=VoxelSphere(), velocity=(0.0, 0.0, -2.0)) | ||
|
||
# `compact_support` needs to be `2.0 * particle_spacing` to be correct | ||
fluid_smoothing_length = 1.0 * fluid_particle_spacing | ||
|
||
trixi_include(@__MODULE__, | ||
joinpath(examples_dir(), "fluid", "falling_water_spheres_2d.jl"), | ||
fluid_particle_spacing=fluid_particle_spacing, tspan=(0.0, 0.2), | ||
initial_fluid_size=(0.0, 0.0, 0.0), | ||
tank_size=(2.0, 1.0, 0.1), sound_speed=sound_speed, | ||
faces=(true, true, true, true, true, false), | ||
acceleration=(0.0, 0.0, -gravity), sphere1=sphere1, sphere2=sphere2, | ||
fluid_smoothing_length=fluid_smoothing_length, | ||
fluid_smoothing_kernel=SchoenbergCubicSplineKernel{3}(), | ||
nu=nu, alpha=10 * nu / (fluid_smoothing_length * sound_speed), | ||
surface_tension_coefficient=1.5, adhesion_coefficient=0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# In this example we can observe that the `SurfaceTensionAkinci` surface tension model correctly leads to a | ||
# surface minimization of the water square and approaches a sphere. | ||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
fluid_density = 1000.0 | ||
|
||
particle_spacing = 0.1 | ||
|
||
# Note: Only square shapes will result in a sphere. | ||
# Furthermore, changes of the coefficients might be necessary for higher resolutions or larger squares. | ||
fluid_size = (0.5, 0.5) | ||
|
||
sound_speed = 20.0 | ||
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, | ||
exponent=7, clip_negative_pressure=true) | ||
|
||
# For all surface tension simulations, we need a compact support of `2 * particle_spacing` | ||
# smoothing_length = 2.0 * particle_spacing | ||
# smoothing_kernel = WendlandC2Kernel{2}() | ||
# nu = 0.01 | ||
|
||
smoothing_length = 1.0 * particle_spacing | ||
smoothing_kernel = SchoenbergCubicSplineKernel{2}() | ||
nu = 0.025 | ||
|
||
fluid = RectangularShape(particle_spacing, round.(Int, fluid_size ./ particle_spacing), | ||
zeros(length(fluid_size)), density=fluid_density) | ||
|
||
alpha = 8 * nu / (smoothing_length * sound_speed) | ||
source_terms = SourceTermDamping(; damping_coefficient=0.5) | ||
fluid_system = WeaklyCompressibleSPHSystem(fluid, SummationDensity(), | ||
state_equation, smoothing_kernel, | ||
smoothing_length, | ||
viscosity=ArtificialViscosityMonaghan(alpha=alpha, | ||
beta=0.0), | ||
surface_tension=SurfaceTensionAkinci(surface_tension_coefficient=0.02), | ||
correction=AkinciFreeSurfaceCorrection(fluid_density), | ||
source_terms=source_terms) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
semi = Semidiscretization(fluid_system) | ||
|
||
tspan = (0.0, 3.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=100) | ||
|
||
# For overwriting via `trixi_include` | ||
saving_callback = SolutionSavingCallback(dt=0.02) | ||
|
||
stepsize_callback = StepsizeCallback(cfl=1.0) | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback, stepsize_callback) | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), | ||
dt=1.0, # This is overwritten by the stepsize callback | ||
save_everystep=false, callback=callbacks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# In this example we can observe that the `SurfaceTensionAkinci` surface tension model correctly leads to a | ||
# surface minimization of the water cube and approaches a sphere. | ||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
fluid_density = 1000.0 | ||
|
||
particle_spacing = 0.1 | ||
fluid_size = (0.9, 0.9, 0.9) | ||
|
||
sound_speed = 20.0 | ||
|
||
# For all surface tension simulations, we need a compact support of `2 * particle_spacing` | ||
smoothing_length = 1.0 * particle_spacing | ||
|
||
nu = 0.01 | ||
|
||
trixi_include(@__MODULE__, | ||
joinpath(examples_dir(), "fluid", "sphere_surface_tension_2d.jl"), | ||
dt=0.1, cfl=1.2, surface_tension_coefficient=0.1, | ||
tspan=(0.0, 10.0), nu=nu, | ||
alpha=10 * nu / (smoothing_length * sound_speed), | ||
smoothing_kernel=SchoenbergCubicSplineKernel{3}(), | ||
particle_spacing=particle_spacing, sound_speed=sound_speed, | ||
fluid_density=fluid_density, fluid_size=fluid_size) |
Oops, something went wrong.