Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
60bad15
added momentum collision
May 5, 2023
94eb48f
minor changes (cfl etc)
May 9, 2023
75873fb
Merge remote-tracking branch 'origin/multi_ion_mhd' into multi_ion_co…
May 9, 2023
7f7ebe9
added energy source term and refactored somewhat
May 9, 2023
cb3fcc1
Added Orszag-Tang test for multi-ion MHD (should be comparable with s…
amrueda May 15, 2023
996a3dc
Updated src/equations/ideal_mhd_multiion_2d.jl to match multi_ion_mhd…
amrueda May 15, 2023
82cad17
Added draft of ion-ion collision terms, and changed OT test ase
amrueda May 16, 2023
c9eff6e
minor modifications to OT
amrueda Jun 6, 2023
efa15f1
Fixed bugs in ion-ion collision terms
amrueda Jun 12, 2023
24dd9dd
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources
amrueda Oct 2, 2023
6d67bb1
Added electron pressure terms and drifting correction for ion-ion col…
amrueda Oct 2, 2023
82ee1e8
Added ion-electron collision terms
amrueda Oct 27, 2023
7855c91
Added ion-electron collision sources with effect on Ohm's law
amrueda Nov 6, 2023
930f2b5
format
amrueda Nov 6, 2023
a3f2ecb
Format examples
amrueda Nov 6, 2023
0641706
Remove multi-ion OT example
amrueda Nov 6, 2023
7c5a016
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources
amrueda Nov 6, 2023
513401e
Improved formatting
amrueda Nov 6, 2023
b3a181a
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources
amrueda Nov 7, 2023
a5ae10d
Added consistent energy source term to ion-electron collision sources…
amrueda Nov 9, 2023
a07362e
Rename 2D multi-ion MHD file
amrueda Dec 12, 2024
cb85cc2
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources and res…
amrueda Dec 12, 2024
ca43f5e
Moved collision routines from ideal_glm_mhd_multiion_2d.jl into ideal…
amrueda Dec 12, 2024
0580c2a
Remove unneeded deps from Project.toml
amrueda Dec 12, 2024
d9ab484
Format
amrueda Dec 12, 2024
3d311c3
Fixed problem with ion-electron collisions and added test for collisi…
amrueda Dec 13, 2024
d5f225a
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources
amrueda Dec 13, 2024
e19782e
Fixed typo and improved comments
amrueda Dec 16, 2024
18561ca
Added default values for additional arguments and type tests for coll…
amrueda Dec 16, 2024
f549d21
Removed allocations in source_terms_collision_ion_ion at the expense …
amrueda Dec 16, 2024
085d51e
Improve comments of elixir_mhdmultiion_collisions.jl
amrueda Dec 16, 2024
932909d
format
amrueda Dec 16, 2024
69c5db0
Removed unneeded keyword arguments for elixir_mhdmultiion_ec.jl
amrueda Dec 16, 2024
0614602
Implemented collision frequency matrix
amrueda Dec 16, 2024
0394b01
Remove outdated TODOs
amrueda Dec 17, 2024
826e9a1
Improved docstring of IdealGlmMhdMultiIonEquations2D
amrueda Dec 17, 2024
0e07cfe
Improved documentation and implementation of collision sources, and c…
amrueda Dec 17, 2024
4797e73
Fix docstring issues
amrueda Dec 18, 2024
c9020d2
Use zero(eltype(u)) instead of 0
amrueda Dec 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
152 changes: 152 additions & 0 deletions examples/tree_2d_dgsem/elixir_mhdmultiion_collisions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# This elixir describes the frictional slowing of an ionized carbon fluid (C6+) with respect to another species
# of a background ionized carbon fluid with an initially nonzero relative velocity. It is the second slow-down
# test (fluids with different densities) described in:
# - Ghosh, D., Chapman, T. D., Berger, R. L., Dimits, A., & Banks, J. W. (2019). A
# multispecies, multifluid model for laser–induced counterstreaming plasma simulations.
# Computers & Fluids, 186, 38-57.
#
# This is effectively a zero-dimensional case because the spatial gradients are zero, and we use it to test the
# collision source terms.
#
# To run this physically relevant test, we use the following characteristic quantities to non-dimensionalize
# the equations:
# Characteristic length: L_inf = 1.00E-03 m (domain size)
# Characteristic density: rho_inf = 1.99E+00 kg/m^3 (corresponds to a number density of 1e20 cm^{-3})
# Characteristic vacuum permeability: mu0_inf = 1.26E-06 N/A^2 (for equations with mu0 = 1)
# Characteristic gas constant: R_inf = 6.92237E+02 J/kg/K (specific gas constant for a Carbon fluid)
# Characteristic velocity: V_inf = 1.00E+06 m/s
#
# The results of the paper can be reproduced using `source_terms = source_terms_collision_ion_ion` (i.e., only
# taking into account ion-ion collisions). However, we include ion-electron collisions assuming a constant
# electron temperature of 1 keV in this elixir to test the function `source_terms_collision_ion_electron`

# Return the electron pressure for a constant electron temperature Te = 1 keV
function electron_pressure_constantTe(u, equations::IdealGlmMhdMultiIonEquations2D)
@unpack charge_to_mass = equations
Te = 0.008029953773 # [nondimensional] = 1 [keV]
total_electron_charge = zero(eltype(u))
for k in eachcomponent(equations)
rho_k = u[3 + (k - 1) * 5 + 1]
total_electron_charge += rho_k * charge_to_mass[k]
end

# Boltzmann constant divided by elementary charge
kB_e = 7.86319034E-02 #[nondimensional]

return total_electron_charge * kB_e * Te
end

# Return the constant electron temperature Te = 1 keV
function electron_temperature_constantTe(u, equations::IdealGlmMhdMultiIonEquations2D)
return 0.008029953773 # [nondimensional] = 1 [keV]
end

# semidiscretization of the ideal MHD equations
equations = IdealGlmMhdMultiIonEquations2D(gammas = (5 / 3, 5 / 3),
charge_to_mass = (76.3049060157692000,
76.3049060157692000), # [nondimensional]
gas_constants = (1.0, 1.0), # [nondimensional]
molar_masses = (1.0, 1.0), # [nondimensional]
ion_ion_collision_constants = [0.0 0.4079382480442680;
0.4079382480442680 0.0], # [nondimensional] (computed with eq (4.142) of Schunk&Nagy (2009))
ion_electron_collision_constants = (8.56368379833E-06,
8.56368379833E-06), # [nondimensional] (computed with eq (9) of Ghosh et al. (2019))
electron_pressure = electron_pressure_constantTe,
electron_temperature = electron_temperature_constantTe,
initial_c_h = 0.0) # Deactivate GLM divergence cleaning

# Frictional slowing of an ionized carbon fluid with respect to another background carbon fluid in motion
function initial_condition_slow_down(x, t, equations::IdealGlmMhdMultiIonEquations2D)
v11 = 0.65508770000000
v21 = 0
v2 = v3 = 0.0
B1 = B2 = B3 = 0.0
rho1 = 0.1
rho2 = 1.0

p1 = 0.00040170535986
p2 = 0.00401705359856

return prim2cons(SVector(B1, B2, B3, rho1, v11, v2, v3, p1, rho2, v21, v2, v3, p2, 0),
equations)
end

# Temperature of ion 1
function temperature1(cons, equations::IdealGlmMhdMultiIonEquations2D)
prim = cons2prim(cons, equations)
rho, _, _, _, p = Trixi.get_component(1, prim, equations)

return p / rho / equations.gas_constants[1]
end

# Temperature of ion 2
function temperature2(cons, equations::IdealGlmMhdMultiIonEquations2D)
prim = cons2prim(cons, equations)
rho, _, _, _, p = Trixi.get_component(2, prim, equations)

return p / rho / equations.gas_constants[2]
end

initial_condition = initial_condition_slow_down
tspan = (0.0, 0.1) # 100 [ps]

# Entropy conservative volume numerical fluxes with standard LLF dissipation at interfaces
volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_lax_friedrichs, flux_nonconservative_central)

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

coordinates_min = (0.0, 0.0)
coordinates_max = (1.0, 1.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 1,
n_cells_max = 1_000_000)

# Ion-ion and ion-electron collision source terms
# In this particular case, we can omit source_terms_lorentz because the magnetic field is zero!
function source_terms(u, x, t, equations::IdealGlmMhdMultiIonEquations2D)
source_terms_collision_ion_ion(u, x, t, equations) +
source_terms_collision_ion_electron(u, x, t, equations)
end

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

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

ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 1
analysis_callback = AnalysisCallback(semi,
save_analysis = true,
interval = analysis_interval,
extra_analysis_integrals = (temperature1,
temperature2))
alive_callback = AliveCallback(analysis_interval = analysis_interval)

stepsize_callback = StepsizeCallback(cfl = 0.01) # Very small CFL due to the stiff source terms

save_restart = SaveRestartCallback(interval = 100,
save_final_restart = true)

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

###############################################################################

sol = Trixi.solve(ode, Trixi.SimpleSSPRK33();
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);

summary_callback() # print the timer summary
3 changes: 2 additions & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ export boundary_condition_do_nothing,
BoundaryConditionCoupled

export initial_condition_convergence_test, source_terms_convergence_test,
source_terms_lorentz
source_terms_lorentz, source_terms_collision_ion_electron,
source_terms_collision_ion_electron_ohm, source_terms_collision_ion_ion
export source_terms_harmonic
export initial_condition_poisson_nonperiodic, source_terms_poisson_nonperiodic,
boundary_condition_poisson_nonperiodic
Expand Down
Loading
Loading