18 integer,
parameter ::
dp = kind(1.0d0)
41 type(bml_matrix_t),
intent(in) :: rho_bml
42 type(bml_matrix_t),
intent(in) :: ham_bml
43 type(bml_matrix_t) :: aux_bml
44 type(bml_matrix_t),
intent(inout) :: pcm_bml
45 integer,
intent(in) :: m
46 integer :: norb, verbose
47 real(
dp),
intent(in) :: threshold
49 character(20) :: bml_type
51 if(verbose.eq.2)
write(*,*)
"In prg_PulayComponent0 ..."
53 norb = bml_get_n(rho_bml)
54 bml_type = bml_get_deep_type(rho_bml)
56 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb ,norb,aux_bml)
58 if(bml_get_n(pcm_bml).le.0)
then
59 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,pcm_bml)
64 call bml_scale(0.0_dp, pcm_bml)
67 call bml_multiply(rho_bml, ham_bml, aux_bml, 1.0d0, 1.0d0,threshold)
69 call bml_multiply(aux_bml,rho_bml,pcm_bml, 1.0d0, 1.0d0,threshold)
71 call bml_scale(0.5_dp, pcm_bml)
73 call bml_deallocate(aux_bml)
94 type(bml_matrix_t),
intent(in) :: rho_bml
95 type(bml_matrix_t),
intent(in) :: ham_bml
96 type(bml_matrix_t),
intent(in) :: zmat_bml
97 type(bml_matrix_t) :: aux_bml
98 type(bml_matrix_t) :: aux1_bml
99 type(bml_matrix_t),
intent(inout) :: pcm_bml
100 integer,
intent(in) :: m
101 integer :: norb, verbose
102 real(
dp),
intent(in) :: threshold
103 character(20),
intent(in) :: bml_type
105 if(verbose.eq.2)
write(*,*)
"In prg_PulayComponentT ..."
107 norb = bml_get_n(rho_bml)
109 if(bml_get_n(pcm_bml).le.0)
then
110 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,pcm_bml)
112 call bml_deallocate(pcm_bml)
113 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb,norb,pcm_bml)
116 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb ,norb,aux_bml)
117 call bml_zero_matrix(bml_type,bml_element_real,
dp,norb ,norb,aux1_bml)
119 if(bml_get_n(zmat_bml).lt.0)
then
120 stop
'ERROR: zmat_bml not allocated'
123 call bml_multiply(zmat_bml,zmat_bml,aux_bml,1.0d0,1.0d0,threshold)
125 call bml_multiply(aux_bml,ham_bml,pcm_bml,1.0d0,1.0d0,threshold)
127 call bml_multiply(pcm_bml,rho_bml,aux1_bml,1.0d0,1.0d0,threshold)
129 call bml_scale(0.0_dp, pcm_bml)
131 call bml_multiply(ham_bml,aux_bml,pcm_bml,1.0d0,1.0d0,threshold)
133 call bml_scale(0.0_dp, aux_bml)
135 call bml_multiply(rho_bml,pcm_bml,aux_bml,1.0d0,1.0d0,threshold)
137 call bml_add_deprecated(0.5d0,aux_bml,0.5d0,aux1_bml)
139 call bml_copy(aux_bml,pcm_bml)
141 call bml_deallocate(aux_bml)
142 call bml_deallocate(aux1_bml)
159 dSx_bml,dSy_bml,dSz_bml,hindex,FPUL,threshold)
161 real(
dp),
allocatable,
intent(inout) :: fpul(:,:)
162 integer,
intent(in) :: nats
163 type(bml_matrix_t),
intent(in) :: dsx_bml, dsy_bml, dsz_bml
164 type(bml_matrix_t),
intent(in) :: rho_bml, ham_bml, zmat_bml
165 integer,
intent(in) :: hindex(:,:)
166 integer :: i_a, i_b, i , j, norb
167 real(
dp),
intent(in) :: threshold
168 type(bml_matrix_t) :: xtmp_bml, ytmp_bml, ztmp_bml, sihd_bml
169 type(bml_matrix_t) :: aux_bml
170 real(
dp),
allocatable :: diagxtmp(:), diagytmp(:), diagztmp(:)
171 real(
dp) :: partrace,partracex,partracey,partracez
173 type(c_ptr) :: xtmp_bml_c_ptr, ytmp_bml_c_ptr, ztmp_bml_c_ptr
175 real(c_double),
pointer :: xtmp_bml_ptr(:,:), ytmp_bml_ptr(:,:), ztmp_bml_ptr(:,:)
178 write(*,*)
"In prg_get_pulayforce ..."
180 if(.not.
allocated(fpul))
then
181 allocate(fpul(3,nats))
186 norb = bml_get_n(rho_bml)
189 call bml_copy_new(zmat_bml,sihd_bml)
190 call bml_copy_new(zmat_bml,aux_bml)
191 call bml_transpose(aux_bml)
192 call bml_multiply(zmat_bml,aux_bml,sihd_bml,2.0_dp,0.0_dp,threshold)
193 call bml_multiply(sihd_bml,ham_bml,aux_bml,1.0_dp,0.0_dp,threshold)
194 call bml_multiply(aux_bml,rho_bml,sihd_bml,1.0_dp,0.0_dp,threshold)
195 call bml_deallocate(aux_bml)
197 call bml_copy_new(rho_bml,xtmp_bml)
198 call bml_multiply(dsx_bml,sihd_bml,xtmp_bml,1.0_dp,0.0_dp,threshold)
199 call bml_copy_new(rho_bml,ytmp_bml)
200 call bml_multiply(dsy_bml,sihd_bml,ytmp_bml,1.0_dp,0.0_dp,threshold)
201 call bml_copy_new(rho_bml,ztmp_bml)
202 call bml_multiply(dsz_bml,sihd_bml,ztmp_bml,1.0_dp,0.0_dp,threshold)
205 xtmp_bml_c_ptr = bml_get_data_ptr_dense(xtmp_bml)
206 ytmp_bml_c_ptr = bml_get_data_ptr_dense(ytmp_bml)
207 ztmp_bml_c_ptr = bml_get_data_ptr_dense(ztmp_bml)
208 ld = bml_get_ld_dense(xtmp_bml)
209 call c_f_pointer(xtmp_bml_c_ptr,xtmp_bml_ptr,shape=[ld,norb])
210 call c_f_pointer(ytmp_bml_c_ptr,ytmp_bml_ptr,shape=[ld,norb])
211 call c_f_pointer(ztmp_bml_c_ptr,ztmp_bml_ptr,shape=[ld,norb])
220 do j=hindex(1,i),hindex(2,i)
221 partracex = partracex + xtmp_bml_ptr(j,j)
222 partracey = partracey + ytmp_bml_ptr(j,j)
223 partracez = partracez + ztmp_bml_ptr(j,j)
226 fpul(1,i) = partracex;
227 fpul(2,i) = partracey;
228 fpul(3,i) = partracez;
234 allocate(diagxtmp(norb))
235 call bml_get_diagonal(xtmp_bml,diagxtmp)
237 allocate(diagytmp(norb))
238 call bml_get_diagonal(ytmp_bml,diagytmp)
240 allocate(diagztmp(norb))
241 call bml_get_diagonal(ztmp_bml,diagztmp)
252 partrace = partrace + diagxtmp(j)
254 fpul(1,i) = partrace;
258 partrace = partrace + diagytmp(j)
260 fpul(2,i) = partrace;
264 partrace = partrace + diagztmp(j)
266 fpul(3,i) = partrace;
275 call bml_deallocate(xtmp_bml)
276 call bml_deallocate(ytmp_bml)
277 call bml_deallocate(ztmp_bml)
278 call bml_deallocate(sihd_bml)
Produces a matrix to get the Pulay Component of the forces.
subroutine, public prg_pulaycomponentt(rho_bml, ham_bml, zmat_bml, pcm_bml, threshold, M, bml_type, verbose)
At , .
subroutine, public prg_pulaycomponent0(rho_bml, ham_bml, pcm_bml, threshold, M, verbose)
At , .
subroutine, public prg_get_pulayforce(nats, zmat_bml, ham_bml, rho_bml, dSx_bml, dSy_bml, dSz_bml, hindex, FPUL, threshold)
Pulay Force FPUL from .