11 integer :: iigrid, igrid, ncycle, ncycle2, ifile, idim
12 double precision :: dtnew, qdtnew, dtmin_mype, factor, dx^D, dxmin^D
14 double precision :: dtmax, dxmin, cmax_mype
15 double precision :: a2max_mype(ndim), tco_mype, tco_global, Tmax_mype, T_peak
16 double precision :: trac_alfa, trac_dmax, trac_tau
18 integer,
parameter :: niter_print = 2000
27 do iigrid=1,igridstail_active; igrid=igrids_active(iigrid);
35 dtnew=min(dtnew,qdtnew)
38 dtnew=min(dtnew,qdtnew)
43 dtnew = min(dtnew,qdtnew)
44 dtmin_mype = min(dtmin_mype,dtnew)
51 if (dtmin_mype<
dtmin)
then
52 write(
unitterm,*)
"Error: Time step too small!", dtmin_mype
60 dtmin_mype=dtmin_mype*factor
76 call mpi_allreduce(dtmin_mype,
dt,1,mpi_double_precision,mpi_min, &
87 if(dtmax > smalldouble)
then
108 if(
mype==0 .and. mod(
it-1, niter_print) .eq. 0)
then
109 write(*,*)
'Max number of STS cycles exceeded, reducing dt to',
dt
114 if(
mype==0 .and. mod(
it-1, niter_print) .eq. 0)
then
115 write(*,*)
'Max number of STS cycles exceeded, reducing dt to',
dt
132 call mpi_allreduce(tmax_mype,t_peak,1,mpi_double_precision,&
143 trac_alfa=trac_dmax**(
dt/trac_tau)
146 call mpi_allreduce(tco_mype,tco_global,1,mpi_double_precision,&
156 call tracl(.false.,t_peak)
159 call tracb(.false.,t_peak)
162 call tracl(.true.,t_peak)
165 call tracb(.true.,t_peak)
167 call mpistop(
"undefined TRAC method type")
178 integer,
intent(in) :: ixI^L, ixO^L
179 double precision,
intent(in) :: x(ixI^S,1:ndim)
180 double precision,
intent(in) :: dx^D
181 double precision,
intent(inout) :: w(ixI^S,1:nw), dtnew, cmax_mype, a2max_mype(ndim)
184 double precision :: courantmax, dxinv(1:ndim), courantmaxtot, courantmaxtots
185 double precision :: cmax(ixI^S), cmaxtot(ixO^S)
186 double precision :: a2max(ndim),tco_local,Tmax_local
197 a2max_mype(idims) = max(a2max_mype(idims),a2max(idims))
202 {^ifoned tco_mype=max(tco_mype,tco_local) }
203 tmax_mype=max(tmax_mype,tmax_local)
232 ^d&dxinv(^d)=one/dx^d;
236 cmaxtot(ixo^s)=cmaxtot(ixo^s)+cmax(ixo^s)*dxinv(idims)
242 cmaxtot(ixo^s)=cmaxtot(ixo^s)+cmax(ixo^s)/
block%ds(ixo^s,idims)
246 courantmaxtots=max(courantmaxtots,maxval(cmaxtot(ixo^s)))
247 if (courantmaxtots>smalldouble) dtnew=min(dtnew,
courantpar/courantmaxtots)
250 ^d&dxinv(^d)=one/dx^d;
254 courantmax=max(courantmax,maxval(cmax(ixo^s)*dxinv(idims)))
255 courantmaxtot=courantmaxtot+courantmax
261 courantmax=max(courantmax,maxval(cmax(ixo^s)/
block%ds(ixo^s,idims)))
262 courantmaxtot=courantmaxtot+courantmax
266 if (courantmaxtot>smalldouble) dtnew=min(dtnew,
courantpar/courantmaxtot)
269 ^d&dxinv(^d)=one/dx^d;
273 courantmax=max(courantmax,maxval(cmax(ixo^s)*dxinv(idims)))
279 courantmax=max(courantmax,maxval(cmax(ixo^s)/
block%ds(ixo^s,idims)))
283 if (courantmax>smalldouble) dtnew=min(dtnew,
courantpar/courantmax)
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
This module contains definitions of global parameters and variables and some generic functions/subrou...
type(state), pointer block
Block pointer for using one block and its previous state.
double precision unit_time
Physical scaling factor for time.
double precision global_time
The global simulation time.
double precision time_max
End time for the simulation.
integer it
Number of time steps taken.
integer it_init
initial iteration count
integer, parameter type_maxsum
integer switchers for type courant
double precision cmax_global
global fastest wave speed needed in fd scheme and glm method
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
double precision dtpar
If dtpar is positive, it sets the timestep dt, otherwise courantpar is used to limit the time step ba...
logical need_global_a2max
global value for schmid scheme
double precision courantpar
The Courant (CFL) number used for the simulation.
integer ixm
the mesh range (within a block with ghost cells)
integer ierrmpi
A global MPI error return code.
integer slowsteps
If > 1, then in the first slowsteps-1 time steps dt is reduced by a factor .
integer type_courant
How to compute the CFL-limited time step.
integer, parameter unitterm
Unit for standard output.
double precision, dimension(nfile) dtsave
Repeatedly save output of type N when dtsave(N) simulation time has passed.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision unit_temperature
Physical scaling factor for temperature.
logical final_dt_reduction
If true, allow final dt reduction for matching time_max on output.
integer, parameter type_summax
logical phys_trac
Use TRAC (Johnston 2019 ApJL, 873, L22) for MHD or 1D HD.
double precision, dimension(nsavehi, nfile) tsave
Save output of type N on times tsave(:, N)
logical need_global_cmax
need global maximal wave speed
logical crash
Save a snapshot before crash a run met unphysical values.
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
double precision dtmin
Stop the simulation when the time step becomes smaller than this value.
integer, parameter nfile
Number of output methods.
logical final_dt_exit
Force timeloop exit when final dt < dtmin.
integer, parameter type_minimum
double precision, dimension(ndim) dxlevel
integer, dimension(nfile) isavet
double precision, dimension(ndim) a2max_global
global largest a2 for schmid scheme
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_get_a2max), pointer phys_get_a2max
procedure(sub_get_dt), pointer phys_get_dt
procedure(sub_get_tcutoff), pointer phys_get_tcutoff
procedure(sub_get_cmax), pointer phys_get_cmax
Generic supertimestepping method 1) in amrvac.par in sts_list set the following parameters which have...
integer, public sourcetype_sts
pure logical function, public is_sts_initialized()
logical function, public set_dt_sts_ncycles(my_dt)
This sets the explicit dt and calculates the number of cycles for each of the terms implemented with ...
integer, parameter, public sourcetype_sts_split
subroutine tracb(mask, T_peak)
subroutine trac_simple(tco_global, trac_alfa, T_peak)
subroutine tracl(mask, T_peak)
Module with all the methods that users can customize in AMRVAC.
procedure(get_dt), pointer usr_get_dt
subroutine setdt()
setdt - set dt for all levels between levmin and levmax. dtpar>0 --> use fixed dtpar for all level dt...
subroutine getdt_courant(w, ixIL, ixOL, dtnew, dxD, x, cmax_mype, a2max_mype)
compute CFL limited dt (for variable time stepping)