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/mhd treemesh 3d #1323

Open
wants to merge 191 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
d5cf820
initial commit of 3d approximation for CNS
andrewwinters5000 Oct 18, 2022
b5e1354
typo fix in CNS 2D file
andrewwinters5000 Oct 18, 2022
ab9329c
add TGV elixir for compressible Navier-Stokes
andrewwinters5000 Oct 18, 2022
82369ec
add DGMulti CNS 3D elixir
jlchan Oct 19, 2022
5929572
need TreeMesh versions of slip wall BC in 3D compressible Euler for c…
andrewwinters5000 Oct 19, 2022
9267369
update comments in CNS 3D file
andrewwinters5000 Oct 19, 2022
01b3752
add convergence test elixir for 3D compressible Navier-Stokes
andrewwinters5000 Oct 19, 2022
2921f1d
remove debug statements from new elixir
andrewwinters5000 Oct 19, 2022
bfb7114
adjust maximum tree size in new elixir
andrewwinters5000 Oct 19, 2022
110b5fa
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 Oct 19, 2022
bfccb07
add convergence test for DGMulti 3D
andrewwinters5000 Oct 19, 2022
323e4cf
add battery of 3D parabolic tests. All pass locally
andrewwinters5000 Oct 19, 2022
1929552
remove old comments and TODOs
andrewwinters5000 Oct 19, 2022
559f47c
bug fix in divergence B analysis routine
andrewwinters5000 Oct 20, 2022
0eaea4d
Merge branch 'main' into ns-treemesh-3d
ranocha Oct 23, 2022
b200526
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 Oct 24, 2022
6fdec4b
Merge branch 'main' into ns-treemesh-3d
ranocha Nov 1, 2022
2f05140
add vorticity and enstrophy functions
andrewwinters5000 Nov 1, 2022
54ff12a
add first version of an enstrophy callback
andrewwinters5000 Nov 1, 2022
91bb5a1
add enstrophy callback to TGV elixir
andrewwinters5000 Nov 1, 2022
fc46ae1
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 Nov 1, 2022
104b8c8
update TGV test values since switched surface flux to flux_hllc
andrewwinters5000 Nov 2, 2022
aa7da6f
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 Nov 3, 2022
8416705
adding draft DGMulti analysis callback
jlchan Nov 3, 2022
28c3eca
adding draft DGMulti analysis callback
jlchan Nov 3, 2022
383ccfe
Merge remote-tracking branch 'refs/remotes/origin/ns-treemesh-3d'
jlchan Nov 3, 2022
315f448
Merge branch 'main' into ns-treemesh-3d
ranocha Nov 11, 2022
5f9e40b
Apply suggestions from code review
andrewwinters5000 Nov 14, 2022
c512038
make sure Experimental code text renders properly in docs
andrewwinters5000 Nov 14, 2022
8c2e242
adding extra analysis integrals
jlchan Nov 14, 2022
82d5311
Merge branch 'ns-treemesh-3d' of https://github.com/trixi-framework/T…
jlchan Nov 14, 2022
8854647
remove unused file path from parabolic test scripts
andrewwinters5000 Nov 16, 2022
9575600
remove threading for reduction
jlchan Nov 22, 2022
94479eb
Merge branch 'main' into ns-treemesh-3d
jlchan Nov 22, 2022
9503279
Merge remote-tracking branch 'origin/ns-treemesh-3d' into ns-treemesh-3d
jlchan Nov 22, 2022
d7c31a7
Merge branch 'main' into ns-treemesh-3d
jlchan Nov 23, 2022
bc4382d
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 Nov 28, 2022
9f2f5e2
Apply suggestions from code review
andrewwinters5000 Nov 29, 2022
29c5aa2
add designation to the 2D test set
andrewwinters5000 Nov 29, 2022
9dee6fe
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 Nov 29, 2022
1e6f825
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 Nov 29, 2022
ecf010e
Added CompressibleMhdDiffusion3D.
SimonCan Jan 9, 2023
251afa6
Added compressible, viscous and diffusive MHD equations module.
SimonCan Jan 9, 2023
10d2f12
Added visco-resistive Alfven wave exmple elixir.
SimonCan Jan 9, 2023
c99b1d3
Added covnergence test for the visco-resistive MHD equtions,
SimonCan Jan 9, 2023
3b3d8c0
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan May 17, 2023
6446dbb
Typos in documentation for compressible_mhd_3d.
SimonCan May 17, 2023
a6116f9
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan May 26, 2023
7205a04
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan May 31, 2023
6a0d47d
Added resistive and viscous MHD wave example in 3d.
iomsn Jun 20, 2023
e9cb99f
Added resistive MHD test.
iomsn Jun 20, 2023
9b20993
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Jun 21, 2023
386b6de
Minor typo.
iomsn Jun 22, 2023
fa22ff0
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
iomsn Jun 22, 2023
072fe6d
Removed redundant elixir file with resistive Alfven waves.
SimonCan Jul 3, 2023
a1eee74
Reformatted compressible mhd 3d equations.
SimonCan Jul 5, 2023
457de18
Minor reformatting.
SimonCan Jul 5, 2023
54897a5
Added turbulent dynamo elixir.
SimonCan Jul 5, 2023
e2bb39b
Added dynamos MHD test.
SimonCan Jul 5, 2023
ff6d120
Typo in docs.
SimonCan Jul 5, 2023
67aec83
Increased relative tolerance for the dynamo test, as we have random n…
SimonCan Jul 5, 2023
a1bd40b
Remove so far unused functionality form the resistive MHD equations m…
SimonCan Jul 6, 2023
c4fcccb
Changed the format of the docs.
SimonCan Jul 6, 2023
7a505ae
Increased relative tolerance for the MHD dynamo test.
SimonCan Jul 6, 2023
e837364
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Jul 6, 2023
6385f06
Updated dynamo test case.
SimonCan Jul 12, 2023
4c10b8b
Updated dynamo elixir example to make it deterministic by using deter…
SimonCan Jul 12, 2023
2d97aa4
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Jul 12, 2023
e09393d
Added magnetic energy for resistive MHD equations.
SimonCan Jul 24, 2023
ec74d9c
Reformatted mhd equation file.
SimonCan Jul 24, 2023
8cda4a5
Change description of the physical setup.
SimonCan Jul 25, 2023
d3179a2
Removed relative errors and reformatted.
SimonCan Jul 25, 2023
a42705b
Added link to Pencil Code example.
SimonCan Jul 25, 2023
853dce0
Changed UInt64 to target type.
SimonCan Jul 26, 2023
24542dd
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Jul 26, 2023
188ce63
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Jul 26, 2023
4ee21cc
Changed randn(1)[1] to randn.
SimonCan Jul 26, 2023
692f1cf
Added SVector to avoid memory allocation.
SimonCan Jul 26, 2023
2b20036
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Jul 26, 2023
4d38046
Fixed description.
SimonCan Jul 26, 2023
36c9626
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Jul 26, 2023
ce6ed4f
Removed rtol and atol.
SimonCan Jul 26, 2023
a58113a
Changed indendation of doc string.
SimonCan Jul 26, 2023
5a93a26
Update src/equations/compressible_mhd_3d.jl
SimonCan Jul 26, 2023
041d72e
Removed commented code.
SimonCan Jul 26, 2023
15817f6
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Jul 26, 2023
8bb44fb
Removed comment.
SimonCan Jul 26, 2023
eb48a5f
Updated dynamo test results.
SimonCan Jul 26, 2023
046b312
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Jul 27, 2023
8964911
Added StableRNGs.
SimonCan Jul 28, 2023
02d5af1
Moved StableRNG from the main Project.toml to the test Project.toml.
SimonCan Aug 1, 2023
4d10ce4
Changed some rand() functions to randn(rng).
SimonCan Aug 1, 2023
fcfa410
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan Aug 1, 2023
f3bfc7e
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan Aug 1, 2023
76339e7
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan Aug 1, 2023
c889688
Update src/equations/compressible_mhd_3d.jl
SimonCan Aug 1, 2023
c5ca22e
Update src/equations/compressible_mhd_3d.jl
SimonCan Aug 1, 2023
6693c12
Added Alfven reference.
SimonCan Aug 1, 2023
6d8f3f5
Changed end time for MHD wagve elixir.
SimonCan Aug 1, 2023
086250c
Changed k-vector into SVector.
SimonCan Aug 1, 2023
71733c4
Added reference for dynamo forcing.
SimonCan Aug 1, 2023
ef41a10
Added DOI for dynamo model.
SimonCan Aug 1, 2023
2f75dcb
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Aug 1, 2023
29b64fa
Update src/equations/compressible_mhd_3d.jl
SimonCan Aug 1, 2023
9390653
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Aug 1, 2023
c83aa20
Added muladd header and footer.
SimonCan Aug 1, 2023
e7f9cc2
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Aug 1, 2023
60eacc8
Renamed visco-resistive MHD equations.
SimonCan Aug 1, 2023
95ab852
Removed redundant comment.
SimonCan Aug 1, 2023
93785f8
Changed et to eta().
SimonCan Aug 1, 2023
1a45991
Changed nu and eta for dynamo test.
SimonCan Aug 1, 2023
b05a24f
Updated dynamo test results.
SimonCan Aug 1, 2023
08985af
Minor typos.
SimonCan Aug 1, 2023
5719aa8
Adjusted cfl condition for MHD elixir.
SimonCan Aug 2, 2023
b4ae412
Corrected test values for damped Alfven wave after adjusting the CFL …
SimonCan Aug 2, 2023
d036fcf
Formatting.
SimonCan Aug 2, 2023
c723a89
Added the visco-resistive equations in the documentation.
SimonCan Aug 3, 2023
12e4611
Added a few comments on Alfven wave setup.
SimonCan Aug 7, 2023
f77ae54
Added section reference for paper.
SimonCan Aug 7, 2023
94fe8ee
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Aug 7, 2023
a7e3e4b
Reformatted reference.
SimonCan Aug 7, 2023
3d4032b
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan Aug 7, 2023
d49ba98
Update src/equations/visco_resistive_mhd_3d.jl
SimonCan Aug 7, 2023
58c9671
Increased the final time for the MHD dynamo to 10.0.
SimonCan Aug 7, 2023
afa6334
Changed time span for MHD dynamo test.
SimonCan Aug 7, 2023
2b6c8e0
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Aug 7, 2023
40cafa1
Added convergence test to the diffusive Alfven wave elixir example.
SimonCan Aug 14, 2023
105aa69
Changed the diffusive Alfven wave parameters.
SimonCan Aug 16, 2023
2d97537
Updated test results for diffusive Alfven waves.
SimonCan Aug 16, 2023
b559632
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Sep 19, 2023
41749dd
Attempt to get convergence for MHD.
SimonCan Sep 22, 2023
ec0390b
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Oct 2, 2023
ea10804
New MHD convergence tests.
SimonCan Oct 4, 2023
8387e30
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Oct 24, 2023
f893b95
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Oct 25, 2023
ea67250
Updated viscous MHD test results.
SimonCan Oct 25, 2023
2655e9b
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Oct 25, 2023
cdba1d4
Removed Andrew's constructed solution and reinstated simpler Alfven w…
SimonCan Oct 25, 2023
702b674
Fixed convergen issue with visco-resistive MHD.
SimonCan Oct 25, 2023
04d85dd
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Oct 25, 2023
873790f
Tried further 3d convergence tests using more complex manufactured so…
SimonCan Oct 27, 2023
1d0e6e5
Added 3d Alfven wave for convergence test.
SimonCan Oct 30, 2023
b533492
Corrected 3d Alfven waves for convergence test.
SimonCan Oct 30, 2023
69dcbb0
Removed 1d Alfven test.
SimonCan Oct 31, 2023
72bab52
Autoformatter on visco-resistive Walfven waves elixir.
SimonCan Oct 31, 2023
3ac76f9
Added convergence test with non-trivial density truncation error.
SimonCan Nov 2, 2023
e41f6b2
Corrected local truncation error for visco-resistive MHD convergence …
SimonCan Nov 14, 2023
f9df450
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 14, 2023
4b37831
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 20, 2023
ee41761
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 21, 2023
b065539
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 21, 2023
50f5e56
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 22, 2023
ca46770
Change parametric type of supertype of visco-resistive MHD equations.
SimonCan Nov 23, 2023
d3c90f6
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Nov 24, 2023
17de344
Removed MHD dynamo test due to long run time.
SimonCan Dec 6, 2023
7b83464
UIpdated errors for visco-resistive MHD test after removing soure term.
SimonCan Dec 6, 2023
9c4063c
Removed source term.
SimonCan Dec 6, 2023
875ecbc
Added visco-resistive MHD converge test.
SimonCan Dec 6, 2023
4d38ee8
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Dec 8, 2023
27ec255
Added 2d Alfven wave test.
SimonCan Dec 12, 2023
4c4ac22
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Dec 12, 2023
6688e5f
Removed dynamo example elixir, as it is too specific/elaborate.
SimonCan Dec 13, 2023
45850b9
Corrected typo in diffusive mhd Alfven wave test results.
SimonCan Dec 13, 2023
26e0222
Added Andrew's suggestion for a manufactured solution in diffusive MHD.
SimonCan Dec 13, 2023
19cbb66
Added 2d visco-resistive MHD conergence test.
SimonCan Dec 14, 2023
6d6edfc
Added visco-resistive MHD equations in 2d.
SimonCan Dec 14, 2023
b466d80
Added visco-resistive MHD in 2d.
SimonCan Dec 14, 2023
2e14c85
Corrected 2d visco-resistive MHD equations (non-conservative part).
SimonCan Dec 15, 2023
eed9610
Corrected manufactured solution for 2d visco-resistive MHED convergen…
SimonCan Dec 15, 2023
cb86297
Added ViscoResistiveMhd2D to the export.
SimonCan Dec 15, 2023
ce33df1
Clean up convergence test elixir for 2d visco-resistive MHD equations.
SimonCan Jan 3, 2024
2856306
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Jan 4, 2024
954ec2f
Auto reformatted MHD example elixirs.
SimonCan Jan 5, 2024
d4a0626
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan Jan 5, 2024
6cb6a65
Removed 2d MHD visco-resistive elixir.
SimonCan Jan 16, 2024
6c6f181
Remoed 2d MHD visco-resistive euations.
SimonCan Jan 16, 2024
bdbf0c4
Removed ViscoResistiveMhd2D.
SimonCan Jan 16, 2024
c2c81b8
Removed 2d visco-0resistive MHD equations, as this is now part of a s…
SimonCan Jan 16, 2024
5a765b8
Cleaned up visco-resistive MHD elixir.
SimonCan Jan 16, 2024
9e4a0ba
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Jan 30, 2024
67f8d5b
Added finite viscosity and resistivity.
SimonCan Jan 30, 2024
602f6dc
Corrected residuals for visco-resistive MHD in 3d.
SimonCan Jan 31, 2024
db6116b
Corrected residual for 3d visco-resistive MHD convergence test.
SimonCan Feb 1, 2024
4549ce8
Corrected residual of 3d Alfven waves.
SimonCan Feb 8, 2024
3421b6e
Corrected residual for 3d Alfven wave for the visco-resistive MHD con…
SimonCan Feb 16, 2024
8100a68
Apple autoformatter on the lengthy expressions for the residuals.
SimonCan Feb 16, 2024
e7d95a1
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Feb 16, 2024
e682381
Simplifie terms for visco-resistive MHD convergence.
SimonCan Feb 22, 2024
7497cda
Removed small numbers that should be 0. Does not affect convergence n…
SimonCan Feb 22, 2024
279d0cf
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan Feb 22, 2024
a941f28
Further convergence tests.
SimonCan Mar 18, 2024
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
101 changes: 101 additions & 0 deletions examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the visco-resistive compressible MHD equations

