Skip to content

Commit

Permalink
Separate dissipation parameters for ions, electrons, neutrals (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasMontoya4 authored and johnomotani committed Apr 26, 2024
1 parent 4030583 commit 95f7ece
Show file tree
Hide file tree
Showing 59 changed files with 319 additions and 174 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ makie_postproc.so
plots_postproc.so
precompile-temp
post_processing_input.toml
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ vperp_discretization = "gausslegendre_pseudospectral"
#vzeta_bc = "periodic"
#vzeta_discretization = "chebyshev_pseudospectral"

#[numerical_dissipation]
#[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 0.0
#vperp_dissipation_coefficient = 0.0
#z_dissipation_coefficient = 0.1
Expand Down
2 changes: 1 addition & 1 deletion examples/geometry/1D-mirror.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ vz_L = 18.0
vz_bc = "both_zero"
vz_discretization = "chebyshev_pseudospectral"

[numerical_dissipation]
[ion_numerical_dissipation]
vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
vperp_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0
Expand Down
16 changes: 10 additions & 6 deletions examples/gk-ions/2D-periodic-gk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ vz_L = 18.0
vz_bc = "both_zero"
vz_discretization = "chebyshev_pseudospectral"

[numerical_dissipation]
vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
vperp_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
#r_disspipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[geometry]
#option="1D-mirror"
DeltaB=0.0
option="constant-helical"
pitch=0.1
rhostar= 0.1

[ion_numerical_dissipation]
vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
vperp_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
#r_disspipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
moment_dissipation_coefficient = 0.0001
vz_dissipation_coefficient = 0.01
2 changes: 1 addition & 1 deletion examples/numerical-dissipation/num-diss-relaxation.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ nwrite = 2000
nwrite_dfns = 2000
split_operators = false

[numerical_dissipation]
[ion_numerical_dissipation]
vpa_dissipation_coefficient = 0.1
vperp_dissipation_coefficient = 0.1
z_dissipation_coefficient = -1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ z_width = 0.125
source_strength = 2.0
source_T = 2.0

[numerical_dissipation]
[ion_numerical_dissipation]
vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ z_width = 0.125
source_strength = 2.0
source_T = 2.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ z_width = 0.125
source_strength = 2.0
source_T = 2.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ z_width = 0.125
source_strength = 2.0
source_T = 2.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
6 changes: 5 additions & 1 deletion examples/wall-bc/wall-bc_cheb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ dt = 1.0e-5
nwrite = 1000
split_operators = false

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0
6 changes: 5 additions & 1 deletion examples/wall-bc/wall-bc_cheb_split1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ dt = 1.0e-5
nwrite = 1000
split_operators = false

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0
6 changes: 5 additions & 1 deletion examples/wall-bc/wall-bc_cheb_split2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ dt = 1.0e-5
nwrite = 1000
split_operators = false

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0
6 changes: 5 additions & 1 deletion examples/wall-bc/wall-bc_cheb_split3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ dt = 1.0e-5
nwrite = 1000
split_operators = false

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-3 #1.0e-2 #1.0e-1
force_minimum_pdf_value = 0.0
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ z_width = 0.125
source_strength = 8.0
source_T = 1.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ z_width = 0.125
source_strength = 8.0
source_T = 1.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ z_width = 0.125
source_strength = 8.0
source_T = 1.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ z_width = 0.125
source_strength = 8.0
source_T = 1.0

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
Expand Down
8 changes: 7 additions & 1 deletion examples/wall-bc/wall-bc_volumerecycle.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ active = true
source_type = "recycling"
recycling_controller_fraction = 0.25

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-1
#vz_dissipation_coefficient = 1.0e-2
#vz_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[krook_collisions]
use_krook = true
frequency_option = "reference_parameters"
8 changes: 7 additions & 1 deletion examples/wall-bc/wall-bc_volumerecycle_split1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ active = true
source_type = "recycling"
recycling_controller_fraction = 0.25

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-1
#vz_dissipation_coefficient = 1.0e-2
#vz_dissipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[krook_collisions]
use_krook = true
frequency_option = "reference_parameters"
8 changes: 7 additions & 1 deletion examples/wall-bc/wall-bc_volumerecycle_split2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ active = true
source_type = "recycling"
recycling_controller_fraction = 0.25

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-1
#vz_dissipation_coefficient = 1.0e-2
#vz_dissipation_coefficient = 1.0e-3
#force_minimum_pdf_value = 0.0

[krook_collisions]
use_krook = true
frequency_option = "reference_parameters"
8 changes: 7 additions & 1 deletion examples/wall-bc/wall-bc_volumerecycle_split3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,18 @@ active = true
source_type = "recycling"
recycling_controller_fraction = 0.25

[numerical_dissipation]
[ion_numerical_dissipation]
#vpa_dissipation_coefficient = 1.0e-1
#vpa_dissipation_coefficient = 1.0e-2
#vpa_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[neutral_numerical_dissipation]
#vz_dissipation_coefficient = 1.0e-1
#vz_dissipation_coefficient = 1.0e-2
#vz_dissipation_coefficient = 1.0e-3
force_minimum_pdf_value = 0.0

[krook_collisions]
use_krook = true
frequency_option = "reference_parameters"
3 changes: 2 additions & 1 deletion moment_kinetics/debug_test/restart_interpolation_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ base_input = Dict(
"vzeta_nelement" => 1,
"vr_ngrid" => 1,
"vr_nelement" => 1,
"numerical_dissipation" => Dict{String,Any}("force_minimum_pdf_value" => 0.0))
"ion_numerical_dissipation" => Dict{String,Any}("force_minimum_pdf_value" => 0.0),
"neutral_numerical_dissipation" => Dict{String,Any}("force_minimum_pdf_value" => 0.0))

