The Elk Code
rhocore.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 !BOP
7 ! !ROUTINE: rhocore
8 ! !INTERFACE:
9 subroutine rhocore
10 ! !USES:
11 use modmain
12 ! !DESCRIPTION:
13 ! Adds the core density and magnetisation to the muffin-tin functions. Also
14 ! computes the amount of leakage of core charge from the muffin-tin spheres
15 ! into the interstitial.
16 !
17 ! !REVISION HISTORY:
18 ! Created April 2003 (JKD)
19 ! Fixed core moment direction, October 2012 (M. Meinert)
20 !EOP
21 !BOC
22 implicit none
23 ! local variables
24 integer ispn,idm,is,ias
25 integer nr,nri,iro,ir,i,i0,i1
26 real(8) v(ndmag),sm,t1
27 ! external functions
28 real(8), external :: rfmtint
29 do ias=1,natmtot
30  is=idxis(ias)
31  nr=nrmt(is)
32  nri=nrmti(is)
33  iro=nri+1
34  sm=0.d0
35 ! loop over spin channels
36  do ispn=1,nspncr
37 ! add the core density to the muffin-tin density
38  i1=lmmaxi*(nri-1)+1
39  rhomt(1:i1:lmmaxi,ias)=rhomt(1:i1:lmmaxi,ias)+rhocr(1:nri,ias,ispn)
40  i0=i1+lmmaxi
41  i1=lmmaxo*(nr-iro)+i0
42  rhomt(i0:i1:lmmaxo,ias)=rhomt(i0:i1:lmmaxo,ias)+rhocr(iro:nr,ias,ispn)
43 ! compute the core charge inside the muffin-tins
44  sm=sm+fourpi*y00*sum(wr2mt(1:nr,is)*rhocr(1:nr,ias,ispn))
45  end do
46 ! core leakage charge
47  chgcrlk(ias)=chgcr(is)-sm
48 ! add to the magnetisation in the case of a spin-polarised core
49  if (spincore) then
50 ! compute the moment in the muffin-tin
51  do idm=1,ndmag
52  v(idm)=rfmtint(nr,nri,wr2mt(:,is),magmt(:,ias,idm))
53  end do
54 ! normalise
55  if (ncmag) then
56  t1=sqrt(v(1)**2+v(2)**2+v(3)**2)
57  else
58  t1=abs(v(1))
59  end if
60 ! add the core magnetisation to the total
61  if (t1 > 1.d-10) then
62  v(1:ndmag)=v(1:ndmag)/t1
63  i=1
64  do ir=1,nri
65  t1=rhocr(ir,ias,1)-rhocr(ir,ias,2)
66  magmt(i,ias,1:ndmag)=magmt(i,ias,1:ndmag)+t1*v(1:ndmag)
67  i=i+lmmaxi
68  end do
69  do ir=iro,nr
70  t1=rhocr(ir,ias,1)-rhocr(ir,ias,2)
71  magmt(i,ias,1:ndmag)=magmt(i,ias,1:ndmag)+t1*v(1:ndmag)
72  i=i+lmmaxo
73  end do
74  end if
75  end if
76 end do
77 end subroutine
78 !EOC
79 
integer lmmaxo
Definition: modmain.f90:203
subroutine rhocore
Definition: rhocore.f90:10
real(8), dimension(:,:), pointer, contiguous rhomt
Definition: modmain.f90:614
real(8), dimension(:,:,:), allocatable rhocr
Definition: modmain.f90:941
integer nspncr
Definition: modmain.f90:945
real(8), dimension(:,:,:), pointer, contiguous magmt
Definition: modmain.f90:616
real(8), dimension(maxspecies) chgcr
Definition: modmain.f90:716
real(8), dimension(:), allocatable chgcrlk
Definition: modmain.f90:720
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
integer lmmaxi
Definition: modmain.f90:207
real(8), parameter fourpi
Definition: modmain.f90:1234
integer natmtot
Definition: modmain.f90:40
logical ncmag
Definition: modmain.f90:240
integer, dimension(maxspecies) nrmti
Definition: modmain.f90:211
real(8), parameter y00
Definition: modmain.f90:1236
logical spincore
Definition: modmain.f90:943
real(8), dimension(:,:), allocatable wr2mt
Definition: modmain.f90:183
integer, dimension(maxspecies) nrmt
Definition: modmain.f90:150