Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow negative particle pressure #218

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/schemes/boundary/dummy_particles/dummy_particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ function compute_pressure!(boundary_model, ::Union{SummationDensity, ContinuityD
system, system_index, v, u, v_ode, u_ode, semi)
(; state_equation, pressure) = boundary_model

# Limit pressure to be non-negative to avoid attractive forces between fluid and
# boundary particles at free surfaces (sticking artifacts).
for particle in eachparticle(system)
pressure[particle] = state_equation(particle_density(v, boundary_model, particle))
pressure[particle] = max(state_equation(particle_density(v, boundary_model,
particle)), 0.0)
end

return boundary_model
Expand Down Expand Up @@ -321,7 +324,8 @@ end
end

for particle in eachparticle(system)
# Limit pressure to be non-negative to avoid negative pressures at free surfaces
# Limit pressure to be non-negative to avoid attractive forces between fluid and
# boundary particles at free surfaces (sticking artifacts).
pressure[particle] = max(pressure[particle], 0.0)
end
end
Expand Down
12 changes: 5 additions & 7 deletions src/schemes/fluid/weakly_compressible_sph/state_equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ end
function (state_equation::StateEquationIdealGas)(density)
(; sound_speed, reference_density, reference_pressure, background_pressure) = state_equation

# Limit pressure to be non-negative to avoid negative pressures at free surfaces
return max(sound_speed^2 * (density - reference_density) + reference_pressure -
background_pressure, 0.0)
return sound_speed^2 * (density - reference_density) + reference_pressure -
background_pressure
end

@doc raw"""
Expand Down Expand Up @@ -69,10 +68,9 @@ end
function (state_equation::StateEquationCole)(density)
(; sound_speed, gamma, reference_density, reference_pressure, background_pressure) = state_equation

# Limit pressure to be non-negative to avoid negative pressures at free surfaces
return max(reference_density * sound_speed^2 / gamma *
((density / reference_density)^gamma - 1) +
reference_pressure - background_pressure, 0.0)
return reference_density * sound_speed^2 / gamma *
((density / reference_density)^gamma - 1) +
reference_pressure - background_pressure
end

function inverse_state_equation(state_equation::StateEquationCole, pressure)
Expand Down