(git:ba1d7ca)
Loading...
Searching...
No Matches
qs_vcd_utils.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
9 USE cell_types, ONLY: cell_type
12 USE cp_dbcsr_api, ONLY: dbcsr_copy,&
16 dbcsr_set,&
17 dbcsr_type_antisymmetric,&
18 dbcsr_type_no_symmetry
22 USE cp_files, ONLY: close_file,&
24 USE cp_fm_types, ONLY: cp_fm_create,&
34 USE cp_output_handling, ONLY: cp_p_file,&
45 USE kinds, ONLY: default_path_length,&
47 dp
60 USE qs_mo_types, ONLY: get_mo_set,&
65 USE qs_vcd_ao, ONLY: build_com_rpnl_r,&
67 USE string_utilities, ONLY: xstring
68#include "./base/base_uses.f90"
69
70 IMPLICIT NONE
71
72 PRIVATE
75 PUBLIC :: vcd_print
76
77 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_vcd_utils'
78
79 REAL(dp), DIMENSION(3, 3, 3), PARAMETER :: Levi_Civita = reshape([ &
80 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, &
81 0.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, -1.0_dp, 0.0_dp, 0.0_dp, &
82 0.0_dp, -1.0_dp, 0.0_dp, 1.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp], [3, 3, 3])
83
84CONTAINS
85
86! *****************************************************************************
87!> \brief Initialize the vcd environment
88!> \param vcd_env ...
89!> \param qs_env ...
90!> \author Edward Ditler
91! **************************************************************************************************
92 SUBROUTINE vcd_env_init(vcd_env, qs_env)
93 TYPE(vcd_env_type), TARGET :: vcd_env
94 TYPE(qs_environment_type), POINTER :: qs_env
95
96 CHARACTER(LEN=*), PARAMETER :: routinen = 'vcd_env_init'
97
98 INTEGER :: handle, i, idir, ispin, j, natom, &
99 nspins, output_unit, reference, &
100 unit_number
101 LOGICAL :: explicit
102 REAL(kind=dp), DIMENSION(:), POINTER :: ref_point
103 TYPE(cell_type), POINTER :: cell
104 TYPE(cp_logger_type), POINTER :: logger
105 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks
106 TYPE(dft_control_type), POINTER :: dft_control
107 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
108 POINTER :: sab_all, sab_orb, sap_ppnl
109 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
110 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
111 TYPE(qs_ks_env_type), POINTER :: ks_env
112 TYPE(section_vals_type), POINTER :: lr_section, vcd_section
113
114 CALL timeset(routinen, handle)
115 vcd_env%do_mfp = .false.
116
117 ! Set up the logger
118 NULLIFY (logger, vcd_section, lr_section)
119 logger => cp_get_default_logger()
120 vcd_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%LINRES%VCD")
121 vcd_env%output_unit = cp_print_key_unit_nr(logger, vcd_section, "PRINT%VCD", &
122 extension=".data", middle_name="vcd", log_filename=.false., &
123 file_position="REWIND", file_status="REPLACE")
124
125 lr_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%LINRES")
126 output_unit = cp_print_key_unit_nr(logger, lr_section, "PRINT%PROGRAM_RUN_INFO", &
127 extension=".linresLog")
128 unit_number = cp_print_key_unit_nr(logger, lr_section, "PRINT%PROGRAM_RUN_INFO", extension=".linresLog")
129
130 ! We can't run a NVPT/MFPT calculation without the coefficients dC/dR.
131 CALL dcdr_env_init(vcd_env%dcdr_env, qs_env)
132 ! vcd_env%dcdr_env%output_unit = vcd_env%output_unit
133
134 IF (output_unit > 0) THEN
135 WRITE (output_unit, "(/,T20,A,/)") "*** Start NVPT/MFPT calculation ***"
136 END IF
137
138 ! Just to make sure. The memory requirements are tiny.
139 CALL init_orbital_pointers(12)
140
141 CALL section_vals_val_get(vcd_section, "DISTRIBUTED_ORIGIN", l_val=vcd_env%distributed_origin)
142 CALL section_vals_val_get(vcd_section, "ORIGIN_DEPENDENT_MFP", l_val=vcd_env%origin_dependent_op_mfp)
143
144 ! Reference point
145 vcd_env%magnetic_origin = 0._dp
146 vcd_env%spatial_origin = 0._dp
147 ! Get the magnetic origin from the input
148 CALL section_vals_val_get(vcd_section, "MAGNETIC_ORIGIN", i_val=reference)
149 CALL section_vals_val_get(vcd_section, "MAGNETIC_ORIGIN_REFERENCE", explicit=explicit)
150 IF (explicit) THEN
151 CALL section_vals_val_get(vcd_section, "MAGNETIC_ORIGIN_REFERENCE", r_vals=ref_point)
152 ELSE
153 IF (reference == use_mom_ref_user) THEN
154 cpabort("User-defined reference point should be given explicitly")
155 END IF
156 END IF
157
158 CALL get_reference_point(rpoint=vcd_env%magnetic_origin, qs_env=qs_env, &
159 reference=reference, &
160 ref_point=ref_point)
161
162 ! Get the spatial origin from the input
163 CALL section_vals_val_get(vcd_section, "SPATIAL_ORIGIN", i_val=reference)
164 CALL section_vals_val_get(vcd_section, "SPATIAL_ORIGIN_REFERENCE", explicit=explicit)
165 IF (explicit) THEN
166 CALL section_vals_val_get(vcd_section, "SPATIAL_ORIGIN_REFERENCE", r_vals=ref_point)
167 ELSE
168 IF (reference == use_mom_ref_user) THEN
169 cpabort("User-defined reference point should be given explicitly")
170 END IF
171 END IF
172
173 CALL get_reference_point(rpoint=vcd_env%spatial_origin, qs_env=qs_env, &
174 reference=reference, &
175 ref_point=ref_point)
176
177 IF (vcd_env%distributed_origin .AND. any(vcd_env%magnetic_origin /= vcd_env%spatial_origin)) THEN
178 cpwarn("The magnetic and spatial origins don't match")
179 ! This is fine for NVP but will give unphysical results for MFP.
180 END IF
181
182 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,3F10.6)") &
183 'The reference point is', vcd_env%dcdr_env%ref_point
184 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,3F10.6)") &
185 'The magnetic origin is', vcd_env%magnetic_origin
186 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,3F10.6)") &
187 'The velocity origin is', vcd_env%spatial_origin
188
189 vcd_env%magnetic_origin_atom = vcd_env%magnetic_origin
190 vcd_env%spatial_origin_atom = vcd_env%spatial_origin
191
192 CALL get_qs_env(qs_env=qs_env, &
193 ks_env=ks_env, &
194 dft_control=dft_control, &
195 sab_orb=sab_orb, &
196 sab_all=sab_all, &
197 sap_ppnl=sap_ppnl, &
198 particle_set=particle_set, &
199 matrix_ks=matrix_ks, &
200 cell=cell, &
201 qs_kind_set=qs_kind_set)
202
203 natom = SIZE(particle_set)
204 nspins = dft_control%nspins
205
206 ALLOCATE (vcd_env%apt_el_nvpt(3, 3, natom))
207 ALLOCATE (vcd_env%apt_nuc_nvpt(3, 3, natom))
208 ALLOCATE (vcd_env%apt_total_nvpt(3, 3, natom))
209 ALLOCATE (vcd_env%aat_atom_nvpt(3, 3, natom))
210 ALLOCATE (vcd_env%aat_atom_mfp(3, 3, natom))
211 vcd_env%apt_el_nvpt = 0._dp
212 vcd_env%apt_nuc_nvpt = 0._dp
213 vcd_env%apt_total_nvpt = 0._dp
214 vcd_env%aat_atom_nvpt = 0._dp
215 vcd_env%aat_atom_mfp = 0._dp
216
217 ALLOCATE (vcd_env%dCV(nspins))
218 ALLOCATE (vcd_env%dCV_prime(nspins))
219 ALLOCATE (vcd_env%op_dV(nspins))
220 ALLOCATE (vcd_env%op_dB(nspins))
221 DO ispin = 1, nspins
222 CALL cp_fm_create(vcd_env%dCV(ispin), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
223 CALL cp_fm_create(vcd_env%dCV_prime(ispin), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
224 CALL cp_fm_create(vcd_env%op_dV(ispin), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
225 CALL cp_fm_create(vcd_env%op_dB(ispin), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
226 END DO
227
228 ALLOCATE (vcd_env%dCB(3))
229 ALLOCATE (vcd_env%dCB_prime(3))
230 DO i = 1, 3
231 CALL cp_fm_create(vcd_env%dCB(i), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
232 CALL cp_fm_create(vcd_env%dCB_prime(i), vcd_env%dcdr_env%likemos_fm_struct(1)%struct, set_zero=.true.)
233 END DO
234
235 ! DBCSR matrices
236 CALL dbcsr_allocate_matrix_set(vcd_env%moments_der, 9, 3)
237 CALL dbcsr_allocate_matrix_set(vcd_env%moments_der_right, 9, 3)
238 CALL dbcsr_allocate_matrix_set(vcd_env%moments_der_left, 9, 3)
239 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_difdip2, 3, 3)
240 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_dSdV, 3)
241 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_dSdB, 3)
242 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_hxc_dsdv, nspins)
243
244 CALL dbcsr_allocate_matrix_set(vcd_env%hcom, 3)
245 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_rcomr, 3, 3)
246 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_rrcom, 3, 3)
247 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_dcom, 3, 3)
248 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_hr, nspins, 3)
249 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_rh, nspins, 3)
250 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_drpnl, 3)
251 CALL dbcsr_allocate_matrix_set(vcd_env%dipvel_ao, 3)
252 CALL dbcsr_allocate_matrix_set(vcd_env%dipvel_ao_delta, 3)
253 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_rxrv, 3)
254 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_r_rxvr, 3, 3)
255 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_rxvr_r, 3, 3)
256 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_r_doublecom, 3, 3)
257
258 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_nosym_temp_33, 3, 3)
259 CALL dbcsr_allocate_matrix_set(vcd_env%matrix_nosym_temp2_33, 3, 3)
260 DO i = 1, 9 ! x, y, z, xx, xy, xz, yy, yz, zz
261 DO idir = 1, 3 ! d/dx, d/dy, d/dz
262 CALL dbcsr_init_p(vcd_env%moments_der(i, idir)%matrix)
263 CALL dbcsr_init_p(vcd_env%moments_der_right(i, idir)%matrix)
264 CALL dbcsr_init_p(vcd_env%moments_der_left(i, idir)%matrix)
265
266 CALL dbcsr_create(vcd_env%moments_der(i, idir)%matrix, template=matrix_ks(1)%matrix, &
267 matrix_type=dbcsr_type_antisymmetric)
268 CALL cp_dbcsr_alloc_block_from_nbl(vcd_env%moments_der(i, idir)%matrix, sab_orb)
269 CALL dbcsr_set(vcd_env%moments_der(i, idir)%matrix, 0.0_dp)
270
271 ! And the ones which will be multiplied by delta_(mu/nu)
272 CALL dbcsr_copy(vcd_env%moments_der_right(i, idir)%matrix, &
273 vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
274 CALL dbcsr_copy(vcd_env%moments_der_left(i, idir)%matrix, &
275 vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
276 END DO
277 END DO
278
279 DO i = 1, 3
280 DO j = 1, 3
281 CALL dbcsr_init_p(vcd_env%matrix_difdip2(i, j)%matrix)
282 CALL dbcsr_copy(vcd_env%matrix_difdip2(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
283 CALL dbcsr_set(vcd_env%matrix_difdip2(i, j)%matrix, 0.0_dp)
284
285 CALL dbcsr_init_p(vcd_env%matrix_nosym_temp_33(i, j)%matrix)
286 CALL dbcsr_create(vcd_env%matrix_nosym_temp_33(i, j)%matrix, template=matrix_ks(1)%matrix, &
287 matrix_type=dbcsr_type_no_symmetry)
288 CALL cp_dbcsr_alloc_block_from_nbl(vcd_env%matrix_nosym_temp_33(i, j)%matrix, sab_all)
289 CALL dbcsr_set(vcd_env%matrix_nosym_temp_33(i, j)%matrix, 0._dp)
290
291 CALL dbcsr_init_p(vcd_env%matrix_nosym_temp2_33(i, j)%matrix)
292 CALL dbcsr_create(vcd_env%matrix_nosym_temp2_33(i, j)%matrix, template=matrix_ks(1)%matrix, &
293 matrix_type=dbcsr_type_no_symmetry)
294 CALL cp_dbcsr_alloc_block_from_nbl(vcd_env%matrix_nosym_temp2_33(i, j)%matrix, sab_all)
295 CALL dbcsr_set(vcd_env%matrix_nosym_temp2_33(i, j)%matrix, 0._dp)
296
297 END DO
298 CALL dbcsr_init_p(vcd_env%matrix_dSdV(i)%matrix)
299 CALL dbcsr_copy(vcd_env%matrix_dSdV(i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
300 CALL dbcsr_init_p(vcd_env%matrix_dSdB(i)%matrix)
301 CALL dbcsr_copy(vcd_env%matrix_dSdB(i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
302 END DO
303
304 DO ispin = 1, nspins
305 CALL dbcsr_init_p(vcd_env%matrix_hxc_dsdv(ispin)%matrix)
306 CALL dbcsr_copy(vcd_env%matrix_hxc_dsdv(ispin)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
307 END DO
308
309 ! Things for op_dV
310 ! lin_mom
311 DO i = 1, 3
312 CALL dbcsr_init_p(vcd_env%dipvel_ao(i)%matrix)
313 CALL dbcsr_copy(vcd_env%dipvel_ao(i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
314
315 CALL dbcsr_init_p(vcd_env%dipvel_ao_delta(i)%matrix)
316 CALL dbcsr_copy(vcd_env%dipvel_ao_delta(i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
317 END DO
318
319 ! [V, r]
320 DO i = 1, 3
321 CALL dbcsr_init_p(vcd_env%hcom(i)%matrix)
322 CALL dbcsr_create(vcd_env%hcom(i)%matrix, template=matrix_ks(1)%matrix, &
323 matrix_type=dbcsr_type_antisymmetric)
324 CALL cp_dbcsr_alloc_block_from_nbl(vcd_env%hcom(i)%matrix, sab_orb)
325
326 CALL dbcsr_init_p(vcd_env%matrix_rxrv(i)%matrix)
327 CALL dbcsr_create(vcd_env%matrix_rxrv(i)%matrix, template=matrix_ks(1)%matrix, &
328 matrix_type=dbcsr_type_antisymmetric)
329 CALL cp_dbcsr_alloc_block_from_nbl(vcd_env%matrix_rxrv(i)%matrix, sab_orb)
330
331 DO j = 1, 3
332 CALL dbcsr_init_p(vcd_env%matrix_rcomr(i, j)%matrix)
333 CALL dbcsr_copy(vcd_env%matrix_rcomr(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
334 CALL dbcsr_init_p(vcd_env%matrix_rrcom(i, j)%matrix)
335 CALL dbcsr_copy(vcd_env%matrix_rrcom(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
336 CALL dbcsr_init_p(vcd_env%matrix_dcom(i, j)%matrix)
337 CALL dbcsr_copy(vcd_env%matrix_dcom(i, j)%matrix, matrix_ks(1)%matrix)
338 CALL dbcsr_set(vcd_env%matrix_dcom(i, j)%matrix, 0._dp)
339
340 CALL dbcsr_init_p(vcd_env%matrix_r_rxvr(i, j)%matrix)
341 CALL dbcsr_copy(vcd_env%matrix_r_rxvr(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
342 CALL dbcsr_set(vcd_env%matrix_r_rxvr(i, j)%matrix, 0._dp)
343
344 CALL dbcsr_init_p(vcd_env%matrix_rxvr_r(i, j)%matrix)
345 CALL dbcsr_copy(vcd_env%matrix_rxvr_r(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
346 CALL dbcsr_set(vcd_env%matrix_rxvr_r(i, j)%matrix, 0._dp)
347
348 CALL dbcsr_init_p(vcd_env%matrix_r_doublecom(i, j)%matrix)
349 CALL dbcsr_copy(vcd_env%matrix_r_doublecom(i, j)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
350 CALL dbcsr_set(vcd_env%matrix_r_doublecom(i, j)%matrix, 0._dp)
351 END DO
352 END DO
353
354 ! matrix_hr: nonsymmetric dbcsr matrix
355 DO ispin = 1, nspins
356 DO i = 1, 3
357 CALL dbcsr_init_p(vcd_env%matrix_hr(ispin, i)%matrix)
358 CALL dbcsr_copy(vcd_env%matrix_hr(ispin, i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
359
360 CALL dbcsr_init_p(vcd_env%matrix_rh(ispin, i)%matrix)
361 CALL dbcsr_copy(vcd_env%matrix_rh(ispin, i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
362 END DO
363 END DO
364
365 ! drpnl for the operator
366 DO i = 1, 3
367 CALL dbcsr_init_p(vcd_env%matrix_drpnl(i)%matrix)
368 CALL dbcsr_copy(vcd_env%matrix_drpnl(i)%matrix, vcd_env%dcdr_env%matrix_nosym_temp(1)%matrix)
369 END DO
370
371 ! NVP matrices
372 ! hr matrices
373 CALL build_matrix_hr_rh(vcd_env, qs_env, [0._dp, 0._dp, 0._dp])
374
375 ! commutator terms
376 ! - [V, r]
377 CALL build_com_mom_nl(qs_kind_set, sab_orb, sap_ppnl, dft_control%qs_control%eps_ppnl, &
378 particle_set, cell=cell, matrix_rv=vcd_env%hcom)
379 ! <[V, r] * r> and <r * [V, r]>
380 CALL build_com_rpnl_r(vcd_env%matrix_rcomr, qs_kind_set, sab_all, sap_ppnl, &
381 dft_control%qs_control%eps_ppnl, particle_set, cell, .true.)
382 CALL build_com_rpnl_r(vcd_env%matrix_rrcom, qs_kind_set, sab_all, sap_ppnl, &
383 dft_control%qs_control%eps_ppnl, particle_set, cell, .false.)
384
385 ! lin_mom
386 CALL build_lin_mom_matrix(qs_env, vcd_env%dipvel_ao)
387
388 ! AAT
389 ! The moments are set to zero and then recomputed in the routine.
390 CALL build_local_moments_der_matrix(qs_env, moments_der=vcd_env%moments_der, &
391 nmoments_der=2, nmoments=0, ref_point=[0._dp, 0._dp, 0._dp])
392
393 ! PP terms
394 CALL build_com_mom_nl(qs_kind_set, sab_orb, sap_ppnl, dft_control%qs_control%eps_ppnl, &
395 particle_set, matrix_rxrv=vcd_env%matrix_rxrv, ref_point=[0._dp, 0._dp, 0._dp], &
396 cell=cell)
397
398 CALL build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, dft_control%qs_control%eps_ppnl, &
399 particle_set, ref_point=[0._dp, 0._dp, 0._dp], cell=cell, &
400 matrix_r_rxvr=vcd_env%matrix_r_rxvr, matrix_rxvr_r=vcd_env%matrix_rxvr_r)
401
402 ! Done with NVP matrices
403
404 CALL cp_print_key_finished_output(output_unit, logger, lr_section, &
405 "PRINT%PROGRAM_RUN_INFO")
406
407 CALL timestop(handle)
408
409 END SUBROUTINE vcd_env_init
410
411! *****************************************************************************
412!> \brief Deallocate the vcd environment
413!> \param qs_env ...
414!> \param vcd_env ...
415!> \author Edward Ditler
416! **************************************************************************************************
417 SUBROUTINE vcd_env_cleanup(qs_env, vcd_env)
418
419 TYPE(qs_environment_type), POINTER :: qs_env
420 TYPE(vcd_env_type) :: vcd_env
421
422 CHARACTER(LEN=*), PARAMETER :: routinen = 'vcd_env_cleanup'
423
424 INTEGER :: handle
425
426 CALL timeset(routinen, handle)
427
428 ! We can't run a NVPT/MFPT calculation without the coefficients dC/dR.
429 CALL dcdr_env_cleanup(qs_env, vcd_env%dcdr_env)
430
431 DEALLOCATE (vcd_env%apt_el_nvpt)
432 DEALLOCATE (vcd_env%apt_nuc_nvpt)
433 DEALLOCATE (vcd_env%apt_total_nvpt)
434 DEALLOCATE (vcd_env%aat_atom_nvpt)
435 DEALLOCATE (vcd_env%aat_atom_mfp)
436
437 CALL cp_fm_release(vcd_env%dCV)
438 CALL cp_fm_release(vcd_env%dCV_prime)
439 CALL cp_fm_release(vcd_env%op_dV)
440 CALL cp_fm_release(vcd_env%op_dB)
441
442 CALL cp_fm_release(vcd_env%dCB)
443 CALL cp_fm_release(vcd_env%dCB_prime)
444
445 ! DBCSR matrices
446 ! Probably, the memory requirements could be reduced by quite a bit
447 ! by not storing each term in its own set of matrices.
448 ! On the other hand, the memory bottleneck is usually the numerical
449 ! integration grid.
450 CALL dbcsr_deallocate_matrix_set(vcd_env%moments_der)
451 CALL dbcsr_deallocate_matrix_set(vcd_env%moments_der_right)
452 CALL dbcsr_deallocate_matrix_set(vcd_env%moments_der_left)
453 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_difdip2)
454 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_dSdV)
455 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_dSdB)
456 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_hxc_dsdv)
457 CALL dbcsr_deallocate_matrix_set(vcd_env%hcom)
458 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_rcomr)
459 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_rrcom)
460 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_dcom)
461 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_hr)
462 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_rh)
463 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_drpnl)
464 CALL dbcsr_deallocate_matrix_set(vcd_env%dipvel_ao)
465 CALL dbcsr_deallocate_matrix_set(vcd_env%dipvel_ao_delta)
466 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_rxrv)
467 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_r_rxvr)
468 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_rxvr_r)
469 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_r_doublecom)
470 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_nosym_temp_33)
471 CALL dbcsr_deallocate_matrix_set(vcd_env%matrix_nosym_temp2_33)
472 CALL timestop(handle)
473
474 END SUBROUTINE vcd_env_cleanup
475
476! **************************************************************************************************
477!> \brief Copied from linres_read_restart
478!> \param qs_env ...
479!> \param linres_section ...
480!> \param vec ...
481!> \param lambda ...
482!> \param beta ...
483!> \param tag ...
484!> \author Edward Ditler
485! **************************************************************************************************
486 SUBROUTINE vcd_read_restart(qs_env, linres_section, vec, lambda, beta, tag)
487 TYPE(qs_environment_type), POINTER :: qs_env
488 TYPE(section_vals_type), POINTER :: linres_section
489 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: vec
490 INTEGER, INTENT(IN) :: lambda, beta
491 CHARACTER(LEN=*) :: tag
492
493 CHARACTER(LEN=*), PARAMETER :: routinen = 'vcd_read_restart'
494
495 CHARACTER(LEN=default_path_length) :: filename
496 CHARACTER(LEN=default_string_length) :: my_middle
497 INTEGER :: beta_tmp, handle, i, i_block, ia, ie, iostat, iounit, ispin, j, lambda_tmp, &
498 max_block, n_rep_val, nao, nao_tmp, nmo, nmo_tmp, nspins, nspins_tmp, rst_unit
499 LOGICAL :: file_exists
500 REAL(kind=dp), DIMENSION(:, :), POINTER :: vecbuffer
501 TYPE(cp_fm_type), POINTER :: mo_coeff
502 TYPE(cp_logger_type), POINTER :: logger
503 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
504 TYPE(mp_para_env_type), POINTER :: para_env
505 TYPE(section_vals_type), POINTER :: print_key
506
507 file_exists = .false.
508
509 CALL timeset(routinen, handle)
510
511 NULLIFY (mos, para_env, logger, print_key, vecbuffer)
512 logger => cp_get_default_logger()
513
514 iounit = cp_print_key_unit_nr(logger, linres_section, &
515 "PRINT%PROGRAM_RUN_INFO", extension=".Log")
516
517 CALL get_qs_env(qs_env=qs_env, &
518 para_env=para_env, &
519 mos=mos)
520
521 nspins = SIZE(mos)
522
523 rst_unit = -1
524 IF (para_env%is_source()) THEN
525 CALL section_vals_val_get(linres_section, "WFN_RESTART_FILE_NAME", &
526 n_rep_val=n_rep_val)
527
528 CALL xstring(tag, ia, ie)
529 my_middle = "RESTART-"//tag(ia:ie)//trim("-")//trim(adjustl(cp_to_string(beta))) &
530 //trim("-")//trim(adjustl(cp_to_string(lambda)))
531
532 IF (n_rep_val > 0) THEN
533 CALL section_vals_val_get(linres_section, "WFN_RESTART_FILE_NAME", c_val=filename)
534 CALL xstring(filename, ia, ie)
535 filename = filename(ia:ie)//trim(my_middle)//".lr"
536 ELSE
537 ! try to read from the filename that is generated automatically from the printkey
538 print_key => section_vals_get_subs_vals(linres_section, "PRINT%RESTART")
539 filename = cp_print_key_generate_filename(logger, print_key, &
540 extension=".lr", middle_name=trim(my_middle), my_local=.false.)
541 END IF
542 INQUIRE (file=filename, exist=file_exists)
543 !
544 ! open file
545 IF (file_exists) THEN
546 CALL open_file(file_name=trim(filename), &
547 file_action="READ", &
548 file_form="UNFORMATTED", &
549 file_position="REWIND", &
550 file_status="OLD", &
551 unit_number=rst_unit)
552
553 IF (iounit > 0) WRITE (iounit, "(T2,A)") &
554 "LINRES| Reading response wavefunctions from the restart file <"//trim(adjustl(filename))//">"
555 ELSE
556 IF (iounit > 0) WRITE (iounit, "(T2,A)") &
557 "LINRES| Restart file <"//trim(adjustl(filename))//"> not found"
558 END IF
559 END IF
560
561 CALL para_env%bcast(file_exists)
562
563 IF (file_exists) THEN
564
565 CALL get_mo_set(mos(1), mo_coeff=mo_coeff)
566 CALL cp_fm_get_info(mo_coeff, nrow_global=nao, ncol_block=max_block)
567
568 ALLOCATE (vecbuffer(nao, max_block))
569 !
570 ! read headers
571 IF (rst_unit > 0) READ (rst_unit, iostat=iostat) lambda_tmp, beta_tmp, nspins_tmp, nao_tmp
572 CALL para_env%bcast(iostat)
573
574 CALL para_env%bcast(beta_tmp)
575 CALL para_env%bcast(lambda_tmp)
576 CALL para_env%bcast(nspins_tmp)
577 CALL para_env%bcast(nao_tmp)
578
579 ! check that the number nao, nmo and nspins are
580 ! the same as in the current mos
581 IF (nspins_tmp /= nspins) THEN
582 cpabort("nspins not consistent")
583 END IF
584 IF (nao_tmp /= nao) cpabort("nao not consistent")
585 ! check that it's the right file
586 ! the same as in the current mos
587 IF (lambda_tmp /= lambda) cpabort("lambda not consistent")
588 IF (beta_tmp /= beta) cpabort("beta not consistent")
589 !
590 DO ispin = 1, nspins
591 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
592 CALL cp_fm_get_info(mo_coeff, ncol_global=nmo)
593 !
594 IF (rst_unit > 0) READ (rst_unit) nmo_tmp
595 CALL para_env%bcast(nmo_tmp)
596 IF (nmo_tmp /= nmo) cpabort("nmo not consistent")
597 !
598 ! read the response
599 DO i = 1, nmo, max(max_block, 1)
600 i_block = min(max_block, nmo - i + 1)
601 DO j = 1, i_block
602 IF (rst_unit > 0) READ (rst_unit) vecbuffer(1:nao, j)
603 END DO
604 CALL para_env%bcast(vecbuffer)
605 CALL cp_fm_set_submatrix(vec(ispin), vecbuffer, 1, i, nao, i_block)
606 END DO
607 END DO
608
609 IF (iostat /= 0) THEN
610 IF (iounit > 0) WRITE (iounit, "(T2,A)") &
611 "LINRES| Restart file <"//trim(adjustl(filename))//"> not found"
612 END IF
613
614 DEALLOCATE (vecbuffer)
615
616 END IF
617
618 IF (para_env%is_source()) THEN
619 IF (file_exists) CALL close_file(unit_number=rst_unit)
620 END IF
621
622 CALL timestop(handle)
623
624 END SUBROUTINE vcd_read_restart
625
626! **************************************************************************************************
627!> \brief Copied from linres_write_restart
628!> \param qs_env ...
629!> \param linres_section ...
630!> \param vec ...
631!> \param lambda ...
632!> \param beta ...
633!> \param tag ...
634!> \author Edward Ditler
635! **************************************************************************************************
636 SUBROUTINE vcd_write_restart(qs_env, linres_section, vec, lambda, beta, tag)
637 TYPE(qs_environment_type), POINTER :: qs_env
638 TYPE(section_vals_type), POINTER :: linres_section
639 TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: vec
640 INTEGER, INTENT(IN) :: lambda, beta
641 CHARACTER(LEN=*) :: tag
642
643 CHARACTER(LEN=*), PARAMETER :: routinen = 'vcd_write_restart'
644
645 CHARACTER(LEN=default_path_length) :: filename
646 CHARACTER(LEN=default_string_length) :: my_middle, my_pos, my_status
647 INTEGER :: handle, i, i_block, ia, ie, iounit, &
648 ispin, j, max_block, nao, nmo, nspins, &
649 rst_unit
650 REAL(kind=dp), DIMENSION(:, :), POINTER :: vecbuffer
651 TYPE(cp_fm_type), POINTER :: mo_coeff
652 TYPE(cp_logger_type), POINTER :: logger
653 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
654 TYPE(mp_para_env_type), POINTER :: para_env
655 TYPE(section_vals_type), POINTER :: print_key
656
657 NULLIFY (logger, mo_coeff, mos, para_env, print_key, vecbuffer)
658
659 CALL timeset(routinen, handle)
660
661 logger => cp_get_default_logger()
662
663 IF (btest(cp_print_key_should_output(logger%iter_info, linres_section, "PRINT%RESTART", &
664 used_print_key=print_key), &
665 cp_p_file)) THEN
666
667 iounit = cp_print_key_unit_nr(logger, linres_section, &
668 "PRINT%PROGRAM_RUN_INFO", extension=".Log")
669
670 CALL get_qs_env(qs_env=qs_env, &
671 mos=mos, &
672 para_env=para_env)
673
674 nspins = SIZE(mos)
675
676 my_status = "REPLACE"
677 my_pos = "REWIND"
678 CALL xstring(tag, ia, ie)
679 my_middle = "RESTART-"//tag(ia:ie)//trim("-")//trim(adjustl(cp_to_string(beta))) &
680 //trim("-")//trim(adjustl(cp_to_string(lambda)))
681 rst_unit = cp_print_key_unit_nr(logger, linres_section, "PRINT%RESTART", &
682 extension=".lr", middle_name=trim(my_middle), file_status=trim(my_status), &
683 file_position=trim(my_pos), file_action="WRITE", file_form="UNFORMATTED")
684
685 filename = cp_print_key_generate_filename(logger, print_key, &
686 extension=".lr", middle_name=trim(my_middle), my_local=.false.)
687
688 IF (iounit > 0) THEN
689 WRITE (unit=iounit, fmt="(T2,A)") &
690 "LINRES| Writing response functions to the restart file <"//trim(adjustl(filename))//">"
691 END IF
692
693 !
694 ! write data to file
695 ! use the scalapack block size as a default for buffering columns
696 CALL get_mo_set(mos(1), mo_coeff=mo_coeff)
697 CALL cp_fm_get_info(mo_coeff, nrow_global=nao, ncol_block=max_block)
698 ALLOCATE (vecbuffer(nao, max_block))
699
700 IF (rst_unit > 0) WRITE (rst_unit) lambda, beta, nspins, nao
701
702 DO ispin = 1, nspins
703 CALL cp_fm_get_info(vec(ispin), ncol_global=nmo)
704
705 IF (rst_unit > 0) WRITE (rst_unit) nmo
706
707 DO i = 1, nmo, max(max_block, 1)
708 i_block = min(max_block, nmo - i + 1)
709 CALL cp_fm_get_submatrix(vec(ispin), vecbuffer, 1, i, nao, i_block)
710 ! doing this in one write would increase efficiency, but breaks RESTART compatibility.
711 ! to old ones, and in cases where max_block is different between runs, as might happen during
712 ! restarts with a different number of CPUs
713 DO j = 1, i_block
714 IF (rst_unit > 0) WRITE (rst_unit) vecbuffer(1:nao, j)
715 END DO
716 END DO
717 END DO
718
719 DEALLOCATE (vecbuffer)
720
721 CALL cp_print_key_finished_output(rst_unit, logger, linres_section, &
722 "PRINT%RESTART")
723 END IF
724
725 CALL timestop(handle)
726
727 END SUBROUTINE vcd_write_restart
728
729! **************************************************************************************************
730!> \brief Print the APTs, AATs, and sum rules
731!> \param vcd_env ...
732!> \param qs_env ...
733!> \author Edward Ditler
734! **************************************************************************************************
735 SUBROUTINE vcd_print(vcd_env, qs_env)
736 TYPE(vcd_env_type) :: vcd_env
737 TYPE(qs_environment_type), POINTER :: qs_env
738
739 CHARACTER(len=*), PARAMETER :: routinen = 'vcd_print'
740
741 CHARACTER(LEN=default_string_length) :: description
742 INTEGER :: alpha, beta, delta, gamma, handle, i, l, &
743 lambda, natom, nsubset, output_unit
744 REAL(dp) :: mean, standard_deviation, &
745 standard_deviation_sum
746 REAL(dp), DIMENSION(:, :, :), POINTER :: apt_el_dcdr, apt_el_nvpt, apt_nuc_dcdr, &
747 apt_nuc_nvpt, apt_total_dcdr, &
748 apt_total_nvpt
749 REAL(dp), DIMENSION(:, :, :, :), POINTER :: apt_center_dcdr, apt_subset_dcdr
750 REAL(kind=dp), DIMENSION(3, 3) :: sum_rule_0, sum_rule_0_second, &
751 sum_rule_1, sum_rule_2, &
752 sum_rule_2_second, sum_rule_3_mfp, &
753 sum_rule_3_second
754 TYPE(cp_logger_type), POINTER :: logger
755 TYPE(cp_result_type), POINTER :: results
756 TYPE(molecule_type), DIMENSION(:), POINTER :: molecule_set
757 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
758 TYPE(section_vals_type), POINTER :: vcd_section
759
760 CALL timeset(routinen, handle)
761
762 NULLIFY (logger)
763
764 logger => cp_get_default_logger()
765 output_unit = cp_logger_get_default_io_unit(logger)
766
767 vcd_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%LINRES%VCD")
768
769 NULLIFY (particle_set)
770 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, molecule_set=molecule_set)
771 natom = SIZE(particle_set)
772 nsubset = SIZE(molecule_set)
773
774 apt_el_dcdr => vcd_env%dcdr_env%apt_el_dcdr
775 apt_nuc_dcdr => vcd_env%dcdr_env%apt_nuc_dcdr
776 apt_total_dcdr => vcd_env%dcdr_env%apt_total_dcdr
777 apt_subset_dcdr => vcd_env%dcdr_env%apt_el_dcdr_per_subset
778 apt_center_dcdr => vcd_env%dcdr_env%apt_el_dcdr_per_center
779
780 apt_el_nvpt => vcd_env%apt_el_nvpt
781 apt_nuc_nvpt => vcd_env%apt_nuc_nvpt
782 apt_total_nvpt => vcd_env%apt_total_nvpt
783
784 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A)") &
785 'APT | Write the final APT matrix per atom (Position perturbation)'
786 DO l = 1, natom
787 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,I3,A,F15.6)") &
788 'APT | Atom', l, ' - GAPT ', &
789 (apt_total_dcdr(1, 1, l) &
790 + apt_total_dcdr(2, 2, l) &
791 + apt_total_dcdr(3, 3, l))/3._dp
792 DO i = 1, 3
793 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,F15.6,F15.6,F15.6)") "APT | ", apt_total_dcdr(i, :, l)
794 END DO
795 END DO
796
797 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A)") &
798 'NVP | Write the final APT matrix per atom (Velocity perturbation)'
799 DO l = 1, natom
800 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,I3,A,F15.6)") &
801 'NVP | Atom', l, ' - GAPT ', &
802 (apt_total_nvpt(1, 1, l) &
803 + apt_total_nvpt(2, 2, l) &
804 + apt_total_nvpt(3, 3, l))/3._dp
805 DO i = 1, 3
806 IF (vcd_env%output_unit > 0) THEN
807 WRITE (vcd_env%output_unit, "(A,F15.6,F15.6,F15.6)") &
808 "NVP | ", apt_total_nvpt(i, :, l)
809 END IF
810 END DO
811 END DO
812
813 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A)") &
814 'NVP | Write the final AAT matrix per atom (Velocity perturbation)'
815 DO l = 1, natom
816 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,I3)") &
817 'NVP | Atom', l
818 DO i = 1, 3
819 IF (vcd_env%output_unit > 0) THEN
820 WRITE (vcd_env%output_unit, "(A,F15.6,F15.6,F15.6)") &
821 "NVP | ", vcd_env%aat_atom_nvpt(i, :, l)
822 END IF
823 END DO
824 END DO
825
826 IF (vcd_env%do_mfp) THEN
827 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A)") &
828 'MFP | Write the final AAT matrix per atom (Magnetic Field perturbation)'
829 DO l = 1, natom
830 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,I3)") &
831 'MFP | Atom', l
832 DO i = 1, 3
833 IF (vcd_env%output_unit > 0) THEN
834 WRITE (vcd_env%output_unit, "(A,F15.6,F15.6,F15.6)") &
835 "MFP | ", vcd_env%aat_atom_mfp(i, :, l)
836 END IF
837 END DO
838 END DO
839 END IF
840
841 ! Get the dipole
842 CALL get_qs_env(qs_env, results=results)
843 description = "[DIPOLE]"
844 CALL get_results(results=results, description=description, values=vcd_env%dcdr_env%dipole_pos(1:3))
845
846 ! Sum rules [for all alpha, beta]
847 sum_rule_0 = 0._dp
848 sum_rule_1 = 0._dp
849 sum_rule_2 = 0._dp
850 sum_rule_0_second = 0._dp
851 sum_rule_2_second = 0._dp
852 sum_rule_3_second = 0._dp
853 sum_rule_3_mfp = 0._dp
854 standard_deviation = 0._dp
855 standard_deviation_sum = 0._dp
856
857 DO alpha = 1, 3
858 DO beta = 1, 3
859 ! 0: sum_lambda apt(alpha, beta, lambda)
860 DO lambda = 1, natom
861 sum_rule_0(alpha, beta) = sum_rule_0(alpha, beta) &
862 + apt_total_dcdr(alpha, beta, lambda)
863 sum_rule_0_second(alpha, beta) = sum_rule_0_second(alpha, beta) &
864 + apt_total_nvpt(alpha, beta, lambda)
865 END DO
866
867 ! 1: sum_gamma epsilon_(alpha beta gamma) mu_gamma
868 DO gamma = 1, 3
869 sum_rule_1(alpha, beta) = sum_rule_1(alpha, beta) &
870 + levi_civita(alpha, beta, gamma)*vcd_env%dcdr_env%dipole_pos(gamma)
871 END DO
872
873 ! 2: sum_(lambda gamma delta) R^lambda_gamma apt(delta, alpha, lambda)
874 DO lambda = 1, natom
875 DO gamma = 1, 3
876 DO delta = 1, 3
877 sum_rule_2(alpha, beta) = sum_rule_2(alpha, beta) &
878 + levi_civita(beta, gamma, delta) &
879 *particle_set(lambda)%r(gamma) &
880 *apt_total_dcdr(delta, alpha, lambda)
881 sum_rule_2_second(alpha, beta) = sum_rule_2_second(alpha, beta) &
882 + levi_civita(beta, gamma, delta) &
883 *particle_set(lambda)%r(gamma) &
884 *apt_total_nvpt(delta, alpha, lambda)
885 END DO
886 END DO
887 END DO
888
889 ! 3: 2c * sum_lambda aat(alpha, beta, lambda)
890 DO lambda = 1, natom
891 sum_rule_3_second(alpha, beta) = sum_rule_3_second(alpha, beta) &
892 + vcd_env%aat_atom_nvpt(alpha, beta, lambda)
893 ! + 2._dp*c_light_au*vcd_env%aat_atom_nvpt(alpha, beta, lambda)
894 END DO
895
896 IF (vcd_env%do_mfp) THEN
897 ! 3: 2c * sum_lambda aat(alpha, beta, lambda)
898 DO lambda = 1, natom
899 sum_rule_3_mfp(alpha, beta) = sum_rule_3_mfp(alpha, beta) &
900 + vcd_env%aat_atom_mfp(alpha, beta, lambda)
901 END DO
902 END IF
903
904 END DO ! beta
905 END DO ! alpha
906
907 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A)") "APT | Position perturbation sum rules"
908 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(A,T19,A,T35,A,T50,A,T65,A)") &
909 "APT |", " Total APT", "Dipole", "R * APT", "AAT"
910 standard_deviation_sum = 0._dp
911 DO alpha = 1, 3
912 DO beta = 1, 3
913 mean = (sum_rule_1(alpha, beta) + sum_rule_2(alpha, beta) + sum_rule_3_mfp(alpha, beta))/3
914 standard_deviation = &
915 sqrt((sum_rule_1(alpha, beta)**2 + sum_rule_2(alpha, beta)**2 + sum_rule_3_mfp(alpha, beta)**2)/3 &
916 - mean**2)
917 standard_deviation_sum = standard_deviation_sum + standard_deviation
918
919 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, &
920 "(A,I3,I3,F15.6,F15.6,F15.6,F15.6,F15.6)") &
921 "APT | ", &
922 alpha, beta, &
923 sum_rule_0(alpha, beta), &
924 sum_rule_1(alpha, beta), &
925 sum_rule_2(alpha, beta), &
926 sum_rule_3_mfp(alpha, beta), &
927 standard_deviation
928 END DO
929 END DO
930 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(T73,F15.6)") standard_deviation_sum
931
932 IF (vcd_env%output_unit > 0) THEN
933 WRITE (vcd_env%output_unit, "(A)") "NVP | Velocity perturbation sum rules"
934 WRITE (vcd_env%output_unit, "(A,T19,A,T35,A,T50,A,T65,A)") "NVP |", " Total APT", "Dipole", "R * APT", "AAT"
935 END IF
936
937 standard_deviation_sum = 0._dp
938 DO alpha = 1, 3
939 DO beta = 1, 3
940 mean = (sum_rule_1(alpha, beta) + sum_rule_2_second(alpha, beta) + sum_rule_3_second(alpha, beta))/3
941 standard_deviation = &
942 sqrt((sum_rule_1(alpha, beta)**2 + sum_rule_2_second(alpha, beta)**2 + sum_rule_3_second(alpha, beta)**2)/3 &
943 - mean**2)
944 standard_deviation_sum = standard_deviation_sum + standard_deviation
945 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, &
946 "(A,I3,I3,F15.6,F15.6,F15.6,F15.6,F15.6)") &
947 "NVP | ", &
948 alpha, &
949 beta, &
950 sum_rule_0_second(alpha, beta), &
951 sum_rule_1(alpha, beta), &
952 sum_rule_2_second(alpha, beta), &
953 sum_rule_3_second(alpha, beta), &
954 standard_deviation
955 END DO
956 END DO
957 IF (vcd_env%output_unit > 0) WRITE (vcd_env%output_unit, "(T73,F15.6)") standard_deviation_sum
958
959 CALL timestop(handle)
960 END SUBROUTINE vcd_print
961
962END MODULE qs_vcd_utils
Handles all functions related to the CELL.
Definition cell_types.F:15
Calculation of the non-local pseudopotential contribution to the core Hamiltonian <a|V(non-local)|b> ...
subroutine, public build_com_mom_nl(qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_set, cell, matrix_rv, matrix_rxrv, matrix_rrv, matrix_rvr, matrix_rrv_vrr, matrix_r_rxvr, matrix_rxvr_r, matrix_r_doublecom, pseudoatom, ref_point)
Calculate [r,Vnl] (matrix_rv), r x [r,Vnl] (matrix_rxrv) or [rr,Vnl] (matrix_rrv) in AO basis....
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_set(matrix, alpha)
...
DBCSR operations in CP2K.
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
Definition cp_files.F:311
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
Definition cp_files.F:122
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
Definition cp_files.F:504
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
character(len=default_path_length) function, public cp_print_key_generate_filename(logger, print_key, middle_name, extension, my_local)
Utility function that returns a unit number to write the print key. Might open a file with a unique f...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
set of type/routines to handle the storage of results in force_envs
set of type/routines to handle the storage of results in force_envs
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Definition gamma.F:15
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public use_mom_ref_user
objects that represent the structure of input sections and the data contained in an input section
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Interface to the message passing library MPI.
Define the data structure for the molecule information.
Calculates the moment integrals <a|r^m|b>
subroutine, public get_reference_point(rpoint, drpoint, qs_env, fist_env, reference, ref_point, ifirst, ilast)
...
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
Define the data structure for the particle information.
Calculate the derivatives of the MO coefficients wrt nuclear coordinates.
subroutine, public dcdr_env_cleanup(qs_env, dcdr_env)
Deallocate the dcdr environment.
subroutine, public dcdr_env_init(dcdr_env, qs_env)
Initialize the dcdr environment.
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.
Define the quickstep kind type and their sub types.
Type definitiona for linear response calculations.
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Calculates the moment integrals <a|r^m|b> and <a|r x d/dr|b>
Definition qs_moments.F:14
subroutine, public build_local_moments_der_matrix(qs_env, moments_der, nmoments_der, nmoments, ref_point, moments, basis_type, minimum_image, ordered, lambda, deltar, neighbor_image)
Calculate right-hand sided derivatives of multipole moments, e. g. < a | xy d/dz | b > Optionally sto...
Definition qs_moments.F:433
Define the neighbor list data types and the corresponding functionality.
subroutine, public build_lin_mom_matrix(qs_env, matrix, minimum_image)
Calculation of the linear momentum matrix <mu|∂|nu> over Cartesian Gaussian functions.
subroutine, public build_com_rpnl_r(matrix_rv, qs_kind_set, sab_all, sap_ppnl, eps_ppnl, particle_set, cell, direction_or)
Builds the [Vnl, r] * r from either side.
Definition qs_vcd_ao.F:1549
subroutine, public build_matrix_hr_rh(vcd_env, qs_env, rc)
Build the matrix Hr*delta_nu^\lambda - rH*delta_mu^\lambda.
Definition qs_vcd_ao.F:118
subroutine, public vcd_print(vcd_env, qs_env)
Print the APTs, AATs, and sum rules.
subroutine, public vcd_env_cleanup(qs_env, vcd_env)
Deallocate the vcd environment.
subroutine, public vcd_write_restart(qs_env, linres_section, vec, lambda, beta, tag)
Copied from linres_write_restart.
subroutine, public vcd_env_init(vcd_env, qs_env)
Initialize the vcd environment.
subroutine, public vcd_read_restart(qs_env, linres_section, vec, lambda, beta, tag)
Copied from linres_read_restart.
Utilities for string manipulations.
elemental subroutine, public xstring(string, ia, ib)
...
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represent a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
contains arbitrary information which need to be stored
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...