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

Sc/polytropic #1526

Merged
merged 132 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
aa1d7c7
Added polytropic Euler equations.
SimonCan Jun 13, 2023
b4ef0cd
Added polytropic Euler equations.
SimonCan Jun 13, 2023
2974c76
Added polytropic Euler equations.
SimonCan Jun 13, 2023
b0252bb
Minor clean up in polytropic equations.
SimonCan Jun 13, 2023
472e824
Added example for the compressible polytropic Euler equations in 2d o…
SimonCan Jun 13, 2023
24777ed
Cleaned up example elicir for polytropic Euler in 2d.
SimonCan Jun 13, 2023
d3c431e
Added polytrropic Euler in 2d in tests.
SimonCan Jun 13, 2023
c072eca
Remoed unused routines.
SimonCan Jun 13, 2023
e4ca383
Merge branch 'main' into sc/polytropic
sloede Jun 16, 2023
3dde966
Update src/equations/polytropic_euler_2d.jl
SimonCan Jun 20, 2023
bd1cb98
Update src/equations/polytropic_euler_2d.jl
SimonCan Jun 20, 2023
1233184
Update src/equations/polytropic_euler_2d.jl
SimonCan Jun 20, 2023
366ff39
Update src/equations/polytropic_euler_2d.jl
SimonCan Jun 20, 2023
4d45e13
Added compressible Euler equations in news.
SimonCan Jun 20, 2023
2a26634
Auto-reformatted equations.
SimonCan Jun 20, 2023
f51d90e
Auto-reformatted docs for polytropic equations.
SimonCan Jun 20, 2023
4a5d33f
Added example elixir for polytropic and isothermal coupling.
SimonCan Jun 22, 2023
003aafd
Corrected typos.
SimonCan Jun 22, 2023
f14ea5d
Update examples/structured_2d_dgsem/elixir_euler_polytropic.jl
SimonCan Jul 3, 2023
dc403ec
Update NEWS.md
SimonCan Jul 3, 2023
75a026c
Renamed elixir_euler_polytropic.jl to elixir_euler_polytropic.jl.
SimonCan Jul 3, 2023
fb6617d
Renamed Euler polytropic elixir in test.
SimonCan Jul 3, 2023
6515f41
Renamed coupled polytropic example elixir.
SimonCan Jul 3, 2023
9edd2b5
Reformatted the boundary conditions for the couple polytropic example…
SimonCan Jul 3, 2023
3c2a125
Removed redundant inv_gamma_minus_one variable.
SimonCan Jul 3, 2023
ba8d163
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 3, 2023
e409677
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 3, 2023
d3109ac
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 3, 2023
a49e2a4
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 3, 2023
4d5959c
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl
SimonCan Jul 3, 2023
8d3c371
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl
SimonCan Jul 3, 2023
1e08200
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl
SimonCan Jul 3, 2023
c53fecf
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_coupled.jl
SimonCan Jul 3, 2023
f74d681
Removed flux Ranocha for polytropic equations.
SimonCan Jul 3, 2023
d8e2560
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 3, 2023
a55c6be
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 4, 2023
3ab5f00
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 4, 2023
8c7cdf2
Added Andrew's flux implementation flux_winters_etal.
SimonCan Jul 4, 2023
989b2ce
Added couped polytropic tests.
SimonCan Jul 5, 2023
26b246d
Added Winter's fluxes for coupled polytropic elixir.
SimonCan Jul 5, 2023
dd21d6e
Added flux_winters_etal.
SimonCan Jul 5, 2023
430bc4a
Added convergence test for polytropic Euler.
SimonCan Jul 7, 2023
d8de77c
Renamed polytropic uler convergence Elixir.
SimonCan Jul 7, 2023
3f56b6c
Added convergence test initial condition.
SimonCan Jul 7, 2023
5d5072d
Corrected variable names in convergence test for polytropic equations.
SimonCan Jul 7, 2023
a28707a
Update src/auxiliary/math.jl
SimonCan Jul 10, 2023
db830d3
Added isotropic Eulre wave test case.
SimonCan Jul 10, 2023
a3afce1
Removed isotropic option in purely polytropic test case.
SimonCan Jul 10, 2023
3a24980
Implmented Andrew's efficient way of computing coefficients.
SimonCan Jul 10, 2023
7c32006
Added isotropic Euler wave as test case.
SimonCan Jul 10, 2023
37dcd27
Reformatted polytrropic_2d.
SimonCan Jul 10, 2023
bface63
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl
SimonCan Jul 10, 2023
4b9babd
Update src/auxiliary/math.jl
SimonCan Jul 10, 2023
7be52e3
Reformatted example elixir for polytropic/isothermal equations.
SimonCan Jul 10, 2023
99a487b
Updated errors for elixir_eulerpolytropic_coupled.jl.
SimonCan Jul 10, 2023
544561d
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Jul 10, 2023
ed59ee8
Added polytropic convergence test and renamed isothermal file.
SimonCan Jul 10, 2023
5c6d422
Corrected gamma and kappa.
SimonCan Jul 11, 2023
66d481c
Added source terms for EOC.
SimonCan Jul 11, 2023
104d226
Added source term for ECO.
SimonCan Jul 11, 2023
d2056d4
Minor corrections.
SimonCan Jul 11, 2023
6c437eb
Added source terms.
SimonCan Jul 11, 2023
41061cb
Corrected primary variables.
SimonCan Jul 11, 2023
c1e6f93
Removed redundant kappa and gamme redefinitions.
SimonCan Jul 11, 2023
500d739
Improved style by using gamma and kappa from equations.
SimonCan Jul 11, 2023
e6b41ea
Improved convergence test for polytropic.
SimonCan Jul 13, 2023
1c68e4b
Corrected convergence test residual for polytropic equations.
SimonCan Jul 13, 2023
aee57da
Allow use of flux_lax_friedrichs
sloede Jul 14, 2023
843166b
Fix comment
sloede Jul 14, 2023
5924fb3
Added flux calculation for polytropic Euler.
SimonCan Jul 15, 2023
9fe78e2
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Jul 15, 2023
571b2cd
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 17, 2023
a70e736
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_wave.jl
SimonCan Jul 17, 2023
99527f0
Moved initial condition and source term before flux function.
SimonCan Jul 17, 2023
b7d665c
Update examples/structured_2d_dgsem/elixir_eulerisothermal_wave.jl
SimonCan Jul 17, 2023
799d165
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 17, 2023
66d5161
Update src/equations/polytropic_euler_2d.jl
SimonCan Jul 17, 2023
6465fd5
Change kappa and gamma in some polytropic Euler elixirs.
SimonCan Jul 17, 2023
119720f
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Jul 17, 2023
1391c8c
Correcte source for Euler polytropic convergence test.
SimonCan Jul 17, 2023
0080a50
Changed parameters gamma and kappa in Euler polytropic convergence te…
SimonCan Jul 17, 2023
9b57fd2
Merge branch 'main' into sc/polytropic
SimonCan Jul 18, 2023
2a56cfc
Reformatted polytropic Euler.
SimonCan Jul 18, 2023
bb9cdce
Spelling errors.
SimonCan Jul 18, 2023
ffea2c4
Reformatted.
SimonCan Jul 18, 2023
85bb9a0
Added elixir for testing entropy conservation for polytropic Euler eq…
SimonCan Jul 18, 2023
124d349
Added weak blast wave as initial condition for the polytropic Euler e…
SimonCan Jul 18, 2023
0163ebb
Added entropy conservation test.
SimonCan Jul 18, 2023
2cd0c82
Typo in tests.
SimonCan Jul 18, 2023
689f204
Auto reformat.
SimonCan Jul 18, 2023
582fe33
Corrected polytropic Euler test reults.
SimonCan Jul 18, 2023
abf3306
Renamed entropy test for Euler polytropic.
SimonCan Jul 18, 2023
c716976
Renamed elixir for shock test.
SimonCan Jul 18, 2023
59ff85c
Added coupled Euler polytropic to the tests.
SimonCan Jul 19, 2023
2c8ee14
Removed redundant flux function.
SimonCan Jul 19, 2023
093ebd0
Changed example parameters for coupled polytropic Euler.
SimonCan Jul 19, 2023
0a9876c
Removed max-speed calculations, as they are not being used.
SimonCan Jul 19, 2023
9ee900e
Removed coupled polytropic elixir, since this PR is on the polytropic
SimonCan Jul 19, 2023
acfdf21
Correcte entropy variables for polytropic Euler.
SimonCan Jul 25, 2023
bb4c268
Merge branch 'main' into sc/polytropic
SimonCan Jul 27, 2023
b98194f
Update examples/structured_2d_dgsem/elixir_eulerpolytropic_convergenc…
SimonCan Aug 1, 2023
56dbd5e
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
b1ed0d4
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
77bd3b7
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
255c007
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
6a78357
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
3fec321
Update src/equations/polytropic_euler_2d.jl
SimonCan Aug 1, 2023
d12f324
Format of comment.
SimonCan Aug 1, 2023
66236b3
git pushMerge branch 'sc/polytropic' of github.com:trixi-framework/Tr…
SimonCan Aug 1, 2023
51a629c
Merge branch 'main' into sc/polytropic
sloede Aug 14, 2023
bf186dc
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Aug 15, 2023
640aabb
Update src/Trixi.jl
SimonCan Aug 15, 2023
8561a38
Updated polytropic wave test results after removing stage limiter.
SimonCan Aug 15, 2023
f650a5a
Removed stqage limiter.
SimonCan Aug 15, 2023
c1085f6
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Aug 15, 2023
4f627a2
Merge branch 'main' into sc/polytropic
SimonCan Sep 19, 2023
0e95b05
Reformatted Trixi.jl.
SimonCan Sep 19, 2023
678d65e
Merge branch 'main' into sc/polytropic
SimonCan Sep 28, 2023
cc07c8c
Merge branch 'main' into sc/polytropic
SimonCan Oct 2, 2023
5eaa88d
Corrected removed exports in Trixi.jl.
SimonCan Oct 4, 2023
2e0f348
Merge branch 'main' into sc/polytropic
SimonCan Oct 4, 2023
ea115cf
Fix for broadcasting.
SimonCan Oct 4, 2023
34fe585
Merge branch 'main' into sc/polytropic
SimonCan Oct 5, 2023
3c4b515
Merge branch 'main' into sc/polytropic
SimonCan Oct 9, 2023
7d33fda
Merge branch 'main' into sc/polytropic
SimonCan Oct 10, 2023
1f3696c
Merge branch 'main' into sc/polytropic
SimonCan Oct 11, 2023
453d1b6
Merge branch 'main' into sc/polytropic
SimonCan Oct 13, 2023
61bc4db
Renamed elixir for isothermal wave.
SimonCan Oct 18, 2023
68e5fc7
Update test/test_structured_2d.jl
SimonCan Oct 18, 2023
d0b04b0
Merge branch 'sc/polytropic' of github.com:trixi-framework/Trixi.jl i…
SimonCan Oct 18, 2023
ad635b4
Merge branch 'main' into sc/polytropic
andrewwinters5000 Oct 18, 2023
462bf61
Added comment about isothermal system in elixir.
SimonCan Oct 18, 2023
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ for human readability.
#### Added

- Experimental support for 3D parabolic diffusion terms has been added.
- Implementation of compressible Euler equations in 2D
SimonCan marked this conversation as resolved.
Show resolved Hide resolved

#### Changed

Expand Down
88 changes: 88 additions & 0 deletions examples/structured_2d_dgsem/elixir_euler_polytropic.jl
sloede marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the polytropic Euler equations

gamma = 1.001 # Isotropic simulation. gamma = 1.0 would lead to a singularity.
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
# gamma = 2.0 # Adiabatic monatomic gas in 2d.
kappa = 1.0 # Scaling factor for the pressure.
equations = PolytropicEulerEquations2D(gamma, kappa)

# Linear pressure wave in the negative x-direction.
function initial_condition_wave(x, t, equations::PolytropicEulerEquations2D)
rho = 1.0
v1 = 0.0
if x[1] > 0.0
rho = ((1.0 + 0.01*sin(x[1]*2*pi)) / kappa)^(1/gamma)
v1 = ((0.01*sin((x[1]-1/2)*2*pi)) / kappa)
end
v2 = 0.0

return prim2cons(SVector(rho, v1, v2), equations)
end
initial_condition = initial_condition_wave

volume_flux = flux_ranocha
solver = DGSEM(polydeg=2, surface_flux=flux_hll,
volume_integral=VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-2.0, -1.0)
coordinates_max = ( 2.0, 1.0)

cells_per_dimension = (64, 32)

boundary_conditions = (
x_neg=boundary_condition_periodic,
x_pos=boundary_condition_periodic,
y_neg=boundary_condition_periodic,
y_pos=boundary_condition_periodic,
)

mesh = StructuredMesh(cells_per_dimension,
coordinates_min,
coordinates_max)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions=boundary_conditions)


###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 200
analysis_callback = AnalysisCallback(semi, interval=analysis_interval)

alive_callback = AliveCallback(analysis_interval=analysis_interval)

save_solution = SaveSolutionCallback(interval=50,
save_initial_solution=true,
save_final_solution=true,
solution_variables=cons2prim)

stepsize_callback = StepsizeCallback(cfl=1.7)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds=(1.0e-4, 1.0e-4),
variables=(Trixi.density, pressure))


###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(stage_limiter!, williamson_condition=false),
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep=false, callback=callbacks);

# Print the timer summary
summary_callback()
155 changes: 155 additions & 0 deletions examples/structured_2d_dgsem/elixir_euler_polytropic_coupled.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# Couple polytropic Euler systems.
#
# In a rectangular domain we solve two different sets of equations for the
# left and the right half. Those are the isothermal equations (left)
# and polytropic equations (right).
# The coupling hapens on two interfaces. One is located at the center of the
# domain such that the right half is coupled through its left boundary
# and the left half is coupled through its right boundary. The other coupling
# makes sure that the domain is periodic. Here the right boundary of the right
# domain is coupled to the left boundary of the left domain.
# The vertical boundaries are simply periodic.
# As test case we send a linear wave through the domain and observe a change
# in the dispersion relation when the wave enters the isothermal domain.

###############################################################################
# define the initial conditions

function initial_condition_wave_isothermal(x, t, equations::PolytropicEulerEquations2D)
gamma = 1.001
kappa = 1.0

rho = 1.0
v1 = 0.0
v2 = 0.0

return prim2cons(SVector(rho, v1, v2), equations)
end

function initial_condition_wave_polytropic(x, t, equations::PolytropicEulerEquations2D)
gamma = 2.0
kappa = 1.0

rho = 1.0
v1 = 0.0
if x[1] > 0.0
rho = ((1.0 + 0.01 * sin(x[1] * 2 * pi)) / kappa)^(1 / gamma)
v1 = ((0.01 * sin((x[1] - 1 / 2) * 2 * pi)) / kappa)
end
v2 = 0.0

return prim2cons(SVector(rho, v1, v2), equations)
end

###############################################################################
# semidiscretization of the linear advection equation

function Trixi.wrap_array(u_ode::AbstractVector, mesh::Trixi.AbstractMesh, equations,
dg::DGSEM, cache)
Trixi.wrap_array_native(u_ode, mesh, equations, dg, cache)
end

# Define the equations involved.
gamma1 = 1.001
kappa1 = 1.0
equations1 = PolytropicEulerEquations2D(gamma_A, kappa_A)
gamma2 = 2.0
kappa2 = 1.0
equations2 = PolytropicEulerEquations2D(gamma_B, kappa_B)

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
volume_flux = flux_ranocha
solver = DGSEM(polydeg = 2, surface_flux = flux_hll,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min1 = (-2.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y))
coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max2 = (2.0, 1.0) # maximum coordinates (max(x), max(y))

