The Elk Code
potdmag.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2025 J. K. Dewhurst and S. Sharma.
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: potdmag
8 ! !INTERFACE:
9 subroutine potdmag
10 ! !USES:
11 use modmain
12 ! !DESCRIPTION:
13 ! Calculates the scalar potential associated with the diamagnetic coupling to
14 ! an external magnetic field. The vector potential corresponding to a constant
15 ! magnetic field ${\bf B}$ is given by
16 ! $$ {\bf A}({\bf r})=\frac{1}{2}{\bf B}\times{\bf r}. $$
17 ! Substituting this into
18 ! $$ \hat{H}=\frac{1}{2}\big(\hat{p}+\frac{1}{c}{\bf A}({\bf r})\big)^2 $$
19 ! yields (among other terms) the diamagnetic contribution to the electronic
20 ! Hamiltonian:
21 ! $$ H_{\rm dia}=\frac{B^2 r^2}{8c^2}\big(1-(\hat{\bf B}\cdot
22 ! \hat{\bf r})^2\big). $$
23 ! This is applied in the muffin-tins by noting that the term in the brackets
24 ! is purely angular and can be represented as coefficients $f_{lm}$ of the
25 ! real spherical harmonics $R_{lm}(\theta,\phi)$. These are given by
26 ! \begin{gather*}
27 ! f_{00}=\sqrt{5/3}\,t, \qquad
28 ! f_{2-2}=t \hat{B}_x \hat{B}_y, \qquad
29 ! f_{2-1}=t \hat{B}_y \hat{B}_z, \\
30 ! f_{20}=(t/\sqrt{12})(\hat{B}_x^2+\hat{B}_y^2-2\hat{B}_z^2), \qquad
31 ! f_{21}=t \hat{B}_x \hat{B}_z, \qquad
32 ! f_{22}=(t/2)(\hat{B}_y^2-\hat{B}_x^2),
33 ! \end{gather*}
34 ! where $t=4\sqrt{\pi/15}$.
35 !
36 ! !REVISION HISTORY:
37 ! Suggested by M. Fechner
38 ! Created June 2025 (JKD)
39 !EOP
40 !BOC
41 implicit none
42 ! local variables
43 integer is,ias,nr,nri,ir,i
44 real(8) cbd,bx,by,bz,r2
45 real(8) f01,f21,f22,f23,f24,f25
46 ! diamagnetic coupling constant of the external field (1/8c²)
47 cbd=1.d0/(8.d0*solsc**2)
48 ! external B-field only
49 if (.not.tbdip) then
50  bx=bfieldc(1); by=bfieldc(2); bz=bfieldc(3)
51  call cfr02
52 end if
53 do ias=1,natmtot
54  is=idxis(ias)
55  nr=nrmt(is)
56  nri=nrmti(is)
57  if (tbdip) then
58 ! external plus average muffin-tin dipole field
59  bx=bfieldc(1)+bdmta(1,ias)
60  by=bfieldc(2)+bdmta(2,ias)
61  bz=bfieldc(3)+bdmta(3,ias)
62  call cfr02
63  end if
64  i=1
65  do ir=1,nr
66  r2=rlmt(ir,2,is)
67  vsmt(i,ias)=vsmt(i,ias)+f01*r2
68  vsmt(i+4,ias)=vsmt(i+4,ias)+f21*r2
69  vsmt(i+5,ias)=vsmt(i+5,ias)+f22*r2
70  vsmt(i+6,ias)=vsmt(i+6,ias)+f23*r2
71  vsmt(i+7,ias)=vsmt(i+7,ias)+f24*r2
72  vsmt(i+8,ias)=vsmt(i+8,ias)+f25*r2
73  if (ir <= nri) then
74  i=i+lmmaxi
75  else
76  i=i+lmmaxo
77  end if
78  end do
79 end do
80 
81 contains
82 
83 subroutine cfr02
84 implicit none
85 ! local variables
86 real(8) b,t1,t2
87 ! coefficients of the real spherical harmonics for l=0 and l=2
88 b=sqrt(bx**2+by**2+bz**2)
89 if (b > 1.d-8) then
90  bx=bx/b; by=by/b; bz=bz/b
91 end if
92 t1=cbd*b**2
93 t2=t1*4.d0*sqrt(pi/15.d0)
94 f01=sqrt(5.d0/3.d0)*t2
95 f21=t2*bx*by
96 f22=t2*by*bz
97 f23=(t2/sqrt(12.d0))*(bx**2+by**2-2.d0*bz**2)
98 f24=t2*bx*bz
99 f25=(t2/2.d0)*(by**2-bx**2)
100 end subroutine
101 
102 end subroutine
103 !EOC
104 
integer lmmaxo
Definition: modmain.f90:203
real(8), dimension(:,:,:), allocatable rlmt
Definition: modmain.f90:179
real(8), dimension(:,:), allocatable bdmta
Definition: modmain.f90:640
real(8), parameter pi
Definition: modmain.f90:1232
subroutine potdmag
Definition: potdmag.f90:10
real(8) solsc
Definition: modmain.f90:1253
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
integer lmmaxi
Definition: modmain.f90:207
logical tbdip
Definition: modmain.f90:643
integer natmtot
Definition: modmain.f90:40
subroutine cfr02
Definition: potdmag.f90:84
real(8), dimension(:,:), pointer, contiguous vsmt
Definition: modmain.f90:649
integer, dimension(maxspecies) nrmti
Definition: modmain.f90:211
real(8), dimension(3) bfieldc
Definition: modmain.f90:269
integer, dimension(maxspecies) nrmt
Definition: modmain.f90:150