-
Notifications
You must be signed in to change notification settings - Fork 0
/
thermostats_m.F90
32 lines (26 loc) · 963 Bytes
/
thermostats_m.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
module thermostats_m
use, intrinsic :: iso_fortran_env, only: dp => real64, i64 => int64
use :: math_utils_m, only: r8_normal_ab
use :: interface_m, only: databloc_params_t
implicit none
public :: andersen_thermostat
contains
subroutine andersen_thermostat(vel, parambox)
implicit none
! In/Out variables
real(kind=DP), dimension(:,:), intent(out) :: vel
type(databloc_params_t), intent(in) :: parambox
! Internal variables
integer(kind=I64) :: j_part, i_coord
real(kind=DP) :: rand_numb, sig
sig = sqrt(parambox%ref_temp)
do j_part = 1, size(vel, dim=2)
call random_number( harvest = rand_numb )
if (rand_numb < parambox%andersen_nu) then
do i_coord = 1, 3
vel(i_coord, j_part) = r8_normal_ab(a=0.0_DP, b=sig)
end do
end if
end do
end subroutine andersen_thermostat
end module thermostats_m