The Elk Code
bfcqinit.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2025 Wenhan Chen, 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 subroutine bfcqinit
7 use modmain
8 use modulr
9 use modrandom
10 implicit none
11 ! local variables
12 integer ifq,idm,ias
13 real(8) cb,t1
14 ! coupling constant of the external field (g_e/4c)
15 cb=gfacte/(4.d0*solsc)
16 ! zero the external magnetic fields
17 bfcq(1:ndmag,1:nfqrz)=0.d0
18 bfcmtq(1:natmtot,1:ndmag,1:nfqrz)=0.d0
19 ! read the external fields from file if required
20 if (trdbfcr) call readbfcr
21 ! add random numbers to magnetic fields if required
22 if (abs(rndbfcu) > 0.d0) then
23  t1=cb*rndbfcu
24  do ifq=1,nfqrz
25  do idm=1,ndmag
26  bfcq(idm,ifq)=bfcq(idm,ifq)+t1*cmplx(randomu()-0.5d0,randomu()-0.5d0,8)
27  do ias=1,natmtot
28  bfcmtq(ias,idm,ifq)=bfcmtq(ias,idm,ifq) &
29  +t1*cmplx(randomu()-0.5d0,randomu()-0.5d0,8)
30  end do
31  end do
32  end do
33  bfcq(1:ndmag,1)=dble(bfcq(1:ndmag,1))
34  bfcmtq(1:natmtot,1:ndmag,1)=dble(bfcmtq(1:natmtot,1:ndmag,1))
35 end if
36 ! add the global external magnetic field
37 do idm=1,ndmag
38  if (ncmag) then
39  t1=cb*bfieldcu(idm)
40  else
41  t1=cb*bfieldcu(3)
42  end if
43  bfcq(idm,1)=bfcq(idm,1)+t1
44  bfcmtq(1:natmtot,idm,1)=bfcmtq(1:natmtot,idm,1)+t1
45 end do
46 ! write the external magnetic fields to file if required
47 if (.not.trdbfcr) call writebfcr
48 end subroutine
49 
integer ndmag
Definition: modmain.f90:238
subroutine bfcqinit
Definition: bfcqinit.f90:7
subroutine writebfcr
Definition: writebfcr.f90:7
real(8), dimension(3) bfieldcu
Definition: modulr.f90:75
real(8) function randomu()
Definition: modrandom.f90:18
real(8), parameter gfacte
Definition: modmain.f90:1277
subroutine readbfcr
Definition: readbfcr.f90:7
real(8) solsc
Definition: modmain.f90:1253
integer nfqrz
Definition: modmain.f90:539
complex(8), dimension(:,:,:), allocatable bfcmtq
Definition: modulr.f90:73
logical trdbfcr
Definition: modulr.f90:69
complex(8), dimension(:,:), allocatable bfcq
Definition: modulr.f90:71
integer natmtot
Definition: modmain.f90:40
Definition: modulr.f90:6
logical ncmag
Definition: modmain.f90:240
real(8) rndbfcu
Definition: modulr.f90:87