Line data Source code
1 : !--------------------------------------------------------------------------------
2 : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
3 : ! This file is part of FLEUR and available as free software under the conditions
4 : ! of the MIT license as expressed in the LICENSE file in more detail.
5 : !--------------------------------------------------------------------------------
6 :
7 : MODULE m_types_hub1data
8 :
9 : USE m_constants
10 : USE m_juDFT
11 :
12 : IMPLICIT NONE
13 :
14 : PRIVATE
15 :
16 : TYPE t_hub1data
17 : !Contains the information for the hubbard 1 solver,
18 : !which is calculated on the fly (fixed parameters are found in types_hub1inp)
19 : INTEGER :: iter=0
20 : INTEGER :: overallIteration=0
21 : LOGICAL :: l_runthisiter=.FALSE. !switch which determines wether Hubbard 1 will be run in the current iteration
22 : LOGICAL :: l_performSpinavg = .TRUE.
23 :
24 :
25 : REAL, ALLOCATABLE :: mag_mom(:,:) !magnetic moment (for exchange splitting)
26 : REAL, ALLOCATABLE :: xi(:) !Spin-orbit coupling parameter
27 : REAL, ALLOCATABLE :: ccfmat(:,:,:) !crystal field splitting matrix
28 :
29 : REAL, ALLOCATABLE :: cdn_atomic(:,:,:,:) !atomic contribution to the charge density
30 : !is used to calculate CF coefficients in writeCFoutput
31 :
32 : CONTAINS
33 :
34 : PROCEDURE, PASS :: init => hub1data_init
35 : PROCEDURE, PASS :: mpi_bc => hub1data_mpi_bc
36 :
37 : END TYPE t_hub1data
38 :
39 : PUBLIC t_hub1data
40 :
41 : CONTAINS
42 :
43 154 : SUBROUTINE hub1data_init(this,atoms,input,hub1inp,fmpi,mmpmatDistancePrev,occDistancePrev,l_error)
44 :
45 : USE m_types_mpi
46 : USE m_types_atoms
47 : USE m_types_input
48 : USE m_types_hub1inp
49 : USE m_gaunt
50 :
51 : CLASS(t_hub1data), INTENT(INOUT) :: this
52 : TYPE(t_atoms), INTENT(IN) :: atoms
53 : TYPE(t_input), INTENT(IN) :: input
54 : TYPE(t_hub1inp), INTENT(IN) :: hub1inp
55 : TYPE(t_mpi), INTENT(IN) :: fmpi
56 : REAL, INTENT(IN) :: mmpmatDistancePrev,occDistancePrev
57 : LOGICAL, INTENT(IN) :: l_error
58 :
59 : INTEGER :: i_hia, l, m, mp, lcoeff, mcoeff
60 : REAL :: gaunt_coef
61 :
62 :
63 154 : this%l_performSpinavg = .FALSE.
64 154 : this%iter = 0
65 154 : this%l_runthisiter = .FALSE.
66 154 : IF(atoms%n_hia>0) THEN
67 0 : IF(fmpi%irank == 0) THEN
68 0 : this%l_performSpinavg = .NOT.hub1inp%l_dftSpinpol
69 :
70 0 : IF(.NOT.l_error.AND..NOT.hub1inp%l_forceHIAiteration) THEN
71 : IF(hub1inp%l_correctEtot.AND..NOT.hub1inp%l_dftSpinpol.AND.&
72 0 : mmpmatDistancePrev<hub1inp%minmatDistance.AND.&
73 : occDistancePrev<hub1inp%minoccDistance) THEN
74 : !If we read converged distances it is assumed that the correction should kick in
75 0 : WRITE(*,*) "Previous density matrix was converged"
76 0 : WRITE(*,*) "Switching off spin averaging"
77 0 : this%l_performSpinavg = .FALSE.
78 : ENDIF
79 : ELSE
80 0 : IF(hub1inp%l_correctEtot) THEN
81 0 : IF(l_error) THEN
82 0 : WRITE(*,*) "No previous density matrix distances found"
83 0 : WRITE(*,*) "setting spin averaging according to dftSpinpol"
84 0 : ELSE IF(hub1inp%l_forceHIAiteration) THEN
85 0 : WRITE(*,*) "Previous density matrix distances are ignored"
86 0 : WRITE(*,*) "setting spin averaging according to dftSpinpol"
87 : ENDIF
88 : ENDIF
89 : ENDIF
90 : ENDIF
91 : ENDIF
92 :
93 :
94 1078 : ALLOCATE (this%mag_mom(MAX(1,atoms%n_hia),lmaxU_const-1),source=0.0)
95 616 : ALLOCATE (this%xi(MAX(1,atoms%n_hia)),source=0.0)
96 154 : DO i_hia = 1, atoms%n_hia
97 154 : IF(hub1inp%l_soc_given(i_hia)) THEN
98 0 : this%xi(i_hia) = hub1inp%xi_par(i_hia)
99 : ENDIF
100 : ENDDO
101 :
102 1296062 : ALLOCATE (this%cdn_atomic(atoms%jmtd,0:lmaxU_const,atoms%ntype,input%jspins),source=0.0)
103 :
104 16786 : ALLOCATE (this%ccfmat(MAX(1,atoms%n_hia),-lmaxU_const:lmaxU_const,-lmaxU_const:lmaxU_const),source=0.0)
105 154 : IF(ANY(ABS(hub1inp%ccf(:)).GT.1e-12)) THEN
106 154 : DO i_hia = 1, atoms%n_hia
107 0 : l = atoms%lda_u(atoms%n_u+i_hia)%l
108 154 : DO lcoeff = 0, 6
109 0 : DO mcoeff = -lcoeff,lcoeff
110 0 : IF(ABS(hub1inp%cfCoeffs(i_hia,lcoeff,mcoeff)).LT.1e-12) CYCLE
111 0 : DO m = -l,l
112 0 : DO mp = -l,l
113 0 : gaunt_coef = gaunt1(l,lcoeff,l,m,mcoeff,mp,6)
114 0 : IF(ABS(gaunt_coef).LT.1e-12) CYCLE
115 0 : this%ccfmat(i_hia,m,mp) = this%ccfmat(i_hia,m,mp) + gaunt_coef * hub1inp%cfCoeffs(i_hia,lcoeff,mcoeff) * boltzmann_const
116 : ENDDO
117 : ENDDO
118 : ENDDO
119 : ENDDO
120 : ENDDO
121 : ENDIF
122 :
123 154 : END SUBROUTINE hub1data_init
124 :
125 156 : SUBROUTINE hub1data_mpi_bc(this, mpi_comm, irank)
126 : USE m_mpi_bc_tool
127 : CLASS(t_hub1data), INTENT(INOUT)::this
128 : INTEGER, INTENT(IN):: mpi_comm
129 : INTEGER, INTENT(IN), OPTIONAL::irank
130 : INTEGER ::rank,myrank,n,ierr
131 156 : IF (PRESENT(irank)) THEN
132 0 : rank = irank
133 : ELSE
134 156 : rank = 0
135 : END IF
136 156 : CALL mpi_bc(this%iter,rank,mpi_comm)
137 156 : CALL mpi_bc(this%overallIteration,rank,mpi_comm)
138 156 : CALL mpi_bc(this%l_runthisiter,rank,mpi_comm)
139 156 : CALL mpi_bc(this%l_performSpinavg,rank,mpi_comm)
140 156 : CALL mpi_bc(this%mag_mom,rank,mpi_comm)
141 156 : CALL mpi_bc(this%xi,rank,mpi_comm)
142 156 : CALL mpi_bc(this%ccfmat,rank,mpi_comm)
143 156 : CALL mpi_bc(this%cdn_atomic,rank,mpi_comm)
144 :
145 156 : END SUBROUTINE hub1data_mpi_bc
146 :
147 0 : END MODULE m_types_hub1data
|