-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdt.f90
54 lines (33 loc) · 994 Bytes
/
dt.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
! dt module
!
! compute the timestep as the minimum dx / (|U| + cs)
module dt_module
use datatypes_module
use grid_module
use params_module
use eos_module
use variables_module
implicit none
private
public :: compute_dt
contains
subroutine compute_dt(U, n, dt)
type(gridvar_t), intent(in ) :: U
integer, intent(inout) :: n
real (kind=dp_t), intent(inout) :: dt
integer :: i
real (kind=dp_t) :: cs, p, e, rho
dt = huge(0.0_dp_t)
do i = U%grid%lo, U%grid%hi
! compute cs (soundspeed)
e = (U%data(i,iuener) - 0.5_dp_t*U%data(i,iumomx)**2/U%data(i,iudens)) / &
U%data(i,iudens)
rho = U%data(i,iudens)
call eos(eos_input_e, p, e, rho)
cs = sqrt(gamma*p/U%data(i,iudens))
dt = min(dt, U%grid%dx/(abs(U%data(i,iumomx)/U%data(i,iudens)) + cs))
enddo
dt = cfl*dt
if (n == 0) dt = init_shrink*dt
end subroutine compute_dt
end module dt_module