Skip to content

Commit

Permalink
test message (changed vpa_dissipation_coefficient to ion_vpa_dissipat…
Browse files Browse the repository at this point in the history
…ion_coefficient)
  • Loading branch information
Lucas committed Mar 13, 2024
1 parent 7a29a8c commit 20ed97d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ ionization_frequency = 2.0
#electron_ionization_frequency = 2.0
#ionization_energy = 1.0
constant_ionization_rate = false
nstep = 1000000
nstep = 1000
#nstep = 1
dt = 1.0e-5
nwrite = 10000
nwrite = 100
nwrite_dfns = 10000
use_semi_lagrange = false
n_rk_stages = 4
Expand Down Expand Up @@ -85,8 +85,8 @@ ascii_output = true
[numerical_dissipation]
#moment_dissipation_coefficient = 0.0001
#moment_dissipation_coefficient = 1.0
vpa_dissipation_coefficient = 0.002
#vpa_dissipation_coefficient = 0.1
#vpa_dissipation_coefficient = 0.002
ion_vpa_dissipation_coefficient = 0.1
#vpa_dissipation_coefficient = 0.2
#vpa_dissipation_coefficient = 2.0
#vpa_dissipation_coefficient = 20.0
13 changes: 6 additions & 7 deletions moment_kinetics/src/numerical_dissipation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using ..type_definitions: mk_float
Base.@kwdef struct numerical_dissipation_parameters
vpa_boundary_buffer_damping_rate::mk_float = -1.0
vpa_boundary_buffer_diffusion_coefficient::mk_float = -1.0
vpa_dissipation_coefficient::mk_float = -1.0
ion_vpa_dissipation_coefficient::mk_float = -1.0
vz_dissipation_coefficient::mk_float = -1.0
vperp_dissipation_coefficient::mk_float = -1.0
z_dissipation_coefficient::mk_float = -1.0
Expand All @@ -29,12 +29,12 @@ Base.@kwdef struct numerical_dissipation_parameters
end

function setup_numerical_dissipation(input_section::Dict, is_1V)
if is_1V && "vpa_dissipation_coefficient" keys(input_section)
if is_1V && "ion_vpa_dissipation_coefficient" keys(input_section)
# Set default for vz_dissipation_coefficient the same as
# vpa_dissipation_coefficient for 1V case
# ion_vpa_dissipation_coefficient for 1V case
input_section["vz_dissipation_coefficient"] =
get(input_section, "vz_dissipation_coefficient",
input_section["vpa_dissipation_coefficient"])
input_section["ion_vpa_dissipation_coefficient"])
end

input = Dict(Symbol(k)=>v for (k,v) in input_section)
Expand Down Expand Up @@ -243,9 +243,8 @@ vpa_dissipation_coefficient = 0.1
```
"""
function vpa_dissipation!(f_out, f_in, vpa, spectral::T_spectral, dt,
num_diss_params::numerical_dissipation_parameters) where T_spectral
diffusion_coefficient) where T_spectral

diffusion_coefficient = num_diss_params.vpa_dissipation_coefficient
if diffusion_coefficient <= 0.0 || vpa.n == 1
return nothing
end
Expand Down Expand Up @@ -534,7 +533,7 @@ function r_dissipation_neutral!(f_out, f_in, r, r_spectral::T_spectral, dt,
end

"""
force_minimum_pdf_value!(f, num_diss_paras::numerical_dissipation_parameters)
force_minimum_pdf_value!(f, num_diss_params::numerical_dissipation_parameters)
Set a minimum value for the pdf-sized array `f`. Any points less than the minimum are
set to the minimum. By default, no minimum is applied. The minimum value can be set by
Expand Down
4 changes: 2 additions & 2 deletions moment_kinetics/src/time_advance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ function setup_advance_flags(moments, composition, t_input, collisions,
# flag to determine if a d^2/dr^2 operator is present
r_diffusion = (advance_numerical_dissipation && num_diss_params.r_dissipation_coefficient > 0.0)
# flag to determine if a d^2/dvpa^2 operator is present
vpa_diffusion = ((advance_numerical_dissipation && num_diss_params.vpa_dissipation_coefficient > 0.0) || explicit_weakform_fp_collisions)
vpa_diffusion = ((advance_numerical_dissipation && num_diss_params.ion_vpa_dissipation_coefficient > 0.0) || explicit_weakform_fp_collisions)
vz_diffusion = (advance_numerical_dissipation && num_diss_params.vz_dissipation_coefficient > 0.0)
end

Expand Down Expand Up @@ -1863,7 +1863,7 @@ function euler_time_advance!(fvec_out, fvec_in, pdf, fields, moments,
# add numerical dissipation
if advance.numerical_dissipation
vpa_dissipation!(fvec_out.pdf, fvec_in.pdf, vpa, vpa_spectral, dt,
num_diss_params)
num_diss_params.ion_vpa_dissipation_coefficient)
vperp_dissipation!(fvec_out.pdf, fvec_in.pdf, vperp, vperp_spectral, dt,
num_diss_params)
z_dissipation!(fvec_out.pdf, fvec_in.pdf, z, z_spectral, dt,
Expand Down

6 comments on commit 20ed97d

@LucasMontoya4
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have changed the vpa_dissipation_coefficient terms to denote those of ions (i.e. ion_vpa_dissipation_coefficient), and will now change the ones involving electrons. Note that this means input files with numerical dissipation parameters have to specify the species involved (though for now, only vpa_dissipation). The parameter vpa_dissipation_coefficient is now obsolete.

@mrhardman
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you will potentially have to do this for all the numerical dissipation input parameters (z,r,vpa,vperp), why not just duplicate the whole .toml grouping of numerical coefficients and have two different "namelists" in the toml, one for ions and one for electrons?

@johnomotani
Copy link
Collaborator

Choose a reason for hiding this comment

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

@LucasMontoya4 cool. Now try opening a 'Pull request' from your branch into electrons-jto-debug 😄

@mrhardman that would make sense, but we wanted to start small while Lucas gets used to git and Github

@LucasMontoya4
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mrhardman John is right, I am a noob

@johnomotani Should I still change all of them manually or create the namelists as @mrhardman suggests? I imagine that would take more effort and I'd possibly have two structs contained in num_diss_params, num_diss_params_ions and num_diss_params_electrons?

@johnomotani
Copy link
Collaborator

Choose a reason for hiding this comment

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

@LucasMontoya4 what you suggest with multiple structs contained in num_diss_params would probably be the neatest thing. You'd need another num_diss_params_neutrals for the neutrals. You're welcome to have a go, but feel free to give up if it starts getting too complicated (which I'm afraid it might!) and we can have a chat on Zoom tomorrow or later in the week about how best to set it all up.

@LucasMontoya4
Copy link
Collaborator

Choose a reason for hiding this comment

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

@johnomotani Got it. I'll give it a go - also, has that pull request made it through?

Please sign in to comment.