18 integer,
parameter ::
dp = kind(1.0d0)
19 real(
dp),
parameter ::
pi = 3.14159265358979323846264338327950_dp
22 character(20) :: respmode
23 character(20) :: typeofpert
24 character(20) :: bmltype
27 logical :: computedipole
28 logical :: getresponse
29 real(
dp) :: fieldintensity
48 integer,
parameter :: nkey_char = 3, nkey_int = 4, nkey_re = 5, nkey_log = 2
49 character(len=*) :: filename
52 character(len=50),
parameter :: keyvector_char(nkey_char) = [character(len=100) :: &
53 'TypeOfPert=',
'BMLType=',
'RespMode=']
54 character(len=100) :: valvector_char(nkey_char) = [character(len=100) :: &
55 'None',
'Dense',
'RayleighSchrodinger']
57 character(len=50),
parameter :: keyvector_int(nkey_int) = [character(len=50) ::
'Mdim=' &
58 ,
'p2=',
'p3=',
'p4=']
59 integer :: valvector_int(nkey_int) = (/0 &
62 character(len=50),
parameter :: keyvector_re(nkey_re) = [character(len=50) :: &
63 'Fieldx=',
'Fieldy=',
'Fieldz=' &
64 ,
'FieldIntensity=',
'NumThresh=' ]
65 real(
dp) :: valvector_re(nkey_re) = (/0.0,0.0,0.0&
68 character(len=50),
parameter :: keyvector_log(nkey_log) = [character(len=100) :: &
69 'ComputeDipole=',
'GetResponse=']
70 logical :: valvector_log(nkey_log) = (/ .false., .false./)
74 character(len=50),
parameter :: startstop(2) = [character(len=50) :: &
78 ,keyvector_int,valvector_int,keyvector_re,valvector_re,&
79 keyvector_log,valvector_log,trim(filename),startstop)
82 respdata%TypeofPert = valvector_char(1)
84 if(valvector_char(2) ==
"Dense")
then
85 respdata%BmlType = bml_matrix_dense
86 elseif(valvector_char(2) ==
"Ellpack")
then
87 respdata%BmlType = bml_matrix_ellpack
88 elseif(valvector_char(2) ==
"Ellblock")
then
89 respdata%BmlType = bml_matrix_ellblock
92 respdata%RespMode = valvector_char(3)
95 respdata%Field(1) = valvector_re(1)
96 respdata%Field(2) = valvector_re(2)
97 respdata%Field(3) = valvector_re(3)
98 respdata%FieldIntensity = valvector_re(4)
99 respdata%NumThresh = valvector_re(5)
102 respdata%ComputeDipole = valvector_log(1)
103 respdata%GetResponse = valvector_log(2)
106 respdata%Mdim = valvector_int(1)
124 integer :: cont, i, nats, verbose
125 real(
dp),
intent(in) :: charges(:), coordinate(:,:), factor
126 real(
dp),
intent(inout) :: dipolemoment(3)
128 if(verbose.gt.1)
write(*,*)
"Computing dipole moment ..."
132 nats =
size(charges,dim=1)
134 dipolemoment = 0.0_dp
137 dipolemoment(1)=dipolemoment(1)+coordinate(1,i)*charges(i)
138 dipolemoment(2)=dipolemoment(2)+coordinate(2,i)*charges(i)
139 dipolemoment(3)=dipolemoment(3)+coordinate(3,i)*charges(i)
142 dipolemoment=factor*dipolemoment
144 write(*,*)
"dipoleMomentx=",dipolemoment(1)
145 write(*,*)
"dipoleMomenty=",dipolemoment(2)
146 write(*,*)
"dipoleMomentz=",dipolemoment(3)
162 integer :: verbose, io_unit
163 real(
dp),
intent(in) :: factor
164 real(
dp),
intent(in) :: dipolemoment(3)
165 character(*),
intent(in) :: file
169 write(io_unit,*)
"mol new ",file
170 write(io_unit,*)
"set molid 0"
172 write(io_unit,*)
"proc vmd_draw_arrow {mol start end} {"
173 write(io_unit,*)
" set middle [vecadd $start [vecscale 0.9 [vecsub $end $start]]]"
174 write(io_unit,*)
" graphics $mol cylinder $start $middle radius 0.15"
175 write(io_unit,*)
" graphics $mol cone $middle $end radius 0.25"
178 write(io_unit,*)
"draw arrow {0 0 0} {",&
179 factor*dipolemoment(1), factor*dipolemoment(2), factor*dipolemoment(3),
"}"
202 integer :: cont, i, nats, verbose
203 real(
dp),
intent(in) :: factor
204 real(
dp),
intent(inout) :: polarizability
205 real(
dp) :: dipolez, dipolex, dipoley
206 type(bml_matrix_t),
intent(in) :: prt_bml, rsp_bml
207 type(bml_matrix_t) :: aux_bml
209 if(verbose.gt.1)
write(*,*)
"Computing polarizability ..."
211 call bml_copy_new(prt_bml,aux_bml)
212 call bml_multiply(rsp_bml,prt_bml,aux_bml,1.0_dp,0.0_dp,0.0_dp)
214 polarizability = -factor*bml_trace(aux_bml)
216 write(*,*)
"Polarizability=",polarizability
218 call bml_deallocate(aux_bml)
227 integer :: norb, verbose
228 type(bml_matrix_t),
intent(inout) :: prt_bml
229 if(verbose.gt.1)
write(*,*)
'Reading perturbation V from file ...'
251 ,bndfil,threshold,verbose)
253 character(20) :: bml_type
254 integer :: i, j, l, norb
256 real(
dp) :: lambda, nocc
257 real(
dp),
allocatable :: aux(:,:), evals(:), row(:)
258 real(
dp),
intent(in) :: bndfil, threshold
259 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml, umat_bml
260 type(bml_matrix_t) :: aux2_bml
261 type(bml_matrix_t),
intent(in) :: ham_bml, prt_bml
262 type(bml_matrix_t),
intent(inout) :: rsp_bml
264 norb = bml_get_n(ham_bml)
266 if(verbose.ge.1)
write(*,*)
'In prg_compute_response_RS... Norbs = ', norb
268 allocate(evals(norb))
270 bml_type = bml_get_type(ham_bml)
273 allocate(aux(norb,norb))
274 call bml_export_to_dense(ham_bml,aux)
275 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,aux_bml)
276 call bml_import_from_dense(bml_matrix_dense,aux,aux_bml,threshold,norb)
279 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,umat_bml)
282 call bml_diagonalize(aux_bml,evals,umat_bml)
283 call bml_deallocate(aux_bml)
286 allocate(aux(norb,norb))
287 call bml_export_to_dense(umat_bml,aux)
288 call bml_deallocate(umat_bml)
289 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,umat_bml)
290 call bml_import_from_dense(bml_type,aux,umat_bml,threshold,norb)
293 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux_bml)
294 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux1_bml)
297 call bml_transpose(umat_bml,aux_bml)
299 call bml_multiply(aux_bml,prt_bml,aux1_bml,1.0_dp,0.0_dp,threshold)
301 call bml_multiply(aux1_bml,umat_bml,aux_bml,1.0_dp,0.0_dp,threshold)
306 call bml_get_row(aux_bml,i,row)
309 row(j) = row(j)/(evals(j)-evals(i))
314 call bml_set_row(aux_bml,i,row,threshold)
319 call bml_multiply(umat_bml,aux_bml,aux1_bml,1.0_dp,0.0_dp,threshold)
323 write(*,*)
"Trace CV",bml_trace(aux_bml), nocc
332 if(abs(nocc - int(nocc)).gt.0.01_dp)
then
333 evals(int(nocc)+1) = 1.0_dp
336 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,occupation_bml)
337 call bml_set_diagonal(occupation_bml, evals)
341 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,aux2_bml)
342 call bml_multiply(umat_bml,occupation_bml,aux_bml,1.0_dp,0.0_dp,threshold)
343 call bml_transpose(aux1_bml,aux2_bml)
344 call bml_multiply(aux_bml,aux2_bml,rsp_bml,1.0_dp,0.0_dp,threshold)
347 call bml_transpose(umat_bml,aux2_bml)
348 call bml_multiply(occupation_bml,aux2_bml,aux_bml,1.0_dp,0.0_dp,threshold)
350 call bml_deallocate(occupation_bml)
351 call bml_deallocate(umat_bml)
353 call bml_multiply(aux1_bml,aux_bml,rsp_bml,1.0_dp,1.0_dp,threshold)
354 call bml_scale(1.0_dp,rsp_bml)
356 write(*,*)
"Trace",bml_trace(rsp_bml)
358 call bml_deallocate(aux_bml)
359 call bml_deallocate(aux1_bml)
381 ,bndfil,threshold,verbose)
383 character(20) :: bml_type
384 integer :: i, j, l, norb
386 real(
dp) :: prg_delta, nocc
387 real(
dp),
allocatable :: resp(:,:), evals(:), row(:)
388 real(
dp),
intent(in) :: bndfil, threshold
389 type(bml_matrix_t) :: rhoplus_bml, rhominus_bml, occupation_bml, umat_bml
390 type(bml_matrix_t) :: aux_bml
391 type(bml_matrix_t),
intent(in) :: ham_bml, prt_bml
392 type(bml_matrix_t),
intent(inout) :: rsp_bml
394 norb = bml_get_n(ham_bml)
396 if(verbose.ge.1)
write(*,*)
'In prg_compute_response_RS... Norbs = ', norb
398 allocate(resp(norb,norb))
400 call bml_copy_new(ham_bml,aux_bml)
402 bml_type = bml_get_type(ham_bml)
405 call bml_add_deprecated(1.0_dp, aux_bml, prg_delta, prt_bml, threshold)
407 call bml_copy_new(ham_bml,rhoplus_bml)
413 call bml_add_deprecated(1.0_dp, aux_bml, -2.0_dp*prg_delta, prt_bml, threshold)
415 call bml_copy_new(ham_bml,rhominus_bml)
421 call bml_add_deprecated(1.0_dp, rhoplus_bml, -1.0_dp, rhominus_bml, threshold)
422 call bml_scale(1.0_dp/(2.0_dp*prg_delta),rhoplus_bml,rsp_bml)
448 ,prt_bml,threshold,spindex,norbi,verbose,over_bml)
450 integer :: cont, i, ii, nats
452 integer,
intent(in) :: spindex(:), norbi(:), verbose
453 real(
dp) :: fieldnorm, fieldx, fieldy, fieldz
454 real(
dp) :: intensity, lambda, threshold
455 real(
dp),
allocatable :: diag(:)
456 real(
dp),
intent(in) :: coordinate(:,:), field(3)
457 type(bml_matrix_t) :: aux_bml
458 type(bml_matrix_t),
intent(inout) :: prt_bml
459 type(bml_matrix_t),
optional,
intent(in) :: over_bml
461 write(*,*)
'Applying a constant field perturbation ...'
467 nats=
size(spindex,dim=1)
468 norb=sum(norbi(spindex(:)))
472 fieldnorm=sqrt(fieldx**2+fieldy**2+fieldz**2)
474 fieldx=intensity*fieldx/fieldnorm
475 fieldy=intensity*fieldy/fieldnorm
476 fieldz=intensity*fieldz/fieldnorm
483 do ii=1,norbi(spindex(i))
485 diag(cont)=lambda*(fieldx*coordinate(1,i) + &
486 fieldy*coordinate(2,i) + fieldz*coordinate(3,i))
490 if(bml_get_n(prt_bml) < 0) stop
"bml_pert not allocated"
492 call bml_set_diagonal(prt_bml,diag,threshold)
496 if(
present(over_bml))
then
497 call bml_copy_new(prt_bml,aux_bml)
498 call bml_multiply(over_bml,aux_bml,prt_bml,0.5_dp, 0.0_dp,threshold)
499 call bml_multiply(aux_bml,over_bml,prt_bml,0.5_dp,1.0_dp,threshold)
500 call bml_deallocate(aux_bml)
525 ,prt_bml,threshold,spindex,norbi,verbose,over_bml)
527 integer :: cont, i, ii, nats
529 integer,
intent(in) :: spindex(:), norbi(:), verbose
530 real(
dp) :: fieldnorm, fieldx, fieldy, fieldz
532 real(
dp) :: intensity, lambda, threshold
533 real(
dp),
allocatable :: diag(:)
534 real(
dp),
intent(in) :: coordinate(:,:)
535 type(bml_matrix_t) :: aux_bml
536 type(bml_matrix_t),
intent(inout) :: prt_bml
537 type(bml_matrix_t),
optional,
intent(in) :: over_bml
538 character :: direction
540 write(*,*)
'Applying a constant field perturbation ...'
542 nats=
size(spindex,dim=1)
543 norb=sum(norbi(spindex(:)))
552 do ii=1,norbi(spindex(i))
554 diag(cont)=lambda*sin(2.0_dp*
pi*((coordinate(1,i)-lx)/lx)-
pi)
558 if(bml_get_n(prt_bml) < 0) stop
"bml_pert not allocated"
560 call bml_set_diagonal(prt_bml,diag,threshold)
564 if(
present(over_bml))
then
565 call bml_copy_new(prt_bml,aux_bml)
566 call bml_multiply(over_bml,aux_bml,prt_bml,0.5_dp, 0.0_dp,threshold)
567 call bml_multiply(aux_bml,over_bml,prt_bml,0.5_dp,1.0_dp,threshold)
568 call bml_deallocate(aux_bml)
593 ,prt_bml,threshold,spindex,norbi,verbose,over_bml)
595 integer :: cont, i, ii, nats
597 integer,
intent(in) :: spindex(:), norbi(:), verbose
598 real(
dp) :: fieldnorm, fieldx, fieldy, fieldz
600 real(
dp) :: intensity, lambda, threshold
601 real(
dp),
allocatable :: diag(:)
602 real(
dp),
intent(in) :: coordinate(:,:)
603 type(bml_matrix_t) :: aux_bml
604 type(bml_matrix_t),
intent(inout) :: prt_bml
605 type(bml_matrix_t),
optional,
intent(in) :: over_bml
606 character :: direction
608 write(*,*)
'Applying a constant field perturbation ...'
610 nats=
size(spindex,dim=1)
611 norb=sum(norbi(spindex(:)))
620 do ii=1,norbi(spindex(i))
622 diag(cont)=lambda*cos(2.0_dp*
pi*((coordinate(1,i)-lx)/lx)-
pi)
626 if(bml_get_n(prt_bml) < 0) stop
"bml_pert not allocated"
628 call bml_set_diagonal(prt_bml,diag,threshold)
632 if(
present(over_bml))
then
633 call bml_copy_new(prt_bml,aux_bml)
634 call bml_multiply(over_bml,aux_bml,prt_bml,0.5_dp, 0.0_dp,threshold)
635 call bml_multiply(aux_bml,over_bml,prt_bml,0.5_dp,1.0_dp,threshold)
636 call bml_deallocate(aux_bml)
654 ,bndfil,minsp2iter,maxsp2iter,sp2conv,idemtol,threshold,verbose)
656 character(20) :: bml_type
657 integer :: i, j, l, norb
658 integer :: verbose, mdim
659 integer,
intent(in) :: minsp2iter, maxsp2iter
660 real(
dp) :: lambda, occ, maxminusmin
661 real(
dp) :: alpha, beta, trx, trd
662 real(
dp),
allocatable :: aux(:,:), evals(:), row(:), gbnd(:)
663 real(
dp),
intent(in) :: bndfil, threshold,idemtol
664 character(len=*),
intent(in) :: sp2conv
665 type(bml_matrix_t) :: aux1_bml, aux_bml, occupation_bml
666 type(bml_matrix_t) :: x2_bml
667 type(bml_matrix_t),
intent(in) :: ham_bml, prt_bml
668 type(bml_matrix_t),
intent(inout) :: rsp_bml, rho_bml
669 real(
dp) :: idemperr, idemperr1, idemperr2
670 integer :: iter, breakloop
671 real(
dp) :: trx2, trxold, tr2xx2
673 real(
dp),
allocatable :: trace(:)
675 if(verbose.ge.1)
write(*,*)
'In prg_compute_response_SP2... '
677 norb = bml_get_n(ham_bml)
678 bml_type = bml_get_type(ham_bml)
679 mdim = bml_get_m(ham_bml)
685 if(bml_get_n(rsp_bml).le.0)
then
686 call bml_zero_matrix(bml_matrix_dense,bml_element_real,
dp,norb,norb,rsp_bml)
689 occ = bndfil*float(norb)
691 call bml_copy(ham_bml, rho_bml)
692 call bml_copy(prt_bml,rsp_bml)
695 call bml_gershgorin(ham_bml, gbnd)
696 maxminusmin = gbnd(2) - gbnd(1)
697 alpha = -1.00_dp/maxminusmin
698 beta = gbnd(2)/maxminusmin
699 call bml_scale_add_identity(rho_bml, alpha, beta, 0.00_dp)
700 call bml_scale(alpha, rsp_bml)
703 trx = bml_trace(rho_bml)
704 trd = bml_trace(rsp_bml)
710 call bml_copy_new(rho_bml, x2_bml)
711 call bml_copy_new(rsp_bml, aux_bml)
713 do while (breakloop .eq. 0 .and. iter .lt. maxsp2iter)
716 call bml_print_matrix(
"rsp_bml",rsp_bml,0,1,0,1)
719 call bml_multiply_x2(rho_bml, x2_bml, threshold, trace)
720 trd = bml_trace(rsp_bml)
723 call bml_multiply(rho_bml, rsp_bml, aux_bml, 1.0d0, 0.0d0)
724 call bml_multiply(rsp_bml,rho_bml, aux_bml, 1.0d0, 1.0d0)
727 write(*,*)
'iter = ', iter,
'trx = ', trx,
' trx2 = ', trx2
728 write(*,*)
'iter = ', iter,
'tr(resp) = ', trd
730 tr2xx2 = 2.0_dp*trx - trx2
732 limdiff = abs(trx2 - occ) - abs(tr2xx2 - occ)
734 if (limdiff .ge. idemtol)
then
737 call bml_add_deprecated(2.0_dp, rho_bml, -1.0_dp, x2_bml, threshold)
738 call bml_add_deprecated(2.0_dp,rsp_bml,-1.0_dp, aux_bml, threshold)
740 trx = 2.0_dp * trx - trx2
742 elseif(limdiff .lt. -idemtol)
then
745 call bml_copy(x2_bml, rho_bml)
746 call bml_copy(aux_bml, rsp_bml)
757 idemperr2 = idemperr1
759 idemperr = abs(trx - trxold)
761 if (sp2conv .eq.
"Rel" .and. iter .ge. minsp2iter .and. &
762 (idemperr .ge. idemperr2 .or. idemperr .lt. idemtol))
then
766 if (iter .eq. maxsp2iter)
then
767 write(*,*)
"SP2 purification is not converging: STOP!"
774 call bml_scale(2.0_dp, rho_bml)
775 call bml_scale(2.0_dp, rsp_bml)
777 call bml_deallocate(x2_bml)
778 call bml_deallocate(aux_bml)
799 integer :: cont, i, j, nats
801 integer,
intent(in) :: norbi(:), spindex(:), verbose
802 real(
dp),
allocatable :: diagonal(:)
803 real(
dp),
allocatable,
intent(inout) :: rspfunc(:)
804 real(
dp),
intent(in) :: coordinates(:,:)
805 type(bml_matrix_t) :: aux_bml
806 type(bml_matrix_t),
intent(in) :: over_bml
807 type(bml_matrix_t),
intent(inout) :: rsp_bml
809 nats=
size(spindex, dim=1)
810 norbs=bml_get_n(rsp_bml)
811 call bml_copy_new(rsp_bml,aux_bml)
812 call bml_multiply(rsp_bml,over_bml,aux_bml,1.0_dp,0.0_dp,0.0_dp)
814 if(.not.
allocated(rspfunc))
allocate(rspfunc(nats))
815 allocate(diagonal(norbs))
817 call bml_get_diagonal(aux_bml,diagonal)
823 do j=1,norbi(spindex(i))
825 rspfunc(i) = rspfunc(i) + diagonal(cont)
831 call bml_deallocate(aux_bml)
851 real(
dp),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
852 type(bml_matrix_t),
intent(inout) :: p1_bml, h1_bml
853 type(bml_matrix_t) :: x_bml
854 integer,
intent(in) :: hdim, m
855 real(
dp),
intent(in) :: evals(hdim), thresh
856 real(
dp),
intent(in) :: beta, mu0
857 real(
dp),
intent(in) :: nocc
858 real(
dp) :: x(hdim,hdim), dx1(hdim,hdim), y(hdim,hdim)
859 real(
dp) :: h_0(hdim), p_0(hdim), dpdmu(hdim), p_02(hdim),id0(hdim)
860 real(
dp) :: cnst, kb, mu1
861 real(
dp),
allocatable :: focc(:), row1(:)
862 real(
dp) :: tmp, tmp2, dmu
864 character(20) :: bml_type
870 focc(i) = 1.0/(1+exp(beta*(evals(i) - mu0)))
874 x(j, i) = evals(i) - evals(j)
875 y(j, i) = focc(i) - focc(j)
881 tmp = exp((evals(i) - mu0) * beta)
882 tmp2 = (1.d0 + tmp) * (1.d0 + tmp)
883 dpdmu(i) = -tmp/tmp2 * beta
887 x(i,i) = x(i,i) + 1.d0
892 x(j,i) = y(j,i) / x(j,i)
894 x(i,i) = x(i,i) + dpdmu(i)
899 bml_type = bml_get_type(h1_bml)
902 call bml_zero_matrix(bml_type, bml_element_real,
dp, hdim, hdim, x_bml)
904 call bml_import_from_dense(bml_type, x, x_bml, thresh,hdim)
905 call bml_element_multiply_ab(x_bml, h1_bml, p1_bml, thresh)
906 call bml_get_diagonal(p1_bml,row1)
912 tmp2 = tmp2 + row1(i)
915 if (abs(tmp) > 1.d-12)
then
922 row1(i) = row1(i) - dmu * x(i,i)
926 call bml_set_diagonal(p1_bml, row1)
927 call bml_deallocate(x_bml)
949 type(bml_matrix_t),
intent(inout) :: p1_bml, h1_bml
950 type(bml_matrix_t) :: dx1_bml
951 real(
dp),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
952 integer,
intent(in) :: hdim, m
953 real(
dp),
intent(in) :: evals(hdim)
954 real(
dp),
intent(in) :: beta, mu0
955 real(
dp) :: x(hdim,hdim), dx1(hdim,hdim), y(hdim,hdim)
956 real(
dp) :: h_0(hdim), p_0(hdim), dpdmu(hdim), p_02(hdim),id0(hdim)
957 real(
dp) :: cnst, kb, mu1
958 real(
dp),
allocatable :: row1(:), row2(:)
959 real(
dp),
intent(in) :: nocc
964 cnst = beta/(1.d0*2**(m+2))
965 p_0 = 0.5d0 + cnst*(h_0-mu0)
967 call bml_copy_new(h1_bml,p1_bml)
968 call bml_copy_new(h1_bml,dx1_bml)
969 call bml_scale(-cnst,p1_bml)
980 call bml_get_row(p1_bml,k,row1)
982 row2(j) = p_0(k)*row1(j) + row1(j)*p_0(j)
984 call bml_set_row(dx1_bml,k,row2)
987 id0 = 1.d0/(2.d0*(p_02-p_0)+1.d0)
994 call bml_get_row(p1_bml,k,row1)
995 call bml_get_row(dx1_bml,k,row2)
997 row1(j) = id0(k)*(row2(j) + 2.d0*(row1(j)-row2(j))*p_0(j))
999 call bml_set_row(p1_bml,k,row1)
1006 call bml_deallocate(dx1_bml)
1008 dpdmu = beta*p_0*(1.d0-p_0)
1010 call bml_get_diagonal(p1_bml,row1)
1015 mu1 = -mu1/sum(dpdmu)
1017 row1(i) = row1(i) + mu1*dpdmu(i)
1019 call bml_set_diagonal(p1_bml,row1)
1040 type(bml_matrix_t),
intent(inout) :: p1_bml, h1_bml
1041 type(bml_matrix_t) :: dx1_bml
1042 real(
dp),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
1043 integer,
intent(in) :: hdim, m
1044 real(
dp),
intent(in) :: evals(hdim), thresh
1045 real(
dp),
intent(in) :: beta, mu0
1046 real(
dp) :: x(hdim,hdim), dx1(hdim,hdim), y(hdim,hdim)
1047 real(
dp) :: h_0(hdim), p_0(hdim), dpdmu(hdim),p_02(hdim),id0(hdim)
1048 real(
dp) :: cnst, kb, mu1
1049 real(
dp),
allocatable :: p1(:,:), h1(:,:)
1050 real(
dp),
intent(in) :: nocc
1052 character(20) :: bml_type
1056 cnst = beta/(1.d0*2**(m+2))
1057 p_0 = 0.5d0 + cnst*(h_0-mu0)
1058 bml_type = bml_get_type(h1_bml)
1059 if(.not.
allocated(h1))
allocate(h1(hdim,hdim))
1060 call bml_export_to_dense(h1_bml,h1)
1061 if(.not.
allocated(p1))
allocate(p1(hdim,hdim))
1072 dx1(k,j) = p_0(k)*p1(k,j) + p1(k,j)*p_0(j)
1076 id0 = 1.d0/(2.d0*(p_02-p_0)+1.d0)
1084 p1(k,j) = id0(k)*(dx1(k,j) + 2.d0*(p1(k,j)-dx1(k,j))*p_0(j))
1090 dpdmu = beta*p_0*(1.d0-p_0)
1096 mu1 = -mu1/sum(dpdmu)
1098 p1(i,i) = p1(i,i) + mu1*dpdmu(i)
1101 call bml_import_from_dense(bml_type, p1, p1_bml, thresh,hdim)
1114 type(bml_matrix_t),
intent(inout) :: p1_bml, h1_bml
1115 type(bml_matrix_t) :: dx1_bml
1116 type(bml_matrix_t) :: q_bml
1117 real(
dp),
parameter :: one = 1.d0, two = 2.d0, zero = 0.d0
1118 integer,
intent(in) :: hdim, m, norbs
1119 real(
dp),
intent(in) :: evals(hdim)
1120 real(
dp),
intent(inout) :: dpdmu(hdim)
1123 real(
dp),
intent(in) :: beta, mu0
1124 real(
dp),
allocatable :: p1(:,:), dx1(:,:)
1125 real(
dp) :: h_0(hdim), p_0(hdim),p_02(hdim),id0(hdim)
1126 real(
dp) :: cnst, kb, mu1, sumdpdmu
1128 character(20) :: bml_type
1132 cnst = beta/(1.d0*2**(m+2))
1133 p_0 = 0.5d0 + cnst*(h_0-mu0)
1134 call bml_copy_new(h1_bml,p1_bml)
1135 call bml_copy_new(h1_bml,dx1_bml)
1136 call bml_scale(-cnst,p1_bml)
1138 allocate(p1(hdim,hdim))
1139 allocate(dx1(hdim,hdim))
1144 call bml_export_to_dense(p1_bml,p1)
1145 call bml_export_to_dense(dx1_bml,dx1)
1154 dx1(k,:) = (p_0(k) + p_0(:))*p1(k,:)
1157 id0 = 1.d0/(2.d0*(p_02-p_0)+1.d0)
1164 p1(k,:) = id0(k)*(dx1(k,:) + 2.d0*(p1(k,:)-dx1(k,:))*p_0(:))
1169 bml_type = bml_get_type(p1_bml)
1170 call bml_import_from_dense(bml_type,p1,p1_bml,zero,hdim)
1175 call bml_deallocate(dx1_bml)
1177 dpdmu = beta*p_0*(1.d0-p_0)
Module to obtain the density matrix by diagonalizing an orthogonalized Hamiltonian.
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...
Some general parsing functions.
subroutine, public prg_parsing_kernel(keyvector_char, valvector_char, keyvector_int, valvector_int, keyvector_re, valvector_re, keyvector_log, valvector_log, filename, startstop)
The general parsing function. It is used to vectorize a set of "keywords" "value" pairs as included i...
Module to handle input output files for the PROGRESS lib.
subroutine, public prg_open_file(io, name)
Opens a file to write.
Module to compute the density matrix response and related quantities.
subroutine, public prg_canon_response_orig(P1_bml, H1_bml, Nocc, beta, evals, mu0, m, thresh, HDIM)
First-order Canonical Density Matrix Perturbation Theory.
subroutine, public prg_canon_response(P1_bml, H1_bml, Nocc, beta, evals, mu0, m, HDIM)
First-order Canonical Density Matrix Perturbation Theory.
subroutine, public prg_project_response(rsp_bml, over_bml, spindex, norbi, coordinates, rspfunc, verbose)
Project the response onto atomic positions. First order response to the perturbation ( ) projected on...
subroutine, public prg_compute_response_rs(ham_bml, prt_bml, rsp_bml, lambda, bndfil, threshold, verbose)
Computes the first order response density matrix using Rayleigh Schrodinger Perturbation theory The t...
subroutine, public prg_compute_dipole(charges, coordinate, dipoleMoment, factor, verbose)
To compute the dipole moment of the system. The units of the dipole moment are determined by the unit...
subroutine, public prg_canon_response_vector(P1_bml, H1_bml, Nocc, beta, evals, mu0, m, thresh, HDIM)
First-order Canonical Density Matrix Perturbation Theory.
subroutine, public prg_parse_response(RespData, filename)
The parser for the calculation of the DM response.
subroutine, public prg_canon_response_p1_dpdmu(P1_bml, dPdMu, H1_bml, Norbs, beta, Q_bml, evals, mu0, m, HDIM)
First-order Canonical Density Matrix Perturbation Theory.
subroutine, public prg_write_dipole_tcl(dipoleMoment, file, factor, verbose)
To visualize a dipole moment using VMD. This will prg_generate a .tcl script that could be run using ...
subroutine, public prg_compute_polarizability(rsp_bml, prt_bml, polarizability, factor, verbose)
To compute the polarizability of the system. The units of the directional polarizability are determin...
subroutine, public prg_compute_response_sp2(ham_bml, prt_bml, rsp_bml, rho_bml, lambda, bndfil, minsp2iter, maxsp2iter, sp2conv, idemtol, threshold, verbose)
Finds the first order response matrix from a Hamiltonian matrix.
subroutine, public prg_pert_sin_pot(direction, lx, coordinate, lambda, prt_bml, threshold, spindex, norbi, verbose, over_bml)
Apply a sinusoidal length dependent potential ( ) where is the x coordinate. The Hamiltonian gets mo...
subroutine, public prg_compute_response_fd(ham_bml, prt_bml, rsp_bml, prg_delta, bndfil, threshold, verbose)
Computes the first order response density matrix using finite differences. The transformation hereby ...
subroutine, public prg_pert_cos_pot(direction, lx, coordinate, lambda, prt_bml, threshold, spindex, norbi, verbose, over_bml)
Apply a cosine length dependent potential ( ) where is the x coordinate. The Hamiltonian gets modifi...
subroutine, public prg_pert_from_file(prt_bml, norb)
Read perturbation from file.
subroutine, public prg_pert_constant_field(field, intensity, coordinate, lambda, prt_bml, threshold, spindex, norbi, verbose, over_bml)
Apply a constant field perturbation through the dipole moment operator ( ). In the matrix representat...