19 integer,
parameter ::
dp = kind(1.0d0)
43 character(20) :: bml_type
45 real(8),
intent(in) :: bndfil, threshold
47 real(
dp),
allocatable :: eigenvalues(:)
48 real(
dp),
allocatable,
optional,
intent(out) :: eigenvalues_out(:)
49 type(bml_matrix_t) :: aux1_bml, aux2_bml, eigenvectors_bml
50 type(bml_matrix_t),
intent(in) :: ham_bml
51 type(bml_matrix_t),
intent(inout) :: rho_bml
52 character(20) :: bml_dmode
55 if (
printrank() .eq. 1) print*,
'prg_build_density_T0: BML_DMODE_DISTRIBUTED'
56 bml_dmode = bml_dmode_distributed
58 print*,
'prg_build_density_T0: BML_DMODE_SEQUENTIAL'
59 bml_dmode = bml_dmode_sequential
62 norb = bml_get_n(ham_bml)
63 bml_type = bml_get_deep_type(ham_bml)
65 allocate(eigenvalues(norb))
67 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,eigenvectors_bml,bml_dmode)
69 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
70 if(
present(eigenvalues_out))
then
71 if(
allocated(eigenvalues_out))
deallocate(eigenvalues_out)
72 allocate(eigenvalues_out(norb))
73 eigenvalues_out = eigenvalues
79 if(real(i)-nocc < 0.0001_dp)
then
80 eigenvalues(i) = 2.0_dp
81 elseif(abs(real(i)-real(nocc)) < 0.0001_dp)
then
82 eigenvalues(i) = 2.0_dp
84 eigenvalues(i) = 0.0_dp
87 if(abs(nocc - int(nocc)) > 0.01_dp)
then
88 eigenvalues(int(nocc)+1) = 1.0_dp
91 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml,bml_dmode)
92 call bml_set_diagonal(aux1_bml, eigenvalues)
94 deallocate(eigenvalues)
96 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,aux2_bml,bml_dmode)
97 call bml_multiply(eigenvectors_bml, aux1_bml, aux2_bml, 1.0_dp, 0.0_dp, threshold)
99 call bml_transpose_new(eigenvectors_bml, aux1_bml)
100 call bml_deallocate(eigenvectors_bml)
102 call bml_multiply(aux2_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
103 call bml_deallocate(aux2_bml)
104 call bml_deallocate(aux1_bml)
124 character(20) :: bml_type
126 real(
dp),
intent(in) :: bndfil, threshold, kbt
127 real(
dp),
intent(inout) :: ef
128 real(
dp) :: nocc, fleveltol, mlsi, efold
129 real(
dp),
allocatable :: eigenvalues(:)
130 real(
dp),
allocatable,
optional,
intent(out) :: eigenvalues_out(:)
131 type(bml_matrix_t) :: aux1_bml, aux2_bml, eigenvectors_bml
132 type(bml_matrix_t),
intent(in) :: ham_bml
133 type(bml_matrix_t),
intent(inout) :: rho_bml
137 write(*,*)
"In get_density_t ..."
140 norb = bml_get_n(ham_bml)
141 bml_type = bml_get_deep_type(ham_bml)
143 allocate(eigenvalues(norb))
144 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,eigenvectors_bml)
146 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
148 if(
present(eigenvalues_out))
then
149 if(
allocated(eigenvalues_out))
deallocate(eigenvalues_out)
150 allocate(eigenvalues_out(norb))
151 eigenvalues_out = eigenvalues
163 write(*,*)
"WARNING: Ef/Chemical potential search failed. We'll use the previous one to proceed"
170 eigenvalues(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
173 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
174 call bml_set_diagonal(aux1_bml, eigenvalues)
176 deallocate(eigenvalues)
178 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,aux2_bml)
179 call bml_multiply(eigenvectors_bml, aux1_bml, aux2_bml, 1.0_dp, 0.0_dp, threshold)
181 call bml_transpose_new(eigenvectors_bml, aux1_bml)
182 call bml_deallocate(eigenvectors_bml)
184 call bml_multiply(aux2_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
185 call bml_deallocate(aux2_bml)
186 call bml_deallocate(aux1_bml)
208 &, evects_bml, fvals)
210 character(20) :: bml_type
212 real(
dp),
intent(in) :: bndfil, threshold, kbt
213 real(
dp),
intent(inout) :: ef
214 real(
dp) :: nocc, fleveltol, efold
215 real(
dp),
allocatable :: eigenvalues(:)
216 real(
dp),
allocatable,
intent(inout) :: eigenvalues_out(:), fvals(:)
217 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
218 type(bml_matrix_t),
intent(in) :: ham_bml
219 type(bml_matrix_t),
intent(inout) :: rho_bml, evects_bml
223 write(*,*)
"In get_density_t_fulldata ..."
226 norb = bml_get_n(ham_bml)
227 bml_type = bml_get_deep_type(ham_bml)
229 allocate(eigenvalues(norb))
230 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
232 call bml_diagonalize(ham_bml,eigenvalues,evects_bml)
234 if(.not.
allocated(eigenvalues_out))
then
235 allocate(eigenvalues_out(norb))
236 allocate(fvals(norb))
237 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
240 eigenvalues_out = eigenvalues
246 if(err)
call prg_get_flevel(eigenvalues,kbt,bndfil,fleveltol,ef,err)
248 write(*,*)
"WARNING: Ef/Chemical potential search failed. We'll use the previous one to proceed"
255 fvals(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
258 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
259 call bml_set_diagonal(occupation_bml, fvals)
261 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
262 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
263 call bml_deallocate(occupation_bml)
265 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
266 call bml_transpose_new(evects_bml, aux1_bml)
268 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
269 call bml_deallocate(aux_bml)
270 call bml_deallocate(aux1_bml)
293 &, dvals, hindex, llsize, verbose)
295 character(20) :: bml_type
296 integer,
allocatable,
intent(in) :: hindex(:,:)
297 integer :: i, j, jj, k, kk, l, norb, norbcore
298 integer,
intent(in) :: llsize, verbose
299 real(
dp),
intent(in) :: bndfil, threshold, kbt
300 real(
dp),
intent(inout) :: ef
302 real(
dp),
allocatable :: eigenvalues(:), row(:),fvals(:),ham(:,:),evects(:,:)
303 real(
dp),
allocatable,
intent(inout) :: evals(:), dvals(:)
304 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
305 type(bml_matrix_t),
intent(in) :: ham_bml
306 type(bml_matrix_t),
intent(inout) :: rho_bml, evects_bml
308 if (
printrank() .eq. 1 .and. verbose >= 1)
then
309 write(*,*)
"In get_density_t_efd ..."
312 norb = bml_get_n(ham_bml)
313 bml_type = bml_get_type(ham_bml)
315 if(
allocated(evals))
then
319 allocate(evals(norb))
320 allocate(dvals(norb))
321 allocate(fvals(norb))
322 allocate(ham(norb,norb))
323 allocate(evects(norb,norb))
324 call bml_export_to_dense(ham_bml,ham)
325 if(bml_get_n(evects_bml) < 0)
then
326 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
328 call eig(ham,evects,evals,
'V',norb)
329 call bml_import_from_dense(bml_type,evects,evects_bml,0.0_dp,norb)
331 write(*,*)
"ham",ham(1,1),ham(1,2),ham(1,3)
334 call bml_print_matrix(
"evects",evects_bml,0,4,0,4)
335 write(*,*)
"Evals",evals(1),evals(2),evals(3)
339 fvals(i) = 2.0_dp*
fermi(evals(i),ef,kbt)
342 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
343 call bml_set_diagonal(occupation_bml, fvals)
347 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
348 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
349 call bml_deallocate(occupation_bml)
351 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
352 call bml_transpose_new(evects_bml, aux1_bml)
357 call bml_get_row(aux1_bml,i,row)
359 do l = hindex(1,k),hindex(2,k)
360 dvals(i) = dvals(i) + row(l)**2
366 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
368 call bml_deallocate(aux_bml)
369 call bml_deallocate(aux1_bml)
387 & llsize, evals, dvals, evects_bml, verbose)
389 character(20) :: bml_type
390 integer,
allocatable,
intent(in) :: hindex(:,:)
391 integer :: i, k, l, norb, nats
392 integer,
intent(in) :: llsize, verbose
393 real(
dp),
intent(in) :: threshold
394 real(
dp),
allocatable :: row(:),ham(:,:),evects(:,:),aux(:,:)
395 real(
dp),
allocatable,
intent(inout) :: evals(:), dvals(:)
396 type(bml_matrix_t),
intent(in) :: ham_bml
397 type(bml_matrix_t),
intent(inout) :: evects_bml
398 type(bml_matrix_t) :: aux1_bml
400 type(c_ptr) :: evects_bml_c_ptr
402 real(c_double),
pointer :: evects_bml_ptr(:,:)
403 real(
dp) :: this_dval
406 if (
printrank() .eq. 1 .and. verbose >= 1)
then
407 write(*,*)
"In get_evalsDvalsEvects ..."
410 norb = bml_get_n(ham_bml)
411 bml_type = bml_get_type(ham_bml)
413 if(.not.
allocated(evals))
allocate(evals(norb))
414 if(.not.
allocated(dvals))
allocate(dvals(norb))
418 if(.not. bml_allocated(evects_bml))
then
419 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,evects_bml)
423 call bml_diagonalize(ham_bml,evals,evects_bml)
428 evects_bml_c_ptr = bml_get_data_ptr_dense(evects_bml)
429 ld = bml_get_ld_dense(evects_bml)
430 nats =
size(hindex,dim=2)
431 call c_f_pointer(evects_bml_c_ptr,evects_bml_ptr,shape=[ld,norb])
440 do l = hindex(1,k),hindex(2,k)
441 this_dval = this_dval + evects_bml_ptr(i,l)*evects_bml_ptr(i,l)
453 call bml_export_to_dense(evects_bml,aux)
460 do l = hindex(1,k),hindex(2,k)
461 dvals(i) = dvals(i) + row(l)**2
482 & bndfil, kbt, ef, verbose)
484 character(20) :: bml_type
485 integer :: i, j, norb
486 integer,
intent(in) :: verbose
487 real(
dp),
intent(in) :: bndfil, threshold, kbt
488 real(
dp),
intent(inout) :: ef
490 real(
dp),
intent(in) :: evals(*)
491 real(
dp),
allocatable :: fvals(:)
492 type(bml_matrix_t) :: aux_bml, occupation_bml
493 type(bml_matrix_t),
intent(inout) :: evects_bml
494 type(bml_matrix_t),
intent(inout) :: rho_bml
496 type(c_ptr) :: evects_bml_c_ptr, aux_bml_c_ptr
498 real(c_double),
pointer :: evects_bml_ptr(:,:), aux_bml_ptr(:,:)
501 if (
printrank() .eq. 1 .and. verbose >= 1)
then
502 write(*,*)
"In get_density_fromEvalsAndEvects ..."
505 norb = bml_get_n(evects_bml)
506 bml_type = bml_get_type(evects_bml)
508 allocate(fvals(norb))
514 fvals(i) = 2.0_dp*
fermi(evals(i),ef,kbt)
519 call bml_noinit_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
521 evects_bml_c_ptr = bml_get_data_ptr_dense(evects_bml)
522 aux_bml_c_ptr = bml_get_data_ptr_dense(aux_bml)
523 ld = bml_get_ld_dense(evects_bml)
524 call c_f_pointer(evects_bml_c_ptr,evects_bml_ptr,shape=[ld,norb])
525 call c_f_pointer(aux_bml_c_ptr,aux_bml_ptr,shape=[ld,norb])
531 aux_bml_ptr(j,i) = evects_bml_ptr(i,j)*fvals(i)
536 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
537 call bml_set_diagonal(occupation_bml, fvals)
539 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
540 call bml_multiply(evects_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
541 call bml_deallocate(occupation_bml)
543 call bml_transpose(aux_bml)
548 call bml_multiply(evects_bml, aux_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
550 call bml_deallocate(aux_bml)
568 character(20) :: bml_type
569 integer :: i, norb, mdim
570 integer,
optional,
intent(in) :: verbose
571 real(
dp),
intent(in) :: threshold, kbt
572 real(
dp),
intent(in) :: ef
573 real(
dp) :: fleveltol
574 real(
dp),
allocatable :: eigenvalues(:)
575 real(
dp),
allocatable :: nocc(:)
576 type(bml_matrix_t) :: aux1_bml, aux_bml, eigenvectors_bml, occupation_bml
577 type(bml_matrix_t),
intent(in) :: ham_bml
578 type(bml_matrix_t),
intent(inout) :: rho_bml
579 real(
dp),
optional,
intent(inout) :: drho
582 if(
present(verbose))
then
584 write(*,*)
"In get_density_t_Fermi ..."
590 norb = bml_get_n(ham_bml)
591 mdim = bml_get_m(ham_bml)
592 bml_type = bml_get_deep_type(ham_bml)
594 allocate(eigenvalues(norb),nocc(norb))
595 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,eigenvectors_bml)
597 call bml_diagonalize(ham_bml,eigenvalues,eigenvectors_bml)
600 nocc(i) = 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
603 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,occupation_bml)
604 call bml_set_diagonal(occupation_bml, nocc)
606 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux_bml)
607 call bml_multiply(eigenvectors_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
608 call bml_deallocate(occupation_bml)
610 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux1_bml)
611 call bml_transpose_new(eigenvectors_bml, aux1_bml)
613 call bml_multiply(aux_bml, aux1_bml, rho_bml, 1.0_dp, 0.0_dp, threshold)
615 if (
present(drho))
then
617 nocc(i) = 2.0_dp *
dfermi(eigenvalues(i),ef,kbt)
620 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,occupation_bml)
621 call bml_set_diagonal(occupation_bml, nocc)
623 call bml_multiply(eigenvectors_bml, occupation_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
625 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,mdim,aux1_bml)
626 call bml_transpose_new(eigenvectors_bml, aux1_bml)
628 call bml_multiply(aux_bml, aux1_bml, occupation_bml, 1.0_dp, 0.0_dp, threshold)
629 drho = bml_trace(occupation_bml)
630 call bml_deallocate(occupation_bml)
634 deallocate(eigenvalues)
635 call bml_deallocate(eigenvectors_bml)
636 call bml_deallocate(aux_bml)
637 call bml_deallocate(aux1_bml)
652 character(len=*),
intent(in) :: bml_type
653 integer :: i, j, index, n_orb, nats
654 integer,
intent(in) :: hindex(:,:), norb, spindex(:)
656 real(
dp),
allocatable :: d_atomic(:)
657 real(
dp),
intent(in) :: numel(:)
658 type(bml_matrix_t),
intent(inout) :: rhoat_bml
660 type(c_ptr) :: rhoat_bml_c_ptr
662 real(c_double),
pointer :: rhoat_bml_ptr(:,:)
664 real(
dp),
allocatable :: rhoat(:)
667 nats =
size(hindex,dim=2)
670 rhoat_bml_c_ptr = bml_get_data_ptr_dense(rhoat_bml)
671 ld = bml_get_ld_dense(rhoat_bml)
673 call c_f_pointer(rhoat_bml_c_ptr,rhoat_bml_ptr,shape=[ld,norb])
680 rhoat_bml_ptr(i,j) = 0.0_dp
689 index = hindex(1,i) - 1
690 n_orb = hindex(2,i)-hindex(1,i) + 1;
693 rhoat_bml_ptr(index,index) = numel(spindex(i));
695 if(numel(spindex(i)) <= 2)
then
697 rhoat_bml_ptr(index,index) = numel(spindex(i));
699 rhoat_bml_ptr(index,index) = 0.0_dp;
701 rhoat_bml_ptr(index,index) = 0.0_dp;
703 rhoat_bml_ptr(index,index) = 0.0_dp;
706 rhoat_bml_ptr(index,index) = 2.0_dp;
709 occ = (numel(spindex(i))-2.0_dp)/3.0_dp;
710 rhoat_bml_ptr(index,index) = occ;
712 rhoat_bml_ptr(index,index) = occ;
714 rhoat_bml_ptr(index,index) = occ;
722 allocate(rhoat(norb))
724 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,rhoat_bml)
729 n_orb = hindex(2,i)-hindex(1,i) + 1;
732 rhoat(index) = numel(spindex(i));
734 if(numel(spindex(i)) <= 2)
then
736 rhoat(index) = numel(spindex(i));
738 rhoat(index) = 0.0_dp;
740 rhoat(index) = 0.0_dp;
742 rhoat(index) = 0.0_dp;
745 rhoat(index) = 2.0_dp;
748 occ = (numel(spindex(i))-2.0_dp)/3.0_dp;
758 call bml_set_diagonal(rhoat_bml,rhoat,0.0_dp)
777 integer :: i, j, k, m
779 real(
dp) :: ft1, ft2, kb, prod
780 real(
dp) :: t, step, tol, nel
781 real(
dp),
intent(in) :: bndfil, eigenvalues(:), kbt
782 real(
dp),
intent(inout) :: ef
783 logical,
intent(inout) :: err
785 norb =
size(eigenvalues,dim=1)
786 nel = bndfil*2.0_dp*norb
788 step=abs((eigenvalues(norb)-eigenvalues(1)))
795 ft1 = ft1 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
804 write(*,*)
"WARNING: Bisection method in prg_get_flevel not converging ..."
807 if(abs(ft1).lt.tol)
then
817 ft2 = ft2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
851 real(
dp) :: ef0, f1, f2, nel
853 real(
dp),
intent(in) :: bndfil, kbt
854 real(
dp),
intent(in) :: tol, eigenvalues(:)
855 real(
dp),
intent(inout) :: ef
856 integer,
optional,
intent(in) :: verbose
857 logical,
intent(inout) :: err
859 norb =
size(eigenvalues, dim=1)
860 nel = bndfil*2.0_dp*real(norb,
dp)
871 f1 = f1 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
884 f2 = f2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
890 if(abs(f2 - f1) < 1.0d-5)
then
895 ef = -f2*step/(f2-f1) + ef0
901 write(*,*)
"WARNING: Newton method in prg_get_flevel_nt is not converging ..."
913 f2 = f2 + 2.0_dp*
fermi(eigenvalues(i),ef,kbt)
919 ef = -f2*step/(f2-f1) + ef0
922 if(abs(f1).lt.tol)
then
937 character(20) :: bml_type
939 integer,
intent(in) :: verbose
941 real(
dp),
allocatable :: aux(:,:)
942 real(
dp),
allocatable,
intent(inout) :: eigenvalues(:)
943 type(bml_matrix_t) :: aux_bml, eigenvectors_bml
944 type(bml_matrix_t),
intent(in) :: ham_bml
946 norb = bml_get_n(ham_bml)
947 bml_type = bml_get_deep_type(ham_bml)
949 if(verbose.ge.1)
write(*,*)
"In prg_get_eigenvalues ..."
950 if(verbose.ge.1)
write(*,*)
"Number of states =",norb
952 if(.not.
allocated(eigenvalues))
allocate(eigenvalues(norb))
955 if(trim(bml_type).ne.
"dense")
then
956 allocate(aux(norb,norb))
957 call bml_export_to_dense(ham_bml,aux)
958 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,aux_bml)
959 call bml_import_from_dense(bml_matrix_dense,aux,aux_bml,0.0_dp,norb)
962 call bml_copy_new(ham_bml,aux_bml)
965 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,eigenvectors_bml)
967 call bml_diagonalize(aux_bml,eigenvalues,eigenvectors_bml)
969 call bml_deallocate(eigenvectors_bml)
970 call bml_deallocate(aux_bml)
982 character(20) :: bml_type
984 real(
dp),
intent(in) :: threshold
985 real(
dp),
intent(out) :: idempotency
986 type(bml_matrix_t) :: aux_bml
987 type(bml_matrix_t),
intent(in) :: mat_bml
989 call bml_copy_new(mat_bml, aux_bml)
991 call bml_multiply(mat_bml, mat_bml, aux_bml, 1.0_dp, 0.0_dp, threshold)
992 call bml_add_deprecated(1.0_dp,aux_bml,-1.0_dp,mat_bml, threshold)
994 idempotency = bml_fnorm(aux_bml)
996 call bml_deallocate(aux_bml)
1006 real(
dp),
intent(in) :: e, ef, kbt
1008 if ((e-ef)/kbt > 100.0_dp)
then
1011 fermi = 1.0_dp/(1.0_dp+exp((e-ef)/(kbt)))
1022 real(
dp),
intent(in) :: e, ef, kbt
1025 if ((e-ef)/kbt > 100.0_dp)
then
1026 if (abs(e-ef)<0.001_dp)
then
1030 dfermi = 1.0_dp/(1.0_dp+exp((e-ef)/(kbt)))
1048 integer,
optional,
intent(in) :: verbose
1049 type(bml_matrix_t),
intent(in) :: mat_bml, evects_bml
1050 type(bml_matrix_t),
intent(inout) :: mateig_bml
1051 type(bml_matrix_t) :: aux_bml
1052 real(
dp),
intent(in) :: threshold
1053 integer :: hdim, mdim
1054 character(20) :: bml_type
1056 if(verbose.eq.1)
write(*,*)
"In prg_toEigenspace ..."
1058 hdim= bml_get_n(mat_bml)
1059 mdim= bml_get_m(mat_bml)
1060 bml_type = bml_get_type(mat_bml)
1062 if(bml_get_n(mateig_bml) < 0)
then
1063 call bml_zero_matrix(bml_type,bml_element_real,
dp,hdim ,mdim,mateig_bml, &
1064 & bml_get_distribution_mode(mat_bml))
1067 call bml_transpose_new(evects_bml, aux_bml)
1069 call bml_multiply(aux_bml, mat_bml, mateig_bml, 1.0_dp, 0.0_dp,threshold)
1071 call bml_multiply(mateig_bml, evects_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
1073 call bml_copy(aux_bml, mateig_bml)
1075 call bml_deallocate(aux_bml)
1092 integer,
optional,
intent(in) :: verbose
1093 type(bml_matrix_t),
intent(in) :: mat_bml, evects_bml
1094 type(bml_matrix_t),
intent(inout) :: matcan_bml
1095 type(bml_matrix_t) :: aux_bml
1096 real(
dp),
intent(in) :: threshold
1097 integer :: hdim, mdim
1098 character(20) :: bml_type
1100 if(verbose.eq.1)
write(*,*)
"In prg_toCacninicalspace ..."
1102 hdim= bml_get_n(mat_bml)
1103 mdim= bml_get_m(mat_bml)
1104 bml_type = bml_get_type(mat_bml)
1107 if(bml_get_n(matcan_bml) < 0)
then
1108 call bml_zero_matrix(bml_type,bml_element_real,
dp,hdim ,mdim,matcan_bml,&
1109 & bml_get_distribution_mode(mat_bml))
1114 call bml_transpose_new(evects_bml, aux_bml)
1115 call bml_multiply(mat_bml, aux_bml, matcan_bml, 1.0_dp, 0.0_dp,threshold)
1117 call bml_multiply(evects_bml,matcan_bml, aux_bml, 1.0_dp, 0.0_dp,threshold)
1119 call bml_copy(aux_bml, matcan_bml)
1121 call bml_deallocate(aux_bml)
1129 integer,
parameter :: prec = 8
1130 real(prec),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
1131 integer,
intent(in) :: hdim, m
1132 real(prec),
intent(in) :: h1(hdim,hdim), q(hdim,hdim), e(hdim), nocc
1133 real(prec),
intent(out) :: p1(hdim,hdim)
1134 real(prec),
intent(in) :: t, mu0
1135 real(prec) :: x(hdim,hdim), dx1(hdim,hdim), y(hdim,hdim)
1136 real(prec) :: h_0(hdim), p_0(hdim), dpdmu(hdim), p_02(hdim),id0(hdim)
1137 real(prec) :: beta, cnst, kb, mu1, sumdpdmu
1138 integer :: i, j, k, norbscore
1143 cnst = beta/(1.d0*2**(m+2))
1144 p_0 = 0.5d0 + cnst*(h_0-mu0)
1158 dx1(k,j) = p_0(k)*p1(k,j) + p1(k,j)*p_0(j)
1161 id0 = 1.d0/(2.d0*(p_02-p_0)+1.d0)
1165 p1(k,j) = id0(k)*(dx1(k,j) + 2.d0*(p1(k,j)-dx1(k,j))*p_0(j))
1169 dpdmu = beta*p_0*(1.d0-p_0)
1175 sumdpdmu = sumdpdmu + dpdmu(i)
1182 p1(i,i) = p1(i,i) + mu1*dpdmu(i)
1192 subroutine eig(A,Q,ee,TYPE,HDIM)
1195 integer,
parameter :: PREC = 8
1196 integer,
intent(in) :: HDIM
1198 integer :: DIAG_LWORK
1199 real(PREC) :: DIAG_WORK(1+6*HDIM+2*HDIM*HDIM)
1200 integer :: DIAG_LIWORK
1201 integer :: DIAG_IWORK(3+5*HDIM)
1202 real(PREC),
intent(in) :: A(HDIM,HDIM)
1203 real(PREC),
intent(out) :: Q(HDIM,HDIM), ee(HDIM)
1204 real(PREC) :: EVECS(HDIM,HDIM), EVALS(HDIM)
1205 character(LEN=1),
parameter :: JOBZ =
"V", uplo =
"U"
1206 character(1),
intent(in) ::
TYPE
1208 diag_lwork = 1+6*hdim+2*hdim*hdim
1209 diag_liwork = 3 + 5*hdim
1212 CALL dsyevd(jobz, uplo, hdim, evecs, hdim, evals, &
1213 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()