Skip to content

Commit

Permalink
Rename 'charged' to 'ion'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnomotani committed Apr 27, 2024
1 parent 56295a4 commit 32f94d6
Show file tree
Hide file tree
Showing 32 changed files with 839 additions and 835 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function makie_post_process(run_dir::Union{String,Tuple},
end
end

plot_charged_pdf_2D_at_wall(run_info_dfns; plot_prefix=plot_prefix)
plot_ion_pdf_2D_at_wall(run_info_dfns; plot_prefix=plot_prefix)
if has_neutrals
plot_neutral_pdf_2D_at_wall(run_info_dfns; plot_prefix=plot_prefix)
end
Expand Down Expand Up @@ -4302,9 +4302,9 @@ function animate_f_unnorm_vs_vpa_z(run_info; input=nothing, neutral=false, is=1,
end

"""
plot_charged_pdf_2D_at_wall(run_info; plot_prefix)
plot_ion_pdf_2D_at_wall(run_info; plot_prefix)
Make plots/animations of the charged particle distribution function at wall boundaries.
Make plots/animations of the ion distribution function at wall boundaries.
The information for the runs to plot is passed in `run_info` (as returned by
[`get_run_info`](@ref)). If `run_info` is a Tuple, comparison plots are made where line
Expand All @@ -4318,7 +4318,7 @@ will be saved with the format `plot_prefix<some_identifying_string>.pdf`. When `
is not a Tuple, `plot_prefix` is optional - plots/animations will be saved only if it is
passed.
"""
function plot_charged_pdf_2D_at_wall(run_info; plot_prefix)
function plot_ion_pdf_2D_at_wall(run_info; plot_prefix)
input = Dict_to_NamedTuple(input_dict_dfns["wall_pdf"])
if !(input.plot || input.animate || input.advection_velocity)
# nothing to do
Expand All @@ -4332,7 +4332,7 @@ function plot_charged_pdf_2D_at_wall(run_info; plot_prefix)
z_lower = 1
z_upper = run_info[1].z.n
if !all(ri.z.n == z_upper for ri run_info)
println("Cannot run plot_charged_pdf_2D_at_wall() for runs with different "
println("Cannot run plot_ion_pdf_2D_at_wall() for runs with different "
* "z-grid sizes. Got $(Tuple(ri.z.n for ri run_info))")
return nothing
end
Expand Down Expand Up @@ -5772,7 +5772,7 @@ end
field_sym_label, norm_label, plot_dims, animate_dims)
Utility function for making plots to avoid duplicated code in
[`compare_charged_pdf_symbolic_test`](@ref) and
[`compare_ion_pdf_symbolic_test`](@ref) and
[`compare_neutral_pdf_symbolic_test`](@ref).
The information for the run to analyse is passed in `run_info` (as returned by
Expand Down Expand Up @@ -5922,7 +5922,7 @@ function _MMS_pdf_plots(run_info, input, variable_name, plot_prefix, field_label
end

"""
compare_charged_pdf_symbolic_test(run_info, plot_prefix; io=nothing,
compare_ion_pdf_symbolic_test(run_info, plot_prefix; io=nothing,
input=nothing)
Compare the computed and manufactured solutions for the ion distribution function.
Expand All @@ -5943,7 +5943,7 @@ Note: when calculating error norms, data is loaded only for 1 time point and for
chunk that is the same size as computed by 1 block of the simulation at run time. This
should prevent excessive memory requirements for this function.
"""
function compare_charged_pdf_symbolic_test(run_info, plot_prefix; io=nothing,
function compare_ion_pdf_symbolic_test(run_info, plot_prefix; io=nothing,
input=nothing)

field_label = L"\tilde{f}_i"
Expand Down Expand Up @@ -6473,7 +6473,7 @@ function manufactured_solutions_analysis_dfns(run_info; plot_prefix)
println_to_stdout_and_file(io, "# ", run_info.run_name)
println_to_stdout_and_file(io, join(run_info.time, " "), " # time / (Lref/cref): ")

compare_charged_pdf_symbolic_test(run_info, plot_prefix; io=io, input=input)
compare_ion_pdf_symbolic_test(run_info, plot_prefix; io=io, input=input)

if run_info.n_neutral_species > 0
compare_neutral_pdf_symbolic_test(run_info, plot_prefix; io=io, input=input)
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/debug_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Suggested debugging strategy for race conditions is:
failure. Usually a failure should indicate where there is a missing
`begin_*_region()` call. There may be places though where synchronization is
required even though the type of loop macros used does not change (for
example when `phi` is calculated contributions from all charged species need
example when `phi` is calculated contributions from all ion species need
to be summed, resulting in an unusual pattern of array accesses); in this
case `_block_synchronize()` can be called directly.
* The function `debug_check_shared_memory()` can be inserted between
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 @@ -450,25 +450,25 @@ using IfElse
geometry_input_data::geometry_input, composition, species, nr, nvperp)
# calculate the geometry symbolically
geometry = geometry_sym(geometry_input_data,Lz,Lr,nr)
charged_species = species.charged[1]
ion_species = species.ion[1]
if composition.n_neutral_species > 0
neutral_species = species.neutral[1]
else
neutral_species = nothing
end

densi = densi_sym(Lr, Lz, r_bc, z_bc, composition, manufactured_solns_input,
charged_species)
ion_species)
upari = upari_sym(Lr, Lz, r_bc, z_bc, composition, geometry, nr, manufactured_solns_input,
charged_species)
ion_species)
ppari = ppari_sym(Lr, Lz, r_bc, z_bc, composition, manufactured_solns_input,
charged_species)
ion_species)
pperpi = pperpi_sym(Lr, Lz, r_bc, z_bc, composition, manufactured_solns_input,
charged_species, nvperp)
ion_species, nvperp)
vthi = vthi_sym(Lr, Lz, r_bc, z_bc, composition, manufactured_solns_input,
charged_species, nvperp)
ion_species, nvperp)
dfni = dfni_sym(Lr, Lz, r_bc, z_bc, composition, geometry, nr,
manufactured_solns_input, charged_species)
manufactured_solns_input, ion_species)