prandtl_number() = 0.72
mu_const = 2e-2
eta_const = 2e-2

equations = IdealGlmMhdEquations3D(5 / 3)
equations_parabolic = ViscoResistiveMhd3D(equations, mu = mu_const,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
equations_parabolic = ViscoResistiveMhd3D(equations, mu = mu_const,
equations_parabolic = ViscoResistiveMhdDiffusion3D(equations, mu = mu_const,

Prandtl = prandtl_number(),
eta = eta_const,
gradient_variables = GradientVariablesPrimitive())

volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
solver = DGSEM(polydeg = 3,
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z))
coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z))

# Create a uniformly refined mesh
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 2,
n_cells_max = 200_000) # set maximum capacity of tree data structure

function initial_condition_constant_alfven(x, t, equations)
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
# Alfvén wave in three space dimensions modified by a periodic density variation.
# For the system without the density variations see: Altmann thesis http://dx.doi.org/10.18419/opus-3895.
# Domain must be set to [-1, 1]^3, γ = 5/3.
omega = 2.0 * pi # may be multiplied by frequency
# r = length-variable = length of computational domain
r = 2.0
# e = epsilon
e = 0.02
nx = 1 / sqrt(r^2 + 1.0)
ny = r / sqrt(r^2 + 1.0)
sqr = 1.0
Va = omega / (ny * sqr)
phi_alv = omega / ny * (nx * (x[1] - 0.5 * r) + ny * (x[2] - 0.5 * r)) - Va * t