cells_per_dimension = (32, 32)

mesh1 = StructuredMesh(cells_per_dimension,
coordinates_min1,
coordinates_max1)
mesh2 = StructuredMesh(cells_per_dimension,
coordinates_min2,
coordinates_max2)

# A semidiscretization collects data structures and functions for the spatial discretization.
semi1 = SemidiscretizationHyperbolic(mesh1, equations1,
initial_condition_wave_thermal, solver,
boundary_conditions = (x_neg = BoundaryConditionCoupled(2,
(:end,
:i_forward),
Float64),
x_pos = BoundaryConditionCoupled(2,
(:begin,
:i_forward),
Float64),
y_neg = boundary_condition_periodic,
y_pos = boundary_condition_periodic))

semi2 = SemidiscretizationHyperbolic(mesh2, equations2,
initial_condition_wave_polytropic, solver,
boundary_conditions = (x_neg = BoundaryConditionCoupled(1,
(:end,
:i_forward),
Float64),
x_pos = BoundaryConditionCoupled(1,
(:begin,
:i_forward),
Float64),
y_neg = boundary_condition_periodic,
y_pos = boundary_condition_periodic))
sloede marked this conversation as resolved.
Show resolved Hide resolved

# Create a semidiscretization that bundles semi1 and semi2
semi = SemidiscretizationCoupled(semi1, semi2)

###############################################################################
# ODE solvers, callbacks etc.

# Create ODE problem with time span from 0.0 to 30.0
ode = semidiscretize(semi, (0.0, 3.0))

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
summary_callback = SummaryCallback()

resid_tol = 5.0e-12
steady_state_callback = SteadyStateCallback(abstol = resid_tol, reltol = 0.0)

# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_callback1 = AnalysisCallback(semi1, interval = 100)
analysis_callback2 = AnalysisCallback(semi2, interval = 100)
analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 5,
solution_variables = cons2prim)

# The StepsizeCallback handles the re-calculcation of the maximum Δt after each time step
stepsize_callback = StepsizeCallback(cfl = 1.0)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback,
analysis_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);

# Print the timer summary
summary_callback()

3 changes: 2 additions & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export AcousticPerturbationEquations2D,
LatticeBoltzmannEquations2D, LatticeBoltzmannEquations3D,
ShallowWaterEquations1D, ShallowWaterEquations2D,
ShallowWaterTwoLayerEquations1D, ShallowWaterTwoLayerEquations2D,
LinearizedEulerEquations2D
LinearizedEulerEquations2D,
PolytropicEulerEquations2D

export LaplaceDiffusion1D, LaplaceDiffusion2D,
CompressibleNavierStokesDiffusion2D, CompressibleNavierStokesDiffusion3D
Expand Down
5 changes: 5 additions & 0 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ abstract type AbstractCompressibleEulerMulticomponentEquations{NDIMS, NVARS, NCO
include("compressible_euler_multicomponent_1d.jl")
include("compressible_euler_multicomponent_2d.jl")

# PolytropicEulerEquations
abstract type AbstractPolytropicEulerEquations{NDIMS, NVARS} <:
AbstractEquations{NDIMS, NVARS} end
include("polytropic_euler_2d.jl")

# Retrieve number of components from equation instance for the multicomponent case
@inline function ncomponents(::AbstractCompressibleEulerMulticomponentEquations{NDIMS,
NVARS,
Expand Down
Loading