Skip to content

Commit

Permalink
[em_fields] section in input
Browse files Browse the repository at this point in the history
Create a section to contain the `force_Er_zero_at_wall` option (and
others in future).

Remove the unused `drive_input` structs.
  • Loading branch information
johnomotani committed Sep 8, 2024
1 parent d2f58f8 commit 002113f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 42 deletions.
5 changes: 3 additions & 2 deletions moment_kinetics/src/em_fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ using MPI

"""
"""
function setup_em_fields(nvperp, nz, nr, n_ion_species, force_phi, drive_amplitude, drive_frequency, force_Er_zero)
function setup_em_fields(nvperp, nz, nr, n_ion_species, em_input)
phi = allocate_shared_float(nz,nr)
phi0 = allocate_shared_float(nz,nr)
Er = allocate_shared_float(nz,nr)
Ez = allocate_shared_float(nz,nr)
gphi = allocate_shared_float(nvperp,nz,nr,n_ion_species)
gEr = allocate_shared_float(nvperp,nz,nr,n_ion_species)
gEz = allocate_shared_float(nvperp,nz,nr,n_ion_species)
return em_fields_struct(phi, phi0, Er, Ez, gphi, gEr, gEz, force_phi, drive_amplitude, drive_frequency, force_Er_zero)
return em_fields_struct(phi, phi0, Er, Ez, gphi, gEr, gEz,
em_input.force_Er_zero_at_wall)
end

"""
Expand Down
25 changes: 0 additions & 25 deletions moment_kinetics/src/input_structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export initial_condition_input, initial_condition_input_mutable
export spatial_initial_condition_input, velocity_initial_condition_input
export ion_species_parameters, neutral_species_parameters, species_parameters_mutable
export species_composition
export drive_input, drive_input_mutable
export collisions_input, krook_collisions_input, fkpl_collisions_input
export io_input
export pp_input
Expand Down Expand Up @@ -330,30 +329,6 @@ Base.@kwdef struct species_composition
neutral::Vector{neutral_species_parameters}
end

"""
"""
mutable struct drive_input_mutable
# if drive.phi = true, include external electrostatic potential
force_phi::Bool
# if external field included, it is of the form
# phi(z,t=0)*amplitude*sinpi(t*frequency)
amplitude::mk_float
frequency::mk_float
end

"""
"""
struct drive_input
# if drive.phi = true, include external electrostatic potential
force_phi::Bool
# if external field included, it is of the form
# phi(z,t=0)*amplitude*sinpi(t*frequency)
amplitude::mk_float
frequency::mk_float
# if true, forces Er = 0.0 at wall plates
force_Er_zero_at_wall::Bool
end

"""
Structs set up for the collision operators so far in use. These will each
be contained in the main collisions_input struct below, as substructs.
Expand Down
5 changes: 2 additions & 3 deletions moment_kinetics/src/moment_kinetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function setup_moment_kinetics(input_dict::AbstractDict;
io_input, evolve_moments, t_input, z, z_spectral, r, r_spectral, vpa, vpa_spectral,
vperp, vperp_spectral, gyrophase, gyrophase_spectral, vz, vz_spectral, vr,
vr_spectral, vzeta, vzeta_spectral, composition, species, collisions, geometry,
drive_input, external_source_settings, num_diss_params,
em_input, external_source_settings, num_diss_params,
manufactured_solns_input = input

# Create loop range variables for shared-memory-parallel loops
Expand All @@ -258,8 +258,7 @@ function setup_moment_kinetics(input_dict::AbstractDict;
# create the "fields" structure that contains arrays
# for the electrostatic potential phi and the electromagnetic fields
fields = setup_em_fields(vperp.n, z.n, r.n, composition.n_ion_species,
drive_input.force_phi, drive_input.amplitude,
drive_input.frequency, drive_input.force_Er_zero_at_wall)
em_input)

# Allocate arrays and create the pdf and moments structs
pdf, moments, boundary_distributions =
Expand Down
20 changes: 8 additions & 12 deletions moment_kinetics/src/moment_kinetics_input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function mk_input(scan_input=OptionsDict(); save_inputs_to_txt=false, ignore_MPI
n_ion_species = composition.n_ion_species
n_neutral_species = composition.n_neutral_species

drive, evolve_moments = load_defaults()
evolve_moments = load_defaults()

# this is the prefix for all output files associated with this run
run_name = get(scan_input, "run_name", "wallBC")
Expand Down Expand Up @@ -351,8 +351,11 @@ function mk_input(scan_input=OptionsDict(); save_inputs_to_txt=false, ignore_MPI
_block_synchronize()
end

force_Er_zero = get(scan_input, "force_Er_zero_at_wall", false)
drive_immutable = drive_input(drive.force_phi, drive.amplitude, drive.frequency, force_Er_zero)
em_fields_settings = set_defaults_and_check_section!(
scan_input, "em_fields";
force_Er_zero_at_wall=false,
)
em_input = Dict_to_NamedTuple(em_fields_settings)

# inputs for file I/O
io_settings = set_defaults_and_check_section!(
Expand Down Expand Up @@ -466,7 +469,7 @@ function mk_input(scan_input=OptionsDict(); save_inputs_to_txt=false, ignore_MPI
r_spectral, vpa, vpa_spectral, vperp, vperp_spectral, gyrophase,
gyrophase_spectral, vz, vz_spectral, vr, vr_spectral, vzeta,
vzeta_spectral, composition, species_immutable, collisions, geometry,
drive_immutable, external_source_settings, num_diss_params,
em_input, external_source_settings, num_diss_params,
manufactured_solns_input)
println(io, "\nAll inputs returned from mk_input():")
println(io, all_inputs)
Expand All @@ -487,14 +490,7 @@ function load_defaults()
evolve_moments = evolve_moments_options(evolve_density, evolve_parallel_flow, evolve_parallel_pressure, conservation)#advective_form)
#################### parameters related to the z grid ######################

# if drive_phi = true, include external electrostatic potential of form
# phi(z,t=0)*drive_amplitude*sinpi(time*drive_frequency)
drive_phi = false
drive_amplitude = 1.0
drive_frequency = 1.0
drive = drive_input_mutable(drive_phi, drive_amplitude, drive_frequency)

return drive, evolve_moments
return evolve_moments
end

"""
Expand Down

0 comments on commit 002113f

Please sign in to comment.