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

Add test for Adami Pressure Extrapolation. #692

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RubberLanding
Copy link
Contributor

Add test for Adami Pressure Extrapolation.

Copy link
Member

@efaulhaber efaulhaber left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@testset "Pressure Extrapolation Adami: Constant Pressure" begin
@testset "Constant Pressure" begin

This is already a subset of "Pressure Extrapolation Adami".

Comment on lines +193 to +202
#=
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#=
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
viscosity = ViscosityAdami(nu=1e-6)

I would remove the extra complexity of the viscosity here.

Comment on lines +249 to +251
#=
Test whether the pressure is constant, if the density of the state equation and in the tank are not the same.
=#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#=
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.

Comment on lines +252 to +254
tank2 = RectangularTank(particle_spacing, (width, height), (width, height),
density, n_layers=n_layers,
faces=(true, true, true, false))
Copy link
Member

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

Suggested change
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) &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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))
Copy link
Member

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)
Copy link
Member

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).

Comment on lines +272 to +276
particle_spacing = 0.1
n_particles = 2
n_layers = 1
width = particle_spacing * n_particles
height = particle_spacing * n_particles
Copy link
Member

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?

@efaulhaber
Copy link
Member

Also, the tests are failing.

@efaulhaber efaulhaber marked this pull request as ready for review January 2, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants