diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
| commit | 5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch) | |
| tree | 1a81af141708b826e9c61e8a04019994fcca8298 /src/labat/ggauxc.f | |
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/labat/ggauxc.f')
| -rw-r--r-- | src/labat/ggauxc.f | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/labat/ggauxc.f b/src/labat/ggauxc.f new file mode 100644 index 0000000..d5fcb61 --- /dev/null +++ b/src/labat/ggauxc.f | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | subroutine ggauxc(r,db,zet,i,imin,imax,donela,donegr,donez, | ||
| 2 | j uxcup,uxcdn) | ||
| 3 | c ggauxc calculates the exchange-correlation potential by taking | ||
| 4 | c the functional derivative of the energy with respect to the density | ||
| 5 | c input r : position coordinate (array) | ||
| 6 | c input db : spin up and down density. (array) | ||
| 7 | c input zet : relative spin polarization (array) | ||
| 8 | c input i : counter, i.e. present position = r(i) | ||
| 9 | c input imin : min value of i | ||
| 10 | c input imax : max value of i | ||
| 11 | c in/output donela : true if r^2*grad(density) is splined | ||
| 12 | c in/output donegr : true if abs(grad(density)) is splined | ||
| 13 | c in/output donez : true if zet is splined | ||
| 14 | c output uxcup : spin-up exchange-correlation potential | ||
| 15 | c output uxcdn : spin-down exchange-correlation potential | ||
| 16 | implicit logical (a-z) | ||
| 17 | double precision r,db,zet,uxcup,uxcdn,gradd,gradup,graddn | ||
| 18 | double precision fkup,fkdn,sk,g,sup,sdn,t,tempz,z2,gradz | ||
| 19 | double precision onethi,pi,d,rs,lapld,laplup,lapldn,deriv | ||
| 20 | double precision gagd,gagup,gagdn,uu,vv,ww,uup,vup,udn,vdn | ||
| 21 | double precision uclcup,uclcdn,ucgaup,ucgadn,uxup,uxdn | ||
| 22 | double precision ucup,ucdn,ec,ecrs,eczet | ||
| 23 | integer i,imin,imax,j | ||
| 24 | logical donela,donegr,donez | ||
| 25 | common/gga/gradd,gradup,graddn,fkup,fkdn,sk,g,sup,sdn,t | ||
| 26 | common/ggaz/tempz,z2 | ||
| 27 | dimension r(561),db(2,561),zet(561),tempz(2,561),z2(2,561) | ||
| 28 | dimension gradd(561),gradup(561),graddn(561),fkup(561) | ||
| 29 | dimension fkdn(561),sk(561),g(561),sup(561),sdn(561),t(561) | ||
| 30 | onethi = 1.d0/3.d0 | ||
| 31 | pi = 4.d0*datan(1.d0) | ||
| 32 | call laplac(r,gradup,graddn,i,imin,imax,donela,lapld,laplup, | ||
| 33 | j lapldn) | ||
| 34 | call grabgr(r,gradup,graddn,i,imin,imax,donegr,gagd,gagup,gagdn) | ||
| 35 | |||
| 36 | c calculate the exchange potential | ||
| 37 | if (db(1,i).gt.1.d-100) then | ||
| 38 | uup = gradup(i)*gagup/(db(1,i)**2*(2.d0*fkup(i))**3) | ||
| 39 | vup = laplup/(db(1,i)*(2.d0*fkup(i))**2) | ||
| 40 | call exchpt(2.d0*db(1,i),sup(i),uup,vup,uxup) | ||
| 41 | else | ||
| 42 | uxup = 0.d0 | ||
| 43 | endif | ||
| 44 | if (db(2,i).gt.1.d-100) then | ||
| 45 | udn = graddn(i)*gagdn/(db(2,i)**2*(2.d0*fkdn(i))**3) | ||
| 46 | vdn = lapldn/(db(2,i)*(2.d0*fkdn(i))**2) | ||
| 47 | call exchpt(2.d0*db(2,i),sdn(i),udn,vdn,uxdn) | ||
| 48 | else | ||
| 49 | uxdn = 0.d0 | ||
| 50 | endif | ||
| 51 | |||
| 52 | c exchange potential done, now calculate the correlation potential | ||
| 53 | |||
| 54 | if (.not.donez) then | ||
| 55 | do 10 j = imin,imax | ||
| 56 | tempz(1,j) = zet(j) | ||
| 57 | 10 continue | ||
| 58 | call spline(r,imin+1,imax,tempz,z2) | ||
| 59 | donez = .true. | ||
| 60 | endif | ||
| 61 | gradz = deriv(r,tempz,z2,1,i,imin,imax) | ||
| 62 | d = db(1,i) + db(2,i) | ||
| 63 | if (d.gt.1.d-18) then | ||
| 64 | rs = (3.d0/(4.d0*pi*d))**onethi | ||
| 65 | uu = gradd(i)*gagd/(d**2*(2.d0*sk(i)*g(i))**3) | ||
| 66 | vv = lapld/(d*(2.d0*sk(i)*g(i))**2) | ||
| 67 | ww = gradd(i)*gradz/(d*(2.d0*sk(i)*g(i))**2) | ||
| 68 | call ldauc(rs,zet(i),ec,ecrs,eczet,uclcup,uclcdn) | ||
| 69 | call ggauc(rs,zet(i),t(i),uu,vv,ww,ec,ecrs,eczet,ucgaup, | ||
| 70 | j ucgadn) | ||
| 71 | ucup = uclcup + ucgaup | ||
| 72 | ucdn = uclcdn + ucgadn | ||
| 73 | else | ||
| 74 | ucdn = 0.d0 | ||
| 75 | ucup = 0.d0 | ||
| 76 | endif | ||
| 77 | uxcup = uxup + ucup | ||
| 78 | uxcdn = uxdn + ucdn | ||
| 79 | |||
| 80 | return | ||
| 81 | end | ||
| 82 | |||
