MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
mod_DFT_FMT_d.F90
Go to the documentation of this file.
1 
5 
6 
7 
8 
9 
10 ! Generated by TAPENADE (INRIA, Tropics team)
11 ! Tapenade 3.10 (r5498) - 20 Jan 2015 09:48
12 !
13 !All equations are taken from the appendix of:
14 !Gross: 'A density functional theory for vapor-liquid interfaces using the PCP-SAFT eos'
15 !But: here we dont treat chain-molecules!! -> no multiplications with segment number
16 MODULE mod_dft_fmt_d
17  IMPLICIT NONE
18  PRIVATE
19  PUBLIC fmt_weighted_densities_d
20  PUBLIC fmt_dfdrho_d
21 
22 CONTAINS
23 ! Differentiation of fmt_weighted_densities in forward (tangent) mode:
24 ! variations of useful results: phi_dn0 phi_dn1 phi_dn2 phi_dnv1
25 ! phi_dn3 phi_dnv2
26 ! with respect to varying inputs: rhop
27  SUBROUTINE fmt_weighted_densities_d(rhop, rhopd, n0, n1, n2, n3, nv1, &
28 & nv2, phi_dn0, phi_dn0d, phi_dn1, phi_dn1d, phi_dn2, phi_dn2d, &
29 & phi_dn3, phi_dn3d, phi_dnv1, phi_dnv1d, phi_dnv2, phi_dnv2d, user)
30  USE parameters, ONLY : pi
31  USE basic_variables, ONLY : ncomp,parame
32  USE eos_variables, Only: dhs
33  USE mod_dft, ONLY : zp, dzp, fa
34 
35 
36 !PETSc module
38 IMPLICIT NONE
39 
40 #include <finclude/petscsys.h>
41 
42 !passed
43 type(userctx) :: user
44 petscscalar :: rhop(ncomp,user%gxs:user%gxe)
45 petscscalar :: rhopd(ncomp,user%gxs:user%gxe)
46 REAL,dimension(user%gxs:user%gxe),Intent(OUT) :: n0,n1,n2,n3,nv1,nv2 !ngp muss groesser als fa+fa/2 sein!!
47 REAL,dimension(user%gxs:user%gxe),Intent(OUT) :: phi_dn0,phi_dn1,phi_dn2,phi_dn3,phi_dnv1,phi_dnv2
48 REAL,dimension(user%gxs:user%gxe),Intent(OUT) :: phi_dn0d,phi_dn1d,phi_dn2d,phi_dn3d,phi_dnv1d,phi_dnv2d
49 
50 
51 
52 
53 !local
54  REAL, DIMENSION(user%gxs:user%gxe) :: n0d,n1d,n2d,n3d,nv1d,nv2d
55  INTEGER :: k, i, j
56  INTEGER :: fa2
57  REAL :: dz, d2, zz
58  INTEGER :: n
59  INTEGER, parameter :: nmax = 800
60  REAL, DIMENSION(NMAX) :: x_int, n2_int, n3_int, nv2_int
61  REAL, DIMENSION(NMAX) :: n2_intd, n3_intd, nv2_intd
62  REAL, DIMENSION(NMAX) :: y2_n2, y2_n3, y2_nv2
63  REAL, DIMENSION(NMAX) :: y2_n2d, y2_n3d, y2_nv2d
64  REAL :: int_n2, int_n3, int_nv2, xhi, xlo
65  REAL :: int_n2d, int_n3d, int_nv2d
66  REAL :: zms, zms2, zms3, logzms
67  REAL :: zmsd, zms2d, zms3d, logzmsd
68  REAL :: nn0, nn1, nn2, nn3, nnv1, nnv2
69  REAL :: nn0d, nn1d, nn2d, nn3d, nnv1d, nnv2d
70  REAL :: rhopjk, rhopjp1k
71  REAL :: rhopjkd, rhopjp1kd
72  INTRINSIC maxval
73  INTRINSIC log
74  REAL :: result1
75 
76 
77 
78  n0 = 0.0
79  n1 = 0.0
80  n2 = 0.0
81  n3 = 0.0
82  nv1 = 0.0
83  nv2 = 0.0
84  result1 = maxval(fa(1:ncomp) + 5)
85  fa2 = result1/2
86  nv1d = 0.0
87  nv2d = 0.0
88  n0d = 0.0
89  n1d = 0.0
90  n2d = 0.0
91  n3d = 0.0
92  y2_n2d = 0.0
93  y2_n3d = 0.0
94  y2_nv2d = 0.0
95  DO k=1,ncomp
96 !fa2 = (fa(k) + 5) / 2 !grid points in sig/2
97 !half of dhs [A]
98  d2 = dhs(k)/2.0
99 
100 
101 
102 
103  Do i=user%xs-fa2,user%xe+fa2 !to evaluate dF/drho at any point, the derivatives dphi/dn have to be evaluated at +-d/2 around this point
104 
105  n = 1
106  x_int = 0.0
107  n2_int = 0.0
108  n3_int = 0.0
109  nv2_int = 0.0
110  n2_intd = 0.0
111  nv2_intd = 0.0
112  n3_intd = 0.0
113 !to evaluate dphi/dn at a given point, the weighted densities are needed at +-d/2 around this point
114  DO j=i-fa2,i+fa2
115  rhopjkd = parame(k,1)*rhopd(k, j)
116  rhopjk = rhop(k, j)*parame(k,1)
117  rhopjp1kd = parame(k,1)*rhopd(k, j+1)
118  rhopjp1k = rhop(k, j+1)*parame(k,1)
119  IF (zp(i) - zp(j+1) .LT. d2 .AND. zp(i) - zp(j) .GE. d2) THEN
120 !the position of j+1 is already within i-d/2 while j is still outside this range in this case, the integration steplength (dz) is
121 ! just the distance, which j+1 overlaps with i-d/2 and what is integrated is the interpolated value of the integrand
122 !here always n=1!
123  IF (n .NE. 1) THEN
124  GOTO 100
125  ELSE
126 !distance between grid points j and i
127  zz = zp(j) - zp(i)
128 !the part of the intervall between zp(j) and zp(j+1) which is already within i-d/2
129  dz = zp(j+1) - (zp(i)-d2)
130 !if(dz < epsilon(dz)) dz = epsilon(dz) !bei unguenstiger Kombination von sig und ngrid kann dz unter Machinengenauigkeit epsilon
131 !liegen, dann ist x(2) = x(1) + dz = x(1) -> das fuehrt zu Abbruch in Spline Interpolation
132 !array containing x-values for spline integration
133  x_int(n) = 0.0
134 !integrand für n2 (=rhop) linear interpoliert für den Punk zp(i)-d/2
135  n2_intd(n) = rhopjkd + (dzp-dz)*(rhopjp1kd-rhopjkd)/dzp
136  n2_int(n) = rhopjk + (rhopjp1k-rhopjk)/dzp*(dzp-dz)
137 !integrand für n3: rhop*(d2**2 - z'**2), da hier gerade z' = d2 -> integrand wird hier = 0!!
138  n3_intd(n) = 0.0
139  n3_int(n) = 0.0
140 !analog
141  nv2_intd(n) = zz*rhopjkd + (dzp-dz)*((zp(j+1)-zp(i))*&
142 & rhopjp1kd-zz*rhopjkd)/dzp
143  nv2_int(n) = rhopjk*zz + (rhopjp1k*(zp(j+1)-zp(i))-rhopjk*&
144 & zz)/dzp*(dzp-dz)
145  END IF
146  ELSE IF (zp(j) .GT. zp(i) - d2 .AND. zp(j) .LE. zp(i) + d2) &
147 & THEN
148 !grid point j within i+-d2
149  n = n + 1
150 !first time in this If condition, dz is stil the old value from above!
151  x_int(n) = x_int(n-1) + dz
152  zz = zp(j) - zp(i)
153  dz = dzp
154  n2_intd(n) = rhopjkd
155  n2_int(n) = rhopjk
156  n3_intd(n) = (d2**2-zz**2)*rhopjkd
157  n3_int(n) = rhopjk*(d2**2-zz**2)
158  nv2_intd(n) = zz*rhopjkd
159  nv2_int(n) = rhopjk*zz
160  IF (zp(j) .LT. zp(i) + d2 .AND. zp(j+1) .GE. zp(i) + d2) &
161 & THEN
162 !zp(j) is still within zp(i)+d2 but zp(j+1) is already outside zp(i)+d2
163  dz = zp(i) + d2 - zp(j)
164 !If(dz <= epsilon(dz)) exit !wie oben, kann auch hier bei ungluecklicher Wahl von sig und ngrid dz < eps werden und somit x(n)
165 != x(n-1) -> Abbruch in Spline interpolation. Dann einfach ngrid aendern!
166  zz = zp(j) - zp(i)
167  n = n + 1
168  x_int(n) = x_int(n-1) + dz
169 ! If(x_int(n) == x_int(n-1)) Then
170 ! n = n - 1
171 ! exit
172 ! End If
173  n2_intd(n) = rhopjkd + dz*(rhopjp1kd-rhopjkd)/dzp
174  n2_int(n) = rhopjk + (rhopjp1k-rhopjk)/dzp*dz
175 !Begründung wie oben
176  n3_intd(n) = 0.0
177  n3_int(n) = 0.0
178  nv2_intd(n) = zz*rhopjkd + dz*((zp(j+1)-zp(i))*rhopjp1kd-&
179 & zz*rhopjkd)/dzp
180  nv2_int(n) = rhopjk*zz + (rhopjp1k*(zp(j+1)-zp(i))-rhopjk*&
181 & zz)/dzp*dz
182  END IF
183  END IF
184  END DO
185 !spline integration
186  xlo = x_int(1)
187  xhi = x_int(n)
188  CALL spline_d(x_int, n2_int, n2_intd, n, 1.e30, 1.e30, y2_n2, &
189 & y2_n2d)
190  CALL spline_d(x_int, n3_int, n3_intd, n, 1.e30, 1.e30, y2_n3, &
191 & y2_n3d)
192  CALL spline_d(x_int, nv2_int, nv2_intd, n, 1.e30, 1.e30, y2_nv2&
193 & , y2_nv2d)
194  CALL splint_integral_d(x_int, n2_int, n2_intd, y2_n2, y2_n2d, n&
195 & , xlo, xhi, int_n2, int_n2d)
196  CALL splint_integral_d(x_int, n3_int, n3_intd, y2_n3, y2_n3d, n&
197 & , xlo, xhi, int_n3, int_n3d)
198  CALL splint_integral_d(x_int, nv2_int, nv2_intd, y2_nv2, y2_nv2d&
199 & , n, xlo, xhi, int_nv2, int_nv2d)
200 !weighted densities
201  n2d(i) = n2d(i) + pi*dhs(k)*int_n2d
202  n2(i) = n2(i) + pi*dhs(k)*int_n2
203  n1d(i) = n1d(i) + 0.5*int_n2d
204  n1(i) = n1(i) + 0.5*int_n2
205  n0d(i) = n0d(i) + int_n2d/dhs(k)
206  n0(i) = n0(i) + int_n2/dhs(k)
207  n3d(i) = n3d(i) + pi*int_n3d
208  n3(i) = n3(i) + pi*int_n3
209  nv2d(i) = nv2d(i) - 2.0*pi*int_nv2d
210  nv2(i) = nv2(i) - 2.0*pi*int_nv2
211  nv1d(i) = nv1d(i) - int_nv2d/dhs(k)
212  nv1(i) = nv1(i) - int_nv2/dhs(k)
213  END DO
214  END DO
215  phi_dn0d = 0.0
216  phi_dn1d = 0.0
217  phi_dn2d = 0.0
218  phi_dnv1d = 0.0
219  phi_dn3d = 0.0
220  phi_dnv2d = 0.0
221 ! If(i < 5) Then
222 ! write(*,*)'i dens',i,nv2(i),n1(i),n0(i)
223 ! write(*,*)'i dens',i,n3(i),nv1(i),nv2(i)
224 ! end if
225 !
226 ! If(i > 95) then
227 ! write(*,*)'i dens',i,nv2(i),n1(i),n0(i)
228 ! write(*,*)'i dens',i,n3(i),nv1(i),nv2(i)
229 ! End If
230 !
231 ! pause
232 
233 
234 !derivatives of FMT helmholtz energy density w.r.t. weighted densities
235 Do i=user%xs-maxval((fa(1:ncomp)+1)/2),user%xe+maxval((fa(1:ncomp)+1)/2)
236 !weils kürzer ist
237  nn0d = n0d(i)
238  nn0 = n0(i)
239  nn1d = n1d(i)
240  nn1 = n1(i)
241  nn2d = n2d(i)
242  nn2 = n2(i)
243  nn3d = n3d(i)
244  nn3 = n3(i)
245  nnv1d = nv1d(i)
246  nnv1 = nv1(i)
247  nnv2d = nv2d(i)
248  nnv2 = nv2(i)
249  zmsd = -nn3d
250  zms = 1.0 - nn3
251  zms2d = zmsd*zms + zms*zmsd
252  zms2 = zms*zms
253  zms3d = zms2d*zms + zms2*zmsd
254  zms3 = zms2*zms
255  logzmsd = zmsd/zms
256  logzms = log(zms)
257 !if(isnan(logzms)) stop 'zms < 0, log(zms) undefined FMT_Weighted_Densities'
258  phi_dn0d(i) = -logzmsd
259  phi_dn0(i) = -logzms
260  phi_dn1d(i) = (nn2d*zms-nn2*zmsd)/zms**2
261  phi_dn1(i) = nn2/zms
262  phi_dn2d(i) = (nn1d*zms-nn1*zmsd)/zms**2 + (3.0*((nn2d*nn2+nn2*&
263 & nn2d-nnv2d*nnv2-nnv2*nnv2d)*(nn3+zms2*logzms)+(nn2*nn2-nnv2*nnv2&
264 & )*(nn3d+zms2d*logzms+zms2*logzmsd))*36.0*pi*nn3**2*zms2-3.0*(nn2&
265 & *nn2-nnv2*nnv2)*(nn3+zms2*logzms)*36.0*pi*((nn3d*nn3+nn3*nn3d)*&
266 & zms2+nn3**2*zms2d))/(36.0*pi*nn3*nn3*zms2)**2
267  phi_dn2(i) = nn1/zms + 3.0*(nn2*nn2-nnv2*nnv2)*(nn3+zms2*logzms)/(&
268 & 36.0*pi*nn3*nn3*zms2)
269  phi_dn3d(i) = (nn0d*zms-nn0*zmsd)/zms**2 + ((nn1d*nn2+nn1*nn2d-&
270 & nnv1d*nnv2-nnv1*nnv2d)*zms2-(nn1*nn2-nnv1*nnv2)*zms2d)/zms2**2 -&
271 & (((3*nn2**2*nn2d-3.0*((nn2d*nnv2+nn2*nnv2d)*nnv2+nn2*nnv2*nnv2d)&
272 & )*(nn3*(nn3**2-5.0*nn3+2.0)+2.0*zms3*logzms)+(nn2**3-3.0*nn2*&
273 & nnv2*nnv2)*(nn3d*(nn3**2-5.0*nn3+2.0)+nn3*(2*nn3*nn3d-5.0*nn3d)+&
274 & 2.0*(zms3d*logzms+zms3*logzmsd)))*36.0*pi*nn3**3*zms3-(nn2**3-&
275 & 3.0*nn2*nnv2*nnv2)*(nn3*(nn3**2-5.0*nn3+2.0)+2.0*zms3*logzms)*&
276 & 36.0*pi*(3*nn3**2*nn3d*zms3+nn3**3*zms3d))/(36.0*pi*nn3**3*zms3)&
277 & **2
278  phi_dn3(i) = nn0/zms + (nn1*nn2-nnv1*nnv2)/zms2 - (nn2**3-3.0*nn2*&
279 & nnv2*nnv2)*(nn3*(nn3**2-5.0*nn3+2.0)+2.0*zms3*logzms)/(36.0*pi*&
280 & nn3**3*zms3)
281  phi_dnv1d(i) = -((nnv2d*zms-nnv2*zmsd)/zms**2)
282  phi_dnv1(i) = -(nnv2/zms)
283  phi_dnv2d(i) = -((nnv1d*zms-nnv1*zmsd)/zms**2) - (6.0*((nn2d*nnv2+&
284 & nn2*nnv2d)*(nn3+zms2*logzms)+nn2*nnv2*(nn3d+zms2d*logzms+zms2*&
285 & logzmsd))*36.0*pi*nn3**2*zms2-6.0*nn2*nnv2*(nn3+zms2*logzms)*&
286 & 36.0*pi*(2*nn3*nn3d*zms2+nn3**2*zms2d))/(36.0*pi*nn3**2*zms2)**2
287  phi_dnv2(i) = -(nnv1/zms) - 6.0*nn2*nnv2*(nn3+zms2*logzms)/(36.0*&
288 & pi*nn3**2*zms2)
289  END DO
290  GOTO 110
291  100 stop
292  110 CONTINUE
293  END SUBROUTINE fmt_weighted_densities_d
294 
295 
296 
297 ! Differentiation of fmt_dfdrho in forward (tangent) mode:
298 ! variations of useful results: df_drho_fmt
299 ! with respect to varying inputs: df_drho_fmt phi_dn0 phi_dn1
300 ! phi_dn2 phi_dnv1 phi_dn3 phi_dnv2
301  SUBROUTINE fmt_dfdrho_d(i, fa, user, phi_dn0, phi_dn0d, phi_dn1, &
302 & phi_dn1d, phi_dn2, phi_dn2d, phi_dn3, phi_dn3d, phi_dnv1, phi_dnv1d&
303 & , phi_dnv2, phi_dnv2d, df_drho_fmt, df_drho_fmtd)
304  USE basic_variables, ONLY : ncomp,parame
305  USE eos_variables, Only: dhs
306  USE mod_dft, ONLY : zp, dzp
307  USE parameters, ONLY : pi
308 
309 
310 !PETSc module
311 Use petscmanagement
312 
313  IMPLICIT NONE
314 
315 !passed
316 INTEGER, INTENT(IN) :: i !the grid point at which to calculate dFdrho
317 INTEGER, INTENT(IN) :: fa(ncomp)
318 type(userctx) :: user
319 REAL,dimension(user%gxs:user%gxe),INTENT(IN) :: phi_dn0,phi_dn1,phi_dn2,phi_dn3,phi_dnv1,phi_dnv2
320 REAL,dimension(user%gxs:user%gxe),INTENT(IN) :: phi_dn0d,phi_dn1d,phi_dn2d,phi_dn3d,phi_dnv1d,phi_dnv2d
321 
322 REAL,dimension(user%xs:user%xe,ncomp), INTENT(OUT) :: df_drho_fmt
323 REAL,dimension(user%xs:user%xe,ncomp), INTENT(OUT) :: df_drho_fmtd
324 
325 
326 !local
327  INTEGER :: j, k, n
328  INTEGER :: fa2
329  REAL :: dz, d2, zz, zz_jp1
330  INTEGER, parameter :: nmax = 800
331  REAL, DIMENSION(NMAX) :: x_int, y_int, y0_int, y1_int, y2_int, y3_int&
332 & , yv1_int, yv2_int, y2
333  REAL, DIMENSION(NMAX) :: y_intd, y2d
334  REAL :: xhi, xlo, integral, int0, int1, int2, int3, intv1, intv2
335  REAL :: integrald
336  REAL :: at_j, at_jp1
337  REAL :: at_jd, at_jp1d
338 
339 
340  y2d = 0.0
341  y_intd = 0.0
342 !Das Integral (Gleichung A1 in Gross DFT 2009) wird hier in einem Schlag berechnet!
343 !Falls die einzelnen Terme einzeln integriert werden sollen, einfach die auskommentierte Version verwenden
344 !das einzige, das hier von k abhaengt, sind fa und dhs!! die Ableitungen phi_dn... sind nicht Komponentenspez, da die
345  DO k=1,ncomp
346 !gewichteten Dichten ja uch nicht mehr Komponentenspez sind (n_i = sum n_i(k))
347  n = 1
348 !number of grid points within dhs/2
349  fa2 = (fa(k)+5)/2
350  d2 = dhs(k)/2.0
351  DO j=i-fa2,i+fa2
352  IF (zp(i) - zp(j+1) .LT. d2 .AND. zp(i) - zp(j) .GE. d2) THEN
353 !the position of j+1 is already within i-d/2 while j is still outside this range in this case, the integration steplength (dz) is
354 ! just the distance, which j+1 overlaps with i-d/2 and what is integrated is the interpolated value of the integrand
355  x_int(n) = 0.0
356  IF (n .NE. 1) THEN
357  GOTO 100
358  ELSE
359  dz = zp(j+1) - (zp(i)-d2)
360  zz = zp(j) - zp(i)
361  zz_jp1 = zp(j+1) - zp(i)
362  at_jd = phi_dn0d(j)/dhs(k) + 0.5*phi_dn1d(j) + pi*dhs(k)*&
363 & phi_dn2d(j) + pi*(d2**2-zz**2)*phi_dn3d(j) + zz*phi_dnv1d(&
364 & j)/dhs(k) + 2.0*pi*zz*phi_dnv2d(j)
365  at_j = phi_dn0(j)/dhs(k) + 0.5*phi_dn1(j) + pi*dhs(k)*&
366 & phi_dn2(j) + pi*phi_dn3(j)*(d2**2-zz**2) + phi_dnv1(j)*zz/&
367 & dhs(k) + 2.0*pi*phi_dnv2(j)*zz
368  at_jp1d = phi_dn0d(j+1)/dhs(k) + 0.5*phi_dn1d(j+1) + pi*dhs(&
369 & k)*phi_dn2d(j+1) + pi*(d2**2-zz_jp1**2)*phi_dn3d(j+1) + &
370 & zz_jp1*phi_dnv1d(j+1)/dhs(k) + 2.0*pi*zz_jp1*phi_dnv2d(j+1&
371 & )
372  at_jp1 = phi_dn0(j+1)/dhs(k) + 0.5*phi_dn1(j+1) + pi*dhs(k)*&
373 & phi_dn2(j+1) + pi*phi_dn3(j+1)*(d2**2-zz_jp1**2) + &
374 & phi_dnv1(j+1)*zz_jp1/dhs(k) + 2.0*pi*phi_dnv2(j+1)*zz_jp1
375 !lineare interpolation genau, wie in FMT_Weighted_Densities
376  y_intd(n) = at_jd + (dzp-dz)*(at_jp1d-at_jd)/dzp
377  y_int(n) = at_j + (at_jp1-at_j)/dzp*(dzp-dz)
378 ! y0_int(n) = phi_dn0(j) + (phi_dn0(j+1) -phi_dn0(j))/dzp * (dzp-dz)
379 ! y1_int(n) = phi_dn1(j) + (phi_dn1(j+1) -phi_dn1(j))/dzp * (dzp-dz)
380 ! y2_int(n) = phi_dn2(j) + (phi_dn2(j+1) -phi_dn2(j))/dzp * (dzp-dz)
381 ! y3_int(n) = phi_dn3(j)*(d2**2-zz**2) + (phi_dn3(j+1)*(d2**2-zz_jp1**2) - phi_dn3(j)*(d2**2-zz**2) )/dzp * (dzp-dz)
382 ! yv1_int(n) = phi_dnv1(j)*zz + (phi_dnv1(j+1)*zz_jp1 - phi_dnv1(j)*zz)/dzp * (dzp-dz)
383 ! yv2_int(n) = phi_dnv2(j)*zz + (phi_dnv2(j+1)*zz_jp1 - phi_dnv2(j)*zz)/dzp * (dzp-dz)
384 !
385  END IF
386  ELSE IF (zp(j) .GT. zp(i) - d2 .AND. zp(j) .LE. zp(i) + d2) THEN
387 !grid points j and j+1 are completely within i+-d2
388  n = n + 1
389  zz = zp(j) - zp(i)
390  x_int(n) = x_int(n-1) + dz
391  y_intd(n) = phi_dn0d(j)/dhs(k) + 0.5*phi_dn1d(j) + pi*dhs(k)*&
392 & phi_dn2d(j) + pi*(d2**2-zz**2)*phi_dn3d(j) + zz*phi_dnv1d(j)&
393 & /dhs(k) + 2.0*pi*zz*phi_dnv2d(j)
394  y_int(n) = phi_dn0(j)/dhs(k) + 0.5*phi_dn1(j) + pi*dhs(k)*&
395 & phi_dn2(j) + pi*phi_dn3(j)*(d2**2-zz**2) + phi_dnv1(j)*zz/&
396 & dhs(k) + 2.0*pi*phi_dnv2(j)*zz
397 ! y0_int(n) = phi_dn0(j)
398 ! y1_int(n) = phi_dn1(j)
399 ! y2_int(n) = phi_dn2(j)
400 ! y3_int(n) = phi_dn3(j)*(d2**2-zz**2)
401 ! yv1_int(n) = phi_dnv1(j)*zz
402 ! yv2_int(n) = phi_dnv2(j)*zz
403 !
404  dz = dzp
405  IF (zp(j) .LT. zp(i) + d2 .AND. zp(j+1) .GT. zp(i) + d2) THEN
406 !zp(j) is still within zp(i)+d2 but zp(j+1) is already out side zp(i)+d2
407  n = n + 1
408  zz = zp(j) - zp(i)
409  zz_jp1 = zp(j+1) - zp(i)
410  dz = zp(i) + d2 - zp(j)
411  x_int(n) = x_int(n-1) + dz
412  at_jd = phi_dn0d(j)/dhs(k) + 0.5*phi_dn1d(j) + pi*dhs(k)*&
413 & phi_dn2d(j) + pi*(d2**2-zz**2)*phi_dn3d(j) + zz*phi_dnv1d(&
414 & j)/dhs(k) + 2.0*pi*zz*phi_dnv2d(j)
415  at_j = phi_dn0(j)/dhs(k) + 0.5*phi_dn1(j) + pi*dhs(k)*&
416 & phi_dn2(j) + pi*phi_dn3(j)*(d2**2-zz**2) + phi_dnv1(j)*zz/&
417 & dhs(k) + 2.0*pi*phi_dnv2(j)*zz
418  at_jp1d = phi_dn0d(j+1)/dhs(k) + 0.5*phi_dn1d(j+1) + pi*dhs(&
419 & k)*phi_dn2d(j+1) + pi*(d2**2-zz_jp1**2)*phi_dn3d(j+1) + &
420 & zz_jp1*phi_dnv1d(j+1)/dhs(k) + 2.0*pi*zz_jp1*phi_dnv2d(j+1&
421 & )
422  at_jp1 = phi_dn0(j+1)/dhs(k) + 0.5*phi_dn1(j+1) + pi*dhs(k)*&
423 & phi_dn2(j+1) + pi*phi_dn3(j+1)*(d2**2-zz_jp1**2) + &
424 & phi_dnv1(j+1)*zz_jp1/dhs(k) + 2.0*pi*phi_dnv2(j+1)*zz_jp1
425  y_intd(n) = at_jd + dz*(at_jp1d-at_jd)/dzp
426  y_int(n) = at_j + (at_jp1-at_j)/dzp*dz
427 ! y0_int(n) = phi_dn0(j) + (phi_dn0(j+1) - phi_dn0(j))/dzp * dz
428 ! y1_int(n) = phi_dn1(j) + (phi_dn1(j+1) - phi_dn1(j))/dzp * dz
429 ! y2_int(n) = phi_dn2(j) + (phi_dn2(j+1) - phi_dn2(j))/dzp * dz
430 ! y3_int(n) = phi_dn3(j)*(d2**2 - zz**2) + (phi_dn3(j+1)*(d2**2 - zz_jp1**2) - phi_dn3(j)*(d2**2 - zz**2))/dzp * dz
431 ! yv1_int(n) = phi_dnv1(j)*zz + (phi_dnv1(j+1)*zz_jp1 - phi_dnv1(j)*zz)/dzp * dz
432 ! yv2_int(n) = phi_dnv2(j)*zz + (phi_dnv2(j+1)*zz_jp1 - phi_dnv2(j)*zz)/dzp * dz
433 !
434  END IF
435  END IF
436  END DO
437 !spline integration
438  xlo = x_int(1)
439  xhi = x_int(n)
440  CALL spline_d(x_int, y_int, y_intd, n, 1.e30, 1.e30, y2, y2d)
441  CALL splint_integral_d(x_int, y_int, y_intd, y2, y2d, n, xlo, xhi&
442 & , integral, integrald)
443 ! call spline ( x_int, y0_int, n, 1.E30, 1.E30, y2 )
444 ! call splint_integral ( x_int, y0_int, y2, n, xlo, xhi, int0 )
445 ! call spline ( x_int, y1_int, n, 1.E30, 1.E30, y2 )
446 ! call splint_integral ( x_int, y1_int, y2, n, xlo, xhi, int1 )
447 ! call spline ( x_int, y2_int, n, 1.E30, 1.E30, y2 )
448 ! call splint_integral ( x_int, y2_int, y2, n, xlo, xhi, int2 )
449 ! call spline ( x_int, y3_int, n, 1.E30, 1.E30, y2 )
450 ! call splint_integral ( x_int, y3_int, y2, n, xlo, xhi, int3 )
451 ! call spline ( x_int, yv1_int, n, 1.E30, 1.E30, y2 )
452 ! call splint_integral ( x_int, yv1_int, y2, n, xlo, xhi, intv1 )
453 ! call spline ( x_int, yv2_int, n, 1.E30, 1.E30, y2 )
454 ! call splint_integral ( x_int, yv2_int, y2, n, xlo, xhi, intv2 )
455 !
456 !dF_drho_FMT(i,k) = int0/dhs(k) + 0.5*int1 + PI*dhs(k)*int2 + PI*int3 + intv1/dhs(k) + 2.0*PI*intv2
457  df_drho_fmtd(i, k) = parame(k,1)*integrald
458  df_drho_fmt(i, k) = integral*parame(k,1)
459  END DO
460  GOTO 110
461  100 stop
462  110 CONTINUE
463  END SUBROUTINE fmt_dfdrho_d
464 
465 END MODULE mod_dft_fmt_d
466 
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains constant...
Definition: modules.f90:6
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
Definition: modules.f90:120
In this module, the application context is defined.
Definition: mod_PETSc.F90:7
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
Definition: modules.f90:29