-
Notifications
You must be signed in to change notification settings - Fork 0
/
forces.f90
99 lines (80 loc) · 2.95 KB
/
forces.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
! *************************************************
! simpleMD 1D - Module file
! *************************************************
! Contains subroutine and functions to compute forces
! *************************************************
! Copyright (C) 2017 Fabien Brieuc under the terms
! of the GNU General Public License.
! *************************************************
module force
use param
implicit none
private
public totalForce, potentialForce
contains
real(dp) function totalForce(x, xm, xp, v, irep, n)
! compute the total force that applies on each replica
implicit none
real(dp), intent(in) :: x ! position of replica i
real(dp), intent(in) :: xm ! position of replica i-1
real(dp), intent(in) :: xp ! position of replica i+1
real(dp), intent(in) :: v ! velocity
integer, intent(in) :: n ! nstep number
integer, intent(in) :: irep ! replica nb
if (nrep > 1) then
totalForce = potentialForce(x) + thermostatForce(v, irep, n) &
&+ replicasForce(x,xm,xp)
else
totalForce = potentialForce(x) + thermostatForce(v, irep, n)
endif
end function totalForce
real(dp) function potentialForce(x)
! compute the potential (external) force
use param
implicit none
real(dp), intent(in) :: x
select case (pot)
case('harmonic')
potentialForce = - MW02 * x * ONREP
case('quartic')
potentialForce = 4.d0 * A * x**3 * ONREP
case ('morse')
potentialForce = TDALP * dexp(-alpha * x) * &
&(dexp(-alpha * x) - 1.d0) * ONREP
case('double-well')
potentialForce = FV0oX02 * x * ((x / x0)**2 - 1.d0) * ONREP
case default
potentialForce = 0.d0
end select
end function potentialForce
real(dp) function thermostatForce(v, irep, n)
! compute forces associated with the thermostat
use param
use thermostats
implicit none
real(dp), intent(in) :: v ! velocity
integer, intent(in) :: n ! step number
integer, intent(in) :: irep ! replica nb
select case (therm)
case('nve')
thermostatForce = 0.d0
case('langevin')
thermostatForce = langevin(v, irep)
case ('bussi')
thermostatForce = 0.0d0
case('qtb')
thermostatForce = qtb(v, irep, n)
case default
thermostatForce = 0.d0
end select
end function thermostatForce
real(dp) function replicasForce(x,xm,xp)
! compute forces associated with the PIMD springs btw adjacent replicas
use param
implicit none
real(dp), intent(in) :: x ! position of replica i
real(dp), intent(in) :: xm ! position of replica i-1
real(dp), intent(in) :: xp ! position of replica i+1
replicasForce = - m * omegaP**2 * (2.d0 * x - xm -xp)
end function replicasForce
end module force