rho = 1.0 + e * cos(phi_alv + 1.0)
v1 = -e * ny * cos(phi_alv) / rho
v2 = e * nx * cos(phi_alv) / rho
v3 = e * sin(phi_alv) / rho
p = 1.0
B1 = nx - rho * v1 * sqr
B2 = ny - rho * v2 * sqr
B3 = -rho * v3 * sqr
psi = 0.0

return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations)
end

initial_condition = initial_condition_constant_alfven

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, solver)

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

# Create ODE problem with time span `tspan`
tspan = (0.0, 0.1)
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
ode = semidiscretize(semi, tspan)

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

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

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

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

glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)

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

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

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1e-5, # 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()
133 changes: 133 additions & 0 deletions examples/tree_3d_dgsem/elixir_mhd_diffusive_convergence.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the visco-resistive compressible MHD equations

prandtl_number() = 0.72
mu_const = 1e-3
eta_const = 1e-3
prandtl_const = prandtl_number()

equations = IdealGlmMhdEquations3D(5 / 3)
equations_parabolic = ViscoResistiveMhd3D(equations, mu = mu_const,
Prandtl = prandtl_number(),
eta = eta_const,
gradient_variables = GradientVariablesPrimitive())

# volume_flux = (flux_hindenlang_gassner, flux_nonconservative_powell)
# solver = DGSEM(polydeg = 3,
# surface_flux = (flux_hindenlang_gassner, flux_nonconservative_powell),
# volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
volume_flux = (flux_central, flux_nonconservative_powell)
solver = DGSEM(polydeg = 3,
surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell),
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-1.0, -1.0, -1.0) # minimum coordinates (min(x), min(y), min(z))
coordinates_max = (1.0, 1.0, 1.0) # maximum coordinates (max(x), max(y), max(z))

