afivo-streamer 1.1
1D/2D/3D streamer simulations with AMR
Loading...
Searching...
No Matches
m_dt.f90
Go to the documentation of this file.
1!> Module to set the time step
2module m_dt
3 use m_af_all
4 use m_types
5
6 implicit none
7 private
8
9 ! Number of time step restrictions
10 integer, parameter, public :: dt_num_cond = 4
11
12 ! Array of time step restrictions per thread
13 real(dp), public :: dt_limits(dt_num_cond)
14
15 ! Index of CFL condition
16 integer, parameter, public :: dt_ix_cfl = 1
17
18 ! Index of dielectric relaxation time step condition
19 integer, parameter, public :: dt_ix_drt = 2
20
21 ! Index of reaction rate time step condition
22 integer, parameter, public :: dt_ix_rates = 3
23
24 ! Index of other time step restrictions
25 integer, parameter, public :: dt_ix_other = 4
26
27 ! Safety factor for the time step
28 real(dp), public, protected :: dt_safety_factor = 0.9_dp
29
30 !> CFL number to use
31 real(dp), public, protected :: dt_cfl_number = undefined_real
32
33 !> If > 0, a density to control the accuracy of the chemistry time step
34 real(dp), public, protected :: dt_chemistry_nmin = -1.0_dp
35
36 !> Limit dt to prevent negative densities due to loss reactions
37 logical, public, protected :: dt_chemistry_limit_loss = .true.
38
39 ! Maximum allowed time step
40 real(dp), public, protected :: dt_max = 1.0e-11_dp
41
42 ! Minimum allowed time step
43 real(dp), public, protected :: dt_min = 1.0e-14_dp
44
45 !> Maximal relative increase dt for the next iteration
46 real(dp), public, protected :: dt_max_growth_factor = 2.0_dp
47
48 !> Which time integrator is used
49 integer, public, protected :: time_integrator
50
51 public :: dt_initialize
52
53contains
54
55 !> Initialize the time step module
56 subroutine dt_initialize(cfg)
57 use m_config
58 type(cfg_t), intent(inout) :: cfg
59 real(dp) :: default_cfl_number = 0.5_dp
60 character(len=name_len) :: integrator
61
62 !> [relevant_parameters]
63 call cfg_add_get(cfg, "dt_max", dt_max, &
64 "The maximum timestep (s)")
65 call cfg_add_get(cfg, "dt_min", dt_min, &
66 "The minimum timestep (s)")
67 call cfg_add_get(cfg, "dt_safety_factor", dt_safety_factor, &
68 "Safety factor for the time step")
69 call cfg_add_get(cfg, "dt_cfl_number", dt_cfl_number, &
70 "CFL number to use")
71 call cfg_add_get(cfg, "dt_chemistry_nmin", dt_chemistry_nmin, &
72 "If > 0, a density to control the accuracy of the chemistry time step")
73 call cfg_add_get(cfg, "dt_chemistry_limit_loss", dt_chemistry_limit_loss, &
74 "Limit dt to prevent negative densities due to loss reactions")
75 !> [relevant_parameters]
76
77 call cfg_add_get(cfg, "dt_max_growth_factor", dt_max_growth_factor, &
78 "Maximal relative increase dt for the next iteration")
79
80 integrator = "heuns_method"
81 call cfg_add_get(cfg, "time_integrator", integrator, &
82 "Time integrator (use arbitrary value to see options)")
83
84 do time_integrator = 1, af_num_integrators
85 if (integrator == af_integrator_names(time_integrator)) exit
86 end do
87
88 if (time_integrator == af_num_integrators+1) then
89 print *, "Use one of the following time integrators:"
90 do time_integrator = 1, af_num_integrators
91 print *, trim(af_integrator_names(time_integrator))
92 end do
93 error stop "Unknown time integrator"
94 end if
95
96 ! Set CFL number automatically if not set
97 if (dt_cfl_number <= undefined_real) dt_cfl_number = default_cfl_number
98
99 end subroutine dt_initialize
100
101end module m_dt
Module to set the time step.
Definition m_dt.f90:2
integer, public, protected time_integrator
Which time integrator is used.
Definition m_dt.f90:49
real(dp), dimension(dt_num_cond), public dt_limits
Definition m_dt.f90:13
integer, parameter, public dt_num_cond
Definition m_dt.f90:10
real(dp), public, protected dt_max
Definition m_dt.f90:40
real(dp), public, protected dt_safety_factor
Definition m_dt.f90:28
integer, parameter, public dt_ix_cfl
Definition m_dt.f90:16
subroutine, public dt_initialize(cfg)
Initialize the time step module.
Definition m_dt.f90:57
real(dp), public, protected dt_chemistry_nmin
If > 0, a density to control the accuracy of the chemistry time step.
Definition m_dt.f90:34
real(dp), public, protected dt_min
Definition m_dt.f90:43
real(dp), public, protected dt_max_growth_factor
Maximal relative increase dt for the next iteration.
Definition m_dt.f90:46
integer, parameter, public dt_ix_rates
Definition m_dt.f90:22
logical, public, protected dt_chemistry_limit_loss
Limit dt to prevent negative densities due to loss reactions.
Definition m_dt.f90:37
integer, parameter, public dt_ix_drt
Definition m_dt.f90:19
real(dp), public, protected dt_cfl_number
CFL number to use.
Definition m_dt.f90:31
integer, parameter, public dt_ix_other
Definition m_dt.f90:25
Module with basic types.
Definition m_types.f90:2
real(dp), parameter undefined_real
Undefined number.
Definition m_types.f90:13