densn = densn_sym(Lr, Lz, r_bc, z_bc, geometry,composition,
manufactured_solns_input, neutral_species)
Expand Down Expand Up @@ -538,7 +538,7 @@ using IfElse
geometry_input_data::geometry_input, collisions,
num_diss_params, species)
geometry = geometry_sym(geometry_input_data,z_coord.L,r_coord.L,r_coord.n)
charged_species = species.charged[1]
ion_species = species.ion[1]
if composition.n_neutral_species > 0
neutral_species = species.neutral[1]
else
Expand All @@ -547,16 +547,16 @@ using IfElse

# ion manufactured solutions
densi = densi_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc, composition,
manufactured_solns_input, charged_species)
upari = upari_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc, composition, geometry, r_coord.n, manufactured_solns_input, charged_species)
manufactured_solns_input, ion_species)
upari = upari_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc, composition, geometry, r_coord.n, manufactured_solns_input, ion_species)
vthi = vthi_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc, composition, manufactured_solns_input,
charged_species, vperp_coord.n)
ion_species, vperp_coord.n)
dfni = dfni_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc, composition,
geometry, r_coord.n, manufactured_solns_input, charged_species)
geometry, r_coord.n, manufactured_solns_input, ion_species)
#dfni in vr vz vzeta coordinates
vrvzvzeta_dfni = cartesian_dfni_sym(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc,
composition, manufactured_solns_input,
charged_species)
ion_species)

# neutral manufactured solutions
densn = densn_sym(r_coord.L,z_coord.L, r_coord.bc, z_coord.bc, geometry,
Expand Down Expand Up @@ -604,7 +604,7 @@ using IfElse
# calculate the electric fields and the potential
Er, Ez, phi = electric_fields(r_coord.L, z_coord.L, r_coord.bc, z_coord.bc,
composition, r_coord.n, manufactured_solns_input,
charged_species)
ion_species)