# Create a uniformly refined mesh
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 1,
n_cells_max = 150_000) # set maximum capacity of tree data structure

function initial_condition_constant_alfven_3d(x, t, equations)
# Alfvén wave in three space dimensions modified by a periodic density variation.
# For the system without the density variations see: Altmann thesis http://dx.doi.org/10.18419/opus-3895.
# Domain must be set to [-1, 1]^3, γ = 5/3.
omega = 2.0 * pi # may be multiplied by frequency
# r = length-variable = length of computational domain
r = 2.0
# e = epsilon
e = 0.02
nx = 1 / sqrt(r^2 + 1.0)
ny = r / sqrt(r^2 + 1.0)
sqr = 1.0
Va = omega / (ny * sqr)
phi_alv = omega / ny * (nx * (x[1] - 0.5 * r) + ny * (x[2] - 0.5 * r)) - Va * t

# 3d Alfven wave
rho = 1.0 + e * cos(phi_alv + 1.0)
v1 = -e * ny * cos(phi_alv) / rho
v2 = e * nx * cos(phi_alv) / rho
v3 = e * sin(phi_alv) / rho
p = 1.0# + e*cos(phi_alv + 1.0)
B1 = nx - rho * v1 * sqr
B2 = ny - rho * v2 * sqr
B3 = -rho * v3 * sqr
psi = 0.0

