-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add test for Adami Pressure Extrapolation. #692
base: main
Are you sure you want to change the base?
Conversation
00b1171
to
aac3a4d
Compare
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.
I think it would make more sense to restructure the test like this:
@testset "Pressure Extrapolation Adami" begin
particle_spacing = 0.1
n_particles = 4
n_layers = 3
...
state_equation = ...
boundary_model = ...
boundary_system = ...
@testset "Constant Zero Pressure" begin
tank1 = ...
fluid_system1 = ...
...
end
@testset "Constant Nonzero Pressure" begin
tank2 = ...
fluid_system2 = ...
end
@testset "Hydrostatic Pressure Gradient" begin
tank3 = ...
fluid_system3 = ...
tank_reference = ...
end
end
Then you can avoid some duplicate code.
@@ -188,6 +188,164 @@ | |||
end | |||
end | |||
end | |||
@testset "Pressure Extrapolation Adami" begin | |||
@testset "Pressure Extrapolation Adami: Constant Pressure" begin |
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.
@testset "Pressure Extrapolation Adami: Constant Pressure" begin | |
@testset "Constant Pressure" begin |
This is already a subset of "Pressure Extrapolation Adami".
#= | ||
Test whether the pressure is constant and 0.0, if the density of the state equation and in the tank are the same. | ||
=# | ||
particle_spacing = 0.1 | ||
n_particles = 4 | ||
n_layers = 3 | ||
width = particle_spacing * n_particles | ||
height = particle_spacing * n_particles | ||
|
||
density = 257 |
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.
#= | |
Test whether the pressure is constant and 0.0, if the density of the state equation and in the tank are the same. | |
=# | |
particle_spacing = 0.1 | |
n_particles = 4 | |
n_layers = 3 | |
width = particle_spacing * n_particles | |
height = particle_spacing * n_particles | |
density = 257 | |
# In this testset, we verify that pressures in a static tank are extrapolated correctly | |
particle_spacing = 0.1 | |
n_particles = 4 | |
n_layers = 3 | |
width = particle_spacing * n_particles | |
height = particle_spacing * n_particles | |
# Use constant density equal to the reference density of the state equation, | |
# so that the pressure is constant zero. Then we test that the extrapolation also yields zero. | |
density = 257 |
|
||
smoothing_kernel = SchoenbergCubicSplineKernel{2}() | ||
smoothing_length = 1.2 * particle_spacing | ||
viscosity = ViscosityAdami(nu=1e-6) |
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.
viscosity = ViscosityAdami(nu=1e-6) |
I would remove the extra complexity of the viscosity here.
#= | ||
Test whether the pressure is constant, if the density of the state equation and in the tank are not the same. | ||
=# |
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.
#= | |
Test whether the pressure is constant, if the density of the state equation and in the tank are not the same. | |
=# | |
# Test whether the pressure is constant if the density of the state equation | |
# and in the tank are not the same. |
tank2 = RectangularTank(particle_spacing, (width, height), (width, height), | ||
density, n_layers=n_layers, | ||
faces=(true, true, true, false)) |
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.
This is still the same density, or did I miss something?
Shouldn't this be
tank2 = RectangularTank(particle_spacing, (width, height), (width, height), | |
density, n_layers=n_layers, | |
faces=(true, true, true, false)) | |
density = 310 | |
tank2 = RectangularTank(particle_spacing, (width, height), (width, height), | |
density, n_layers=n_layers, | |
faces=(true, true, true, false)) |
v_fluid, | ||
neighborhood_search) | ||
|
||
@test all(boundary_system.boundary_model.pressure .== 0.0) & |
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.
@test all(boundary_system.boundary_model.pressure .== 0.0) & | |
@test all(boundary_system.boundary_model.pressure .== 0.0) && |
state_equation, | ||
smoothing_kernel, smoothing_length) | ||
fluid_system2.cache.density .= tank2.fluid.density | ||
v_fluid2 = zeros(2, TrixiParticles.nparticles(fluid_system2)) |
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.
You can use v_fluid
again, no?
smoothing_kernel, smoothing_length) | ||
fluid_system2.cache.density .= tank2.fluid.density | ||
v_fluid2 = zeros(2, TrixiParticles.nparticles(fluid_system2)) | ||
TrixiParticles.compute_pressure!(fluid_system2, v_fluid2) |
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.
This is only computing the pressure for the fluid system, not for the boundary. I guess it worked because you didn't actually change the density (see my comment above).
particle_spacing = 0.1 | ||
n_particles = 2 | ||
n_layers = 1 | ||
width = particle_spacing * n_particles | ||
height = particle_spacing * n_particles |
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.
Why are you not using the same sizes as before?
Also, the tests are failing. |
Add test for Adami Pressure Extrapolation.