From d73fd1be82ff67d8d48b4a14987a1da5d3240df4 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Thu, 31 Oct 2024 07:43:43 +0100 Subject: [PATCH 1/4] add `density_calculator` to example --- examples/fluid/taylor_green_vortex_2d.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/fluid/taylor_green_vortex_2d.jl b/examples/fluid/taylor_green_vortex_2d.jl index 551863ccb..a515692ff 100644 --- a/examples/fluid/taylor_green_vortex_2d.jl +++ b/examples/fluid/taylor_green_vortex_2d.jl @@ -65,6 +65,7 @@ fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0. fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length, sound_speed, + density_calculator=SummationDensity(), transport_velocity=TransportVelocityAdami(background_pressure), viscosity=ViscosityAdami(; nu)) From 379a0dba0a359d5307c96d0f7844fd7a060b8821 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Thu, 31 Oct 2024 08:44:33 +0100 Subject: [PATCH 2/4] add perturbation option --- examples/fluid/taylor_green_vortex_2d.jl | 6 ++++-- .../validation_taylor_green_vortex_2d.jl | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/fluid/taylor_green_vortex_2d.jl b/examples/fluid/taylor_green_vortex_2d.jl index a515692ff..e8b0fe81d 100644 --- a/examples/fluid/taylor_green_vortex_2d.jl +++ b/examples/fluid/taylor_green_vortex_2d.jl @@ -58,14 +58,16 @@ background_pressure = sound_speed^2 * fluid_density smoothing_length = 1.0 * particle_spacing smoothing_kernel = SchoenbergQuinticSplineKernel{2}() +perturbate_coordinates = true fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0.0, 0.0), - coordinates_perturbation=0.2, # To avoid stagnant streamlines when not using TVF. + coordinates_perturbation=perturbate_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF. density=fluid_density, pressure=initial_pressure_function, velocity=initial_velocity_function) +density_calculator = SummationDensity() fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length, sound_speed, - density_calculator=SummationDensity(), + density_calculator=density_calculator, transport_velocity=TransportVelocityAdami(background_pressure), viscosity=ViscosityAdami(; nu)) diff --git a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl index cd9d18159..5648506df 100644 --- a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl +++ b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl @@ -9,6 +9,9 @@ particle_spacings = [0.02, 0.01, 0.005] tspan = (0.0, 5.0) reynolds_number = 100.0 +density_calculators = [SummationDensity(), ContinuityDensity()] +perturbate_coordinates = [true, false] + function compute_l1v_error(v, u, t, system) v_analytical_avg = 0.0 v_avg = 0.0 @@ -60,10 +63,16 @@ function diff_p_loc_p_avg(v, u, t, system) return v[end, :] .- p_avg_tot end -for particle_spacing in particle_spacings +for density_calculator in density_calculators, perturbation in perturbate_coordinates, + particle_spacing in particle_spacings + n_particles_xy = round(Int, 1.0 / particle_spacing) - output_directory = joinpath("out_tgv", + name_density_calculator = density_calculator isa SummationDensity ? + "summation_density" : "continuity_density" + name_perturbation = perturbation ? "perturbed" : "" + + output_directory = joinpath("out_tgv", "$(name_density_calculator)_$name_perturbation", "validation_run_taylor_green_vortex_2d_nparticles_$(n_particles_xy)x$(n_particles_xy)") saving_callback = SolutionSavingCallback(dt=0.02, output_directory=output_directory, @@ -79,6 +88,8 @@ for particle_spacing in particle_spacings # Import variables into scope trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "taylor_green_vortex_2d.jl"), + density_calculator=density_calculator, + perturbate_coordinates=perturbation, particle_spacing=particle_spacing, reynolds_number=reynolds_number, tspan=tspan, saving_callback=saving_callback, pp_callback=pp_callback) end From 7ca1aaece80620ba32c9b16a814203d4f84bcb49 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Thu, 31 Oct 2024 08:51:56 +0100 Subject: [PATCH 3/4] fix typo --- examples/fluid/taylor_green_vortex_2d.jl | 4 ++-- .../validation_taylor_green_vortex_2d.jl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/fluid/taylor_green_vortex_2d.jl b/examples/fluid/taylor_green_vortex_2d.jl index e8b0fe81d..83de3c27f 100644 --- a/examples/fluid/taylor_green_vortex_2d.jl +++ b/examples/fluid/taylor_green_vortex_2d.jl @@ -58,9 +58,9 @@ background_pressure = sound_speed^2 * fluid_density smoothing_length = 1.0 * particle_spacing smoothing_kernel = SchoenbergQuinticSplineKernel{2}() -perturbate_coordinates = true +pertube_coordinates = true fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0.0, 0.0), - coordinates_perturbation=perturbate_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF. + coordinates_perturbation=pertube_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF. density=fluid_density, pressure=initial_pressure_function, velocity=initial_velocity_function) diff --git a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl index 5648506df..9d0d0b3dc 100644 --- a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl +++ b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl @@ -10,7 +10,7 @@ tspan = (0.0, 5.0) reynolds_number = 100.0 density_calculators = [SummationDensity(), ContinuityDensity()] -perturbate_coordinates = [true, false] +pertube_coordinates = [true, false] function compute_l1v_error(v, u, t, system) v_analytical_avg = 0.0 @@ -63,7 +63,7 @@ function diff_p_loc_p_avg(v, u, t, system) return v[end, :] .- p_avg_tot end -for density_calculator in density_calculators, perturbation in perturbate_coordinates, +for density_calculator in density_calculators, perturbation in pertube_coordinates, particle_spacing in particle_spacings n_particles_xy = round(Int, 1.0 / particle_spacing) @@ -89,7 +89,7 @@ for density_calculator in density_calculators, perturbation in perturbate_coordi trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "taylor_green_vortex_2d.jl"), density_calculator=density_calculator, - perturbate_coordinates=perturbation, + pertube_coordinates=perturbation, particle_spacing=particle_spacing, reynolds_number=reynolds_number, tspan=tspan, saving_callback=saving_callback, pp_callback=pp_callback) end From a1c4ae3a5d6b4699b7a3dc0a99b2fd05f21d6902 Mon Sep 17 00:00:00 2001 From: LasNikas Date: Thu, 31 Oct 2024 13:56:58 +0100 Subject: [PATCH 4/4] implement suggestions --- examples/fluid/taylor_green_vortex_2d.jl | 6 ++++-- .../validation_taylor_green_vortex_2d.jl | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/fluid/taylor_green_vortex_2d.jl b/examples/fluid/taylor_green_vortex_2d.jl index 83de3c27f..fc4ad9e63 100644 --- a/examples/fluid/taylor_green_vortex_2d.jl +++ b/examples/fluid/taylor_green_vortex_2d.jl @@ -58,9 +58,11 @@ background_pressure = sound_speed^2 * fluid_density smoothing_length = 1.0 * particle_spacing smoothing_kernel = SchoenbergQuinticSplineKernel{2}() -pertube_coordinates = true +# To be set via `trixi_include` +perturb_coordinates = true fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0.0, 0.0), - coordinates_perturbation=pertube_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF. + # Perturb particle coordinates to avoid stagnant streamlines without TVF + coordinates_perturbation=perturb_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF. density=fluid_density, pressure=initial_pressure_function, velocity=initial_velocity_function) diff --git a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl index 9d0d0b3dc..99b83ca03 100644 --- a/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl +++ b/validation/taylor_green_vortex_2d/validation_taylor_green_vortex_2d.jl @@ -10,7 +10,7 @@ tspan = (0.0, 5.0) reynolds_number = 100.0 density_calculators = [SummationDensity(), ContinuityDensity()] -pertube_coordinates = [true, false] +perturb_coordinates = [false, true] function compute_l1v_error(v, u, t, system) v_analytical_avg = 0.0 @@ -63,7 +63,7 @@ function diff_p_loc_p_avg(v, u, t, system) return v[end, :] .- p_avg_tot end -for density_calculator in density_calculators, perturbation in pertube_coordinates, +for density_calculator in density_calculators, perturbation in perturb_coordinates, particle_spacing in particle_spacings n_particles_xy = round(Int, 1.0 / particle_spacing) @@ -89,7 +89,7 @@ for density_calculator in density_calculators, perturbation in pertube_coordinat trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "taylor_green_vortex_2d.jl"), density_calculator=density_calculator, - pertube_coordinates=perturbation, + perturb_coordinates=perturbation, particle_spacing=particle_spacing, reynolds_number=reynolds_number, tspan=tspan, saving_callback=saving_callback, pp_callback=pp_callback) end