return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations)
end

@inline function source_terms_mhd_convergence_test_3d(u, x, t, equations)
r_1 = 0.02*sqrt(5)*pi*sin(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1)

r_2 = sqrt(5)*pi^2*mu_const*(-0.04*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)) + (0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)*(0.0012*cos(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) - 0.0004*cos(1)) + 3.2e-5*sin(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)))/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^3

r_3 = -sqrt(5)*pi^2*mu_const*(-0.02*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)) + (0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)*(0.0006*cos(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) - 0.0002*cos(1)) + 1.6e-5*sin(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)))/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^3

r_4 = -pi^2*mu_const*((0.003*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) + 0.001*sin(1))*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1) + 0.1*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])) - 8.0e-5*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))*sin(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1)^2)/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^3

# r_5 = 0.2*pi*(2.77777777777778e-7*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) -2.58888888888889e-5*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 1.38888888888889e-7*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^3 - 1.78888888888889e-5*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 0.000547222222222222*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) + 2.77777777777778e-7*pi*mu_const*sin(-sqrt(5)*pi*t +pi*x[1] + 2*pi*x[2] + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) - 2.58888888888889e-5*pi*mu_const*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2 + 1.38888888888889e-7*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^3 - 1.78888888888889e-5*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 0.000547222222222223*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] -2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) + 1.0e-7*sqrt(5)*(-sin(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) + 2*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 2) - sin(2)) + 1.0e-7*sqrt(5)*(sin(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) + 2*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 2) + sin(2)) - 8.0e-9*sqrt(5)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 - 2.0e-5*sqrt(5)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) - 8.0e-9*sqrt(5)*sin(-sqrt(5)*pi*t+ pi*x[1] + 2*pi*x[2] + 1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 - 2.0e-5*sqrt(5)*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2)/(-0.04*sin(pi*x[2])*sin(-sqrt(5)*pi*t + pi*x[1] + pi*x[2] + 1) + 0.02*cos(-sqrt(5)*pi*t + pi*x[1] + 1) - 1.0)^4

