forked from mhzimmer1/SecCGMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
integrator.f90
executable file
·55 lines (40 loc) · 2.23 KB
/
integrator.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
55
!============================================================================================
! Module containing the integrators that can be used to update position (and velocities).
!============================================================================================
module integrator
use sys_param ! Contains parameters for the functions used here
use rand_num ! random number generator
implicit none
double precision :: brownian_factor1, brownian_factor2
! Put whatever variables we still need here
contains
!============================================================================================
! Subroutine to initialize some values that are used in the integrator, this saves time
! because we wont have to recalculate these every iteration.
!============================================================================================
subroutine init_integrator()
implicit none
call init_random_seed() ! rand_num.f90, initialize the seed
brownian_factor1 = dt*diffusion_constant/kBT
brownian_factor2 = sqrt(2.0*diffusion_constant*dt)
end subroutine init_integrator
!============================================================================================
! Subroutine for a Brownian integrator. It uses the parameters dt and diffusivity
! that are defined in sys_param. It also uses a random number generator that samplese a
! Gaussian distribution with zero mean and unit variance to get variable eta.
!============================================================================================
subroutine brownian_integrate(pos,force)
! Define input and output
implicit none
double precision, intent(in) :: force(freeStart:nFree,1:NDIM)
double precision, intent(inout) :: pos(freeStart:nFree,1:NDIM)
double precision :: eta
integer :: ib,coord ! used for loops
do ib = freeStart,nFree ! *** Here I move all beads, modify if some beads are not translocated
do coord = 1,NDIM
eta = gasdev()
pos(ib,coord) = pos(ib,coord) + brownian_factor1*force(ib,coord) + brownian_factor2*eta
enddo
enddo
end subroutine brownian_integrate
end module integrator