-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
* add average pressure * add transport velocity * add tvf in rhs * add update callback * use `step_limiter!` instead of using a callback * add taylor green vortex example * add lid driven cavity example * add periodic array of cylinder example * add tests * add Random package * reexport `seed!` * remove obsolet `system_index` * skip CI * add callback * rename edac cache * move functions to `transport_velocity.jl` * prepare for wcsph * calculate volume term on the fly * adapt example files * time dependent initial velocity function * time dependent pressure function * remove velocity function * multi dimensional functions * apply formatter * fix for open boundaries * add `UpdateCallback` * fix typo * prepare for merge `update-callback` * fix bug * fix example * fix tests * fix update bug * apply formatter * fix test * minor changes * add tests * add docs * fix tpos * add configuration check * add setter for tvf * fix callback used check * adapt examples * minor changes * clean up * add tgv validation example * add ldc validation * modify validation * increase `maxiters` * remove double velocity initialization * add random displacement * implement suggestions * update `NEWS.md` * remove check for viscosity * fix tests * add short tilde description in docs * remove discarded example from tests * implement suggestions * apply formatter * implement suggestions * add comment * fix test
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Lid-driven cavity | ||
# | ||
# S. Adami et al | ||
# "A transport-velocity formulation for smoothed particle hydrodynamics". | ||
# In: Journal of Computational Physics, Volume 241 (2013), pages 292-307. | ||
# https://doi.org/10.1016/j.jcp.2013.01.043 | ||
|
||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
# ========================================================================================== | ||
# ==== Resolution | ||
particle_spacing = 0.02 | ||
|
||
# Make sure that the kernel support of fluid particles at a boundary is always fully sampled | ||
boundary_layers = 4 | ||
|
||
# ========================================================================================== | ||
# ==== Experiment Setup | ||
tspan = (0.0, 5.0) | ||
reynolds_number = 100.0 | ||
|
||
cavity_size = (1.0, 1.0) | ||
|
||
fluid_density = 1.0 | ||
|
||
const VELOCITY_LID = 1.0 | ||
sound_speed = 10 * VELOCITY_LID | ||
|
||
pressure = sound_speed^2 * fluid_density | ||
|
||
viscosity = ViscosityAdami(; nu=VELOCITY_LID / reynolds_number) | ||
|
||
cavity = RectangularTank(particle_spacing, cavity_size, cavity_size, fluid_density, | ||
n_layers=boundary_layers, | ||
faces=(true, true, true, false), pressure=pressure) | ||
|
||
lid_position = 0.0 - particle_spacing * boundary_layers | ||
lid_length = cavity.n_particles_per_dimension[1] + 2boundary_layers | ||
|
||
lid = RectangularShape(particle_spacing, (lid_length, 3), | ||
(lid_position, cavity_size[2]), density=fluid_density) | ||
|
||
# ========================================================================================== | ||
# ==== Fluid | ||
|
||
smoothing_length = 1.0 * particle_spacing | ||
smoothing_kernel = SchoenbergQuinticSplineKernel{2}() | ||
|
||
fluid_system = EntropicallyDampedSPHSystem(cavity.fluid, smoothing_kernel, smoothing_length, | ||
density_calculator=ContinuityDensity(), | ||
sound_speed, viscosity=viscosity, | ||
transport_velocity=TransportVelocityAdami(pressure)) | ||
|
||
# ========================================================================================== | ||
# ==== Boundary | ||
|
||
lid_movement_function(t) = SVector(VELOCITY_LID * t, 0.0) | ||
|
||
is_moving(t) = true | ||
|
||
lid_movement = BoundaryMovement(lid_movement_function, is_moving) | ||
|
||
boundary_model_cavity = BoundaryModelDummyParticles(cavity.boundary.density, | ||
cavity.boundary.mass, | ||
AdamiPressureExtrapolation(), | ||
viscosity=viscosity, | ||
smoothing_kernel, smoothing_length) | ||
|
||
boundary_model_lid = BoundaryModelDummyParticles(lid.density, lid.mass, | ||
AdamiPressureExtrapolation(), | ||
viscosity=viscosity, | ||
smoothing_kernel, smoothing_length) | ||
|
||
boundary_system_cavity = BoundarySPHSystem(cavity.boundary, boundary_model_cavity) | ||
|
||
boundary_system_lid = BoundarySPHSystem(lid, boundary_model_lid, movement=lid_movement) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
bnd_thickness = boundary_layers * particle_spacing | ||
periodic_box = PeriodicBox(min_corner=[-bnd_thickness, -bnd_thickness], | ||
max_corner=cavity_size .+ [bnd_thickness, bnd_thickness]) | ||
|
||
semi = Semidiscretization(fluid_system, boundary_system_cavity, boundary_system_lid, | ||
neighborhood_search=GridNeighborhoodSearch{2}(; periodic_box)) | ||
|
||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=100) | ||
|
||
saving_callback = SolutionSavingCallback(dt=0.02) | ||
|
||
pp_callback = nothing | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback, pp_callback, UpdateCallback()) | ||
|
||
# Use a Runge-Kutta method with automatic (error based) time step size control | ||
sol = solve(ode, RDPK3SpFSAL49(), | ||
abstol=1e-6, # Default abstol is 1e-6 (may needs to be tuned to prevent boundary penetration) | ||
reltol=1e-4, # Default reltol is 1e-3 (may needs to be tuned to prevent boundary penetration) | ||
dtmax=1e-2, # Limit stepsize to prevent crashing | ||
maxiters=Int(1e7), | ||
save_everystep=false, callback=callbacks); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Channel flow through periodic array of cylinders | ||
# | ||
# S. Adami et al. | ||
# "A transport-velocity formulation for smoothed particle hydrodynamics". | ||
# In: Journal of Computational Physics, Volume 241 (2013), pages 292-307. | ||
# https://doi.org/10.1016/j.jcp.2013.01.043 | ||
|
||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
# ========================================================================================== | ||
# ==== Resolution | ||
n_particles_x = 144 | ||
|
||
# Make sure that the kernel support of fluid particles at a boundary is always fully sampled | ||
boundary_layers = 3 | ||
|
||
# ========================================================================================== | ||
# ==== Experiment Setup | ||
tspan = (0.0, 5.0) | ||
|
||
acceleration_x = 2.5e-4 | ||
|
||
# Boundary geometry and initial fluid particle positions | ||
cylinder_radius = 0.02 | ||
tank_size = (6 * cylinder_radius, 4 * cylinder_radius) | ||
fluid_size = tank_size | ||
|
||
fluid_density = 1000.0 | ||
nu = 0.1 / fluid_density # viscosity parameter | ||
|
||
# Adami uses `c = 0.1 * sqrt(acceleration_x * cylinder_radius)`` but the original setup | ||
# from M. Ellero and N. A. Adams (https://doi.org/10.1002/nme.3088) uses `c = 0.02` | ||
sound_speed = 0.02 | ||
|
||
pressure = sound_speed^2 * fluid_density | ||
|
||
particle_spacing = tank_size[1] / n_particles_x | ||
|
||
box = RectangularTank(particle_spacing, fluid_size, tank_size, | ||
fluid_density, n_layers=boundary_layers, | ||
pressure=pressure, faces=(false, false, true, true)) | ||
|
||
cylinder = SphereShape(particle_spacing, cylinder_radius, tank_size ./ 2, | ||
fluid_density, sphere_type=RoundSphere()) | ||
|
||
fluid = setdiff(box.fluid, cylinder) | ||
boundary = union(cylinder, box.boundary) | ||
|
||
# ========================================================================================== | ||
# ==== Fluid | ||
smoothing_length = 1.2 * particle_spacing | ||
smoothing_kernel = SchoenbergQuarticSplineKernel{2}() | ||
fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length, | ||
sound_speed, viscosity=ViscosityAdami(; nu), | ||
transport_velocity=TransportVelocityAdami(pressure), | ||
acceleration=(acceleration_x, 0.0)) | ||
|
||
# ========================================================================================== | ||
# ==== Boundary | ||
boundary_model = BoundaryModelDummyParticles(boundary.density, boundary.mass, | ||
AdamiPressureExtrapolation(), | ||
viscosity=ViscosityAdami(; nu), | ||
smoothing_kernel, smoothing_length) | ||
|
||
boundary_system = BoundarySPHSystem(boundary, boundary_model) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
periodic_box = PeriodicBox(min_corner=[0.0, -tank_size[2]], | ||
max_corner=[tank_size[1], 2 * tank_size[2]]) | ||
semi = Semidiscretization(fluid_system, boundary_system, | ||
neighborhood_search=GridNeighborhoodSearch{2}(; periodic_box)) | ||
|
||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=10) | ||
saving_callback = SolutionSavingCallback(dt=0.02, prefix="") | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback()) | ||
|
||
# Use a Runge-Kutta method with automatic (error based) time step size control | ||
sol = solve(ode, RDPK3SpFSAL49(), | ||
abstol=1e-8, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration) | ||
reltol=1e-4, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration) | ||
dtmax=1e-2, # Limit stepsize to prevent crashing | ||
save_everystep=false, callback=callbacks); |
1 comment
on commit ccd08be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/118371
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
@JuliaRegistrator register
Release notes:
## Breaking changes
- blah
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:
git tag -a v0.2.3 -m "<description of version>" ccd08be91e3e91752ff9afdb8b4280a87820f74d
git push origin v0.2.3
@JuliaRegistrator register