r_5 = 0.2*pi*(1.7205356741103e-21*pi*mu_const*(cos(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) - cos(2)) - 1.01643953670516e-19*pi*mu_const*(cos(-3*sqrt(5)*pi*t + 3*pi*x[1] + 6*pi*x[2] + 1) - cos(sqrt(5)*pi*t - pi*x[1] - 2*pi*x[2] + 1)) + 2.77777777777778e-7*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) - 2.58888888888889e-5*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 1.38888888888889e-7*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^3 - 1.78888888888889e-5*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 0.000547222222222222*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) + 4.33680868994202e-18*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2 - 1.17643464896431e-22*pi*mu_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 2.77777777777778e-7*pi*mu_const*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) - 2.58888888888889e-5*pi*mu_const*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2 - 2.16840434497101e-25*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^4 + 1.38888888888889e-7*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^3 - 1.78888888888889e-5*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 + 0.000547222222222223*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) - 6.64073830647371e-18*pi*mu_const*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2 + 1.0842021724855e-21*sqrt(5)*(-sin(-3*sqrt(5)*pi*t + 3*pi*x[1] + 6*pi*x[2] + 1) + sin(sqrt(5)*pi*t - pi*x[1] - 2*pi*x[2] + 1)) + 1.0842021724855e-27*sqrt(5)*(cos(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 2) + 1)^2*sin(pi*(-2*sqrt(5)*t + 2*x[1] + 4*x[2])) - 1.62630325872826e-23*sqrt(5)*(-2*sin(pi*(-2*sqrt(5)*t + 2*x[1] + 4*x[2])) - sin(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) + sin(2)) + 1.0e-7*sqrt(5)*(-sin(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) + 2*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 2) - sin(2)) + 1.0e-7*sqrt(5)*(sin(-4*sqrt(5)*pi*t + 4*pi*x[1] + 8*pi*x[2] + 2) + 2*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 2) + sin(2)) + 2.71050543121376e-20*sqrt(5)*sin(pi*(-2*sqrt(5)*t + 2*x[1] + 4*x[2])) - 8.0e-9*sqrt(5)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 - 2.0e-5*sqrt(5)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))^2*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1) + 1.73472347597681e-24*sqrt(5)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2]))*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^3 - 8.0e-9*sqrt(5)*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2*cos(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)^2 - 2.0e-5*sqrt(5)*sin(-sqrt(5)*pi*t + pi*x[1] + 2*pi*x[2] + 1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0))^2)/(-0.04*sin(pi*x[2])*sin(-sqrt(5)*pi*t + pi*x[1] + pi*x[2] + 1) + 0.02*cos(-sqrt(5)*pi*t + pi*x[1] + 1) - 1.0)^4

