(git:ed6f26b)
Loading...
Searching...
No Matches
ec_external.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Routines for an external energy correction on top of a Kohn-Sham calculation
10!> \par History
11!> 10.2024 created
12!> \author JGH
13! **************************************************************************************************
16 USE cell_types, ONLY: cell_type
17 USE core_ppl, ONLY: build_core_ppl
18 USE core_ppnl, ONLY: build_core_ppnl
20 USE cp_dbcsr_api, ONLY: dbcsr_add,&
24 dbcsr_set,&
26 dbcsr_type_symmetric
35 USE cp_fm_types, ONLY: cp_fm_create,&
47 USE kinds, ONLY: default_string_length,&
48 dp
49 USE mathlib, ONLY: det_3x3
53 USE physcon, ONLY: pascal
66 USE qs_rho_types, ONLY: qs_rho_get,&
68 USE trexio_utils, ONLY: read_trexio
70 USE virial_types, ONLY: virial_type
71#include "./base/base_uses.f90"
72
73 IMPLICIT NONE
74
75 PRIVATE
76
77! *** Global parameters ***
78
79 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'ec_external'
80
81 PUBLIC :: ec_ext_energy
82
83CONTAINS
84
85! **************************************************************************************************
86!> \brief External energy method
87!> \param qs_env ...
88!> \param ec_env ...
89!> \param calculate_forces ...
90!> \par History
91!> 10.2024 created
92!> \author JGH
93! **************************************************************************************************
94 SUBROUTINE ec_ext_energy(qs_env, ec_env, calculate_forces)
95 TYPE(qs_environment_type), POINTER :: qs_env
96 TYPE(energy_correction_type), POINTER :: ec_env
97 LOGICAL, INTENT(IN) :: calculate_forces
98
99 CHARACTER(len=*), PARAMETER :: routinen = 'ec_ext_energy'
100
101 INTEGER :: handle, ispin, nocc, nspins, unit_nr
102 REAL(kind=dp) :: focc
103 TYPE(cp_fm_struct_type), POINTER :: fm_struct
104 TYPE(cp_fm_type), DIMENSION(:), POINTER :: cpmos, mo_occ, mo_ref
105 TYPE(cp_fm_type), POINTER :: mo_coeff
106 TYPE(cp_logger_type), POINTER :: logger
107 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_s
108 TYPE(dft_control_type), POINTER :: dft_control
109 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
110
111 CALL timeset(routinen, handle)
112
113 CALL get_qs_env(qs_env, dft_control=dft_control)
114 nspins = dft_control%nspins
115
116 logger => cp_get_default_logger()
117 IF (logger%para_env%is_source()) THEN
118 unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
119 ELSE
120 unit_nr = -1
121 END IF
122
123 CALL get_qs_env(qs_env, mos=mos)
124 ALLOCATE (cpmos(nspins), mo_ref(nspins), mo_occ(nspins))
125
126 CALL cp_fm_release(ec_env%mo_occ)
127 CALL cp_fm_release(ec_env%cpmos)
128 IF (ec_env%debug_external) THEN
129 !
130 DO ispin = 1, nspins
131 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=nocc)
132 NULLIFY (fm_struct)
133 CALL cp_fm_struct_create(fm_struct, ncol_global=nocc, &
134 template_fmstruct=mo_coeff%matrix_struct)
135 CALL cp_fm_create(cpmos(ispin), fm_struct)
136 CALL cp_fm_set_all(cpmos(ispin), 0.0_dp)
137 CALL cp_fm_create(mo_ref(ispin), fm_struct)
138 CALL cp_fm_set_all(mo_ref(ispin), 0.0_dp)
139 CALL cp_fm_create(mo_occ(ispin), fm_struct)
140 CALL cp_fm_to_fm(mo_coeff, mo_occ(ispin), nocc)
141 CALL cp_fm_struct_release(fm_struct)
142 END DO
143 !
144 ec_env%mo_occ => mo_ref
145 CALL ec_ext_debug(qs_env, ec_env, calculate_forces, unit_nr)
146 !
147 IF (calculate_forces) THEN
148 focc = 2.0_dp
149 IF (nspins == 1) focc = 4.0_dp
150 DO ispin = 1, nspins
151 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=nocc)
152 CALL cp_dbcsr_sm_fm_multiply(ec_env%matrix_h(1, 1)%matrix, ec_env%mo_occ(ispin), &
153 cpmos(ispin), nocc, &
154 alpha=focc, beta=0.0_dp)
155 END DO
156 END IF
157 ec_env%cpmos => cpmos
158 ELSE
159 DO ispin = 1, nspins
160 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=nocc)
161 NULLIFY (fm_struct)
162 CALL cp_fm_struct_create(fm_struct, ncol_global=nocc, &
163 template_fmstruct=mo_coeff%matrix_struct)
164 CALL cp_fm_create(cpmos(ispin), fm_struct)
165 CALL cp_fm_set_all(cpmos(ispin), 0.0_dp)
166 CALL cp_fm_create(mo_occ(ispin), fm_struct)
167 CALL cp_fm_to_fm(mo_coeff, mo_occ(ispin), nocc)
168 CALL cp_fm_create(mo_ref(ispin), fm_struct)
169 CALL cp_fm_set_all(mo_ref(ispin), 0.0_dp)
170 CALL cp_fm_struct_release(fm_struct)
171 END DO
172
173 ! get external information
174 CALL ec_ext_interface(qs_env, ec_env%exresp_fn, mo_occ, mo_ref, cpmos, calculate_forces, unit_nr)
175 ec_env%mo_occ => mo_ref
176 ec_env%cpmos => cpmos
177 END IF
178
179 IF (calculate_forces) THEN
180 ! check for orbital rotations
181 CALL get_qs_env(qs_env, matrix_s=matrix_s)
182 DO ispin = 1, nspins
183 CALL align_vectors(ec_env%cpmos(ispin), ec_env%mo_occ(ispin), mo_occ(ispin), &
184 matrix_s(1)%matrix, unit_nr)
185 END DO
186 ! set up matrices for response
187 CALL ec_ext_setup(qs_env, ec_env, .true., unit_nr)
188 ! orthogonality force
189 CALL matrix_r_forces(qs_env, ec_env%cpmos, ec_env%mo_occ, &
190 ec_env%matrix_w(1, 1)%matrix, unit_nr)
191 ELSE
192 CALL ec_ext_setup(qs_env, ec_env, .false., unit_nr)
193 END IF
194
195 CALL cp_fm_release(mo_occ)
196
197 CALL timestop(handle)
198
199 END SUBROUTINE ec_ext_energy
200
201! **************************************************************************************************
202
203! **************************************************************************************************
204!> \brief ...
205!> \param qs_env ...
206!> \param trexio_fn ...
207!> \param mo_occ ...
208!> \param mo_ref ...
209!> \param cpmos ...
210!> \param calculate_forces ...
211!> \param unit_nr ...
212! **************************************************************************************************
213 SUBROUTINE ec_ext_interface(qs_env, trexio_fn, mo_occ, mo_ref, cpmos, calculate_forces, unit_nr)
214 TYPE(qs_environment_type), POINTER :: qs_env
215 CHARACTER(LEN=*) :: trexio_fn
216 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_occ, mo_ref, cpmos
217 LOGICAL, INTENT(IN) :: calculate_forces
218 INTEGER, INTENT(IN) :: unit_nr
219
220 CHARACTER(LEN=*), PARAMETER :: routinen = 'ec_ext_interface'
221
222 INTEGER :: handle, ispin, nao, nmos, nocc(2), nspins
223 REAL(kind=dp) :: focc
224 TYPE(cp_fm_type), POINTER :: mo_coeff
225 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: energy_derivative
226 TYPE(dft_control_type), POINTER :: dft_control
227 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos_trexio
228 TYPE(mp_para_env_type), POINTER :: para_env
229
230 CALL timeset(routinen, handle)
231
232 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, para_env=para_env)
233
234 nspins = dft_control%nspins
235 nocc = 0
236 DO ispin = 1, nspins
237 CALL cp_fm_get_info(mo_occ(ispin), nrow_global=nao, ncol_global=nocc(ispin))
238 END DO
239
240 IF (unit_nr > 0) THEN
241 WRITE (unit_nr, '(T2,A)') " Read EXTERNAL Response from file: "//trim(trexio_fn)
242 END IF
243 ALLOCATE (mos_trexio(nspins))
244 IF (calculate_forces) THEN
245 NULLIFY (energy_derivative)
246 CALL dbcsr_allocate_matrix_set(energy_derivative, nspins)
247 !
248 CALL read_trexio(qs_env, trexio_filename=trexio_fn, &
249 mo_set_trexio=mos_trexio, &
250 energy_derivative=energy_derivative)
251 !
252 focc = 2.0_dp
253 IF (nspins == 1) focc = 4.0_dp
254 DO ispin = 1, nspins
255 CALL get_mo_set(mo_set=mos_trexio(ispin), mo_coeff=mo_coeff, homo=nmos)
256 CALL cp_dbcsr_sm_fm_multiply(energy_derivative(ispin)%matrix, mo_occ(ispin), &
257 cpmos(ispin), ncol=nmos, alpha=focc, beta=0.0_dp)
258 END DO
259 !
260 CALL dbcsr_deallocate_matrix_set(energy_derivative)
261 ELSE
262 CALL read_trexio(qs_env, trexio_filename=trexio_fn, &
263 mo_set_trexio=mos_trexio)
264 END IF
265 !
266 DO ispin = 1, nspins
267 CALL get_mo_set(mo_set=mos_trexio(ispin), mo_coeff=mo_coeff, homo=nmos)
268 CALL cp_fm_to_fm(mo_coeff, mo_ref(ispin), nmos)
269 CALL deallocate_mo_set(mos_trexio(ispin))
270 END DO
271 DEALLOCATE (mos_trexio)
272
273 CALL timestop(handle)
274
275 END SUBROUTINE ec_ext_interface
276
277! **************************************************************************************************
278
279! **************************************************************************************************
280!> \brief ...
281!> \param qs_env ...
282!> \param ec_env ...
283!> \param calculate_forces ...
284!> \param unit_nr ...
285! **************************************************************************************************
286 SUBROUTINE ec_ext_debug(qs_env, ec_env, calculate_forces, unit_nr)
287 TYPE(qs_environment_type), POINTER :: qs_env
288 TYPE(energy_correction_type), POINTER :: ec_env
289 LOGICAL, INTENT(IN) :: calculate_forces
290 INTEGER, INTENT(IN) :: unit_nr
291
292 CHARACTER(LEN=*), PARAMETER :: routinen = 'ec_ext_debug'
293
294 CHARACTER(LEN=default_string_length) :: headline
295 INTEGER :: handle, ispin, nocc, nspins
296 TYPE(cp_fm_type), POINTER :: mo_coeff
297 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_h, matrix_p, matrix_s
298 TYPE(dft_control_type), POINTER :: dft_control
299 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos
300 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
301 POINTER :: sab_orb
302 TYPE(qs_rho_type), POINTER :: rho
303
304 CALL timeset(routinen, handle)
305
306 CALL get_qs_env(qs_env=qs_env, &
307 dft_control=dft_control, &
308 sab_orb=sab_orb, &
309 rho=rho, &
310 matrix_s_kp=matrix_s, &
311 matrix_h_kp=matrix_h)
312
313 nspins = dft_control%nspins
314 CALL get_qs_env(qs_env, mos=mos)
315 DO ispin = 1, nspins
316 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, homo=nocc)
317 CALL cp_fm_to_fm(mo_coeff, ec_env%mo_occ(ispin), nocc)
318 END DO
319
320 ! Core Hamiltonian matrix
321 IF (ASSOCIATED(ec_env%matrix_h)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_h)
322 CALL dbcsr_allocate_matrix_set(ec_env%matrix_h, 1, 1)
323 headline = "CORE HAMILTONIAN MATRIX"
324 ALLOCATE (ec_env%matrix_h(1, 1)%matrix)
325 CALL dbcsr_create(ec_env%matrix_h(1, 1)%matrix, name=trim(headline), &
326 template=matrix_h(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
327 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_h(1, 1)%matrix, sab_orb)
328 CALL dbcsr_copy(ec_env%matrix_h(1, 1)%matrix, matrix_h(1, 1)%matrix)
329
330 ! Get density matrix of reference calculation
331 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
332 ! Use Core energy as model energy
333 CALL calculate_ptrace(ec_env%matrix_h, matrix_p, ec_env%ex, nspins)
334
335 IF (calculate_forces) THEN
336 ! force of model energy
337 CALL ec_debug_force(qs_env, matrix_p, unit_nr)
338 END IF
339
340 CALL timestop(handle)
341
342 END SUBROUTINE ec_ext_debug
343
344! **************************************************************************************************
345!> \brief ...
346!> \param qs_env ...
347!> \param matrix_p ...
348!> \param unit_nr ...
349! **************************************************************************************************
350 SUBROUTINE ec_debug_force(qs_env, matrix_p, unit_nr)
351 TYPE(qs_environment_type), POINTER :: qs_env
352 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_p
353 INTEGER, INTENT(IN) :: unit_nr
354
355 CHARACTER(LEN=*), PARAMETER :: routinen = 'ec_debug_force'
356
357 INTEGER :: handle, iounit, nder, nimages
358 INTEGER, DIMENSION(:, :, :), POINTER :: cell_to_index
359 LOGICAL :: calculate_forces, debug_forces, &
360 debug_stress, use_virial
361 REAL(kind=dp) :: eps_ppnl, fconv
362 REAL(kind=dp), DIMENSION(3) :: fodeb
363 REAL(kind=dp), DIMENSION(3, 3) :: stdeb, sttot
364 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
365 TYPE(cell_type), POINTER :: cell
366 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: scrm
367 TYPE(dft_control_type), POINTER :: dft_control
368 TYPE(mp_para_env_type), POINTER :: para_env
369 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
370 POINTER :: sab_orb, sac_ppl, sap_ppnl
371 TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
372 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
373 TYPE(qs_kind_type), DIMENSION(:), POINTER :: qs_kind_set
374 TYPE(qs_ks_env_type), POINTER :: ks_env
375 TYPE(virial_type), POINTER :: virial
376
377 CALL timeset(routinen, handle)
378
379 debug_forces = .true.
380 debug_stress = .true.
381 iounit = unit_nr
382
383 calculate_forces = .true.
384
385 ! no k-points possible
386 NULLIFY (cell, dft_control, force, ks_env, para_env, virial)
387 CALL get_qs_env(qs_env=qs_env, &
388 cell=cell, &
389 dft_control=dft_control, &
390 force=force, &
391 ks_env=ks_env, &
392 para_env=para_env, &
393 virial=virial)
394 nimages = dft_control%nimages
395 IF (nimages /= 1) THEN
396 cpabort("K-points not implemented")
397 END IF
398
399 ! check for virial
400 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
401
402 fconv = 1.0e-9_dp*pascal/cell%deth
403 IF (debug_stress .AND. use_virial) THEN
404 sttot = virial%pv_virial
405 END IF
406
407 ! check for GAPW/GAPW_XC
408 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc) THEN
409 cpabort("GAPW not implemented")
410 END IF
411
412 ! get neighbor lists
413 NULLIFY (sab_orb, sac_ppl, sap_ppnl)
414 CALL get_qs_env(qs_env=qs_env, &
415 sab_orb=sab_orb, sac_ppl=sac_ppl, sap_ppnl=sap_ppnl)
416
417 ! initialize src matrix
418 NULLIFY (scrm)
419 CALL dbcsr_allocate_matrix_set(scrm, 1, 1)
420 ALLOCATE (scrm(1, 1)%matrix)
421 CALL dbcsr_create(scrm(1, 1)%matrix, template=matrix_p(1, 1)%matrix)
422 CALL cp_dbcsr_alloc_block_from_nbl(scrm(1, 1)%matrix, sab_orb)
423
424 nder = 1
425 IF (SIZE(matrix_p, 1) == 2) THEN
426 CALL dbcsr_add(matrix_p(1, 1)%matrix, matrix_p(2, 1)%matrix, &
427 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
428 END IF
429
430 ! kinetic energy
431 IF (debug_forces) fodeb(1:3) = force(1)%kinetic(1:3, 1)
432 IF (debug_stress .AND. use_virial) stdeb = virial%pv_ekinetic
433 CALL build_kinetic_matrix(ks_env, matrixkp_t=scrm, &
434 matrix_name="KINETIC ENERGY MATRIX", &
435 basis_type="ORB", &
436 sab_nl=sab_orb, calculate_forces=.true., &
437 matrixkp_p=matrix_p)
438 IF (debug_forces) THEN
439 fodeb(1:3) = force(1)%kinetic(1:3, 1) - fodeb(1:3)
440 CALL para_env%sum(fodeb)
441 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Pout*dT ", fodeb
442 END IF
443 IF (debug_stress .AND. use_virial) THEN
444 stdeb = fconv*(virial%pv_ekinetic - stdeb)
445 CALL para_env%sum(stdeb)
446 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
447 'STRESS| Pout*dT', one_third_sum_diag(stdeb), det_3x3(stdeb)
448 END IF
449 IF (SIZE(matrix_p, 1) == 2) THEN
450 CALL dbcsr_add(matrix_p(1, 1)%matrix, matrix_p(2, 1)%matrix, &
451 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
452 END IF
453
454 ! compute the ppl contribution to the core hamiltonian
455 NULLIFY (atomic_kind_set, particle_set, qs_kind_set)
456 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, particle_set=particle_set, &
457 atomic_kind_set=atomic_kind_set)
458
459 IF (ASSOCIATED(sac_ppl)) THEN
460 IF (calculate_forces .AND. debug_forces) fodeb(1:3) = force(1)%gth_ppl(1:3, 1)
461 IF (debug_stress .AND. use_virial) stdeb = virial%pv_ppl
462 CALL build_core_ppl(scrm, matrix_p, force, &
463 virial, calculate_forces, use_virial, nder, &
464 qs_kind_set, atomic_kind_set, particle_set, sab_orb, sac_ppl, &
465 nimages, cell_to_index, "ORB")
466 IF (calculate_forces .AND. debug_forces) THEN
467 fodeb(1:3) = force(1)%gth_ppl(1:3, 1) - fodeb(1:3)
468 CALL para_env%sum(fodeb)
469 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Pout*dH_PPL ", fodeb
470 END IF
471 IF (debug_stress .AND. use_virial) THEN
472 stdeb = fconv*(virial%pv_ppl - stdeb)
473 CALL para_env%sum(stdeb)
474 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
475 'STRESS| Pout*dH_PPL', one_third_sum_diag(stdeb), det_3x3(stdeb)
476 END IF
477 END IF
478
479 ! compute the ppnl contribution to the core hamiltonian ***
480 eps_ppnl = dft_control%qs_control%eps_ppnl
481 IF (ASSOCIATED(sap_ppnl)) THEN
482 IF (calculate_forces .AND. debug_forces) fodeb(1:3) = force(1)%gth_ppnl(1:3, 1)
483 IF (debug_stress .AND. use_virial) stdeb = virial%pv_ppnl
484 CALL build_core_ppnl(scrm, matrix_p, force, &
485 virial, calculate_forces, use_virial, nder, &
486 qs_kind_set, atomic_kind_set, particle_set, &
487 sab_orb, sap_ppnl, eps_ppnl, &
488 nimages, cell_to_index, "ORB")
489 IF (calculate_forces .AND. debug_forces) THEN
490 fodeb(1:3) = force(1)%gth_ppnl(1:3, 1) - fodeb(1:3)
491 CALL para_env%sum(fodeb)
492 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Pout*dH_PPNL", fodeb
493 END IF
494 IF (debug_stress .AND. use_virial) THEN
495 stdeb = fconv*(virial%pv_ppnl - stdeb)
496 CALL para_env%sum(stdeb)
497 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
498 'STRESS| Pout*dH_PPNL', one_third_sum_diag(stdeb), det_3x3(stdeb)
499 END IF
500 END IF
501
502 IF (debug_stress .AND. use_virial) THEN
503 stdeb = fconv*(virial%pv_virial - sttot)
504 CALL para_env%sum(stdeb)
505 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
506 'STRESS| Stress Pout*dHcore ', one_third_sum_diag(stdeb), det_3x3(stdeb)
507 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") ' '
508 END IF
509
510 ! delete scr matrix
512
513 CALL timestop(handle)
514
515 END SUBROUTINE ec_debug_force
516
517! **************************************************************************************************
518
519! **************************************************************************************************
520!> \brief ...
521!> \param qs_env ...
522!> \param ec_env ...
523!> \param calc_forces ...
524!> \param unit_nr ...
525! **************************************************************************************************
526 SUBROUTINE ec_ext_setup(qs_env, ec_env, calc_forces, unit_nr)
527 TYPE(qs_environment_type), POINTER :: qs_env
528 TYPE(energy_correction_type), POINTER :: ec_env
529 LOGICAL, INTENT(IN) :: calc_forces
530 INTEGER, INTENT(IN) :: unit_nr
531
532 CHARACTER(LEN=*), PARAMETER :: routinen = 'ec_ext_setup'
533
534 CHARACTER(LEN=default_string_length) :: headline
535 INTEGER :: handle, ispin, nao, nocc, nspins
536 REAL(kind=dp) :: a_max, c_max
537 TYPE(cp_fm_struct_type), POINTER :: fm_struct, mat_struct
538 TYPE(cp_fm_type) :: emat, ksmo, smo
539 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_h, matrix_ks, matrix_p, matrix_s
540 TYPE(dft_control_type), POINTER :: dft_control
541 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
542 POINTER :: sab_orb
543 TYPE(qs_rho_type), POINTER :: rho
544
545 CALL timeset(routinen, handle)
546
547 CALL get_qs_env(qs_env=qs_env, &
548 dft_control=dft_control, &
549 sab_orb=sab_orb, &
550 rho=rho, &
551 matrix_s_kp=matrix_s, &
552 matrix_ks_kp=matrix_ks, &
553 matrix_h_kp=matrix_h)
554
555 nspins = dft_control%nspins
556
557 ! KS Hamiltonian matrix
558 IF (ASSOCIATED(ec_env%matrix_ks)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_ks)
559 CALL dbcsr_allocate_matrix_set(ec_env%matrix_ks, nspins, 1)
560 headline = "HAMILTONIAN MATRIX"
561 DO ispin = 1, nspins
562 ALLOCATE (ec_env%matrix_ks(ispin, 1)%matrix)
563 CALL dbcsr_create(ec_env%matrix_ks(ispin, 1)%matrix, name=trim(headline), &
564 template=matrix_ks(ispin, 1)%matrix, matrix_type=dbcsr_type_symmetric)
565 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_ks(ispin, 1)%matrix, sab_orb)
566 CALL dbcsr_copy(ec_env%matrix_ks(ispin, 1)%matrix, matrix_ks(ispin, 1)%matrix)
567 END DO
568
569 ! Overlap matrix
570 IF (ASSOCIATED(ec_env%matrix_s)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_s)
571 CALL dbcsr_allocate_matrix_set(ec_env%matrix_s, 1, 1)
572 headline = "OVERLAP MATRIX"
573 ALLOCATE (ec_env%matrix_s(1, 1)%matrix)
574 CALL dbcsr_create(ec_env%matrix_s(1, 1)%matrix, name=trim(headline), &
575 template=matrix_s(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
576 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_s(1, 1)%matrix, sab_orb)
577 CALL dbcsr_copy(ec_env%matrix_s(1, 1)%matrix, matrix_s(1, 1)%matrix)
578
579 ! density matrix
580 ! Get density matrix of reference calculation
581 CALL qs_rho_get(rho, rho_ao_kp=matrix_p)
582 IF (ASSOCIATED(ec_env%matrix_p)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_p)
583 CALL dbcsr_allocate_matrix_set(ec_env%matrix_p, nspins, 1)
584 headline = "DENSITY MATRIX"
585 DO ispin = 1, nspins
586 ALLOCATE (ec_env%matrix_p(ispin, 1)%matrix)
587 CALL dbcsr_create(ec_env%matrix_p(ispin, 1)%matrix, name=trim(headline), &
588 template=matrix_p(ispin, 1)%matrix, matrix_type=dbcsr_type_symmetric)
589 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_p(ispin, 1)%matrix, sab_orb)
590 CALL dbcsr_copy(ec_env%matrix_p(ispin, 1)%matrix, matrix_p(ispin, 1)%matrix)
591 END DO
592
593 IF (calc_forces) THEN
594 ! energy weighted density matrix
595 ! for security, we recalculate W here (stored in qs_env)
596 IF (ASSOCIATED(ec_env%matrix_w)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_w)
597 CALL dbcsr_allocate_matrix_set(ec_env%matrix_w, nspins, 1)
598 headline = "ENERGY WEIGHTED DENSITY MATRIX"
599 DO ispin = 1, nspins
600 ALLOCATE (ec_env%matrix_w(ispin, 1)%matrix)
601 CALL dbcsr_create(ec_env%matrix_w(ispin, 1)%matrix, name=trim(headline), &
602 template=matrix_p(ispin, 1)%matrix, matrix_type=dbcsr_type_symmetric)
603 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_w(ispin, 1)%matrix, sab_orb)
604 CALL dbcsr_set(ec_env%matrix_w(ispin, 1)%matrix, 0.0_dp)
605 END DO
606
607 ! hz matrix
608 IF (ASSOCIATED(ec_env%matrix_hz)) CALL dbcsr_deallocate_matrix_set(ec_env%matrix_hz)
609 CALL dbcsr_allocate_matrix_set(ec_env%matrix_hz, nspins)
610 headline = "Hz MATRIX"
611 DO ispin = 1, nspins
612 ALLOCATE (ec_env%matrix_hz(ispin)%matrix)
613 CALL dbcsr_create(ec_env%matrix_hz(ispin)%matrix, name=trim(headline), &
614 template=matrix_s(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
615 CALL cp_dbcsr_alloc_block_from_nbl(ec_env%matrix_hz(ispin)%matrix, sab_orb)
616 CALL dbcsr_set(ec_env%matrix_hz(ispin)%matrix, 0.0_dp)
617 END DO
618
619 ! Test for consistency of orbitals and KS matrix
620 DO ispin = 1, nspins
621 mat_struct => ec_env%mo_occ(ispin)%matrix_struct
622 CALL cp_fm_create(ksmo, mat_struct)
623 CALL cp_fm_get_info(ksmo, nrow_global=nao, ncol_global=nocc)
624 CALL cp_dbcsr_sm_fm_multiply(ec_env%matrix_ks(ispin, 1)%matrix, ec_env%mo_occ(ispin), &
625 ksmo, nocc, alpha=1.0_dp, beta=0.0_dp)
626 CALL cp_fm_create(smo, mat_struct)
627 CALL cp_dbcsr_sm_fm_multiply(ec_env%matrix_s(1, 1)%matrix, ec_env%mo_occ(ispin), &
628 smo, nocc, alpha=1.0_dp, beta=0.0_dp)
629 CALL cp_fm_struct_create(fm_struct, ncol_global=nocc, nrow_global=nocc, &
630 template_fmstruct=mat_struct)
631 CALL cp_fm_create(emat, fm_struct)
632 CALL parallel_gemm('T', 'N', nocc, nocc, nao, 1.0_dp, ec_env%mo_occ(ispin), ksmo, 0.0_dp, emat)
633 CALL parallel_gemm('N', 'N', nao, nocc, nocc, -1.0_dp, smo, emat, 1.0_dp, ksmo)
634 CALL cp_fm_maxabsval(ksmo, a_max)
635 CALL cp_fm_struct_release(fm_struct)
636 CALL cp_fm_release(smo)
637 CALL cp_fm_release(ksmo)
638 CALL cp_fm_release(emat)
639 CALL cp_fm_maxabsval(ec_env%mo_occ(ispin), c_max)
640 IF (unit_nr > 0) THEN
641 WRITE (unit_nr, "(T3,A,T50,I2,T61,F20.12)") "External:: Max value of MO coeficients", ispin, c_max
642 WRITE (unit_nr, "(T3,A,T50,I2,T61,F20.12)") "External:: Max value of MO gradients", ispin, a_max
643 END IF
644 END DO
645 END IF
646
647 CALL timestop(handle)
648
649 END SUBROUTINE ec_ext_setup
650
651! **************************************************************************************************
652!> \brief ...
653!> \param cpmos ...
654!> \param mo_ref ...
655!> \param mo_occ ...
656!> \param matrix_s ...
657!> \param unit_nr ...
658! **************************************************************************************************
659 SUBROUTINE align_vectors(cpmos, mo_ref, mo_occ, matrix_s, unit_nr)
660 TYPE(cp_fm_type), INTENT(IN) :: cpmos, mo_ref, mo_occ
661 TYPE(dbcsr_type), POINTER :: matrix_s
662 INTEGER, INTENT(IN) :: unit_nr
663
664 CHARACTER(LEN=*), PARAMETER :: routinen = 'align_vectors'
665
666 INTEGER :: handle, i, nao, nocc, scg
667 REAL(kind=dp) :: a_max
668 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: diag
669 TYPE(cp_fm_struct_type), POINTER :: fm_struct, mat_struct
670 TYPE(cp_fm_type) :: emat, smo
671
672 CALL timeset(routinen, handle)
673
674 mat_struct => cpmos%matrix_struct
675 CALL cp_fm_create(smo, mat_struct)
676 CALL cp_fm_get_info(smo, nrow_global=nao, ncol_global=nocc)
677 CALL cp_dbcsr_sm_fm_multiply(matrix_s, mo_occ, smo, nocc, alpha=1.0_dp, beta=0.0_dp)
678 CALL cp_fm_struct_create(fm_struct, ncol_global=nocc, nrow_global=nocc, &
679 template_fmstruct=mat_struct)
680 CALL cp_fm_create(emat, fm_struct)
681 CALL parallel_gemm('T', 'N', nocc, nocc, nao, 1.0_dp, mo_ref, smo, 0.0_dp, emat)
682 CALL parallel_gemm('N', 'N', nao, nocc, nocc, 1.0_dp, cpmos, emat, 0.0_dp, smo)
683 CALL cp_fm_to_fm(smo, cpmos)
684 CALL cp_fm_to_fm(mo_occ, mo_ref)
685 !
686 ALLOCATE (diag(nocc))
687 CALL cp_fm_get_diag(emat, diag)
688 a_max = nocc - sum(diag)
689 scg = 0
690 DO i = 1, nocc
691 IF (abs(diag(i) + 1.0_dp) < 0.001) scg = scg + 1
692 END DO
693 IF (unit_nr > 0) THEN
694 WRITE (unit_nr, "(T3,A,T61,F20.8)") "External:: Orbital rotation index", a_max
695 WRITE (unit_nr, "(T3,A,T71,I10)") "External:: Number of orbital phase changes", scg
696 END IF
697
698 DEALLOCATE (diag)
699 CALL cp_fm_struct_release(fm_struct)
700 CALL cp_fm_release(smo)
701 CALL cp_fm_release(emat)
702
703 CALL timestop(handle)
704
705 END SUBROUTINE align_vectors
706
707! **************************************************************************************************
708!> \brief ...
709!> \param qs_env ...
710!> \param matrix_w ...
711!> \param unit_nr ...
712! **************************************************************************************************
713 SUBROUTINE matrix_w_forces(qs_env, matrix_w, unit_nr)
714 TYPE(qs_environment_type), POINTER :: qs_env
715 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: matrix_w
716 INTEGER, INTENT(IN) :: unit_nr
717
718 CHARACTER(LEN=*), PARAMETER :: routinen = 'matrix_w_forces'
719
720 INTEGER :: handle, iounit, nder, nimages
721 LOGICAL :: debug_forces, debug_stress, use_virial
722 REAL(kind=dp) :: fconv
723 REAL(kind=dp), DIMENSION(3) :: fodeb
724 REAL(kind=dp), DIMENSION(3, 3) :: stdeb, sttot
725 TYPE(cell_type), POINTER :: cell
726 TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: scrm
727 TYPE(dft_control_type), POINTER :: dft_control
728 TYPE(mp_para_env_type), POINTER :: para_env
729 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
730 POINTER :: sab_orb
731 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
732 TYPE(qs_ks_env_type), POINTER :: ks_env
733 TYPE(virial_type), POINTER :: virial
734
735 CALL timeset(routinen, handle)
736
737 debug_forces = .true.
738 debug_stress = .true.
739
740 iounit = unit_nr
741
742 ! no k-points possible
743 CALL get_qs_env(qs_env=qs_env, &
744 cell=cell, &
745 dft_control=dft_control, &
746 force=force, &
747 ks_env=ks_env, &
748 sab_orb=sab_orb, &
749 para_env=para_env, &
750 virial=virial)
751 nimages = dft_control%nimages
752 IF (nimages /= 1) THEN
753 cpabort("K-points not implemented")
754 END IF
755
756 ! check for virial
757 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
758
759 fconv = 1.0e-9_dp*pascal/cell%deth
760 IF (debug_stress .AND. use_virial) THEN
761 sttot = virial%pv_virial
762 END IF
763
764 ! initialize src matrix
765 NULLIFY (scrm)
766 CALL dbcsr_allocate_matrix_set(scrm, 1, 1)
767 ALLOCATE (scrm(1, 1)%matrix)
768 CALL dbcsr_create(scrm(1, 1)%matrix, template=matrix_w(1, 1)%matrix)
769 CALL cp_dbcsr_alloc_block_from_nbl(scrm(1, 1)%matrix, sab_orb)
770
771 nder = 1
772 IF (SIZE(matrix_w, 1) == 2) THEN
773 CALL dbcsr_add(matrix_w(1, 1)%matrix, matrix_w(2, 1)%matrix, &
774 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
775 END IF
776
777 ! Overlap and kinetic energy matrices
778 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
779 IF (debug_stress .AND. use_virial) stdeb = virial%pv_overlap
780 CALL build_overlap_matrix(ks_env, matrixkp_s=scrm, &
781 matrix_name="OVERLAP MATRIX", &
782 basis_type_a="ORB", &
783 basis_type_b="ORB", &
784 sab_nl=sab_orb, calculate_forces=.true., &
785 matrixkp_p=matrix_w)
786
787 IF (debug_forces) THEN
788 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
789 CALL para_env%sum(fodeb)
790 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Wout*dS ", fodeb
791 END IF
792 IF (debug_stress .AND. use_virial) THEN
793 stdeb = fconv*(virial%pv_overlap - stdeb)
794 CALL para_env%sum(stdeb)
795 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
796 'STRESS| Wout*dS', one_third_sum_diag(stdeb), det_3x3(stdeb)
797 END IF
798 IF (SIZE(matrix_w, 1) == 2) THEN
799 CALL dbcsr_add(matrix_w(1, 1)%matrix, matrix_w(2, 1)%matrix, &
800 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
801 END IF
802
803 ! delete scrm matrix
805
806 CALL timestop(handle)
807
808 END SUBROUTINE matrix_w_forces
809
810! **************************************************************************************************
811!> \brief ...
812!> \param qs_env ...
813!> \param cpmos ...
814!> \param mo_occ ...
815!> \param matrix_r ...
816!> \param unit_nr ...
817! **************************************************************************************************
818 SUBROUTINE matrix_r_forces(qs_env, cpmos, mo_occ, matrix_r, unit_nr)
819 TYPE(qs_environment_type), POINTER :: qs_env
820 TYPE(cp_fm_type), DIMENSION(:), POINTER :: cpmos, mo_occ
821 TYPE(dbcsr_type), POINTER :: matrix_r
822 INTEGER, INTENT(IN) :: unit_nr
823
824 CHARACTER(LEN=*), PARAMETER :: routinen = 'matrix_r_forces'
825
826 INTEGER :: handle, iounit, ispin, nao, nocc, nspins
827 LOGICAL :: debug_forces, debug_stress, use_virial
828 REAL(kind=dp) :: fconv, focc
829 REAL(kind=dp), DIMENSION(3) :: fodeb
830 REAL(kind=dp), DIMENSION(3, 3) :: stdeb
831 TYPE(cell_type), POINTER :: cell
832 TYPE(cp_fm_struct_type), POINTER :: fm_struct, mat_struct
833 TYPE(cp_fm_type) :: chcmat, rcvec
834 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: scrm
835 TYPE(dft_control_type), POINTER :: dft_control
836 TYPE(mp_para_env_type), POINTER :: para_env
837 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
838 POINTER :: sab_orb
839 TYPE(qs_force_type), DIMENSION(:), POINTER :: force
840 TYPE(qs_ks_env_type), POINTER :: ks_env
841 TYPE(virial_type), POINTER :: virial
842
843 CALL timeset(routinen, handle)
844
845 debug_forces = .true.
846 debug_stress = .true.
847 iounit = unit_nr
848
849 nspins = SIZE(mo_occ)
850 focc = 1.0_dp
851 IF (nspins == 1) focc = 2.0_dp
852 focc = 0.25_dp*focc
853
854 CALL dbcsr_set(matrix_r, 0.0_dp)
855 DO ispin = 1, nspins
856 CALL cp_fm_get_info(cpmos(ispin), matrix_struct=fm_struct, nrow_global=nao, ncol_global=nocc)
857 CALL cp_fm_create(rcvec, fm_struct)
858 CALL cp_fm_struct_create(mat_struct, nrow_global=nocc, ncol_global=nocc, template_fmstruct=fm_struct)
859 CALL cp_fm_create(chcmat, mat_struct)
860 CALL parallel_gemm("T", "N", nocc, nocc, nao, 1.0_dp, mo_occ(ispin), cpmos(ispin), 0.0_dp, chcmat)
861 CALL parallel_gemm("N", "N", nao, nocc, nocc, 1.0_dp, mo_occ(ispin), chcmat, 0.0_dp, rcvec)
862 CALL cp_dbcsr_plus_fm_fm_t(matrix_r, matrix_v=rcvec, matrix_g=mo_occ(ispin), ncol=nocc, alpha=focc)
863 CALL cp_fm_struct_release(mat_struct)
864 CALL cp_fm_release(rcvec)
865 CALL cp_fm_release(chcmat)
866 END DO
867
868 CALL get_qs_env(qs_env=qs_env, &
869 cell=cell, &
870 dft_control=dft_control, &
871 force=force, &
872 ks_env=ks_env, &
873 sab_orb=sab_orb, &
874 para_env=para_env, &
875 virial=virial)
876 ! check for virial
877 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
878 fconv = 1.0e-9_dp*pascal/cell%deth
879
880 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
881 IF (debug_stress .AND. use_virial) stdeb = virial%pv_overlap
882 NULLIFY (scrm)
883 CALL build_overlap_matrix(ks_env, matrix_s=scrm, &
884 matrix_name="OVERLAP MATRIX", &
885 basis_type_a="ORB", basis_type_b="ORB", &
886 sab_nl=sab_orb, calculate_forces=.true., &
887 matrix_p=matrix_r)
888 IF (debug_forces) THEN
889 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
890 CALL para_env%sum(fodeb)
891 IF (iounit > 0) WRITE (iounit, "(T3,A,T33,3F16.8)") "DEBUG:: Wz*dS ", fodeb
892 END IF
893 IF (debug_stress .AND. use_virial) THEN
894 stdeb = fconv*(virial%pv_overlap - stdeb)
895 CALL para_env%sum(stdeb)
896 IF (iounit > 0) WRITE (unit=iounit, fmt="(T2,A,T41,2(1X,ES19.11))") &
897 'STRESS| Wz ', one_third_sum_diag(stdeb), det_3x3(stdeb)
898 END IF
900
901 CALL timestop(handle)
902
903 END SUBROUTINE matrix_r_forces
904
905END MODULE ec_external
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
Definition cell_types.F:15
Calculation of the local pseudopotential contribution to the core Hamiltonian <a|V(local)|b> = <a|Sum...
Definition core_ppl.F:18
subroutine, public build_core_ppl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sac_ppl, nimages, cell_to_index, basis_type, deltar, atcore)
...
Definition core_ppl.F:97
Calculation of the non-local pseudopotential contribution to the core Hamiltonian <a|V(non-local)|b> ...
Definition core_ppnl.F:15
subroutine, public build_core_ppnl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, nimages, cell_to_index, basis_type, deltar, matrix_l, atcore)
...
Definition core_ppnl.F:90
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_set(matrix, alpha)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
subroutine, public cp_fm_get_diag(matrix, diag)
returns the diagonal elements of a fm
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_maxabsval(matrix, a_max, ir_max, ic_max)
find the maximum absolute value of the matrix element maxval(abs(matrix))
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Types needed for a for a Energy Correction.
Routines for an external energy correction on top of a Kohn-Sham calculation.
Definition ec_external.F:14
subroutine, public ec_ext_energy(qs_env, ec_env, calculate_forces)
External energy method.
Definition ec_external.F:95
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
Collection of simple mathematical functions and subroutines.
Definition mathlib.F:15
subroutine, public diag(n, a, d, v)
Diagonalize matrix a. The eigenvalues are returned in vector d and the eigenvectors are returned in m...
Definition mathlib.F:1496
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public pascal
Definition physcon.F:174
Calculation of the energies concerning the core charge distribution.
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, 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, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
Calculation of kinetic energy matrix and forces.
Definition qs_kinetic.F:15
subroutine, public build_kinetic_matrix(ks_env, matrix_t, matrixkp_t, matrix_name, basis_type, sab_nl, calculate_forces, matrix_p, matrixkp_p, eps_filter, nderivative)
Calculation of the kinetic energy matrix over Cartesian Gaussian functions.
Definition qs_kinetic.F:101
Definition and initialisation of the mo data type.
Definition qs_mo_types.F:22
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
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.
Define the neighbor list data types and the corresponding functionality.
Calculation of overlap matrix, its derivatives and forces.
Definition qs_overlap.F:19
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p)
Calculation of the overlap matrix over Cartesian Gaussian functions.
Definition qs_overlap.F:120
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
The module to read/write TREX IO files for interfacing CP2K with other programs.
subroutine, public read_trexio(qs_env, trexio_filename, mo_set_trexio, energy_derivative)
Read a trexio file.
pure real(kind=dp) function, public one_third_sum_diag(a)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Definition cell_types.F:55
keeps the information about the structure of a full matrix
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 information on the energy correction functional for KG.
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 ...
keeps the density in various representations, keeping track of which ones are valid.