-
Notifications
You must be signed in to change notification settings - Fork 112
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
SimonCan
wants to merge
191
commits into
main
Choose a base branch
from
sc/mhd-treemesh-3d
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+505
−0
Open
Sc/mhd treemesh 3d #1323
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 b5e1354
typo fix in CNS 2D file
andrewwinters5000 ab9329c
add TGV elixir for compressible Navier-Stokes
andrewwinters5000 82369ec
add DGMulti CNS 3D elixir
jlchan 5929572
need TreeMesh versions of slip wall BC in 3D compressible Euler for c…
andrewwinters5000 9267369
update comments in CNS 3D file
andrewwinters5000 01b3752
add convergence test elixir for 3D compressible Navier-Stokes
andrewwinters5000 2921f1d
remove debug statements from new elixir
andrewwinters5000 bfb7114
adjust maximum tree size in new elixir
andrewwinters5000 110b5fa
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 bfccb07
add convergence test for DGMulti 3D
andrewwinters5000 323e4cf
add battery of 3D parabolic tests. All pass locally
andrewwinters5000 1929552
remove old comments and TODOs
andrewwinters5000 559f47c
bug fix in divergence B analysis routine
andrewwinters5000 0eaea4d
Merge branch 'main' into ns-treemesh-3d
ranocha b200526
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 6fdec4b
Merge branch 'main' into ns-treemesh-3d
ranocha 2f05140
add vorticity and enstrophy functions
andrewwinters5000 54ff12a
add first version of an enstrophy callback
andrewwinters5000 91bb5a1
add enstrophy callback to TGV elixir
andrewwinters5000 fc46ae1
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 104b8c8
update TGV test values since switched surface flux to flux_hllc
andrewwinters5000 aa7da6f
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 8416705
adding draft DGMulti analysis callback
jlchan 28c3eca
adding draft DGMulti analysis callback
jlchan 383ccfe
Merge remote-tracking branch 'refs/remotes/origin/ns-treemesh-3d'
jlchan 315f448
Merge branch 'main' into ns-treemesh-3d
ranocha 5f9e40b
Apply suggestions from code review
andrewwinters5000 c512038
make sure Experimental code text renders properly in docs
andrewwinters5000 8c2e242
adding extra analysis integrals
jlchan 82d5311
Merge branch 'ns-treemesh-3d' of https://github.com/trixi-framework/T…
jlchan 8854647
remove unused file path from parabolic test scripts
andrewwinters5000 9575600
remove threading for reduction
jlchan 94479eb
Merge branch 'main' into ns-treemesh-3d
jlchan 9503279
Merge remote-tracking branch 'origin/ns-treemesh-3d' into ns-treemesh-3d
jlchan d7c31a7
Merge branch 'main' into ns-treemesh-3d
jlchan bc4382d
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 9f2f5e2
Apply suggestions from code review
andrewwinters5000 29c5aa2
add designation to the 2D test set
andrewwinters5000 9dee6fe
Merge branch 'ns-treemesh-3d' of github.com:trixi-framework/Trixi.jl …
andrewwinters5000 1e6f825
Merge branch 'main' into ns-treemesh-3d
andrewwinters5000 ecf010e
Added CompressibleMhdDiffusion3D.
SimonCan 251afa6
Added compressible, viscous and diffusive MHD equations module.
SimonCan 10d2f12
Added visco-resistive Alfven wave exmple elixir.
SimonCan c99b1d3
Added covnergence test for the visco-resistive MHD equtions,
SimonCan 3b3d8c0
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 6446dbb
Typos in documentation for compressible_mhd_3d.
SimonCan a6116f9
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 7205a04
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 6a0d47d
Added resistive and viscous MHD wave example in 3d.
iomsn e9cb99f
Added resistive MHD test.
iomsn 9b20993
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 386b6de
Minor typo.
iomsn fa22ff0
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
iomsn 072fe6d
Removed redundant elixir file with resistive Alfven waves.
SimonCan a1eee74
Reformatted compressible mhd 3d equations.
SimonCan 457de18
Minor reformatting.
SimonCan 54897a5
Added turbulent dynamo elixir.
SimonCan e2bb39b
Added dynamos MHD test.
SimonCan ff6d120
Typo in docs.
SimonCan 67aec83
Increased relative tolerance for the dynamo test, as we have random n…
SimonCan a1bd40b
Remove so far unused functionality form the resistive MHD equations m…
SimonCan c4fcccb
Changed the format of the docs.
SimonCan 7a505ae
Increased relative tolerance for the MHD dynamo test.
SimonCan e837364
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 6385f06
Updated dynamo test case.
SimonCan 4c10b8b
Updated dynamo elixir example to make it deterministic by using deter…
SimonCan 2d97aa4
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan e09393d
Added magnetic energy for resistive MHD equations.
SimonCan ec74d9c
Reformatted mhd equation file.
SimonCan 8cda4a5
Change description of the physical setup.
SimonCan d3179a2
Removed relative errors and reformatted.
SimonCan a42705b
Added link to Pencil Code example.
SimonCan 853dce0
Changed UInt64 to target type.
SimonCan 24542dd
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan 188ce63
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan 4ee21cc
Changed randn(1)[1] to randn.
SimonCan 692f1cf
Added SVector to avoid memory allocation.
SimonCan 2b20036
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan 4d38046
Fixed description.
SimonCan 36c9626
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan ce6ed4f
Removed rtol and atol.
SimonCan a58113a
Changed indendation of doc string.
SimonCan 5a93a26
Update src/equations/compressible_mhd_3d.jl
SimonCan 041d72e
Removed commented code.
SimonCan 15817f6
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 8bb44fb
Removed comment.
SimonCan eb48a5f
Updated dynamo test results.
SimonCan 046b312
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 8964911
Added StableRNGs.
SimonCan 02d5af1
Moved StableRNG from the main Project.toml to the test Project.toml.
SimonCan 4d10ce4
Changed some rand() functions to randn(rng).
SimonCan fcfa410
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan f3bfc7e
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan 76339e7
Update examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
SimonCan c889688
Update src/equations/compressible_mhd_3d.jl
SimonCan c5ca22e
Update src/equations/compressible_mhd_3d.jl
SimonCan 6693c12
Added Alfven reference.
SimonCan 6d8f3f5
Changed end time for MHD wagve elixir.
SimonCan 086250c
Changed k-vector into SVector.
SimonCan 71733c4
Added reference for dynamo forcing.
SimonCan ef41a10
Added DOI for dynamo model.
SimonCan 2f75dcb
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan 29b64fa
Update src/equations/compressible_mhd_3d.jl
SimonCan 9390653
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan c83aa20
Added muladd header and footer.
SimonCan e7f9cc2
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 60eacc8
Renamed visco-resistive MHD equations.
SimonCan 95ab852
Removed redundant comment.
SimonCan 93785f8
Changed et to eta().
SimonCan 1a45991
Changed nu and eta for dynamo test.
SimonCan b05a24f
Updated dynamo test results.
SimonCan 08985af
Minor typos.
SimonCan 5719aa8
Adjusted cfl condition for MHD elixir.
SimonCan b4ae412
Corrected test values for damped Alfven wave after adjusting the CFL …
SimonCan d036fcf
Formatting.
SimonCan c723a89
Added the visco-resistive equations in the documentation.
SimonCan 12e4611
Added a few comments on Alfven wave setup.
SimonCan f77ae54
Added section reference for paper.
SimonCan 94fe8ee
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan a7e3e4b
Reformatted reference.
SimonCan 3d4032b
Update examples/tree_3d_dgsem/elixir_mhd_dynamo.jl
SimonCan d49ba98
Update src/equations/visco_resistive_mhd_3d.jl
SimonCan 58c9671
Increased the final time for the MHD dynamo to 10.0.
SimonCan afa6334
Changed time span for MHD dynamo test.
SimonCan 2b6c8e0
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 40cafa1
Added convergence test to the diffusive Alfven wave elixir example.
SimonCan 105aa69
Changed the diffusive Alfven wave parameters.
SimonCan 2d97537
Updated test results for diffusive Alfven waves.
SimonCan b559632
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 41749dd
Attempt to get convergence for MHD.
SimonCan ec0390b
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan ea10804
New MHD convergence tests.
SimonCan 8387e30
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan f893b95
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan ea67250
Updated viscous MHD test results.
SimonCan 2655e9b
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan cdba1d4
Removed Andrew's constructed solution and reinstated simpler Alfven w…
SimonCan 702b674
Fixed convergen issue with visco-resistive MHD.
SimonCan 04d85dd
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 873790f
Tried further 3d convergence tests using more complex manufactured so…
SimonCan 1d0e6e5
Added 3d Alfven wave for convergence test.
SimonCan b533492
Corrected 3d Alfven waves for convergence test.
SimonCan 69dcbb0
Removed 1d Alfven test.
SimonCan 72bab52
Autoformatter on visco-resistive Walfven waves elixir.
SimonCan 3ac76f9
Added convergence test with non-trivial density truncation error.
SimonCan e41f6b2
Corrected local truncation error for visco-resistive MHD convergence …
SimonCan f9df450
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 4b37831
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan ee41761
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan b065539
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 50f5e56
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan ca46770
Change parametric type of supertype of visco-resistive MHD equations.
SimonCan d3c90f6
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 17de344
Removed MHD dynamo test due to long run time.
SimonCan 7b83464
UIpdated errors for visco-resistive MHD test after removing soure term.
SimonCan 9c4063c
Removed source term.
SimonCan 875ecbc
Added visco-resistive MHD converge test.
SimonCan 4d38ee8
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 27ec255
Added 2d Alfven wave test.
SimonCan 4c4ac22
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 6688e5f
Removed dynamo example elixir, as it is too specific/elaborate.
SimonCan 45850b9
Corrected typo in diffusive mhd Alfven wave test results.
SimonCan 26e0222
Added Andrew's suggestion for a manufactured solution in diffusive MHD.
SimonCan 19cbb66
Added 2d visco-resistive MHD conergence test.
SimonCan 6d6edfc
Added visco-resistive MHD equations in 2d.
SimonCan b466d80
Added visco-resistive MHD in 2d.
SimonCan 2e14c85
Corrected 2d visco-resistive MHD equations (non-conservative part).
SimonCan eed9610
Corrected manufactured solution for 2d visco-resistive MHED convergen…
SimonCan cb86297
Added ViscoResistiveMhd2D to the export.
SimonCan ce33df1
Clean up convergence test elixir for 2d visco-resistive MHD equations.
SimonCan 2856306
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 954ec2f
Auto reformatted MHD example elixirs.
SimonCan d4a0626
Merge branch 'sc/mhd-treemesh-3d' of github.com:trixi-framework/Trixi…
SimonCan 6cb6a65
Removed 2d MHD visco-resistive elixir.
SimonCan 6c6f181
Remoed 2d MHD visco-resistive euations.
SimonCan bdbf0c4
Removed ViscoResistiveMhd2D.
SimonCan c2c81b8
Removed 2d visco-0resistive MHD equations, as this is now part of a s…
SimonCan 5a765b8
Cleaned up visco-resistive MHD elixir.
SimonCan 9e4a0ba
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan 67f8d5b
Added finite viscosity and resistivity.
SimonCan 602f6dc
Corrected residuals for visco-resistive MHD in 3d.
SimonCan db6116b
Corrected residual for 3d visco-resistive MHD convergence test.
SimonCan 4549ce8
Corrected residual of 3d Alfven waves.
SimonCan 3421b6e
Corrected residual for 3d Alfven wave for the visco-resistive MHD con…
SimonCan 8100a68
Apple autoformatter on the lengthy expressions for the residuals.
SimonCan e7d95a1
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan e682381
Simplifie terms for visco-resistive MHD convergence.
SimonCan 7497cda
Removed small numbers that should be 0. Does not affect convergence n…
SimonCan 279d0cf
Merge branch 'main' into sc/mhd-treemesh-3d
SimonCan a941f28
Further convergence tests.
SimonCan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
examples/tree_3d_dgsem/elixir_mhd_diffusive_alfven_wave.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
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
133
examples/tree_3d_dgsem/elixir_mhd_diffusive_convergence.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -146,6 +146,7 @@ export AcousticPerturbationEquations2D, | |||||
CompressibleEulerMulticomponentEquations2D, | ||||||
CompressibleEulerEquationsQuasi1D, | ||||||
IdealGlmMhdEquations1D, IdealGlmMhdEquations2D, IdealGlmMhdEquations3D, | ||||||
ViscoResistiveMhd3D, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
IdealGlmMhdMulticomponentEquations1D, IdealGlmMhdMulticomponentEquations2D, | ||||||
HyperbolicDiffusionEquations1D, HyperbolicDiffusionEquations2D, | ||||||
HyperbolicDiffusionEquations3D, | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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} <: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
AbstractEquationsParabolic{NDIMS, NVARS, GradientVariablesConservative} end | ||||||
include("visco_resistive_mhd_3d.jl") | ||||||
SimonCan marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.