r_6 = pi*(-0.04*(sqrt(5)*pi*eta_const*cos(pi*(-sqrt(5)*t + x[1] + 2*x[2])) + sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])))*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2 + 0.04*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])) + 0.0004*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) + 0.0004*sin(1))/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2

r_7 = pi*(0.02*(sqrt(5)*pi*eta_const*cos(pi*(-sqrt(5)*t + x[1] + 2*x[2])) + sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])))*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2 - 0.02*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])) - 0.0002*sin(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) - 0.0002*sin(1))/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1]+ 2*x[2] - 3.0) + 1) + 1)^2

r_8 = pi*((0.1*pi*eta_const*sin(pi*(-sqrt(5)*t + x[1] + 2*x[2])) + 0.02*sqrt(5)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)))*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2 - 0.02*sqrt(5)*(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) +1)*cos(pi*(sqrt(5)*t - x[1] - 2*x[2] + 3.0)) + 0.0002*sqrt(5)*(cos(-2*sqrt(5)*pi*t + 2*pi*x[1] + 4*pi*x[2] + 1) - cos(1)))/(0.02*cos(-sqrt(5)*pi*t + pi*(x[1] + 2*x[2] - 3.0) + 1) + 1)^2

r_9 = 0.0

return SVector(r_1, r_2, r_3, r_4, r_5, r_6, r_7, r_8, r_9)
end

initial_condition = initial_condition_constant_alfven_3d
source_terms = source_terms_mhd_convergence_test_3d

semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
initial_condition, solver;
source_terms = source_terms)

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

# Create ODE problem with time span `tspan`
tspan = (0.0, 1.5)
ode = semidiscretize(semi, tspan)

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

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

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

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

glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)

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

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

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1e-5, # 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()
1 change: 1 addition & 0 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export AcousticPerturbationEquations2D,
CompressibleEulerMulticomponentEquations2D,
CompressibleEulerEquationsQuasi1D,
IdealGlmMhdEquations1D, IdealGlmMhdEquations2D, IdealGlmMhdEquations3D,
ViscoResistiveMhd3D,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ViscoResistiveMhd3D,
ViscoResistiveMhdDiffusion3D,

IdealGlmMhdMulticomponentEquations1D, IdealGlmMhdMulticomponentEquations2D,
HyperbolicDiffusionEquations1D, HyperbolicDiffusionEquations2D,
HyperbolicDiffusionEquations3D,
Expand Down
5 changes: 5 additions & 0 deletions src/equations/equations_parabolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ include("compressible_navier_stokes.jl")
include("compressible_navier_stokes_1d.jl")
include("compressible_navier_stokes_2d.jl")
include("compressible_navier_stokes_3d.jl")

# Resistive and visuous MHD
abstract type AbstractViscoResistiveMhd{NDIMS, NVARS} <:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
abstract type AbstractViscoResistiveMhd{NDIMS, NVARS} <:
abstract type AbstractViscoResistiveMhdDiffusion{NDIMS, NVARS} <:

AbstractEquationsParabolic{NDIMS, NVARS, GradientVariablesConservative} end
include("visco_resistive_mhd_3d.jl")
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading