21INTEGER (KIND=c_int) FUNCTION g_of_r (NDR, DTR, FCR) bind (C,NAME='g_of_r_')
45INTEGER (KIND=c_int),
INTENT(IN) :: ndr, fcr
46real(kind=c_double),
INTENT(IN) :: dtr
47DOUBLE PRECISION :: hcap1, hcap2, vcap, dgr
48DOUBLE PRECISION :: norm_fact, grlim
49DOUBLE PRECISION :: suml, xsuml
50LOGICAL :: is_crystal=.false.
58 INTEGER,
INTENT(IN) :: ndr
60 LOGICAL FUNCTION grbt(GrToBT, NDTR)
62 INTEGER,
INTENT(IN) :: ndtr
63 DOUBLE PRECISION,
DIMENSION(NDTR,NSP,NSP),
INTENT(IN) :: grtobt
65 DOUBLE PRECISION FUNCTION calcdij (R12, AT1, AT2, STEP_1, STEP_2, SID)
66 DOUBLE PRECISION,
DIMENSION(3),
INTENT(INOUT) :: r12
67 INTEGER,
INTENT(IN) :: at1, at2, step_1, step_2, sid
78 shell_vol(i) = 4.0d0*pi*(((i-1)*dtr+dtr)**3 - ((i-1)*dtr)**3)/3
81 if (overall_cubic .and. i*dtr.gt.mbox)
then
83 if ((i-1)*dtr .le. mbox)
then
88 vcap=hcap1**2*(3*i*dtr - hcap1) - hcap2**2*(3*(i-1)*dtr - hcap2)
90 shell_vol(i)=shell_vol(i)-vcap
98 numth = omp_get_max_threads()
100 if (ns.lt.numth)
then
101 if (numth .ge. 2*(ns-1))
then
108 if (all_atoms) doatoms=.true.
116 if (na.lt.numth) numth=na
125 if (ncells .gt. 1)
then
130 if (dij <= grlim)
then
139 gr_index = int(dgr/dtr)+1
140 norm_fact = 1.0d0/(shell_vol(gr_index)*dble(n))
142 gij(gr_index,l,m,k) = gij(gr_index,l,m,k) + norm_fact/(dble(nbspbs(m))/meanvol)
144 dn(gr_index,l,m,k) = dn(gr_index,l,m,k) + 1.0d0
161 if (ncells .gt. 1)
then
166 if (dij <= grlim)
then
175 gr_index = int(dgr/dtr)+1
176 norm_fact = 1.0d0/(shell_vol(gr_index)*dble(n))
180 gij(gr_index,l,m,k) = gij(gr_index,l,m,k) + norm_fact/(dble(nbspbs(m))/meanvol)
184 dn(gr_index,l,m,k) = dn(gr_index,l,m,k) + 1.0d0
199 dn(i,j,j,l) = 2.0d0*dn(i,j,j,l)/dble(nbspbs(j)-1)
203 dn(i,j,k,l) = dn(i,j,k,l)+dn(i,k,j,l)
204 dn(i,k,j,l) = dn(i,j,k,l)
205 dn(i,j,k,l) = dn(i,j,k,l)/dble(nbspbs(j))
206 dn(i,k,j,l) = dn(i,k,j,l)/dble(nbspbs(k))
216 dn(i,j,k,l) = dn(i-1,j,k,l) + dn(i,j,k,l)
226 dn_ij(k,i,j) = dn_ij(k,i,j) + dn(k,i,j,l)
227 gr_ij(k,i,j) = gr_ij(k,i,j) + gij(k,i,j,l)
229 gr_ij(k,i,j) = gr_ij(k,i,j)/dble(ns)
230 dn_ij(k,i,j) = dn_ij(k,i,j)/dble(ns)
237 gr_ij(k,l,l) = 2.0d0*gr_ij(k,l,l)
241 gr_ij(k,i,j) = gr_ij(k,i,j) + gr_ij(k,j,i)
242 gr_ij(k,j,i) = gr_ij(k,i,j)
247if (
allocated(dn))
deallocate(dn)
248if (
allocated(gij))
deallocate(gij)
254 grtab(k)=gr_ij(k,i,j)
256 call save_curve (ndr, grtab, l, idgr)
259 ggr_ij(k,i,j) = (gr_ij(k,i,j)-1.0)*4.0*pi*(na/meanvol)*(k-0.5)*dtr
260 grtab(k) = ggr_ij(k,i,j)
262 call save_curve (ndr, grtab, l, idgr)
265 grtab(k)=dn_ij(k,i,j)
267 call save_curve (ndr, grtab, l, idgr)
273 if (
grbt(gr_ij, ndr))
then
277 call save_curve (ndr, grtab, l, idgr)
282 call save_curve (ndr, grtab, l, idgr)
287 call save_curve (ndr, grtab, l, idgr)
289 if (
allocated(btij))
deallocate(btij)
295 suml=suml+nscattl(k)*xi(k)
296 xsuml=xsuml+xscattl(k)*xi(k)
305 grtot(i) = grtot(i) + xi(j)*xi(k)*nscattl(j)*nscattl(k)*gr_ij(i,j,k)
306 ggrtot(i) = ggrtot(i) + xi(j)*xi(k)*nscattl(j)*nscattl(k)*ggr_ij(i,j,k)
307 xgrtot(i) = xgrtot(i) + xi(j)*xi(k)*xscattl(j)*xscattl(k)*gr_ij(i,j,k)
308 xggrtot(i) = xggrtot(i) + xi(j)*xi(k)*xscattl(j)*xscattl(k)*ggr_ij(i,j,k)
311 grtot(i) = grtot(i)/suml
313 trn(i) = drn(i) + 4.0*pi*(na/meanvol)*(i-0.5)*dtr*suml
314 ggrtot(i) = ggrtot(i)/suml
317 xgrtot(i) = xgrtot(i)/xsuml
319 trx(i) = drx(i) + 4.0*pi*(na/meanvol)*(i-0.5)*dtr*xsuml
320 xggrtot(i) = xggrtot(i)/xsuml
326call save_curve (ndr, grtab, 0, idgr)
331call save_curve (ndr, grtab, 2, idgr)
336call save_curve (ndr, grtab, 4, idgr)
341call save_curve (ndr, grtab, 6, idgr)
346call save_curve (ndr, grtab, 8, idgr)
349 grtab(i) = xggrtot(i)
351call save_curve (ndr, grtab, 10, idgr)
356call save_curve (ndr, grtab, 12, idgr)
361call save_curve (ndr, grtab, 14, idgr)
363if (fcr .eq. 1)
call fitcutoffs
369if (
allocated(dn))
deallocate (dn)
370if (
allocated(gij))
deallocate (gij)
371if (
allocated(dn_ij))
deallocate (dn_ij)
372if (
allocated(grtab))
deallocate (grtab)
373if (
allocated(ggrtot))
deallocate (ggrtot)
374if (
allocated(xggrtot))
deallocate (xggrtot)
375if (
allocated(trn))
deallocate (trn)
376if (
allocated(trx))
deallocate (trx)
377if (
allocated(drn))
deallocate (drn)
378if (
allocated(drx))
deallocate (drx)
379if (
allocated(ggr_ij))
deallocate (ggr_ij)
380if (
allocated(gr_ij))
deallocate (gr_ij)
381if (
allocated(shell_vol))
deallocate(shell_vol)
388 INTEGER FUNCTION cutfit (TABTOFIT, NPOINTS)
390 INTEGER,
INTENT(IN) :: npoints
391 DOUBLE PRECISION,
DIMENSION(NPOINTS),
INTENT(IN) :: tabtofit
395if (
allocated(gfft))
deallocate(gfft)
396allocate(gfft(ndr), stat=err)
398 call show_error (
"Impossible to allocate memory"//char(0), &
399 "Subroutine: FITCUTOFFS"//char(0),
"Table: GFFT"//char(0))
407 gr_cut(l,j) = (
cutfit(gfft, ndr) - 0.5) * dtr
410gr_cutoff = (
cutfit(grtot, ndr) - 0.5) * dtr
412call sendcutoffs(nsp, gr_cutoff, gr_cut)
414if (
allocated(gfft))
deallocate(gfft)