65 INTEGER,
INTENT(IN) :: unit_number
66 REAL(kind=
dp),
INTENT(IN) :: q_max
68 CHARACTER(LEN=*),
PARAMETER :: routinen =
'xray_diffraction_spectrum'
69 INTEGER,
PARAMETER :: nblock = 100
71 INTEGER :: handle, i, ig, ig_shell, ipe, ishell, &
72 jg, ng, npe, nshell, nshell_gather
73 INTEGER(KIND=int_8) :: ngpts
74 INTEGER,
DIMENSION(3) :: npts
75 INTEGER,
DIMENSION(:),
POINTER :: aux_index, ng_shell, ng_shell_gather, &
77 REAL(kind=
dp) :: cutoff, f, f2, q, rho_hard, rho_soft, &
79 REAL(kind=
dp),
DIMENSION(3) :: dg, dr
80 REAL(kind=
dp),
DIMENSION(:),
POINTER :: f2sum, f2sum_gather, f4sum, f4sum_gather, fmax, &
81 fmax_gather, fmin, fmin_gather, fsum, fsum_gather, gsq, q_shell, q_shell_gather
92 cpassert(
ASSOCIATED(qs_env))
94 CALL timeset(routinen, handle)
96 NULLIFY (atomic_kind_set)
98 NULLIFY (auxbas_pw_pool)
101 NULLIFY (f2sum_gather)
103 NULLIFY (f4sum_gather)
105 NULLIFY (fmax_gather)
107 NULLIFY (fmin_gather)
109 NULLIFY (fsum_gather)
112 NULLIFY (ng_shell_gather)
116 NULLIFY (particle_set)
119 NULLIFY (q_shell_gather)
121 NULLIFY (rho_atom_set)
126 atomic_kind_set=atomic_kind_set, &
127 dft_control=dft_control, &
129 particle_set=particle_set, &
132 rho_atom_set=rho_atom_set)
135 auxbas_pw_pool=auxbas_pw_pool)
137 npe = para_env%num_pe
141 CALL auxbas_pw_pool%create_pw(pw=rhotot_elec_gspace)
142 CALL pw_zero(rhotot_elec_gspace)
151 dg(:) =
twopi/(npts(:)*dr(:))
156 auxbas_pw_pool=auxbas_pw_pool, &
157 rhotot_elec_gspace=rhotot_elec_gspace, &
162 rho_total = rho_hard + rho_soft
178 q_shell(1) = sqrt(gsq(1))
182 cpassert(gsq(ig) >= gsq(jg))
183 IF (abs(gsq(ig) - gsq(jg)) > 1.0e-12_dp)
THEN
185 IF (nshell >
SIZE(q_shell))
THEN
186 CALL reallocate(q_shell, 1,
SIZE(q_shell) + nblock)
187 CALL reallocate(ng_shell, 1,
SIZE(ng_shell) + nblock)
198 ng_shell(nshell) = ng_shell(nshell) + 1
211 DO ishell = 1, nshell
212 fmin(ishell) = huge(0.0_dp)
213 fmax(ishell) = 0.0_dp
214 fsum(ishell) = 0.0_dp
215 f2sum(ishell) = 0.0_dp
216 f4sum(ishell) = 0.0_dp
217 DO ig_shell = 1, ng_shell(ishell)
218 f = abs(rhotot_elec_gspace%array(ig + ig_shell))
219 fmin(ishell) = min(fmin(ishell), f)
220 fmax(ishell) = max(fmax(ishell), f)
221 fsum(ishell) = fsum(ishell) + f
223 f2sum(ishell) = f2sum(ishell) + f2
224 f4sum(ishell) = f4sum(ishell) + f2*f2
226 ig = ig + ng_shell(ishell)
234 CALL para_env%gather(nshell, nshell_pe)
239 IF (unit_number > 0)
THEN
240 nshell_gather = sum(nshell_pe)
243 offset_pe(ipe) = offset_pe(ipe - 1) + nshell_pe(ipe - 1)
249 CALL reallocate(q_shell_gather, 1, nshell_gather)
250 CALL reallocate(ng_shell_gather, 1, nshell_gather)
251 CALL reallocate(fmin_gather, 1, nshell_gather)
252 CALL reallocate(fmax_gather, 1, nshell_gather)
253 CALL reallocate(fsum_gather, 1, nshell_gather)
254 CALL reallocate(f2sum_gather, 1, nshell_gather)
255 CALL reallocate(f4sum_gather, 1, nshell_gather)
257 CALL para_env%gatherv(q_shell, q_shell_gather, nshell_pe, offset_pe)
258 CALL para_env%gatherv(ng_shell, ng_shell_gather, nshell_pe, offset_pe)
259 CALL para_env%gatherv(fmax, fmax_gather, nshell_pe, offset_pe)
260 CALL para_env%gatherv(fmin, fmin_gather, nshell_pe, offset_pe)
261 CALL para_env%gatherv(fsum, fsum_gather, nshell_pe, offset_pe)
262 CALL para_env%gatherv(f2sum, f2sum_gather, nshell_pe, offset_pe)
263 CALL para_env%gatherv(f4sum, f4sum_gather, nshell_pe, offset_pe)
265 IF (
ASSOCIATED(offset_pe))
THEN
266 DEALLOCATE (offset_pe)
269 IF (
ASSOCIATED(nshell_pe))
THEN
270 DEALLOCATE (nshell_pe)
275 IF (unit_number > 0)
THEN
281 CALL sort(q_shell_gather, nshell_gather, aux_index)
296 q_shell(1) = q_shell_gather(1)
298 ng_shell(1) = ng_shell_gather(i)
299 fmin(1) = fmin_gather(i)
300 fmax(1) = fmax_gather(i)
301 fsum(1) = fsum_gather(i)
302 f2sum(1) = f2sum_gather(i)
303 f4sum(1) = f4sum_gather(i)
305 DO ig = 2, nshell_gather
307 IF (abs(q_shell_gather(ig) - q_shell_gather(jg)) > 1.0e-12_dp)
THEN
309 q_shell(nshell) = q_shell_gather(ig)
310 ng_shell(nshell) = ng_shell_gather(i)
311 fmin(nshell) = fmin_gather(i)
312 fmax(nshell) = fmax_gather(i)
313 fsum(nshell) = fsum_gather(i)
314 f2sum(nshell) = f2sum_gather(i)
315 f4sum(nshell) = f4sum_gather(i)
318 ng_shell(nshell) = ng_shell(nshell) + ng_shell_gather(i)
319 fmin(nshell) = min(fmin(nshell), fmin_gather(i))
320 fmax(nshell) = max(fmax(nshell), fmax_gather(i))
321 fsum(nshell) = fsum(nshell) + fsum_gather(i)
322 f2sum(nshell) = f2sum(nshell) + f2sum_gather(i)
323 f4sum(nshell) = f4sum(nshell) + f4sum_gather(i)
329 IF (
ASSOCIATED(aux_index))
THEN
330 DEALLOCATE (aux_index)
345 WRITE (unit=unit_number, fmt=
"(A)") &
347 "# Coherent X-ray diffraction spectrum", &
349 WRITE (unit=unit_number, fmt=
"(A,1X,F20.10)") &
350 "# Soft electronic charge (G-space) :", rho_soft, &
351 "# Hard electronic charge (G-space) :", rho_hard, &
352 "# Total electronic charge (G-space):", rho_total, &
353 "# Density cutoff [Rydberg] :", 2.0_dp*cutoff, &
354 "# q(min) [1/Angstrom] :", q_shell(2)/
angstrom, &
355 "# q(max) [1/Angstrom] :", q_shell(nshell)/
angstrom, &
356 "# q(max) [1/Angstrom] (requested) :", q_max/
angstrom
357 WRITE (unit=unit_number, fmt=
"(A,2X,I8)") &
358 "# Number of g-vectors (grid points):", ngpts, &
359 "# Number of g-vector shells :", nshell
360 WRITE (unit=unit_number, fmt=
"(A,3(1X,I6))") &
361 "# Grid size (a,b,c) :", npts(1:3)
362 WRITE (unit=unit_number, fmt=
"(A,3F7.3)") &
363 "# dg [1/Angstrom] :", dg(1:3)/
angstrom, &
364 "# dr [Angstrom] :", dr(1:3)*
angstrom
365 WRITE (unit=unit_number, fmt=
"(A)") &
367 "# shell points q [1/A] <|F(q)|^2> Min(|F(q)|)"// &
368 " Max(|F(q)|) <|F(q)|>^2 <|F(q)|^4>"
370 DO ishell = 1, nshell
371 WRITE (unit=unit_number, fmt=
"(T2,I6,2X,I6,5(1X,F15.6),1X,ES15.6)") &
375 f2sum(ishell)/real(ng_shell(ishell), kind=
dp), &
378 (fsum(ishell)/real(ng_shell(ishell), kind=
dp))**2, &
379 f4sum(ishell)/real(ng_shell(ishell), kind=
dp)
386 IF (
ASSOCIATED(fmin))
THEN
390 IF (
ASSOCIATED(fmax))
THEN
394 IF (
ASSOCIATED(fsum))
THEN
398 IF (
ASSOCIATED(f2sum))
THEN
402 IF (
ASSOCIATED(f4sum))
THEN
406 IF (
ASSOCIATED(ng_shell))
THEN
407 DEALLOCATE (ng_shell)
410 IF (
ASSOCIATED(q_shell))
THEN
414 IF (
ASSOCIATED(fmin_gather))
THEN
415 DEALLOCATE (fmin_gather)
418 IF (
ASSOCIATED(fmax_gather))
THEN
419 DEALLOCATE (fmax_gather)
422 IF (
ASSOCIATED(fsum_gather))
THEN
423 DEALLOCATE (fsum_gather)
426 IF (
ASSOCIATED(f2sum_gather))
THEN
427 DEALLOCATE (f2sum_gather)
430 IF (
ASSOCIATED(f4sum_gather))
THEN
431 DEALLOCATE (f4sum_gather)
434 IF (
ASSOCIATED(ng_shell_gather))
THEN
435 DEALLOCATE (ng_shell_gather)
438 IF (
ASSOCIATED(q_shell_gather))
THEN
439 DEALLOCATE (q_shell_gather)
442 CALL auxbas_pw_pool%give_back_pw(rhotot_elec_gspace)
444 CALL timestop(handle)
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.