test_input =
merge(base_input,
Expand Down
28 changes: 14 additions & 14 deletions moment_kinetics/ext/manufactured_solns_ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -638,31 +638,31 @@ using IfElse
Si += - nuii_krook*(FMaxwellian - dfni)
end
include_num_diss_in_MMS = true
if num_diss_params.vpa_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.vpa_dissipation_coefficient*Dvpa(Dvpa(dfni))
if num_diss_params.ion.vpa_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.ion.vpa_dissipation_coefficient*Dvpa(Dvpa(dfni))
end
if num_diss_params.vperp_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.vperp_dissipation_coefficient*Dvperp(Dvperp(dfni))
if num_diss_params.ion.vperp_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.ion.vperp_dissipation_coefficient*Dvperp(Dvperp(dfni))
end
if num_diss_params.r_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - rfac*num_diss_params.r_dissipation_coefficient*Dr(Dr(dfni))
if num_diss_params.ion.r_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - rfac*num_diss_params.ion.r_dissipation_coefficient*Dr(Dr(dfni))
end
if num_diss_params.z_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.z_dissipation_coefficient*Dz(Dz(dfni))
if num_diss_params.ion.z_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Si += - num_diss_params.ion.z_dissipation_coefficient*Dz(Dz(dfni))
end

Source_i = expand_derivatives(Si)

# the neutral source to maintain the manufactured solution
Sn = Dt(dfnn) + vz * Dz(dfnn) + rfac*vr * Dr(dfnn) + cx_frequency* (densi*dfnn - densn*vrvzvzeta_dfni) + ionization_frequency*dense*dfnn
if num_diss_params.vz_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - num_diss_params.vz_dissipation_coefficient*Dvz(Dvz(dfnn))
if num_diss_params.neutral.vz_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - num_diss_params.neutral.vz_dissipation_coefficient*Dvz(Dvz(dfnn))
end
if num_diss_params.r_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - rfac*num_diss_params.r_dissipation_coefficient*Dr(Dr(dfnn))
if num_diss_params.neutral.r_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - rfac*num_diss_params.neutral.r_dissipation_coefficient*Dr(Dr(dfnn))
end
if num_diss_params.z_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - num_diss_params.z_dissipation_coefficient*Dz(Dz(dfnn))
if num_diss_params.neutral.z_dissipation_coefficient > 0.0 && include_num_diss_in_MMS
Sn += - num_diss_params.neutral.z_dissipation_coefficient*Dz(Dz(dfnn))
end

Source_n = expand_derivatives(Sn)
Expand Down
4 changes: 2 additions & 2 deletions moment_kinetics/src/continuity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function continuity_equation!(dens_out, fvec_in, moments, composition, dt, spect
end

# Ad-hoc diffusion to stabilise numerics...
diffusion_coefficient = num_diss_params.moment_dissipation_coefficient
diffusion_coefficient = num_diss_params.ion.moment_dissipation_coefficient
if diffusion_coefficient > 0.0
@loop_s_r_z is ir iz begin
dens_out[iz,ir,is] += dt*diffusion_coefficient*moments.ion.d2dens_dz2[iz,ir,is]
Expand Down Expand Up @@ -80,7 +80,7 @@ function neutral_continuity_equation!(dens_out, fvec_in, moments, composition, d
end

# Ad-hoc diffusion to stabilise numerics...
diffusion_coefficient = num_diss_params.moment_dissipation_coefficient
diffusion_coefficient = num_diss_params.neutral.moment_dissipation_coefficient
if diffusion_coefficient > 0.0
@loop_sn_r_z isn ir iz begin
dens_out[iz,ir,isn] += dt*diffusion_coefficient*moments.neutral.d2dens_dz2[iz,ir,isn]
Expand Down
4 changes: 2 additions & 2 deletions moment_kinetics/src/energy_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function energy_equation!(ppar, fvec, moments, collisions, dt, spectral, composi
end
end

diffusion_coefficient = num_diss_params.moment_dissipation_coefficient
diffusion_coefficient = num_diss_params.ion.moment_dissipation_coefficient
if diffusion_coefficient > 0.0
@loop_s_r_z is ir iz begin
ppar[iz,ir,is] += dt*diffusion_coefficient*moments.ion.d2ppar_dz2[iz,ir,is]
Expand Down Expand Up @@ -82,7 +82,7 @@ function neutral_energy_equation!(pz, fvec, moments, collisions, dt, spectral,
end
end

diffusion_coefficient = num_diss_params.moment_dissipation_coefficient
diffusion_coefficient = num_diss_params.neutral.moment_dissipation_coefficient
if diffusion_coefficient > 0.0
@loop_sn_r_z isn ir iz begin
pz[iz,ir,isn] += dt*diffusion_coefficient*moments.neutral.d2pz_dz2[iz,ir,isn]
Expand Down
Loading

0 comments on commit 95f7ece

Please sign in to comment.