-
Notifications
You must be signed in to change notification settings - Fork 0
/
potentials.f90
187 lines (167 loc) · 4.52 KB
/
potentials.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
module potentials
use input_data
type, public :: potential
type(inp), pointer :: ip
real(8) :: rb, rp
real(8) :: Vmin, Vmax
contains
procedure :: potential_
procedure :: Vn
procedure :: Vc
procedure :: Vcnt
procedure :: Wn
procedure :: find_rmin
procedure :: dV_dr
end type
contains
!----------------------------------------------------------------------
subroutine potential_(this, ip)
implicit none
class(potential), intent(out) :: this
type(inp), intent(in), target :: ip
this%ip => ip
end subroutine
!----------------------------------------------------------------------
elemental function Vc(this, r) result(V)
use global_constant, only : e2
implicit none
class(potential), intent(in) :: this
real(8), intent(in) :: r
real(8) :: V
if (r > this%ip%Rc) then
V = this%ip%Zp * this%ip%Zt * e2 / r
else
V = 0.5d0*this%ip%Zp*this%ip%Zt*e2 &
* (3.0d0*this%ip%Rc*this%ip%Rc - r*r) / this%ip%Rc**3
end if
return
end function
!----------------------------------------------------------------------!
elemental function Vn(this, r) result(V)
implicit none
class(potential), intent(in) :: this
real(8), intent(in) :: r
real(8) :: V
if (r >= this%ip%rcut) then
V = 0.0d0
return
end if
V = - this%ip%V0 / (1.0d0 + exp((r - this%ip%Rn) / this%ip%a))
return
end function
!----------------------------------------------------------------------!
elemental function Wn(this, r) result(W)
implicit none
class(potential), intent(in) :: this
real(8), intent(in) :: r
real(8) :: W
if (r >= this%ip%rcut) then
W = 0.0d0
return
end if
W = - this%ip%W0 / (1.0d0 + exp((r - this%ip%Rw) / this%ip%aw))
return
end function
!----------------------------------------------------------------------!
elemental function Vcnt(this, J, r) result(V)
use global_constant, only : hbar
implicit none
class(potential), intent(in) :: this
integer, intent(in) :: J
real(8), intent(in) :: r
real(8) :: V
V = 0.5d0 * hbar * hbar / this%ip%rmass * dble(J * (J + 1)) / (r * r)
return
end function
!----------------------------------------------------------------------
function find_rmin(this, J) result(pocket)
implicit none
class(potential), intent(inout) :: this
logical :: pocket
integer, intent(in) :: J
integer :: i
real(8), parameter :: dr = 0.1d0
real(8), parameter :: r0 = 3.0d0, rmax = 20.0d0
real(8), parameter :: epsr = 1.0d-15, epsa = 1.0d-200
real(8) :: V1, V2, r1, r2, rh
r1 = r0
r2 = r1 + dr
do while(r1 < this%ip%rmax)
if (sign(1.0d0,dV_dr(this,J,r1)) * sign(1.0d0,dV_dr(this,J,r2)) > 0.0d0) then
r1 = r2
r2 = r1 + dr
else
exit
end if
end do
if (r1 >= this%ip%rmax) then
this%rp = 0.0d0
this%rb = 0.0d0
pocket = .false.
end if
rh = 0.5d0 * (r1 + r2)
V2 = 0.0d0
i = 0
pocket = .true.
do
V1 = dV_dr(this,J,rh)
if (abs((V1 - V2)) < abs(V1) * epsr + epsa) exit
if (V1 < 0.0d0) then
r1 = rh
else
r2 = rh
end if
rh = 0.5d0 * (r1 + r2)
V2 = V1
if (i == 50 .or. rh > rmax) then
pocket = .false.
return
end if
i = i + 1
end do
this%rp = rh
this%Vmin = Vn(this, this%rp) + Vc(this, this%rp)
r1 = rh + 1.0d-14
r2 = r1 + dr
do
if (dV_dr(this,J,r1) * dV_dr(this,J,r2) >= 0.0d0) then
r1 = r2
r2 = r1 + dr
else
exit
end if
end do
rh = 0.5d0 * (r1 + r2)
V2 = 0.0d0
i = 0
do
V1 = dV_dr(this,J,rh)
if (abs((V1 - V2)) < abs(V1) * epsr + epsa) exit
if (V1 > 0.0d0) then
r1 = rh
else
r2 = rh
end if
rh = 0.5d0 * (r1 + r2)
V2 = V1
if (i == 60) then
exit
end if
i = i + 1
end do
this%rb = rh
this%Vmax = Vn(this, this%rb) + Vc(this, this%rb)
end function
!----------------------------------------------------------------------
elemental function dV_dr(this, J, r) result(dV)
use global_constant, only : e2, hbar
implicit none
class(potential), intent(in) :: this
integer, intent(in) :: J
real(8), intent(in) :: r
real(8) :: dV, f
f = exp((r - this%ip%Rn) / this%ip%a)
dV = this%ip%V0*f / (this%ip%a*(1.0d0+f)**2) - this%ip%Zp*this%ip%Zt*e2 / (r*r) &
- dble(J * (J + 1)) * hbar * hbar / (this%ip%rmass*r**3)
end function
end module