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
193 procedure(af_subr_prolong),
pointer,
public,
protected :: &
202 use iso_fortran_env,
only: int64
211 type(af_t),
intent(inout) :: tree
212 type(cfg_t),
intent(inout) :: cfg
213 integer,
intent(in) :: ndim
214 integer :: n, k, n_threads, ix_chemistry
215 character(len=name_len) :: prolong_method, bc_method
216 character(len=name_len) :: source_factor =
"none"
217 character(len=string_len) :: tmp_str
218 integer :: rng_int4_seed(4) = &
219 [8123, 91234, 12399, 293434]
220 integer(int64) :: rng_int8_seed(2)
223 logical :: write_source_factor = .false.
238 if (
i_1pos_ion == -1) error stop
"No positive ion species (1+) found"
241 call af_add_fc_variable(tree,
"flux_elec", ix=
flux_elec, &
242 write_binary=.false.)
249 call af_add_fc_variable(tree,
"flux_energy", ix=
flux_energy, &
250 write_binary=.false.)
301 call af_add_cc_variable(tree,
"phi", ix=
i_phi, n_copies=2)
303 call af_add_cc_variable(tree,
"rhs", ix=
i_rhs)
304 call af_add_cc_variable(tree,
"tmp", write_out=.false., &
305 write_binary=.false., ix=
i_tmp)
308 "Whether cylindrical coordinates are used (only in 2D)")
311 "Whether a dielectric is used (experimental)")
313 call af_add_cc_variable(tree,
"eps", ix=
i_eps)
314 call af_set_cc_methods(tree,
i_eps, af_bc_neumann_zero, &
315 af_gc_prolong_copy, af_prolong_zeroth)
319 "Whether to include an electrode")
321 call af_add_cc_variable(tree,
"lsf", ix=
i_lsf)
324 bc_method =
"neumann_zero"
325 call cfg_add_get(cfg,
"species_boundary_condition", &
327 "Boundary condition for the plasma species")
328 select case (bc_method)
329 case (
"neumann_zero")
331 case (
"dirichlet_zero")
334 print *,
"Unknown boundary condition: ", trim(bc_method)
335 print *,
"Try neumann_zero or dirichlet_zero"
340 "Whether to compute the deposited power density")
347 "Whether the length of the streamer is used to end the simulation")
349 "Streamer length at which the simulation will end.")
350 call cfg_add_get(cfg,
"initial_streamer_pos_steps_wait", &
352 "Number of simulation steps to wait before initializing "&
353 "the starting position of the streamer")
355 call cfg_add_get(cfg,
"abort_axisymmetric_if_branching", &
357 "Abort axisymmetric simulations if there is branching")
360 "The desired endtime (s) of the simulation")
362 "The number of grid cells per coordinate in a box")
364 "The size of the coarse grid")
366 "The length of the domain (m)")
368 "The origin of the domain (m)")
370 "Whether the domain is periodic (per dimension)")
373 "Whether to limit plasma reactions to a certain region")
375 "Limit plasma reactions to coordinates between rmin and rmax")
377 "Limit plasma reactions to coordinates between rmin and rmax")
387 if (tmp > 1.001_dp)
then
388 print *,
"!!! Warning: using non-square grid cells"
389 write(*,
"(A,F12.4)")
" !!! Maximal aspect ratio:", tmp
393 "Number of V-cycles to perform per time step")
394 call cfg_add_get(cfg,
"multigrid_max_rel_residual", &
396 "Stop multigrid when residual is smaller than this factor times max(|rhs|)")
398 call cfg_add_get(cfg,
"current_update_per_steps", &
400 "Per how many iterations the electric current is computed")
402 prolong_method =
"limit"
403 call cfg_add_get(cfg,
"prolong_density", prolong_method, &
404 "Density prolongation method (limit, linear, linear_cons, sparse)")
405 select case (prolong_method)
417 error stop
"Unknown prolong_density method"
421 "Enable flux limiting, but prevent field from exceeding this value")
423 error stop
"fixes%drt_max_field not yet implemented"
427 call cfg_add_get(cfg,
"fixes%source_factor", source_factor, &
428 "Use source factor to prevent unphysical effects due to diffusion")
429 call cfg_add_get(cfg,
"fixes%write_source_factor", write_source_factor, &
430 "Whether to write the source factor to the output")
431 call cfg_add_get(cfg,
"fixes%source_min_electrons_per_cell", &
433 "Minimum number of electrons per cell to include source terms")
435 select case (source_factor)
441 print *,
"Options fixes%source_factor: none, flux"
442 error stop
"Unknown fixes%source_factor"
446 call af_add_cc_variable(tree,
"srcfac", ix=
i_srcfac)
449 call cfg_add_get(cfg,
"rng_seed", rng_int4_seed, &
450 "Seed for random numbers; if all zero, generate randomly")
452 if (all(rng_int4_seed == 0))
then
453 rng_int4_seed = get_random_seed()
454 print *,
"RNG seed: ", rng_int4_seed
457 write(tmp_str, *)
"rng_seed = ", rng_int4_seed
458 call cfg_update_from_line(cfg, tmp_str)
461 rng_int8_seed = transfer(rng_int4_seed, rng_int8_seed)
462 call st_rng%set_seed(rng_int8_seed)
463 n_threads = af_get_max_threads()
477 function get_random_seed()
result(seed)
478 use iso_fortran_env,
only: int64
482 integer(int64) :: time
488 call system_clock(time)
491 call random_number(rr)
492 seed(i) = ieor(int(time), int(huge(1) * rr))
494 end function get_random_seed
501 subroutine bc_species_dirichlet_zero(box, nb, iv, coords, bc_val, bc_type)
502 type(box_t),
intent(in) :: box
503 integer,
intent(in) :: nb
504 integer,
intent(in) :: iv
505 real(dp),
intent(in) :: coords(ndim, box%n_cell**(ndim-1))
506 real(dp),
intent(out) :: bc_val(box%n_cell**(ndim-1))
507 integer,
intent(out) :: bc_type
509 if (af_neighb_dim(nb) == ndim)
then
510 bc_type = af_bc_dirichlet_copy
513 bc_type = af_bc_neumann
516 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.
logical, public, protected st_abort_axisymmetric_if_branching
Abort axisymmetric simulations if there is branching.
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.