forked from QcmPlab/CDMFT-LANC-ED
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathED_MAIN.f90
226 lines (183 loc) · 6.66 KB
/
ED_MAIN.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
module ED_MAIN
USE ED_INPUT_VARS
USE ED_VARS_GLOBAL
USE ED_EIGENSPACE, only: state_list,es_delete_espace,delete_eigenspace
USE ED_AUX_FUNX
USE ED_HLOC_DECOMPOSITION
USE ED_SETUP
USE ED_BATH
USE ED_HAMILTONIAN
USE ED_GREENS_FUNCTIONS
USE ED_OBSERVABLES
USE ED_DIAG
USE SF_IOTOOLS, only: str,reg
USE SF_TIMER,only: start_timer,stop_timer
implicit none
private
interface ed_init_solver
module procedure :: ed_init_solver_single
#ifdef _MPI
module procedure :: ed_init_solver_single_mpi
#endif
end interface ed_init_solver
interface ed_solve
module procedure :: ed_solve_single
#ifdef _MPI
module procedure :: ed_solve_single_mpi
#endif
end interface ed_solve
public :: ed_init_solver
public :: ed_solve
contains
! PURPOSE: allocate and initialize one or multiple baths -+!
subroutine ed_init_solver_single(bath)
real(8),dimension(:),intent(inout) :: bath
logical :: check
logical,save :: isetup=.true.
integer :: i
!
write(LOGfile,"(A)")"INIT SOLVER FOR "//trim(ed_file_suffix)
!
!Init ED Structure & memory
if(isetup)call init_ed_structure()
!
!Init bath:
!call set_Hloc(Hloc)
!
check = check_bath_dimension(bath)
if(.not.check)stop "init_ed_solver_single error: wrong bath dimensions"
!
bath = 0d0
!
call allocate_dmft_bath()
!if( (Nspin>1) .AND. &
! any(Hloc(:,:,1,Nspin,:,:).ne.0d0) )stop "ED ERROR: impHloc.mask(s,s`) /= 0. Spin-Flip terms are not allowed"
call init_dmft_bath()
call get_dmft_bath(bath) !dmft_bath --> user_bath
!
if(isetup)call setup_global
call deallocate_dmft_bath()
isetup=.false.
!
end subroutine ed_init_solver_single
#ifdef _MPI
subroutine ed_init_solver_single_mpi(MpiComm,bath)
integer :: MpiComm
real(8),dimension(:),intent(inout) :: bath
logical :: check
logical,save :: isetup=.true.
integer :: i
!
!
!SET THE LOCAL MPI COMMUNICATOR :
call ed_set_MpiComm(MpiComm)
!
write(LOGfile,"(A)")"INIT SOLVER FOR "//trim(ed_file_suffix)
!
!Init ED Structure & memory
if(isetup)call init_ed_structure()
!
!Init bath:
!call set_hloc(Hloc)
!
check = check_bath_dimension(bath)
if(.not.check)stop "init_ed_solver_single error: wrong bath dimensions"
!
bath = 0d0
!
call allocate_dmft_bath()
!if(MPIMASTER .AND. &
! (Nspin>1) .AND. &
! any(Hloc(:,:,1,Nspin,:,:).ne.0d0) )stop "ED ERROR: impHloc.mask(s,s`) /= 0. Spin-Flip terms are not allowed"
call init_dmft_bath()
call get_dmft_bath(bath) !dmft_bath --> user_bath
if(isetup)call setup_global
call deallocate_dmft_bath()
isetup=.false.
!
call ed_del_MpiComm()
!
end subroutine ed_init_solver_single_mpi
#endif
!+-----------------------------------------------------------------------------+!
!PURPOSE: solve the impurity problems for a single or many independent
! lattice site using ED.
!+-----------------------------------------------------------------------------+!
!+-----------------------------------------------------------------------------+!
! SINGLE SITE !
!+-----------------------------------------------------------------------------+!
subroutine ed_solve_single(bath)
real(8),dimension(:),intent(in) :: bath
!complex(8),optional,intent(in) :: Hloc(Nlat,Nlat,Nspin,Nspin,Norb,Norb)
logical :: check
!
if(MpiMaster)call save_input_file(str(ed_input_file))
!
!if(present(Hloc))call set_Hloc(Hloc)
!
check = check_bath_dimension(bath)
if(.not.check)stop "ED_SOLVE error: wrong bath dimensions"
!
call allocate_dmft_bath()
call set_dmft_bath(bath) !user_bath --> dmft_bath
call write_dmft_bath(LOGfile)
if(MpiMaster)call save_dmft_bath(used=.true.)
!
!
!SOLVE THE QUANTUM IMPURITY PROBLEM:
call diagonalize_impurity() !find target states by digonalization of Hamiltonian
call buildgf_impurity() !build the one-particle impurity Green's functions & Self-energy
! if(chiflag)call buildchi_impurity() !build the local susceptibilities (spin [todo charge])
call observables_impurity() !obtain impurity observables as thermal averages.
call get_custom_observables() !obtain custom user-defined observables(if initialized)
call local_energy_impurity() !obtain the local energy of the effective impurity problem
!
call deallocate_dmft_bath()
call es_delete_espace(state_list)
!
nullify(spHtimesV_p)
end subroutine ed_solve_single
#ifdef _MPI
!+-----------------------------------------------------------------------------+!
! SINGLE SITE !
!+-----------------------------------------------------------------------------+!
subroutine ed_solve_single_mpi(MpiComm,bath)
integer :: MpiComm
real(8),dimension(:),intent(in) :: bath
!complex(8),optional,intent(in) :: Hloc(Nlat,Nlat,Nspin,Nspin,Norb,Norb)
logical :: check
!
!SET THE LOCAL MPI COMMUNICATOR :
call ed_set_MpiComm(MpiComm)
!
if(MpiMaster)call save_input_file(str(ed_input_file))
!
!if(present(Hloc))call set_Hloc(Hloc)
!
check = check_bath_dimension(bath)
if(.not.check)stop "ED_SOLVE error: wrong bath dimensions"
!
call allocate_dmft_bath()
call set_dmft_bath(bath) !user_bath --> dmft_bath
call write_dmft_bath(LOGfile)
if(MpiMaster)call save_dmft_bath(used=.true.)
!
!
!SOLVE THE QUANTUM IMPURITY PROBLEM:
call diagonalize_impurity() !find target states by digonalization of Hamiltonian
call buildgf_impurity() !build the one-particle impurity Green's functions & Self-energy
! if(chiflag)call buildchi_impurity() !build the local susceptibilities (spin [todo charge])
call observables_impurity() !obtain impurity observables as thermal averages.
call get_custom_observables() !obtain custom user-defined observables(if initialized)
call local_energy_impurity() !obtain the local energy of the effective impurity problem
!
call deallocate_dmft_bath()
call es_delete_espace(state_list)
!
!DELETE THE LOCAL MPI COMMUNICATOR:
call ed_del_MpiComm()
!
nullify(spHtimesV_p)
end subroutine ed_solve_single_mpi
#endif
end module ED_MAIN