# the adiabatic invariant (for compactness)
mu = 0.5*(vperp^2)/Bmag
Expand Down
6 changes: 3 additions & 3 deletions moment_kinetics/src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using ..coordinates: coordinate
using ..initial_conditions: vpagrid_to_dzdt
using ..interpolation: interpolate_to_grid_1d
using ..load_data: open_readonly_output_file, get_nranks, load_pdf_data, load_rank_data
using ..load_data: load_distributed_charged_pdf_slice
using ..load_data: load_distributed_ion_pdf_slice
using ..looping
using ..type_definitions: mk_int
using ..velocity_moments: integrate_over_vspace
Expand Down Expand Up @@ -140,12 +140,12 @@ function check_Chodura_condition(r, z, vperp, vpa, dens, upar, vth, composition,
end
end
if f_lower === nothing
f_lower = load_distributed_charged_pdf_slice(run_name, nblocks, t_range,
f_lower = load_distributed_ion_pdf_slice(run_name, nblocks, t_range,
composition.n_ion_species, r, z,
vperp, vpa; iz=1, ir=ir0)
end
if f_upper === nothing
f_upper = load_distributed_charged_pdf_slice(run_name, nblocks, t_range,
f_upper = load_distributed_ion_pdf_slice(run_name, nblocks, t_range,
composition.n_ion_species, r, z,
vperp, vpa; iz=z.n_global, ir=ir0)
end
Expand Down
20 changes: 10 additions & 10 deletions moment_kinetics/src/charge_exchange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function charge_exchange_collisions_1V!(f_out, f_neutral_out, fvec_in, moments,
f_out[:,1,:,:,is], fvec_in.pdf[:,1,:,:,is],
fvec_in.pdf_neutral[:,1,1,:,:,is],
fvec_in.density_neutral[:,:,is], fvec_in.upar[:,:,is],
fvec_in.uz_neutral[:,:,is], moments.charged.vth[:,:,is],
fvec_in.uz_neutral[:,:,is], moments.ion.vth[:,:,is],
moments.neutral.vth[:,:,is], moments, vpa, vz, charge_exchange_frequency,
vz_spectral, dt)
end
Expand All @@ -42,7 +42,7 @@ function charge_exchange_collisions_1V!(f_out, f_neutral_out, fvec_in, moments,
f_neutral_out[:,1,1,:,:,isn], fvec_in.pdf_neutral[:,1,1,:,:,isn],
fvec_in.pdf[:,1,:,:,isn], fvec_in.density[:,:,isn],
fvec_in.uz_neutral[:,:,isn], fvec_in.upar[:,:,isn],
moments.neutral.vth[:,:,isn], moments.charged.vth[:,:,isn], moments,
moments.neutral.vth[:,:,isn], moments.ion.vth[:,:,isn], moments,
vz, vpa, charge_exchange_frequency, vpa_spectral, dt)
end
else
Expand Down Expand Up @@ -135,7 +135,7 @@ function charge_exchange_collisions_single_species!(f_out, pdf_in, pdf_other,
end
end

function charge_exchange_collisions_3V!(f_out, f_neutral_out, f_neutral_gav_in, f_charged_vrvzvzeta_in, fvec_in, composition, vz, vr, vzeta, vpa, vperp, z, r,
function charge_exchange_collisions_3V!(f_out, f_neutral_out, f_neutral_gav_in, f_ion_vrvzvzeta_in, fvec_in, composition, vz, vr, vzeta, vpa, vperp, z, r,
charge_exchange_frequency, dt)
# This routine assumes a 3V model with:
@boundscheck vz.n == size(f_neutral_out,1) || throw(BoundsError(f_neutral_out))
Expand All @@ -144,12 +144,12 @@ function charge_exchange_collisions_3V!(f_out, f_neutral_out, f_neutral_gav_in,
@boundscheck z.n == size(f_neutral_out,4) || throw(BoundsError(f_neutral_out))
@boundscheck r.n == size(f_neutral_out,5) || throw(BoundsError(f_neutral_out))
@boundscheck composition.n_neutral_species == size(f_neutral_out,6) || throw(BoundsError(f_neutral_out))
@boundscheck vz.n == size(f_charged_vrvzvzeta_in,1) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck vr.n == size(f_charged_vrvzvzeta_in,2) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck vzeta.n == size(f_charged_vrvzvzeta_in,3) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck z.n == size(f_charged_vrvzvzeta_in,4) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck r.n == size(f_charged_vrvzvzeta_in,5) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck composition.n_neutral_species == size(f_charged_vrvzvzeta_in,6) || throw(BoundsError(f_charged_vrvzvzeta_in))
@boundscheck vz.n == size(f_ion_vrvzvzeta_in,1) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck vr.n == size(f_ion_vrvzvzeta_in,2) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck vzeta.n == size(f_ion_vrvzvzeta_in,3) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck z.n == size(f_ion_vrvzvzeta_in,4) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck r.n == size(f_ion_vrvzvzeta_in,5) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck composition.n_neutral_species == size(f_ion_vrvzvzeta_in,6) || throw(BoundsError(f_ion_vrvzvzeta_in))
@boundscheck vpa.n == size(f_out,1) || throw(BoundsError(f_out))
@boundscheck vperp.n == size(f_out,2) || throw(BoundsError(f_out))
@boundscheck z.n == size(f_out,3) || throw(BoundsError(f_out))
Expand Down Expand Up @@ -181,7 +181,7 @@ function charge_exchange_collisions_3V!(f_out, f_neutral_out, f_neutral_gav_in,
for is 1:composition.n_ion_species
f_neutral_out[ivz,ivr,ivzeta,iz,ir,isn] +=
dt*charge_exchange_frequency*(
f_charged_vrvzvzeta_in[ivz,ivr,ivzeta,iz,ir,is]*fvec_in.density_neutral[iz,ir,isn]
f_ion_vrvzvzeta_in[ivz,ivr,ivzeta,iz,ir,is]*fvec_in.density_neutral[iz,ir,isn]
- fvec_in.pdf_neutral[ivz,ivr,ivzeta,iz,ir,isn]*fvec_in.density[iz,ir,is])
end
end
Expand Down
10 changes: 5 additions & 5 deletions moment_kinetics/src/continuity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using ..calculus: derivative!
using ..looping

"""
use the continuity equation dn/dt + d(n*upar)/dz to update the density n for all charged
use the continuity equation dn/dt + d(n*upar)/dz to update the density n for all ion
species
"""
function continuity_equation!(dens_out, fvec_in, moments, composition, dt, spectral,
Expand All @@ -18,8 +18,8 @@ function continuity_equation!(dens_out, fvec_in, moments, composition, dt, spect
@loop_s_r_z is ir iz begin
# Use ddens_dz is upwinded using upar
dens_out[iz,ir,is] -=
dt*(fvec_in.upar[iz,ir,is]*moments.charged.ddens_dz_upwind[iz,ir,is] +
fvec_in.density[iz,ir,is]*moments.charged.dupar_dz[iz,ir,is])
dt*(fvec_in.upar[iz,ir,is]*moments.ion.ddens_dz_upwind[iz,ir,is] +
fvec_in.density[iz,ir,is]*moments.ion.dupar_dz[iz,ir,is])
end

# update the density to account for ionization collisions;
Expand All @@ -31,7 +31,7 @@ function continuity_equation!(dens_out, fvec_in, moments, composition, dt, spect
end

if ion_source_settings.active
source_amplitude = moments.charged.external_source_density_amplitude
source_amplitude = moments.ion.external_source_density_amplitude
@loop_s_r_z is ir iz begin
dens_out[iz,ir,is] +=
dt * source_amplitude[iz,ir]
Expand All @@ -42,7 +42,7 @@ function continuity_equation!(dens_out, fvec_in, moments, composition, dt, spect
diffusion_coefficient = num_diss_params.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.charged.d2dens_dz2[iz,ir,is]
dens_out[iz,ir,is] += dt*diffusion_coefficient*moments.ion.d2dens_dz2[iz,ir,is]
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions moment_kinetics/src/derivatives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using ..looping
Centered derivatives
df/dr group of rountines for
fields & moments -> [z,r]
dfns (charged) -> [vpa,vperp,z,r,s]
dfns (ion) -> [vpa,vperp,z,r,s]
dfns (neutrals) -> [vz,vr,vzeta,z,r,sn]
"""

Expand Down Expand Up @@ -87,7 +87,7 @@ function derivative_r!(dfdr::AbstractArray{mk_float,3}, f::AbstractArray{mk_floa
end

#df/dr
#5D version for f[vpa,vperp,z,r,s] -> charged particle dfn (species indexing taken outside this loop)
#5D version for f[vpa,vperp,z,r,s] -> ion particle dfn
function derivative_r!(dfdr::AbstractArray{mk_float,5}, f::AbstractArray{mk_float,5},
dfdr_lower_endpoints::AbstractArray{mk_float,4},
dfdr_upper_endpoints::AbstractArray{mk_float,4},
Expand Down Expand Up @@ -139,7 +139,7 @@ end
Centered derivatives
df/dz group of rountines for
fields & moments -> [z,r]
dfns (charged) -> [vpa,vperp,z,r,s]
dfns (ion) -> [vpa,vperp,z,r,s]
dfns (neutrals) -> [vz,vr,vzeta,z,r,sn]
"""

Expand Down Expand Up @@ -206,7 +206,7 @@ function derivative_z!(dfdz::AbstractArray{mk_float,3}, f::AbstractArray{mk_floa
end
end

#5D version for f[vpa,vperp,z,r,s] -> dfn charged particles
#5D version for f[vpa,vperp,z,r,s] -> dfn ions
function derivative_z!(dfdz::AbstractArray{mk_float,5}, f::AbstractArray{mk_float,5},
dfdz_lower_endpoints::AbstractArray{mk_float,4},
dfdz_upper_endpoints::AbstractArray{mk_float,4},
Expand Down Expand Up @@ -258,7 +258,7 @@ end
Upwind derivatives
df/dr group of rountines for
fields & moments -> [z,r]
dfns (charged) -> [vpa,vperp,z,r,s]
dfns (ion) -> [vpa,vperp,z,r,s]
dfns (neutrals) -> [vz,vr,vzeta,z,r,sn]
"""

Expand Down Expand Up @@ -335,7 +335,7 @@ function derivative_r!(dfdr::AbstractArray{mk_float,3}, f::AbstractArray{mk_floa
end

#df/dr
#5D version for f[vpa,vperp,z,r,s] -> charged particle dfn (species indexing taken outside this loop)
#5D version for f[vpa,vperp,z,r,s] -> ion particle dfn
function derivative_r!(dfdr::AbstractArray{mk_float,5}, f::AbstractArray{mk_float,5},
advect, adv_fac_lower_buffer::AbstractArray{mk_float,4},
adv_fac_upper_buffer::AbstractArray{mk_float,4},
Expand Down Expand Up @@ -398,7 +398,7 @@ end
Upwind derivatives
df/dz group of rountines for
fields & moments -> [z,r]
dfns (charged) -> [vpa,vperp,z,r,s]
dfns (ion) -> [vpa,vperp,z,r,s]
dfns (neutrals) -> [vz,vr,vzeta,z,r,sn]
"""

Expand Down Expand Up @@ -472,7 +472,7 @@ function derivative_z!(dfdz::AbstractArray{mk_float,3}, f::AbstractArray{mk_floa
end
end

#5D version for f[vpa,vperp,z,r,s] -> dfn charged particles
#5D version for f[vpa,vperp,z,r,s] -> dfn ion particles
function derivative_z!(dfdz::AbstractArray{mk_float,5}, f::AbstractArray{mk_float,5},
advect, adv_fac_lower_buffer::AbstractArray{mk_float,4},
adv_fac_upper_buffer::AbstractArray{mk_float,4},
Expand Down
11 changes: 6 additions & 5 deletions moment_kinetics/src/energy_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ function energy_equation!(ppar, fvec, moments, collisions, dt, spectral, composi
begin_s_r_z_region()

@loop_s_r_z is ir iz begin
ppar[iz,ir,is] += dt*(-fvec.upar[iz,ir,is]*moments.charged.dppar_dz_upwind[iz,ir,is]
- moments.charged.dqpar_dz[iz,ir,is]
- 3.0*fvec.ppar[iz,ir,is]*moments.charged.dupar_dz[iz,ir,is])
ppar[iz,ir,is] += dt*(-fvec.upar[iz,ir,is]*moments.ion.dppar_dz_upwind[iz,ir,is]
- moments.ion.dqpar_dz[iz,ir,is]
- 3.0*fvec.ppar[iz,ir,is]*moments.ion.dupar_dz[iz,ir,is])
end


if ion_source_settings.active
source_amplitude = moments.charged.external_source_pressure_amplitude
source_amplitude = moments.ion.external_source_pressure_amplitude
@loop_s_r_z is ir iz begin
ppar[iz,ir,is] += dt * source_amplitude[iz,ir]
end
Expand All @@ -32,7 +33,7 @@ function energy_equation!(ppar, fvec, moments, collisions, dt, spectral, composi
diffusion_coefficient = num_diss_params.moment_dissipation_coefficient
if diffusion_coefficient > 0.0
@loop_s_r_z is ir iz begin
ppar[iz,ir,is] += dt*diffusion_coefficient*moments.charged.d2ppar_dz2[iz,ir,is]
ppar[iz,ir,is] += dt*diffusion_coefficient*moments.ion.d2ppar_dz2[iz,ir,is]
end
end

Expand Down
Loading

0 comments on commit 32f94d6

Please sign in to comment.