7#include "../afivo/src/cpp_macros.h"
18 integer,
public,
protected ::
i_phi = -1
32 integer,
public,
protected ::
i_rhs = -1
34 integer,
public,
protected ::
i_tmp = -1
36 integer,
public,
protected ::
i_eps = -1
38 integer,
public,
protected ::
i_lsf = -1
83 procedure(af_subr_bc),
public,
protected,
pointer :: &
87 type(mg_t),
public ::
mg
190 procedure(af_subr_prolong),
pointer,
public,
protected :: &
199 use iso_fortran_env,
only: int64
208 type(af_t),
intent(inout) :: tree
209 type(cfg_t),
intent(inout) :: cfg
210 integer,
intent(in) :: ndim
211 integer :: n, k, n_threads, ix_chemistry
212 character(len=name_len) :: prolong_method, bc_method
213 character(len=name_len) :: source_factor =
"none"
214 character(len=string_len) :: tmp_str
215 integer :: rng_int4_seed(4) = &
216 [8123, 91234, 12399, 293434]
217 integer(int64) :: rng_int8_seed(2)
220 logical :: write_source_factor = .false.
235 if (
i_1pos_ion == -1) error stop
"No positive ion species (1+) found"
238 call af_add_fc_variable(tree,
"flux_elec", ix=
flux_elec, &
239 write_binary=.false.)
246 call af_add_fc_variable(tree,
"flux_energy", ix=
flux_energy, &
247 write_binary=.false.)
298 call af_add_cc_variable(tree,
"phi", ix=
i_phi, n_copies=2)
300 call af_add_cc_variable(tree,
"rhs", ix=
i_rhs)
301 call af_add_cc_variable(tree,
"tmp", write_out=.false., &
302 write_binary=.false., ix=
i_tmp)
305 "Whether cylindrical coordinates are used (only in 2D)")
308 "Whether a dielectric is used (experimental)")
310 call af_add_cc_variable(tree,
"eps", ix=
i_eps)
311 call af_set_cc_methods(tree,
i_eps, af_bc_neumann_zero, &
312 af_gc_prolong_copy, af_prolong_zeroth)
316 "Whether to include an electrode")
318 call af_add_cc_variable(tree,
"lsf", ix=
i_lsf)
321 bc_method =
"neumann_zero"
322 call cfg_add_get(cfg,
"species_boundary_condition", &
324 "Boundary condition for the plasma species")
325 select case (bc_method)
326 case (
"neumann_zero")
328 case (
"dirichlet_zero")
331 print *,
"Unknown boundary condition: ", trim(bc_method)
332 print *,
"Try neumann_zero or dirichlet_zero"
337 "Whether to compute the deposited power density")
344 "Whether the length of the streamer is used to end the simulation")
346 "Streamer length at which the simulation will end.")
347 call cfg_add_get(cfg,
"initial_streamer_pos_steps_wait", &
349 "Number of simulation steps to wait before initializing "&
350 "the starting position of the streamer")
353 "The desired endtime (s) of the simulation")
355 "The number of grid cells per coordinate in a box")
357 "The size of the coarse grid")
359 "The length of the domain (m)")
361 "The origin of the domain (m)")
363 "Whether the domain is periodic (per dimension)")
366 "Whether to limit plasma reactions to a certain region")
368 "Limit plasma reactions to coordinates between rmin and rmax")
370 "Limit plasma reactions to coordinates between rmin and rmax")
380 if (tmp > 1.001_dp)
then
381 print *,
"!!! Warning: using non-square grid cells"
382 write(*,
"(A,F12.4)")
" !!! Maximal aspect ratio:", tmp
386 "Number of V-cycles to perform per time step")
387 call cfg_add_get(cfg,
"multigrid_max_rel_residual", &
389 "Stop multigrid when residual is smaller than this factor times max(|rhs|)")
391 call cfg_add_get(cfg,
"current_update_per_steps", &
393 "Per how many iterations the electric current is computed")
395 prolong_method =
"limit"
396 call cfg_add_get(cfg,
"prolong_density", prolong_method, &
397 "Density prolongation method (limit, linear, linear_cons, sparse)")
398 select case (prolong_method)
410 error stop
"Unknown prolong_density method"
414 "Enable flux limiting, but prevent field from exceeding this value")
416 error stop
"fixes%drt_max_field not yet implemented"
420 call cfg_add_get(cfg,
"fixes%source_factor", source_factor, &
421 "Use source factor to prevent unphysical effects due to diffusion")
422 call cfg_add_get(cfg,
"fixes%write_source_factor", write_source_factor, &
423 "Whether to write the source factor to the output")
424 call cfg_add_get(cfg,
"fixes%source_min_electrons_per_cell", &
426 "Minimum number of electrons per cell to include source terms")
428 select case (source_factor)
434 print *,
"Options fixes%source_factor: none, flux"
435 error stop
"Unknown fixes%source_factor"
439 call af_add_cc_variable(tree,
"srcfac", ix=
i_srcfac)
442 call cfg_add_get(cfg,
"rng_seed", rng_int4_seed, &
443 "Seed for random numbers; if all zero, generate randomly")
445 if (all(rng_int4_seed == 0))
then
446 rng_int4_seed = get_random_seed()
447 print *,
"RNG seed: ", rng_int4_seed
450 write(tmp_str, *)
"rng_seed = ", rng_int4_seed
451 call cfg_update_from_line(cfg, tmp_str)
454 rng_int8_seed = transfer(rng_int4_seed, rng_int8_seed)
455 call st_rng%set_seed(rng_int8_seed)
456 n_threads = af_get_max_threads()
470 function get_random_seed()
result(seed)
471 use iso_fortran_env,
only: int64
475 integer(int64) :: time
481 call system_clock(time)
484 call random_number(rr)
485 seed(i) = ieor(int(time), int(huge(1) * rr))
487 end function get_random_seed
494 subroutine bc_species_dirichlet_zero(box, nb, iv, coords, bc_val, bc_type)
495 type(box_t),
intent(in) :: box
496 integer,
intent(in) :: nb
497 integer,
intent(in) :: iv
498 real(dp),
intent(in) :: coords(ndim, box%n_cell**(ndim-1))
499 real(dp),
intent(out) :: bc_val(box%n_cell**(ndim-1))
500 integer,
intent(out) :: bc_type
502 if (af_neighb_dim(nb) == ndim)
then
503 bc_type = af_bc_dirichlet_copy
506 bc_type = af_bc_neumann
509 end subroutine bc_species_dirichlet_zero
Module for handling chemical reactions.
integer, dimension(max_num_species), public, protected species_charge
Charge of the species.
integer, dimension(max_num_species), public, protected species_itree
species_itree(n) holds the index of species n in the tree (cell-centered variables)
integer, public, protected n_species
Number of species present.
elemental integer function, public species_index(name)
Find index of a species, return -1 if not found.
integer, public, protected n_gas_species
Number of gas species present.
integer, public, protected n_reactions
Number of reactions present.
Module to set the time step.
Module that stores parameters related to the gas.
Module to set the type of model.
logical, public, protected model_has_energy_equation
Whether the model has an energy equation.
This module contains several pre-defined variables like:
logical, public, protected st_cylindrical
Whether cylindrical coordinates are used.
real(dp), public wc_time_refine
procedure(af_subr_prolong), pointer, public, protected st_prolongation_method
Method used to prolong (interpolate) densities.
integer, public, protected flux_num_electron_vars
Number of electron flux variables.
integer, dimension(:), allocatable, public, protected flux_species_charge
List of the charges of the flux species.
integer, dimension(:), allocatable, public, protected flux_species_charge_sign
List of the signs of the charges of the flux species (+- 1)
real(dp), public wc_time_output
integer, parameter, public source_factor_none
integer, public, protected i_eps
Index can be set to include a dielectric.
real(dp), dimension(:), allocatable, public st_global_rates
Global sum of reaction rates.
integer, public, protected current_update_per_steps
Per how many iterations the electric current is computed.
integer, public, protected st_initial_streamer_pos_steps_wait
Wait n steps before initializing streamer begin position.
real(dp), public wc_time_field
integer, public, protected i_srcfac
Index of correction factor for source terms.
real(dp), public st_global_jdote_current
Electric current through electrodes due to J.E.
integer, dimension(:), allocatable, public, protected flux_pos_ion
List of positive ion fluxes (useful for secondary emission)
integer, dimension(:), allocatable, public, protected flux_variables
List of all flux variables (face-centered index)
integer, public, protected st_source_factor
Use source factor to prevent unphysical effects due to diffusion.
real(dp), public global_dt
Global time step.
logical, public, protected st_drt_limit_flux
Avoid dielectric relaxation time step constraint by limiting flux.
real(dp), public, protected st_drt_max_field
Ensure that flux limiting does not lead to fields higher than this.
type(mg_t), public mg
Multigrid option structure.
integer, dimension(ndim), public, protected st_coarse_grid_size
Size of the coarse grid.
subroutine, public st_initialize(tree, cfg, ndim)
Create the configuration file with default values.
integer, public, protected st_box_size
The size of the boxes that we use to construct our mesh.
real(dp), dimension(:, :), allocatable, public st_current_jdote
Current sum of J.E per thread.
logical, dimension(ndim), public, protected st_periodic
Whether the domain is periodic (per dimension)
integer, public, protected i_electron_energy
Index of electron energy density.
real(dp), public global_time
Global time.
procedure(af_subr_bc), pointer, public, protected bc_species
Boundary condition for the plasma species.
logical, public, protected st_use_electrode
Whether to include an electrode.
integer, dimension(:), allocatable, public, protected flux_species
List of all flux species (cell-centered index)
real(dp), public wc_time_source
integer, public, protected ix_electron
Index of electron density (in species list)
integer, public, protected flux_energy
Index of electron energy flux.
integer, public, protected i_lsf
Index can be set to include an electrode.
logical, public, protected st_use_dielectric
Whether a dielectric is used.
integer, public, protected flux_elec
Index of electron flux.
integer, public, protected i_electron
Index of electron density.
integer, public, protected electric_fld
Index of electric field vector.
integer, public, protected i_rhs
Index of source term Poisson.
integer, public, protected i_1pos_ion
Index of first positive ion species.
integer, public, protected i_phi
Index of electrical potential.
real(dp), public wc_time_flux
real(dp), public st_global_jdote
Global sum of J.E.
real(dp), dimension(ndim), public, protected st_plasma_region_rmin
Limit plasma reactions to coordinates between rmin and rmax.
integer, public, protected st_multigrid_num_vcycles
Number of V-cycles to perform per time step.
real(dp), dimension(ndim), public, protected st_plasma_region_rmax
Limit plasma reactions to coordinates between rmin and rmax.
integer, public, protected i_electric_fld
Index of electric field norm.
real(dp), public wc_time_copy_state
real(dp), public, protected st_end_streamer_length
Streamer length at which the simulation will stop.
real(dp), dimension(ndim), public, protected st_domain_len
Domain length per dimension.
integer, public, protected ix_1pos_ion
Index of first positive ion (in species list)
real(dp), public, protected st_end_time
End time of the simulation.
real(dp), dimension(ndim), public, protected st_domain_origin
Origin of domain.
type(rng_t), public st_rng
Random number generator.
integer, dimension(:), allocatable, public, protected all_densities
Index of all densities that evolve in time.
integer, public, protected flux_num_species
Number of flux variables.
integer, public, protected i_power_density
Index of deposited power density.
real(dp), public wc_time_photoi
logical, public, protected st_use_end_streamer_length
Whether streamer length is used as a simulation stopping.
type(prng_t), public st_prng
Parallel random number generator.
integer, public, protected i_tmp
Index of temporary variable.
logical, public, protected compute_power_density
Include deposited power density in output.
logical, public, protected st_plasma_region_enabled
Whether to limit plasma reactions to a certain region.
real(dp), dimension(:, :), allocatable, public st_current_rates
Current sum of reaction rates per thread.
real(dp), public st_global_displ_current
Electric current through electrodes due to displacement current.
integer, parameter, public source_factor_original_flux
real(dp), public, protected st_source_min_electrons_per_cell
Minimum number of electrons per cell to include source terms.
real(dp), public, protected st_multigrid_max_rel_residual
integer, parameter, public source_factor_flux
Module that provides routines for reading in arbritrary transport data.
type(ion_transport_t), public transport_data_ions
Module that contains physical and numerical constants.