14 integer,
parameter ::
dp = kind(1.0d0)
38 character(20) :: bml_type
40 real(8),
intent(in) :: bndfil, threshold
42 real(
dp),
allocatable :: eigenvalues(:)
43 real(
dp),
allocatable,
optional,
intent(out) :: eigenvalues_out(:)
44 type(bml_matrix_t) :: aux1_bml, aux2_bml, eigenvectors_bml
45 type(bml_matrix_t),
intent(in) :: ham_bml
46 type(bml_matrix_t),
intent(inout) :: rho_bml
47 character(20) :: bml_dmode
50 if (
printrank() .eq. 1) print*,
'prg_build_density_T0: BML_DMODE_DISTRIBUTED'
51 bml_dmode = bml_dmode_distributed
53 print*,
'prg_build_density_T0: BML_DMODE_SEQUENTIAL'
54 bml_dmode = bml_dmode_sequential
57 norb = bml_get_n(ham_bml)
58 bml_type = bml_get_deep_type(ham_bml)
60 allocate(eigenvalues(norb))
62 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,eigenvectors_bml,bml_dmode)
64 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
65 if(
present(eigenvalues_out))
then
66 if(
allocated(eigenvalues_out))
deallocate(eigenvalues_out)
67 allocate(eigenvalues_out(norb))
68 eigenvalues_out = eigenvalues
74 if(real(i)-nocc < 0.0001_dp)
then
75 eigenvalues(i) = 2.0_dp
76 elseif(abs(real(i)-real(nocc)) < 0.0001_dp)
then
77 eigenvalues(i) = 2.0_dp
79 eigenvalues(i) = 0.0_dp
82 if(abs(nocc - int(nocc)) > 0.01_dp)
then
83 eigenvalues(int(nocc)+1) = 1.0_dp
86 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml,bml_dmode)
87 call bml_set_diagonal(aux1_bml, eigenvalues)
89 deallocate(eigenvalues)
91 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,aux2_bml,bml_dmode)
92 call bml_multiply(eigenvectors_bml, aux1_bml, aux2_bml, 1.0_dp, 0.0_dp, threshold)
94 call bml_transpose(eigenvectors_bml, aux1_bml)
95 call bml_deallocate(eigenvectors_bml)
97 call bml_multiply(aux2_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
98 call bml_deallocate(aux2_bml)
99 call bml_deallocate(aux1_bml)
119 character(20) :: bml_type
121 real(
dp),
intent(in) :: bndfil, threshold, kbt
122 real(
dp),
intent(inout) :: ef
123 real(
dp) :: nocc, fleveltol, mlsi, efold
124 real(
dp),
allocatable :: eigenvalues(:)
125 real(
dp),
allocatable,
optional,
intent(out) :: eigenvalues_out(:)
126 type(bml_matrix_t) :: aux1_bml, aux2_bml, eigenvectors_bml
127 type(bml_matrix_t),
intent(in) :: ham_bml
128 type(bml_matrix_t),
intent(inout) :: rho_bml
132 write(*,*)
"In get_density_t ..."
135 norb = bml_get_n(ham_bml)
136 bml_type = bml_get_deep_type(ham_bml)
138 allocate(eigenvalues(norb))
139 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,eigenvectors_bml)
141 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
143 if(
present(eigenvalues_out))
then
144 if(
allocated(eigenvalues_out))
deallocate(eigenvalues_out)
145 allocate(eigenvalues_out(norb))
146 eigenvalues_out = eigenvalues
158 write(*,*)
"WARNING: Ef/Chemical potential search failed. We'll use the previous one to proceed"
165 eigenvalues(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
168 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
169 call bml_set_diagonal(aux1_bml, eigenvalues)
171 deallocate(eigenvalues)
173 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,aux2_bml)
174 call bml_multiply(eigenvectors_bml, aux1_bml, aux2_bml, 1.0_dp, 0.0_dp, threshold)
176 call bml_transpose(eigenvectors_bml, aux1_bml)
177 call bml_deallocate(eigenvectors_bml)
179 call bml_multiply(aux2_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
180 call bml_deallocate(aux2_bml)
181 call bml_deallocate(aux1_bml)
203 &, evects_bml, fvals)
205 character(20) :: bml_type
207 real(
dp),
intent(in) :: bndfil, threshold, kbt
208 real(
dp),
intent(inout) :: ef
209 real(
dp) :: nocc, fleveltol, efold
210 real(
dp),
allocatable :: eigenvalues(:)
211 real(
dp),
allocatable,
intent(inout) :: eigenvalues_out(:), fvals(:)
212 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
213 type(bml_matrix_t),
intent(in) :: ham_bml
214 type(bml_matrix_t),
intent(inout) :: rho_bml, evects_bml
218 write(*,*)
"In get_density_t_fulldata ..."
221 norb = bml_get_n(ham_bml)
222 bml_type = bml_get_deep_type(ham_bml)
224 allocate(eigenvalues(norb))
225 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
227 call bml_diagonalize(ham_bml,eigenvalues,evects_bml)
229 if(.not.
allocated(eigenvalues_out))
then
230 allocate(eigenvalues_out(norb))
231 allocate(fvals(norb))
232 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
235 eigenvalues_out = eigenvalues
241 if(err)
call prg_get_flevel(eigenvalues,kbt,bndfil,fleveltol,ef,err)
243 write(*,*)
"WARNING: Ef/Chemical potential search failed. We'll use the previous one to proceed"
250 fvals(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
253 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
254 call bml_set_diagonal(occupation_bml, fvals)
256 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
257 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
258 call bml_deallocate(occupation_bml)
260 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
261 call bml_transpose(evects_bml, aux1_bml)
263 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
264 call bml_deallocate(aux_bml)
265 call bml_deallocate(aux1_bml)
288 &, dvals, hindex, llsize, verbose)
290 character(20) :: bml_type
291 integer,
allocatable,
intent(in) :: hindex(:,:)
292 integer :: i, j, jj, k, kk, l, norb, norbcore
293 integer,
intent(in) :: llsize, verbose
294 real(
dp),
intent(in) :: bndfil, threshold, kbt
295 real(
dp),
intent(inout) :: ef
297 real(
dp),
allocatable :: eigenvalues(:), row(:),fvals(:),ham(:,:),evects(:,:)
298 real(
dp),
allocatable,
intent(inout) :: evals(:), dvals(:)
299 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
300 type(bml_matrix_t),
intent(in) :: ham_bml
301 type(bml_matrix_t),
intent(inout) :: rho_bml, evects_bml
303 if (
printrank() .eq. 1 .and. verbose >= 1)
then
304 write(*,*)
"In get_density_t_efd ..."
307 norb = bml_get_n(ham_bml)
308 bml_type = bml_get_type(ham_bml)
310 if(
allocated(evals))
then
314 allocate(evals(norb))
315 allocate(dvals(norb))
316 allocate(fvals(norb))
317 allocate(ham(norb,norb))
318 allocate(evects(norb,norb))
319 call bml_export_to_dense(ham_bml,ham)
320 if(bml_get_n(evects_bml) < 0)
then
321 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
323 call eig(ham,evects,evals,
'V',norb)
324 call bml_import_from_dense(bml_type,evects,evects_bml,0.0_dp,norb)
326 write(*,*)
"ham",ham(1,1),ham(1,2),ham(1,3)
329 call bml_print_matrix(
"evects",evects_bml,0,4,0,4)
330 write(*,*)
"Evals",evals(1),evals(2),evals(3)
334 fvals(i) = 2.0_dp*
fermi(evals(i),ef,kbt)
337 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
338 call bml_set_diagonal(occupation_bml, fvals)
342 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
343 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
344 call bml_deallocate(occupation_bml)
346 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
347 call bml_transpose(evects_bml, aux1_bml)
352 call bml_get_row(aux1_bml,i,row)
354 do l = hindex(1,k),hindex(2,k)
355 dvals(i) = dvals(i) + row(l)**2
361 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
363 call bml_deallocate(aux_bml)
364 call bml_deallocate(aux1_bml)
382 & llsize, evals, dvals, evects_bml, verbose)
384 character(20) :: bml_type
385 integer,
allocatable,
intent(in) :: hindex(:,:)
386 integer :: i, k, l, norb
387 integer,
intent(in) :: llsize, verbose
388 real(
dp),
intent(in) :: threshold
389 real(
dp),
allocatable :: row(:),ham(:,:),evects(:,:),aux(:,:)
390 real(
dp),
allocatable,
intent(inout) :: evals(:), dvals(:)
391 type(bml_matrix_t),
intent(in) :: ham_bml
392 type(bml_matrix_t),
intent(inout) :: evects_bml
393 type(bml_matrix_t) :: aux1_bml
395 if (
printrank() .eq. 1 .and. verbose >= 1)
then
396 write(*,*)
"In get_evalsDvalsEvects ..."
399 norb = bml_get_n(ham_bml)
400 bml_type = bml_get_type(ham_bml)
402 if(.not.
allocated(evals))
allocate(evals(norb))
403 if(.not.
allocated(dvals))
allocate(dvals(norb))
407 if(.not. bml_allocated(evects_bml))
then
408 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
412 call bml_diagonalize(ham_bml,evals,evects_bml)
416 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
417 call bml_transpose(evects_bml, aux1_bml)
418 allocate(aux(norb,norb))
419 call bml_export_to_dense(aux1_bml,aux)
420 call bml_deallocate(aux1_bml)
428 do l = hindex(1,k),hindex(2,k)
429 dvals(i) = dvals(i) + row(l)**2
449 & bndfil, kbt, ef, verbose)
451 character(20) :: bml_type
453 integer,
intent(in) :: verbose
454 real(
dp),
intent(in) :: bndfil, threshold, kbt
455 real(
dp),
intent(inout) :: ef
457 real(
dp),
intent(in) :: evals(*)
458 real(
dp),
allocatable :: fvals(:)
459 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
460 type(bml_matrix_t),
intent(in) :: evects_bml
461 type(bml_matrix_t),
intent(inout) :: rho_bml
463 if (
printrank() .eq. 1 .and. verbose >= 1)
then
464 write(*,*)
"In get_density_fromEvalsAndEvects ..."
467 norb = bml_get_n(evects_bml)
468 bml_type = bml_get_type(evects_bml)
470 allocate(fvals(norb))
475 fvals(i) = 2.0_dp*
fermi(evals(i),ef,kbt)
478 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
479 call bml_set_diagonal(occupation_bml, fvals)
483 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
484 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
485 call bml_deallocate(occupation_bml)
487 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
488 call bml_transpose(evects_bml, aux1_bml)
490 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
492 call bml_deallocate(aux_bml)
493 call bml_deallocate(aux1_bml)
511 character(20) :: bml_type
512 integer :: i, norb, mdim
513 integer,
optional,
intent(in) :: verbose
514 real(
dp),
intent(in) :: threshold, kbt
515 real(
dp),
intent(in) :: ef
516 real(
dp) :: fleveltol
517 real(
dp),
allocatable :: eigenvalues(:)
518 real(
dp),
allocatable :: nocc(:)
519 type(bml_matrix_t) :: aux1_bml, aux_bml, eigenvectors_bml, occupation_bml
520 type(bml_matrix_t),
intent(in) :: ham_bml
521 type(bml_matrix_t),
intent(inout) :: rho_bml
522 real(
dp),
optional,
intent(inout) :: drho
525 if(
present(verbose))
then
527 write(*,*)
"In get_density_t_Fermi ..."
533 norb = bml_get_n(ham_bml)
534 mdim = bml_get_m(ham_bml)
535 bml_type = bml_get_deep_type(ham_bml)
537 allocate(eigenvalues(norb),nocc(norb))
538 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,eigenvectors_bml)
540 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
543 nocc(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
546 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,occupation_bml)
547 call bml_set_diagonal(occupation_bml, nocc)
549 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux_bml)
550 call bml_multiply(eigenvectors_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
551 call bml_deallocate(occupation_bml)
553 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux1_bml)
554 call bml_transpose(eigenvectors_bml, aux1_bml)
556 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
558 if (
present(drho))
then
560 nocc(i) = 2.0_dp *
dfermi(eigenvalues(i),ef,kbt)
563 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,occupation_bml)
564 call bml_set_diagonal(occupation_bml, nocc)
566 call bml_multiply(eigenvectors_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
568 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux1_bml)
569 call bml_transpose(eigenvectors_bml, aux1_bml)
571 call bml_multiply(aux_bml, aux1_bml, occupation_bml, 1.0_dp, 0.0_dp, threshold)
572 drho = bml_trace(occupation_bml)
573 call bml_deallocate(occupation_bml)
577 deallocate(eigenvalues)
578 call bml_deallocate(eigenvectors_bml)
579 call bml_deallocate(aux_bml)
580 call bml_deallocate(aux1_bml)
595 character(len=*),
intent(in) :: bml_type
596 integer :: i, index, n_orb, nats
597 integer,
intent(in) :: hindex(:,:), norb, spindex(:)
599 real(
dp),
allocatable :: d_atomic(:), rhoat(:)
600 real(
dp),
intent(in) :: numel(:)
601 type(bml_matrix_t),
intent(inout) :: rhoat_bml
603 nats =
size(hindex,dim=2)
605 allocate(rhoat(norb))
607 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,rhoat_bml)
612 n_orb = hindex(2,i)-hindex(1,i) + 1;
615 rhoat(index) = numel(spindex(i));
617 if(numel(spindex(i)) <= 2)
then
619 rhoat(index) = numel(spindex(i));
621 rhoat(index) = 0.0_dp;
623 rhoat(index) = 0.0_dp;
625 rhoat(index) = 0.0_dp;
628 rhoat(index) = 2.0_dp;
631 occ = (numel(spindex(i))-2.0_dp)/3.0_dp;
641 call bml_set_diagonal(rhoat_bml,rhoat,0.0_dp)
659 integer :: i, j, k, m
661 real(
dp) :: ft1, ft2, kb, prod
662 real(
dp) :: t, step, tol, nel
663 real(
dp),
intent(in) :: bndfil, eigenvalues(:), kbt
664 real(
dp),
intent(inout) :: ef
665 logical,
intent(inout) :: err
667 norb =
size(eigenvalues,dim=1)
668 nel = bndfil*2.0_dp*norb
670 step=abs((eigenvalues(norb)-eigenvalues(1)))
677 ft1 = ft1 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
686 write(*,*)
"WARNING: Bisection method in prg_get_flevel not converging ..."
689 if(abs(ft1).lt.tol)
then
699 ft2 = ft2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
733 real(
dp) :: ef0, f1, f2, nel
735 real(
dp),
intent(in) :: bndfil, kbt
736 real(
dp),
intent(in) :: tol, eigenvalues(:)
737 real(
dp),
intent(inout) :: ef
738 integer,
optional,
intent(in) :: verbose
739 logical,
intent(inout) :: err
741 norb =
size(eigenvalues, dim=1)
742 nel = bndfil*2.0_dp*real(norb,
dp)
753 f1 = f1 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
766 f2 = f2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
772 if(abs(f2 - f1) < 1.0d-5)
then
777 ef = -f2*step/(f2-f1) + ef0
783 write(*,*)
"WARNING: Newton method in prg_get_flevel_nt is not converging ..."
795 f2 = f2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
801 ef = -f2*step/(f2-f1) + ef0
804 if(abs(f1).lt.tol)
then
819 character(20) :: bml_type
821 integer,
intent(in) :: verbose
823 real(
dp),
allocatable :: aux(:,:)
824 real(
dp),
allocatable,
intent(inout) :: eigenvalues(:)
825 type(bml_matrix_t) :: aux_bml, eigenvectors_bml
826 type(bml_matrix_t),
intent(in) :: ham_bml
828 norb = bml_get_n(ham_bml)
829 bml_type = bml_get_deep_type(ham_bml)
831 if(verbose.ge.1)
write(*,*)
"In prg_get_eigenvalues ..."
832 if(verbose.ge.1)
write(*,*)
"Number of states =",norb
834 if(.not.
allocated(eigenvalues))
allocate(eigenvalues(norb))
837 if(trim(bml_type).ne.
"dense")
then
838 allocate(aux(norb,norb))
839 call bml_export_to_dense(ham_bml,aux)
840 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,aux_bml)
841 call bml_import_from_dense(bml_matrix_dense,aux,aux_bml,0.0_dp,norb)
844 call bml_copy_new(ham_bml,aux_bml)
847 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,eigenvectors_bml)
849 call bml_diagonalize(aux_bml,eigenvalues,eigenvectors_bml)
851 call bml_deallocate(eigenvectors_bml)
852 call bml_deallocate(aux_bml)
864 character(20) :: bml_type
866 real(
dp),
intent(in) :: threshold
867 real(
dp),
intent(out) :: idempotency
868 type(bml_matrix_t) :: aux_bml
869 type(bml_matrix_t),
intent(in) :: mat_bml
871 call bml_copy_new(mat_bml, aux_bml)
873 call bml_multiply(mat_bml, mat_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
874 call bml_add_deprecated(1.0_dp,aux_bml,-1.0_dp,mat_bml, threshold)
876 idempotency = bml_fnorm(aux_bml)
878 call bml_deallocate(aux_bml)
888 real(
dp),
intent(in) :: e, ef, kbt
890 if ((e-ef)/kbt > 100.0_dp)
then
893 fermi = 1.0_dp/(1.0_dp+exp((e-ef)/(kbt)))
904 real(
dp),
intent(in) :: e, ef, kbt
907 if ((e-ef)/kbt > 100.0_dp)
then
908 if (abs(e-ef)<0.001_dp)
then
912 dfermi = 1.0_dp/(1.0_dp+exp((e-ef)/(kbt)))
930 integer,
optional,
intent(in) :: verbose
931 type(bml_matrix_t),
intent(in) :: mat_bml, evects_bml
932 type(bml_matrix_t),
intent(inout) :: mateig_bml
933 type(bml_matrix_t) :: aux_bml
934 real(
dp),
intent(in) :: threshold
935 integer :: hdim, mdim
936 character(20) :: bml_type
938 if(verbose.eq.1)
write(*,*)
"In prg_toEigenspace ..."
940 hdim= bml_get_n(mat_bml)
941 mdim= bml_get_m(mat_bml)
942 bml_type = bml_get_type(mat_bml)
944 if(bml_get_n(mateig_bml) < 0)
then
945 call bml_zero_matrix(bml_type,bml_element_real,
dp,hdim ,mdim,mateig_bml, &
946 & bml_get_distribution_mode(mat_bml))
949 call bml_transpose(evects_bml, aux_bml)
951 call bml_multiply(aux_bml, mat_bml, mateig_bml, 1.0_dp, 0.0_dp,threshold)
953 call bml_multiply(mateig_bml, evects_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
955 call bml_copy(aux_bml, mateig_bml)
957 call bml_deallocate(aux_bml)
974 integer,
optional,
intent(in) :: verbose
975 type(bml_matrix_t),
intent(in) :: mat_bml, evects_bml
976 type(bml_matrix_t),
intent(inout) :: matcan_bml
977 type(bml_matrix_t) :: aux_bml
978 real(
dp),
intent(in) :: threshold
979 integer :: hdim, mdim
980 character(20) :: bml_type
982 if(verbose.eq.1)
write(*,*)
"In prg_toCacninicalspace ..."
984 hdim= bml_get_n(mat_bml)
985 mdim= bml_get_m(mat_bml)
986 bml_type = bml_get_type(mat_bml)
989 if(bml_get_n(matcan_bml) < 0)
then
990 call bml_zero_matrix(bml_type,bml_element_real,
dp,hdim ,mdim,matcan_bml,&
991 & bml_get_distribution_mode(mat_bml))
996 call bml_transpose(evects_bml, aux_bml)
997 call bml_multiply(mat_bml, aux_bml, matcan_bml, 1.0_dp, 0.0_dp,threshold)
999 call bml_multiply(evects_bml,matcan_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
1001 call bml_copy(aux_bml, matcan_bml)
1003 call bml_deallocate(aux_bml)
1011 integer,
parameter :: prec = 8
1012 real(prec),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
1013 integer,
intent(in) :: hdim, m
1014 real(prec),
intent(in) :: h1(hdim,hdim), q(hdim,hdim), e(hdim), nocc
1015 real(prec),
intent(out) :: p1(hdim,hdim)
1016 real(prec),
intent(in) :: t, mu0
1017 real(prec) :: x(hdim,hdim), dx1(hdim,hdim), y(hdim,hdim)
1018 real(prec) :: h_0(hdim), p_0(hdim), dpdmu(hdim), p_02(hdim),id0(hdim)
1019 real(prec) :: beta, cnst, kb, mu1, sumdpdmu
1020 integer :: i, j, k, norbscore
1025 cnst = beta/(1.d0*2**(m+2))
1026 p_0 = 0.5d0 + cnst*(h_0-mu0)
1040 dx1(k,j) = p_0(k)*p1(k,j) + p1(k,j)*p_0(j)
1043 id0 = 1.d0/(2.d0*(p_02-p_0)+1.d0)
1047 p1(k,j) = id0(k)*(dx1(k,j) + 2.d0*(p1(k,j)-dx1(k,j))*p_0(j))
1051 dpdmu = beta*p_0*(1.d0-p_0)
1057 sumdpdmu = sumdpdmu + dpdmu(i)
1064 p1(i,i) = p1(i,i) + mu1*dpdmu(i)
1074 subroutine eig(A,Q,ee,TYPE,HDIM)
1077 integer,
parameter :: PREC = 8
1078 integer,
intent(in) :: HDIM
1080 integer :: DIAG_LWORK
1081 real(PREC) :: DIAG_WORK(1+6*HDIM+2*HDIM*HDIM)
1082 integer :: DIAG_LIWORK
1083 integer :: DIAG_IWORK(3+5*HDIM)
1084 real(PREC),
intent(in) :: A(HDIM,HDIM)
1085 real(PREC),
intent(out) :: Q(HDIM,HDIM), ee(HDIM)
1086 real(PREC) :: EVECS(HDIM,HDIM), EVALS(HDIM)
1087 character(LEN=1),
parameter :: JOBZ =
"V", uplo =
"U"
1088 character(1),
intent(in) ::
TYPE
1090 diag_lwork = 1+6*hdim+2*hdim*hdim
1091 diag_liwork = 3 + 5*hdim
1094 CALL dsyevd(jobz, uplo, hdim, evecs, hdim, evals, &
1095 diag_work, diag_lwork, diag_iwork, diag_liwork, info)
Module to obtain the density matrix by diagonalizing an orthogonalized Hamiltonian.
real(dp) function fermi(e, ef, kbt)
Gives the Fermi distribution value for energy e.
subroutine, public prg_get_flevel_nt(eigenvalues, kbt, bndfil, tol, ef, err, verbose)
Routine to compute the Fermi level given a set of eigenvalues and a temperature. It applies the Newto...
subroutine, public prg_build_density_t(ham_bml, rho_bml, threshold, bndfil, kbt, ef, eigenvalues_out)
Builds the density matrix from for electronic temperature T. Where, is the matrix eigenvector and ...
subroutine, public prg_build_density_t_fermi(ham_bml, rho_bml, threshold, kbt, ef, verbose, drho)
Builds the density matrix from for electronic temperature T. Where, is the matrix eigenvector and ...
subroutine, public prg_build_density_t0(ham_bml, rho_bml, threshold, bndfil, eigenvalues_out)
Builds the density matrix from for zero electronic temperature. Where, is the matrix eigenvector a...
subroutine, public prg_build_density_t_ed(ham_bml, rho_bml, evects_bml, threshold, bndfil, kbt, ef, evals, dvals, hindex, llsize, verbose)
Builds the density matrix from for electronic temperature T. Where, is the matrix eigenvector and ...
subroutine, public prg_get_eigenvalues(ham_bml, eigenvalues, verbose)
Gets the eigenvalues of the Orthogonalized Hamiltonian.
subroutine, public prg_tocanonicalspace(mat_bml, matCan_bml, evects_bml, threshold, verbose)
Change an operator into the eigenspace representation.
subroutine, public prg_check_idempotency(mat_bml, threshold, idempotency)
To check the idempotency error of a matrix. This is calculated as the Frobenius norm of .
subroutine, public prg_build_atomic_density(rhoat_bml, numel, hindex, spindex, norb, bml_type)
Builds the atomic density matrix. Where, is the number of electrons for orbital i.
real(dp) function dfermi(e, ef, kbt)
Gives the gradient of Fermi distribution w.r.t. ef.
subroutine, public prg_build_density_t_fulldata(ham_bml, rho_bml, threshold, bndfil, kbt, ef, eigenvalues_out, evects_bml, fvals)
Builds the density matrix from for electronic temperature T. Where, is the matrix eigenvector and ...
subroutine, public canon_dm_prt(P1, H1, Nocc, T, Q, e, mu0, m, HDIM)
subroutine, public prg_get_evalsdvalsevects(ham_bml, threshold, hindex, llsize, evals, dvals, evects_bml, verbose)
Gets the eigenvalues and eigenvectors and the core contribution to each eigenvalue (dvals) .
subroutine, public prg_toeigenspace(mat_bml, matEig_bml, evects_bml, threshold, verbose)
Change an operator into the eigenspace representation.
subroutine eig(A, Q, ee, TYPE, HDIM)
subroutine, public prg_build_density_fromevalsandevects(evects_bml, evals, rho_bml, threshold, bndfil, kbt, ef, verbose)
Builds the density matrix from the evects and evals for electronic temperature T.
subroutine, public prg_get_flevel(eigenvalues, kbt, bndfil, tol, Ef, err)
Routine to compute the Fermi level given a set of eigenvalues and a temperature. It applies the Bisec...
integer function, public printrank()
integer function, public getnranks()