(git:3d5d2e5)
Loading...
Searching...
No Matches
qs_environment_types.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
8! **************************************************************************************************
9!> \par History
10!> - mo_set_p_type added to qs_env (23.04.02,MK)
11!> - qs_force_type added to qs_env (05.06.02,MK)
12!> \author MK (23.01.2002)
13! **************************************************************************************************
15 USE admm_types, ONLY: admm_env_release,&
20 USE atprop_types, ONLY: atprop_type
21 USE cell_types, ONLY: cell_release,&
33 USE cp_fm_types, ONLY: cp_fm_release,&
41 USE ec_env_types, ONLY: ec_env_release,&
60 USE hfx_types, ONLY: hfx_release,&
69 USE kinds, ONLY: dp
70 USE kpoint_types, ONLY: kpoint_type
78 USE mp2_types, ONLY: mp2_env_release,&
85 USE pw_env_types, ONLY: pw_env_type
86 USE pw_types, ONLY: pw_c1d_gs_type,&
100 USE qs_gcp_types, ONLY: qs_gcp_release,&
104 USE qs_kind_types, ONLY: qs_kind_type
107 USE qs_ks_types, ONLY: get_ks_env,&
120 rhoz_type,&
124 USE qs_mo_types, ONLY: deallocate_mo_set,&
133 USE qs_rho0_types, ONLY: rho0_atom_type,&
136 USE qs_rho_types, ONLY: qs_rho_p_type,&
139 USE qs_scf_types, ONLY: qs_scf_env_type,&
141 USE qs_subsys_types, ONLY: qs_subsys_set,&
163 USE virial_types, ONLY: virial_type
165 USE xas_env_types, ONLY: xas_env_release,&
169#include "./base/base_uses.f90"
170
171 IMPLICIT NONE
172
173 PRIVATE
174
175 CHARACTER(LEN=*), PARAMETER, PRIVATE :: moduleN = 'qs_environment_types'
176
177 ! Public data types
178
179 PUBLIC :: qs_environment_type
180
181 ! Public subroutines
182
183 PUBLIC :: get_qs_env, &
188
189! **************************************************************************************************
190!> \param local_rho_set contains the atomic, compensations and core densities
191!> and the local parts of the xc terms
192!> \param hartree_local contains the 1, 2 and 3 centers coulomb terms
193!> \param requires_mo_derivs logical, true if dE/dC is required (e.g. OT)
194!> \param has_unit_metric logical, true if the S matrix is considered unity for the SCF
195!> \param mo_derivs the actual derivatives of the total energy wrt to MO coeffs (divided by 2*f_i)
196!> \param xas_env temporary information for xas calculation
197!> \param dftb_potential pair potentials for use with DFTB
198!> \param dispersion_env environment for use with QS dispersion
199!>
200!> compatibility get (things that you should get from the subsys):
201!> \param atomic_kind_set array with infos about the species (atomic_kinds)
202!> present in the system
203!> \param particle_set info on the atoms you simulate, pos,...
204!> \param local_particles which particles ar local to this processor
205!> new:
206!> \param local_molecules which molecules are local to this processor
207!> \param molecule_kind_set description of the molecule kinds
208!> \param molecule_set all the molecule description
209!> \param rtp all data needed for real time propagation
210!> \param x contains data used in Hartree-Fock-Exchange calculations
211!> \param task_list the list of tasks used in collocate and integrate
212!> \param task_list_soft the list of tasks used in collocate and integrate in case of soft basis functions
213!> \param mo_loc_history if a history of localized wfn is kept, they are stored here.
214!> \param molecular_scf_guess_env contains inforamation about and results of claculations
215!> on separate molecules
216!> \par History
217!> 11.2002 added doc and attribute description [fawzi]
218!> 08.2004 renamed some of the very short names (s,c,k,h) for easier grepping
219!> 06.2018 polar_env added (MK)
220!> \author Matthias Krack & fawzi
221! **************************************************************************************************
222
224 LOGICAL :: qmmm = .false., qmmm_periodic = .false.
225 LOGICAL :: mimic = .false.
226 LOGICAL :: requires_mo_derivs = .false.
227 LOGICAL :: requires_matrix_vxc = .false.
228 LOGICAL :: has_unit_metric = .false.
229 LOGICAL :: run_rtp = .false.
230 LOGICAL :: linres_run = .false.
231 LOGICAL :: calc_image_preconditioner = .false.
232 LOGICAL :: do_transport = .false.
233 LOGICAL :: single_point_run = .false.
234 ! Set only by the standalone single-point driver, not by library callers.
235 LOGICAL :: skip_wf_history = .false.
236 LOGICAL :: given_embed_pot = .false.
237 LOGICAL :: energy_correction = .false.
238 LOGICAL :: harris_method = .false.
239 LOGICAL :: do_rixs = .false.
240 REAL(kind=dp) :: sim_time = -1.0_dp
241 REAL(kind=dp) :: start_time = -1.0_dp, target_time = -1.0_dp
242 REAL(kind=dp), DIMENSION(:, :), POINTER :: image_matrix => null()
243 REAL(kind=dp), DIMENSION(:), POINTER :: image_coeff => null()
244 INTEGER, DIMENSION(:), POINTER :: ipiv => null()
245 INTEGER :: sim_step = -1
246 TYPE(ls_scf_env_type), POINTER :: ls_scf_env => null()
247 TYPE(almo_scf_env_type), POINTER :: almo_scf_env => null()
248 TYPE(transport_env_type), POINTER :: transport_env => null()
249 TYPE(cell_type), POINTER :: super_cell => null()
250 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos => null()
251 TYPE(cp_fm_type), DIMENSION(:), POINTER :: mo_loc_history => null()
252 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: mo_derivs => null()
253 TYPE(scf_control_type), POINTER :: scf_control => null()
254 TYPE(rel_control_type), POINTER :: rel_control => null()
255 ! ZMP adding variables
256 TYPE(qs_rho_type), POINTER :: rho_external => null()
257 TYPE(pw_r3d_rs_type), POINTER :: external_vxc => null()
258 TYPE(pw_r3d_rs_type), POINTER :: mask => null()
259 TYPE(qs_charges_type), POINTER :: qs_charges => null()
260 TYPE(qs_ks_env_type), POINTER :: ks_env => null()
261 TYPE(qs_ks_qmmm_env_type), POINTER :: ks_qmmm_env => null()
262 TYPE(qmmm_env_qm_type), POINTER :: qmmm_env_qm => null()
263 TYPE(qs_wf_history_type), POINTER :: wf_history => null()
264 TYPE(qs_scf_env_type), POINTER :: scf_env => null()
265 LOGICAL :: scf_convergence_available = .false., scf_converged = .false.
266 TYPE(qs_matrix_pools_type), POINTER :: mpools => null()
267 TYPE(oce_matrix_type), POINTER :: oce => null()
268 TYPE(local_rho_type), POINTER :: local_rho_set => null()
269 TYPE(hartree_local_type), POINTER :: hartree_local => null()
270 TYPE(section_vals_type), POINTER :: input => null()
271 TYPE(linres_control_type), POINTER :: linres_control => null()
272 TYPE(xas_environment_type), POINTER :: xas_env => null()
273 TYPE(cp_ddapc_type), POINTER :: cp_ddapc_env => null()
274 TYPE(cp_ddapc_ewald_type), POINTER :: cp_ddapc_ewald => null()
275 REAL(kind=dp), DIMENSION(:, :), POINTER :: outer_scf_history => null()
276 INTEGER :: outer_scf_ihistory = -1
277 REAL(kind=dp), DIMENSION(:, :), POINTER :: gradient_history => null(), &
278 variable_history => null()
279 TYPE(hfx_type), DIMENSION(:, :), POINTER :: x_data => null()
280 TYPE(et_coupling_type), POINTER :: et_coupling => null()
281 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), POINTER :: dftb_potential => null()
282 TYPE(admm_type), POINTER :: admm_env => null()
283 TYPE(active_space_type), POINTER :: active_space => null()
284 ! LRI
285 TYPE(lri_environment_type), POINTER :: lri_env => null()
286 TYPE(lri_density_type), POINTER :: lri_density => null()
287 ! Harris model
288 TYPE(harris_type), POINTER :: harris_env => null()
289 ! Energy correction
290 TYPE(energy_correction_type), POINTER :: ec_env => null()
291 ! Excited States
292 LOGICAL :: excited_state = .false.
293 TYPE(excited_energy_type), POINTER :: exstate_env => null()
294 ! Empirical dispersion
295 TYPE(qs_dispersion_type), POINTER :: dispersion_env => null()
296 ! Empirical geometrical BSSE correction
297 TYPE(qs_gcp_type), POINTER :: gcp_env => null()
298 ! Semi-empirical and DFTB types
299 TYPE(ewald_environment_type), POINTER :: ewald_env => null()
300 TYPE(ewald_pw_type), POINTER :: ewald_pw => null()
301 ! Semi-empirical types
302 TYPE(se_taper_type), POINTER :: se_taper => null()
303 TYPE(semi_empirical_si_type), POINTER :: se_store_int_env => null()
304 TYPE(nddo_mpole_type), POINTER :: se_nddo_mpole => null()
305 TYPE(fist_nonbond_env_type), POINTER :: se_nonbond_env => null()
306 TYPE(rt_prop_type), POINTER :: rtp => null()
307 TYPE(efield_berry_type), POINTER :: efield => null()
308 ! a history for the broyden ot
309 REAL(kind=dp) :: broyden_adaptive_sigma = -1.0_dp
310 TYPE(mp2_type), POINTER :: mp2_env => null()
311 TYPE(post_scf_bandstructure_type), POINTER :: bs_env => null()
312 TYPE(kg_environment_type), POINTER :: kg_env => null()
313 TYPE(wannier_centres_type), POINTER, DIMENSION(:) :: wanniercentres => null()
314 TYPE(molecular_scf_guess_env_type), POINTER :: molecular_scf_guess_env => null()
315 ! Subsystem densities
316 TYPE(qs_rho_p_type), DIMENSION(:), POINTER :: subsys_dens => null()
317 ! Embedding potential
318 TYPE(pw_r3d_rs_type), POINTER :: embed_pot => null()
319 TYPE(pw_r3d_rs_type), POINTER :: spin_embed_pot => null()
320 ! Polarizability tensor
321 TYPE(polar_env_type), POINTER :: polar_env => null()
322 ! EEQ charges
323 REAL(kind=dp), DIMENSION(:), POINTER :: eeq => null()
324 ! Resp charges
325 REAL(kind=dp), DIMENSION(:), POINTER :: rhs => null()
326 REAL(kind=dp) :: total_zeff_corr = -1.0_dp, surface_dipole_moment = -1.0_dp
327 ! Plane-averaged Hartree potential (incl. dipole correction) just below/above the dipole
328 ! correction reference plane, i.e. the vacuum level on either side of the slab
329 REAL(kind=dp) :: vacuum_level_below = 0.0_dp, vacuum_level_above = 0.0_dp
330 ! Position of the dipole correction reference plane [Angstrom]
331 REAL(kind=dp) :: surface_dipole_ref_pos = 0.0_dp
332 LOGICAL :: surface_dipole_switch_off = .false.
333 TYPE(mo_set_type), DIMENSION(:), POINTER :: mos_last_converged => null()
334 ! tblite
335 TYPE(tblite_type), POINTER :: tb_tblite => null()
336 TYPE(cp_gauxc_cache_type), POINTER :: gauxc_cache => null()
337 TYPE(native_grid_cache_type) :: native_grid_cache
338 END TYPE qs_environment_type
339
340CONTAINS
341
342! **************************************************************************************************
343!> \brief Get the QUICKSTEP environment.
344!> \param qs_env ...
345!> \param atomic_kind_set ...
346!> \param qs_kind_set ...
347!> \param cell ...
348!> \param super_cell ...
349!> \param cell_ref ...
350!> \param use_ref_cell ...
351!> \param kpoints ...
352!> \param dft_control ...
353!> \param mos ...
354!> \param sab_orb ...
355!> \param sab_all ...
356!> \param qmmm ...
357!> \param qmmm_periodic ...
358!> \param mimic ...
359!> \param sac_ae ...
360!> \param sac_ppl ...
361!> \param sac_lri ...
362!> \param sap_ppnl ...
363!> \param sab_vdw ...
364!> \param sab_scp ...
365!> \param sap_oce ...
366!> \param sab_lrc ...
367!> \param sab_se ...
368!> \param sab_xtbe ...
369!> \param sab_tbe ...
370!> \param sab_core ...
371!> \param sab_xb ...
372!> \param sab_xtb_pp ...
373!> \param sab_xtb_nonbond ...
374!> \param sab_almo ...
375!> \param sab_kp ...
376!> \param sab_kp_nosym ...
377!> \param sab_cneo ...
378!> \param particle_set ...
379!> \param energy ...
380!> \param force ...
381!> \param matrix_h ...
382!> \param matrix_h_im ...
383!> \param matrix_ks ...
384!> \param matrix_ks_im ...
385!> \param matrix_vxc ...
386!> \param run_rtp ...
387!> \param rtp ...
388!> \param matrix_h_kp ...
389!> \param matrix_h_im_kp ...
390!> \param matrix_ks_kp ...
391!> \param matrix_ks_im_kp ...
392!> \param matrix_vxc_kp ...
393!> \param kinetic_kp ...
394!> \param matrix_s_kp ...
395!> \param matrix_w_kp ...
396!> \param matrix_s_RI_aux_kp ...
397!> \param matrix_s ...
398!> \param matrix_s_RI_aux ...
399!> \param matrix_w ...
400!> \param matrix_p_mp2 ...
401!> \param matrix_p_mp2_admm ...
402!> \param matrix_vhxc ...
403!> \param rho ...
404!> \param rho_xc ...
405!> \param pw_env ...
406!> \param ewald_env ...
407!> \param ewald_pw ...
408!> \param active_space ...
409!> \param mpools ...
410!> \param input ...
411!> \param para_env ...
412!> \param blacs_env ...
413!> \param scf_control ...
414!> \param rel_control ...
415!> \param kinetic ...
416!> \param qs_charges ...
417!> \param vppl ...
418!> \param xcint_weights ...
419!> \param rho_core ...
420!> \param rho_nlcc ...
421!> \param rho_nlcc_g ...
422!> \param ks_env ...
423!> \param ks_qmmm_env ...
424!> \param wf_history ...
425!> \param scf_env ...
426!> \param local_particles ...
427!> \param local_molecules ...
428!> \param distribution_2d ...
429!> \param dbcsr_dist ...
430!> \param molecule_kind_set ...
431!> \param molecule_set ...
432!> \param subsys ...
433!> \param cp_subsys ...
434!> \param oce ...
435!> \param local_rho_set ...
436!> \param rho_atom_set ...
437!> \param task_list ...
438!> \param task_list_soft ...
439!> \param rho0_atom_set ...
440!> \param rho0_mpole ...
441!> \param rhoz_set ...
442!> \param rhoz_cneo_set ...
443!> \param ecoul_1c ...
444!> \param rho0_s_rs ...
445!> \param rho0_s_gs ...
446!> \param rhoz_cneo_s_rs ...
447!> \param rhoz_cneo_s_gs ...
448!> \param do_kpoints ...
449!> \param has_unit_metric ...
450!> \param requires_mo_derivs ...
451!> \param mo_derivs ...
452!> \param mo_loc_history ...
453!> \param nkind ...
454!> \param natom ...
455!> \param nelectron_total ...
456!> \param nelectron_spin ...
457!> \param efield ...
458!> \param neighbor_list_id ...
459!> \param linres_control ...
460!> \param xas_env ...
461!> \param virial ...
462!> \param cp_ddapc_env ...
463!> \param cp_ddapc_ewald ...
464!> \param outer_scf_history ...
465!> \param outer_scf_ihistory ...
466!> \param x_data ...
467!> \param et_coupling ...
468!> \param dftb_potential ...
469!> \param results ...
470!> \param se_taper ...
471!> \param se_store_int_env ...
472!> \param se_nddo_mpole ...
473!> \param se_nonbond_env ...
474!> \param admm_env ...
475!> \param lri_env ...
476!> \param lri_density ...
477!> \param exstate_env ...
478!> \param ec_env ...
479!> \param harris_env ...
480!> \param dispersion_env ...
481!> \param gcp_env ...
482!> \param vee ...
483!> \param rho_external ...
484!> \param external_vxc ...
485!> \param mask ...
486!> \param mp2_env ...
487!> \param bs_env ...
488!> \param kg_env ...
489!> \param WannierCentres ...
490!> \param atprop ...
491!> \param ls_scf_env ...
492!> \param do_transport ...
493!> \param transport_env ...
494!> \param v_hartree_rspace ...
495!> \param s_mstruct_changed ...
496!> \param rho_changed ...
497!> \param potential_changed ...
498!> \param forces_up_to_date ...
499!> \param mscfg_env ...
500!> \param almo_scf_env ...
501!> \param gradient_history ...
502!> \param variable_history ...
503!> \param embed_pot ...
504!> \param spin_embed_pot ...
505!> \param polar_env ...
506!> \param mos_last_converged ... [SGh]
507!> \param eeq ...
508!> \param rhs ...
509!> \param do_rixs ...
510!> \param tb_tblite ...
511!> \param matrix_metric Orbital normalization metric, including USPP augmentation when present.
512!> \param matrix_metric_kp Metric in the image-indexed representation.
513!> \date 23.01.2002
514!> \author MK
515!> \version 1.0
516! **************************************************************************************************
517 SUBROUTINE get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, &
518 dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, &
519 sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, &
520 sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, &
521 sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, &
522 matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, &
523 matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, &
524 matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, &
525 matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, &
526 rho_xc, pw_env, ewald_env, ewald_pw, active_space, &
527 mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, &
528 vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, &
529 ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, &
530 local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, &
531 molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, &
532 task_list, task_list_soft, &
533 rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, &
534 rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, &
535 do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, &
536 mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, &
537 neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, &
538 outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, &
539 se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, &
540 lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, &
541 rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, &
542 WannierCentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, &
543 s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, &
544 gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, &
545 eeq, rhs, do_rixs, tb_tblite, matrix_metric, matrix_metric_kp)
546
547 TYPE(qs_environment_type), INTENT(IN) :: qs_env
548 TYPE(atomic_kind_type), DIMENSION(:), OPTIONAL, &
549 POINTER :: atomic_kind_set
550 TYPE(qs_kind_type), DIMENSION(:), OPTIONAL, &
551 POINTER :: qs_kind_set
552 TYPE(cell_type), OPTIONAL, POINTER :: cell, super_cell, cell_ref
553 LOGICAL, OPTIONAL :: use_ref_cell
554 TYPE(kpoint_type), OPTIONAL, POINTER :: kpoints
555 TYPE(dft_control_type), OPTIONAL, POINTER :: dft_control
556 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos
557 TYPE(neighbor_list_set_p_type), DIMENSION(:), &
558 OPTIONAL, POINTER :: sab_orb, sab_all
559 LOGICAL, OPTIONAL :: qmmm, qmmm_periodic, mimic
560 TYPE(neighbor_list_set_p_type), DIMENSION(:), OPTIONAL, POINTER :: sac_ae, sac_ppl, sac_lri, &
561 sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, &
562 sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo
563 TYPE(particle_type), DIMENSION(:), OPTIONAL, &
564 POINTER :: particle_set
565 TYPE(qs_energy_type), OPTIONAL, POINTER :: energy
566 TYPE(qs_force_type), DIMENSION(:), OPTIONAL, &
567 POINTER :: force
568 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
569 POINTER :: matrix_h, matrix_h_im, matrix_ks, &
570 matrix_ks_im, matrix_vxc
571 LOGICAL, OPTIONAL :: run_rtp
572 TYPE(rt_prop_type), OPTIONAL, POINTER :: rtp
573 TYPE(dbcsr_p_type), DIMENSION(:, :), OPTIONAL, POINTER :: matrix_h_kp, matrix_h_im_kp, &
574 matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, &
575 matrix_s_ri_aux_kp
576 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
577 POINTER :: matrix_s, matrix_s_ri_aux, matrix_w, &
578 matrix_p_mp2, matrix_p_mp2_admm, &
579 matrix_vhxc
580 TYPE(qs_rho_type), OPTIONAL, POINTER :: rho, rho_xc
581 TYPE(pw_env_type), OPTIONAL, POINTER :: pw_env
582 TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
583 TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
584 TYPE(active_space_type), OPTIONAL, POINTER :: active_space
585 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
586 TYPE(section_vals_type), OPTIONAL, POINTER :: input
587 TYPE(mp_para_env_type), OPTIONAL, POINTER :: para_env
588 TYPE(cp_blacs_env_type), OPTIONAL, POINTER :: blacs_env
589 TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
590 TYPE(rel_control_type), OPTIONAL, POINTER :: rel_control
591 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
592 POINTER :: kinetic
593 TYPE(qs_charges_type), OPTIONAL, POINTER :: qs_charges
594 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: vppl, xcint_weights
595 TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho_core
596 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: rho_nlcc
597 TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho_nlcc_g
598 TYPE(qs_ks_env_type), OPTIONAL, POINTER :: ks_env
599 TYPE(qs_ks_qmmm_env_type), OPTIONAL, POINTER :: ks_qmmm_env
600 TYPE(qs_wf_history_type), OPTIONAL, POINTER :: wf_history
601 TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
602 TYPE(distribution_1d_type), OPTIONAL, POINTER :: local_particles, local_molecules
603 TYPE(distribution_2d_type), OPTIONAL, POINTER :: distribution_2d
604 TYPE(dbcsr_distribution_type), OPTIONAL, POINTER :: dbcsr_dist
605 TYPE(molecule_kind_type), DIMENSION(:), OPTIONAL, &
606 POINTER :: molecule_kind_set
607 TYPE(molecule_type), DIMENSION(:), OPTIONAL, &
608 POINTER :: molecule_set
609 TYPE(qs_subsys_type), OPTIONAL, POINTER :: subsys
610 TYPE(cp_subsys_type), OPTIONAL, POINTER :: cp_subsys
611 TYPE(oce_matrix_type), OPTIONAL, POINTER :: oce
612 TYPE(local_rho_type), OPTIONAL, POINTER :: local_rho_set
613 TYPE(rho_atom_type), DIMENSION(:), OPTIONAL, &
614 POINTER :: rho_atom_set
615 TYPE(task_list_type), OPTIONAL, POINTER :: task_list, task_list_soft
616 TYPE(rho0_atom_type), DIMENSION(:), OPTIONAL, &
617 POINTER :: rho0_atom_set
618 TYPE(rho0_mpole_type), OPTIONAL, POINTER :: rho0_mpole
619 TYPE(rhoz_type), DIMENSION(:), OPTIONAL, POINTER :: rhoz_set
620 TYPE(rhoz_cneo_type), DIMENSION(:), OPTIONAL, &
621 POINTER :: rhoz_cneo_set
622 TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
623 POINTER :: ecoul_1c
624 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: rho0_s_rs
625 TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rho0_s_gs
626 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: rhoz_cneo_s_rs
627 TYPE(pw_c1d_gs_type), OPTIONAL, POINTER :: rhoz_cneo_s_gs
628 LOGICAL, OPTIONAL :: do_kpoints, has_unit_metric, &
629 requires_mo_derivs
630 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
631 POINTER :: mo_derivs
632 TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mo_loc_history
633 INTEGER, OPTIONAL :: nkind, natom, nelectron_total
634 INTEGER, DIMENSION(2), OPTIONAL :: nelectron_spin
635 TYPE(efield_berry_type), OPTIONAL, POINTER :: efield
636 INTEGER, OPTIONAL :: neighbor_list_id
637 TYPE(linres_control_type), OPTIONAL, POINTER :: linres_control
638 TYPE(xas_environment_type), OPTIONAL, POINTER :: xas_env
639 TYPE(virial_type), OPTIONAL, POINTER :: virial
640 TYPE(cp_ddapc_type), OPTIONAL, POINTER :: cp_ddapc_env
641 TYPE(cp_ddapc_ewald_type), OPTIONAL, POINTER :: cp_ddapc_ewald
642 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: outer_scf_history
643 INTEGER, INTENT(OUT), OPTIONAL :: outer_scf_ihistory
644 TYPE(hfx_type), DIMENSION(:, :), OPTIONAL, POINTER :: x_data
645 TYPE(et_coupling_type), OPTIONAL, POINTER :: et_coupling
646 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
647 OPTIONAL, POINTER :: dftb_potential
648 TYPE(cp_result_type), OPTIONAL, POINTER :: results
649 TYPE(se_taper_type), OPTIONAL, POINTER :: se_taper
650 TYPE(semi_empirical_si_type), OPTIONAL, POINTER :: se_store_int_env
651 TYPE(nddo_mpole_type), OPTIONAL, POINTER :: se_nddo_mpole
652 TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: se_nonbond_env
653 TYPE(admm_type), OPTIONAL, POINTER :: admm_env
654 TYPE(lri_environment_type), OPTIONAL, POINTER :: lri_env
655 TYPE(lri_density_type), OPTIONAL, POINTER :: lri_density
656 TYPE(excited_energy_type), OPTIONAL, POINTER :: exstate_env
657 TYPE(energy_correction_type), OPTIONAL, POINTER :: ec_env
658 TYPE(harris_type), OPTIONAL, POINTER :: harris_env
659 TYPE(qs_dispersion_type), OPTIONAL, POINTER :: dispersion_env
660 TYPE(qs_gcp_type), OPTIONAL, POINTER :: gcp_env
661 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: vee
662 TYPE(qs_rho_type), OPTIONAL, POINTER :: rho_external
663 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: external_vxc, mask
664 TYPE(mp2_type), OPTIONAL, POINTER :: mp2_env
665 TYPE(post_scf_bandstructure_type), OPTIONAL, &
666 POINTER :: bs_env
667 TYPE(kg_environment_type), OPTIONAL, POINTER :: kg_env
668 TYPE(wannier_centres_type), DIMENSION(:), &
669 OPTIONAL, POINTER :: wanniercentres
670 TYPE(atprop_type), OPTIONAL, POINTER :: atprop
671 TYPE(ls_scf_env_type), OPTIONAL, POINTER :: ls_scf_env
672 LOGICAL, OPTIONAL :: do_transport
673 TYPE(transport_env_type), OPTIONAL, POINTER :: transport_env
674 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: v_hartree_rspace
675 LOGICAL, OPTIONAL :: s_mstruct_changed, rho_changed, &
676 potential_changed, forces_up_to_date
677 TYPE(molecular_scf_guess_env_type), OPTIONAL, &
678 POINTER :: mscfg_env
679 TYPE(almo_scf_env_type), OPTIONAL, POINTER :: almo_scf_env
680 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: gradient_history, variable_history
681 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: embed_pot, spin_embed_pot
682 TYPE(polar_env_type), OPTIONAL, POINTER :: polar_env
683 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_last_converged
684 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: eeq, rhs
685 LOGICAL, OPTIONAL :: do_rixs
686 TYPE(tblite_type), OPTIONAL, POINTER :: tb_tblite
687 TYPE(dbcsr_p_type), OPTIONAL, POINTER :: matrix_metric(:), matrix_metric_kp(:, :)
688
689 TYPE(rho0_mpole_type), POINTER :: rho0_m
690
691 NULLIFY (rho0_m)
692 cpassert(ASSOCIATED(qs_env%ks_env))
693
694 IF (PRESENT(outer_scf_history)) outer_scf_history => qs_env%outer_scf_history
695 IF (PRESENT(outer_scf_ihistory)) outer_scf_ihistory = qs_env%outer_scf_ihistory
696 IF (PRESENT(gradient_history)) gradient_history => qs_env%gradient_history
697 IF (PRESENT(variable_history)) variable_history => qs_env%variable_history
698 IF (PRESENT(mp2_env)) mp2_env => qs_env%mp2_env
699 IF (PRESENT(bs_env)) bs_env => qs_env%bs_env
700 IF (PRESENT(kg_env)) kg_env => qs_env%kg_env
701 IF (PRESENT(super_cell)) super_cell => qs_env%super_cell
702 IF (PRESENT(qmmm)) qmmm = qs_env%qmmm
703 IF (PRESENT(qmmm_periodic)) qmmm_periodic = qs_env%qmmm_periodic
704 IF (PRESENT(mimic)) mimic = qs_env%mimic
705 IF (PRESENT(mos)) mos => qs_env%mos
706 IF (PRESENT(mos_last_converged)) mos_last_converged => qs_env%mos_last_converged
707 IF (PRESENT(ewald_env)) ewald_env => qs_env%ewald_env
708 IF (PRESENT(ewald_pw)) ewald_pw => qs_env%ewald_pw
709 IF (PRESENT(mpools)) mpools => qs_env%mpools
710 IF (PRESENT(scf_control)) scf_control => qs_env%scf_control
711 IF (PRESENT(rel_control)) rel_control => qs_env%rel_control
712 ! ZMP pointing vectors
713 IF (PRESENT(rho_external)) rho_external => qs_env%rho_external
714 IF (PRESENT(external_vxc)) external_vxc => qs_env%external_vxc
715 IF (PRESENT(mask)) mask => qs_env%mask
716 IF (PRESENT(qs_charges)) qs_charges => qs_env%qs_charges
717 IF (PRESENT(ks_env)) ks_env => qs_env%ks_env
718 IF (PRESENT(ks_qmmm_env)) ks_qmmm_env => qs_env%ks_qmmm_env
719 IF (PRESENT(wf_history)) wf_history => qs_env%wf_history
720 IF (PRESENT(scf_env)) scf_env => qs_env%scf_env
721 IF (PRESENT(oce)) oce => qs_env%oce
722 IF (PRESENT(requires_mo_derivs)) requires_mo_derivs = qs_env%requires_mo_derivs
723 IF (PRESENT(has_unit_metric)) has_unit_metric = qs_env%has_unit_metric
724 IF (PRESENT(mo_derivs)) mo_derivs => qs_env%mo_derivs
725 IF (PRESENT(mo_loc_history)) mo_loc_history => qs_env%mo_loc_history
726 IF (PRESENT(linres_control)) linres_control => qs_env%linres_control
727 IF (PRESENT(se_taper)) se_taper => qs_env%se_taper
728 IF (PRESENT(se_store_int_env)) se_store_int_env => qs_env%se_store_int_env
729 IF (PRESENT(se_nddo_mpole)) se_nddo_mpole => qs_env%se_nddo_mpole
730 IF (PRESENT(se_nonbond_env)) se_nonbond_env => qs_env%se_nonbond_env
731 IF (PRESENT(lri_env)) lri_env => qs_env%lri_env
732 IF (PRESENT(lri_density)) lri_density => qs_env%lri_density
733 IF (PRESENT(harris_env)) harris_env => qs_env%harris_env
734 IF (PRESENT(ec_env)) ec_env => qs_env%ec_env
735 IF (PRESENT(exstate_env)) exstate_env => qs_env%exstate_env
736 IF (PRESENT(dispersion_env)) dispersion_env => qs_env%dispersion_env
737 IF (PRESENT(gcp_env)) gcp_env => qs_env%gcp_env
738 IF (PRESENT(run_rtp)) run_rtp = qs_env%run_rtp
739 IF (PRESENT(rtp)) rtp => qs_env%rtp
740 IF (PRESENT(ls_scf_env)) ls_scf_env => qs_env%ls_scf_env
741 IF (PRESENT(almo_scf_env)) almo_scf_env => qs_env%almo_scf_env
742 IF (PRESENT(do_transport)) do_transport = qs_env%do_transport
743 IF (PRESENT(transport_env)) transport_env => qs_env%transport_env
744 IF (PRESENT(mscfg_env)) mscfg_env => qs_env%molecular_scf_guess_env
745 IF (PRESENT(active_space)) active_space => qs_env%active_space
746 IF (PRESENT(admm_env)) admm_env => qs_env%admm_env
747 IF (PRESENT(do_rixs)) do_rixs = qs_env%do_rixs
748
749 ! Embedding potential
750 IF (PRESENT(embed_pot)) embed_pot => qs_env%embed_pot
751 IF (PRESENT(spin_embed_pot)) spin_embed_pot => qs_env%spin_embed_pot
752
753 ! Polarisability tensor
754 IF (PRESENT(polar_env)) polar_env => qs_env%polar_env
755
756 ! EEQ charges
757 IF (PRESENT(eeq)) eeq => qs_env%eeq
758
759 ! Resp charges
760 IF (PRESENT(rhs)) rhs => qs_env%rhs
761
762 IF (PRESENT(local_rho_set)) THEN
763 local_rho_set => qs_env%local_rho_set
764 END IF
765 IF (PRESENT(rho_atom_set)) THEN
766 CALL get_local_rho(qs_env%local_rho_set, rho_atom_set=rho_atom_set)
767 END IF
768 IF (PRESENT(rho0_atom_set)) THEN
769 CALL get_local_rho(qs_env%local_rho_set, rho0_atom_set=rho0_atom_set)
770 END IF
771 IF (PRESENT(rho0_mpole)) THEN
772 CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_mpole)
773 END IF
774 IF (PRESENT(rhoz_set)) THEN
775 CALL get_local_rho(qs_env%local_rho_set, rhoz_set=rhoz_set)
776 END IF
777 IF (PRESENT(rhoz_cneo_set)) THEN
778 CALL get_local_rho(qs_env%local_rho_set, rhoz_cneo_set=rhoz_cneo_set)
779 END IF
780 IF (PRESENT(ecoul_1c)) THEN
781 CALL get_hartree_local(qs_env%hartree_local, ecoul_1c=ecoul_1c)
782 END IF
783 IF (PRESENT(rho0_s_rs)) THEN
784 CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
785 IF (ASSOCIATED(rho0_m)) THEN
786 rho0_s_rs => rho0_m%rho0_s_rs
787 END IF
788 END IF
789 IF (PRESENT(rho0_s_gs)) THEN
790 CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
791 IF (ASSOCIATED(rho0_m)) THEN
792 rho0_s_gs => rho0_m%rho0_s_gs
793 END IF
794 END IF
795 IF (PRESENT(rhoz_cneo_s_rs)) THEN
796 CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
797 IF (ASSOCIATED(rho0_m)) THEN
798 rhoz_cneo_s_rs => rho0_m%rhoz_cneo_s_rs
799 END IF
800 END IF
801 IF (PRESENT(rhoz_cneo_s_gs)) THEN
802 CALL get_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_m)
803 IF (ASSOCIATED(rho0_m)) THEN
804 rhoz_cneo_s_gs => rho0_m%rhoz_cneo_s_gs
805 END IF
806 END IF
807
808 IF (PRESENT(xas_env)) xas_env => qs_env%xas_env
809 IF (PRESENT(input)) input => qs_env%input
810 IF (PRESENT(cp_ddapc_env)) cp_ddapc_env => qs_env%cp_ddapc_env
811 IF (PRESENT(cp_ddapc_ewald)) cp_ddapc_ewald => qs_env%cp_ddapc_ewald
812 IF (PRESENT(x_data)) x_data => qs_env%x_data
813 IF (PRESENT(et_coupling)) et_coupling => qs_env%et_coupling
814 IF (PRESENT(dftb_potential)) dftb_potential => qs_env%dftb_potential
815 IF (PRESENT(efield)) efield => qs_env%efield
816 IF (PRESENT(wanniercentres)) wanniercentres => qs_env%WannierCentres
817
818 CALL get_ks_env(qs_env%ks_env, &
819 v_hartree_rspace=v_hartree_rspace, &
820 s_mstruct_changed=s_mstruct_changed, &
821 rho_changed=rho_changed, &
822 potential_changed=potential_changed, &
823 forces_up_to_date=forces_up_to_date, &
824 matrix_h=matrix_h, &
825 matrix_h_im=matrix_h_im, &
826 matrix_ks=matrix_ks, &
827 matrix_ks_im=matrix_ks_im, &
828 matrix_vxc=matrix_vxc, &
829 kinetic=kinetic, &
830 matrix_s=matrix_s, &
831 matrix_metric=matrix_metric, &
832 matrix_metric_kp=matrix_metric_kp, &
833 matrix_s_ri_aux=matrix_s_ri_aux, &
834 matrix_ks_im_kp=matrix_ks_im_kp, &
835 matrix_w=matrix_w, &
836 matrix_p_mp2=matrix_p_mp2, &
837 matrix_p_mp2_admm=matrix_p_mp2_admm, &
838 matrix_vhxc=matrix_vhxc, &
839 matrix_h_kp=matrix_h_kp, &
840 matrix_h_im_kp=matrix_h_im_kp, &
841 matrix_ks_kp=matrix_ks_kp, &
842 matrix_vxc_kp=matrix_vxc_kp, &
843 kinetic_kp=kinetic_kp, &
844 matrix_s_kp=matrix_s_kp, &
845 matrix_w_kp=matrix_w_kp, &
846 matrix_s_ri_aux_kp=matrix_s_ri_aux_kp, &
847 rho=rho, &
848 rho_xc=rho_xc, &
849 xcint_weights=xcint_weights, &
850 rho_core=rho_core, &
851 rho_nlcc=rho_nlcc, &
852 rho_nlcc_g=rho_nlcc_g, &
853 vppl=vppl, &
854 vee=vee, &
855 neighbor_list_id=neighbor_list_id, &
856 sab_orb=sab_orb, &
857 sab_all=sab_all, &
858 sab_scp=sab_scp, &
859 sab_vdw=sab_vdw, &
860 sac_ae=sac_ae, &
861 sac_ppl=sac_ppl, &
862 sac_lri=sac_lri, &
863 sap_ppnl=sap_ppnl, &
864 sap_oce=sap_oce, &
865 sab_se=sab_se, &
866 sab_lrc=sab_lrc, &
867 sab_tbe=sab_tbe, &
868 sab_xtbe=sab_xtbe, &
869 sab_core=sab_core, &
870 sab_xb=sab_xb, &
871 sab_xtb_pp=sab_xtb_pp, &
872 sab_xtb_nonbond=sab_xtb_nonbond, &
873 sab_almo=sab_almo, &
874 sab_kp=sab_kp, &
875 sab_kp_nosym=sab_kp_nosym, &
876 sab_cneo=sab_cneo, &
877 task_list=task_list, &
878 task_list_soft=task_list_soft, &
879 kpoints=kpoints, &
880 do_kpoints=do_kpoints, &
881 local_molecules=local_molecules, &
882 local_particles=local_particles, &
883 atprop=atprop, &
884 virial=virial, &
885 results=results, &
886 cell=cell, &
887 cell_ref=cell_ref, &
888 use_ref_cell=use_ref_cell, &
889 energy=energy, &
890 force=force, &
891 qs_kind_set=qs_kind_set, &
892 subsys=subsys, &
893 cp_subsys=cp_subsys, &
894 atomic_kind_set=atomic_kind_set, &
895 particle_set=particle_set, &
896 molecule_kind_set=molecule_kind_set, &
897 molecule_set=molecule_set, &
898 natom=natom, &
899 nkind=nkind, &
900 dft_control=dft_control, &
901 dbcsr_dist=dbcsr_dist, &
902 distribution_2d=distribution_2d, &
903 pw_env=pw_env, &
904 para_env=para_env, &
905 blacs_env=blacs_env, &
906 nelectron_total=nelectron_total, &
907 nelectron_spin=nelectron_spin)
908
909 IF (PRESENT(tb_tblite)) tb_tblite => qs_env%tb_tblite
910
911 END SUBROUTINE get_qs_env
912
913! **************************************************************************************************
914!> \brief Initialise the QUICKSTEP environment.
915!> \param qs_env ...
916!> \param globenv ...
917!> \date 25.01.2002
918!> \author MK
919!> \version 1.0
920! **************************************************************************************************
921 SUBROUTINE init_qs_env(qs_env, globenv)
922
923 TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
924 TYPE(global_environment_type), OPTIONAL, POINTER :: globenv
925
926 NULLIFY (qs_env%ls_scf_env)
927 NULLIFY (qs_env%almo_scf_env)
928 NULLIFY (qs_env%transport_env)
929 NULLIFY (qs_env%image_matrix)
930 NULLIFY (qs_env%ipiv)
931 NULLIFY (qs_env%image_coeff)
932 NULLIFY (qs_env%super_cell)
933 NULLIFY (qs_env%mos)
934 NULLIFY (qs_env%mos_last_converged)
935 NULLIFY (qs_env%mpools)
936 NULLIFY (qs_env%ewald_env)
937 NULLIFY (qs_env%ewald_pw)
938 NULLIFY (qs_env%scf_control)
939 NULLIFY (qs_env%rel_control)
940 NULLIFY (qs_env%qs_charges)
941 ! ZMP initializing arrays
942 NULLIFY (qs_env%rho_external)
943 NULLIFY (qs_env%external_vxc)
944 NULLIFY (qs_env%mask)
945 ! Embedding potential
946 NULLIFY (qs_env%embed_pot)
947 NULLIFY (qs_env%spin_embed_pot)
948
949 ! Polarisability tensor
950 NULLIFY (qs_env%polar_env)
951
952 NULLIFY (qs_env%ks_env)
953 NULLIFY (qs_env%ks_qmmm_env)
954 NULLIFY (qs_env%wf_history)
955 NULLIFY (qs_env%scf_env)
956 NULLIFY (qs_env%oce)
957 NULLIFY (qs_env%local_rho_set)
958 NULLIFY (qs_env%hartree_local)
959 NULLIFY (qs_env%input)
960 NULLIFY (qs_env%linres_control)
961 NULLIFY (qs_env%xas_env)
962 NULLIFY (qs_env%cp_ddapc_env)
963 NULLIFY (qs_env%cp_ddapc_ewald)
964 NULLIFY (qs_env%outer_scf_history)
965 NULLIFY (qs_env%gradient_history)
966 NULLIFY (qs_env%variable_history)
967 NULLIFY (qs_env%x_data)
968 NULLIFY (qs_env%et_coupling)
969 NULLIFY (qs_env%dftb_potential)
970 NULLIFY (qs_env%active_space)
971
972 NULLIFY (qs_env%se_taper)
973 NULLIFY (qs_env%se_store_int_env)
974 NULLIFY (qs_env%se_nddo_mpole)
975 NULLIFY (qs_env%se_nonbond_env)
976 NULLIFY (qs_env%admm_env)
977 NULLIFY (qs_env%efield)
978 NULLIFY (qs_env%lri_env)
979 NULLIFY (qs_env%harris_env)
980 NULLIFY (qs_env%ec_env)
981 NULLIFY (qs_env%exstate_env)
982 NULLIFY (qs_env%lri_density)
983 NULLIFY (qs_env%gcp_env)
984 NULLIFY (qs_env%rtp)
985 NULLIFY (qs_env%mp2_env)
986 NULLIFY (qs_env%bs_env)
987 NULLIFY (qs_env%kg_env)
988 NULLIFY (qs_env%WannierCentres)
989
990 qs_env%outer_scf_ihistory = 0
991 qs_env%broyden_adaptive_sigma = -1.0_dp
992
993 CALL local_rho_set_create(qs_env%local_rho_set)
994 CALL hartree_local_create(qs_env%hartree_local)
995 qs_env%run_rtp = .false.
996 qs_env%linres_run = .false.
997 qs_env%single_point_run = .false.
998 qs_env%skip_wf_history = .false.
999 qs_env%qmmm = .false.
1000 qs_env%qmmm_periodic = .false.
1001 qs_env%mimic = .false.
1002 qs_env%requires_mo_derivs = .false.
1003 qs_env%requires_matrix_vxc = .false.
1004 qs_env%has_unit_metric = .false.
1005 qs_env%calc_image_preconditioner = .true.
1006 qs_env%do_transport = .false.
1007 qs_env%given_embed_pot = .false.
1008 qs_env%do_rixs = .false.
1009 IF (PRESENT(globenv)) THEN
1010 qs_env%target_time = globenv%cp2k_target_time
1011 qs_env%start_time = globenv%cp2k_start_time
1012 qs_env%single_point_run = (globenv%run_type_id == energy_run .OR. &
1013 globenv%run_type_id == energy_force_run)
1014 ELSE
1015 qs_env%target_time = 0.0_dp
1016 qs_env%start_time = 0.0_dp
1017 END IF
1018
1019 qs_env%sim_time = 0._dp
1020 qs_env%sim_step = 0
1021
1022 qs_env%total_zeff_corr = 0.0_dp
1023 qs_env%surface_dipole_moment = 0.0_dp
1024 qs_env%vacuum_level_below = 0.0_dp
1025 qs_env%vacuum_level_above = 0.0_dp
1026 qs_env%surface_dipole_ref_pos = 0.0_dp
1027 qs_env%surface_dipole_switch_off = .false.
1028
1029 ! Zero all variables containing results
1030 NULLIFY (qs_env%mo_derivs)
1031 NULLIFY (qs_env%mo_loc_history)
1032
1033 IF (.NOT. ASSOCIATED(qs_env%molecular_scf_guess_env)) ALLOCATE (qs_env%molecular_scf_guess_env)
1034
1035 NULLIFY (qs_env%tb_tblite)
1036 NULLIFY (qs_env%gauxc_cache)
1037
1038 END SUBROUTINE init_qs_env
1039
1040! **************************************************************************************************
1041!> \brief Set the QUICKSTEP environment.
1042!> \param qs_env ...
1043!> \param super_cell ...
1044!> \param mos ...
1045!> \param qmmm ...
1046!> \param qmmm_periodic ...
1047!> \param mimic ...
1048!> \param ewald_env ...
1049!> \param ewald_pw ...
1050!> \param mpools ...
1051!> \param rho_external ...
1052!> \param external_vxc ...
1053!> \param mask ...
1054!> \param scf_control ...
1055!> \param rel_control ...
1056!> \param qs_charges ...
1057!> \param ks_env ...
1058!> \param ks_qmmm_env ...
1059!> \param wf_history ...
1060!> \param scf_env ...
1061!> \param active_space ...
1062!> \param input ...
1063!> \param oce ...
1064!> \param rho_atom_set ...
1065!> \param rho0_atom_set ...
1066!> \param rho0_mpole ...
1067!> \param run_rtp ...
1068!> \param rtp ...
1069!> \param rhoz_set ...
1070!> \param rhoz_tot ...
1071!> \param ecoul_1c ...
1072!> \param has_unit_metric ...
1073!> \param requires_mo_derivs ...
1074!> \param mo_derivs ...
1075!> \param mo_loc_history ...
1076!> \param efield ...
1077!> \param rhoz_cneo_set ...
1078!> \param linres_control ...
1079!> \param xas_env ...
1080!> \param cp_ddapc_env ...
1081!> \param cp_ddapc_ewald ...
1082!> \param outer_scf_history ...
1083!> \param outer_scf_ihistory ...
1084!> \param x_data ...
1085!> \param et_coupling ...
1086!> \param dftb_potential ...
1087!> \param se_taper ...
1088!> \param se_store_int_env ...
1089!> \param se_nddo_mpole ...
1090!> \param se_nonbond_env ...
1091!> \param admm_env ...
1092!> \param ls_scf_env ...
1093!> \param do_transport ...
1094!> \param transport_env ...
1095!> \param lri_env ...
1096!> \param lri_density ...
1097!> \param exstate_env ...
1098!> \param ec_env ...
1099!> \param dispersion_env ...
1100!> \param harris_env ...
1101!> \param gcp_env ...
1102!> \param mp2_env ...
1103!> \param bs_env ...
1104!> \param kg_env ...
1105!> \param force ...
1106!> \param kpoints ...
1107!> \param WannierCentres ...
1108!> \param almo_scf_env ...
1109!> \param gradient_history ...
1110!> \param variable_history ...
1111!> \param embed_pot ...
1112!> \param spin_embed_pot ...
1113!> \param polar_env ...
1114!> \param mos_last_converged ... [SGh]
1115!> \param eeq ...
1116!> \param rhs ...
1117!> \param do_rixs ...
1118!> \param tb_tblite ...
1119!> \date 23.01.2002
1120!> \author MK
1121!> \version 1.0
1122! **************************************************************************************************
1123 SUBROUTINE set_qs_env(qs_env, super_cell, &
1124 mos, qmmm, qmmm_periodic, mimic, &
1125 ewald_env, ewald_pw, mpools, &
1126 rho_external, external_vxc, mask, &
1127 scf_control, rel_control, qs_charges, ks_env, &
1128 ks_qmmm_env, wf_history, scf_env, active_space, &
1129 input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, &
1130 rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, &
1131 mo_loc_history, efield, rhoz_cneo_set, &
1132 linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, &
1133 outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, &
1134 se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, &
1135 do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, &
1136 harris_env, gcp_env, mp2_env, bs_env, kg_env, force, &
1137 kpoints, WannierCentres, almo_scf_env, gradient_history, variable_history, embed_pot, &
1138 spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
1139
1140 TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1141 TYPE(cell_type), OPTIONAL, POINTER :: super_cell
1142 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos
1143 LOGICAL, OPTIONAL :: qmmm, qmmm_periodic, mimic
1144 TYPE(ewald_environment_type), OPTIONAL, POINTER :: ewald_env
1145 TYPE(ewald_pw_type), OPTIONAL, POINTER :: ewald_pw
1146 TYPE(qs_matrix_pools_type), OPTIONAL, POINTER :: mpools
1147 TYPE(qs_rho_type), OPTIONAL, POINTER :: rho_external
1148 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: external_vxc, mask
1149 TYPE(scf_control_type), OPTIONAL, POINTER :: scf_control
1150 TYPE(rel_control_type), OPTIONAL, POINTER :: rel_control
1151 TYPE(qs_charges_type), OPTIONAL, POINTER :: qs_charges
1152 TYPE(qs_ks_env_type), OPTIONAL, POINTER :: ks_env
1153 TYPE(qs_ks_qmmm_env_type), OPTIONAL, POINTER :: ks_qmmm_env
1154 TYPE(qs_wf_history_type), OPTIONAL, POINTER :: wf_history
1155 TYPE(qs_scf_env_type), OPTIONAL, POINTER :: scf_env
1156 TYPE(active_space_type), OPTIONAL, POINTER :: active_space
1157 TYPE(section_vals_type), OPTIONAL, POINTER :: input
1158 TYPE(oce_matrix_type), OPTIONAL, POINTER :: oce
1159 TYPE(rho_atom_type), DIMENSION(:), OPTIONAL, &
1160 POINTER :: rho_atom_set
1161 TYPE(rho0_atom_type), DIMENSION(:), OPTIONAL, &
1162 POINTER :: rho0_atom_set
1163 TYPE(rho0_mpole_type), OPTIONAL, POINTER :: rho0_mpole
1164 LOGICAL, OPTIONAL :: run_rtp
1165 TYPE(rt_prop_type), OPTIONAL, POINTER :: rtp
1166 TYPE(rhoz_type), DIMENSION(:), OPTIONAL, POINTER :: rhoz_set
1167 REAL(dp), OPTIONAL :: rhoz_tot
1168 TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
1169 POINTER :: ecoul_1c
1170 LOGICAL, OPTIONAL :: has_unit_metric, requires_mo_derivs
1171 TYPE(dbcsr_p_type), DIMENSION(:), OPTIONAL, &
1172 POINTER :: mo_derivs
1173 TYPE(cp_fm_type), DIMENSION(:), OPTIONAL, POINTER :: mo_loc_history
1174 TYPE(efield_berry_type), OPTIONAL, POINTER :: efield
1175 TYPE(rhoz_cneo_type), DIMENSION(:), OPTIONAL, &
1176 POINTER :: rhoz_cneo_set
1177 TYPE(linres_control_type), OPTIONAL, POINTER :: linres_control
1178 TYPE(xas_environment_type), OPTIONAL, POINTER :: xas_env
1179 TYPE(cp_ddapc_type), OPTIONAL, POINTER :: cp_ddapc_env
1180 TYPE(cp_ddapc_ewald_type), OPTIONAL, POINTER :: cp_ddapc_ewald
1181 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: outer_scf_history
1182 INTEGER, INTENT(IN), OPTIONAL :: outer_scf_ihistory
1183 TYPE(hfx_type), DIMENSION(:, :), OPTIONAL, POINTER :: x_data
1184 TYPE(et_coupling_type), OPTIONAL, POINTER :: et_coupling
1185 TYPE(qs_dftb_pairpot_type), DIMENSION(:, :), &
1186 OPTIONAL, POINTER :: dftb_potential
1187 TYPE(se_taper_type), OPTIONAL, POINTER :: se_taper
1188 TYPE(semi_empirical_si_type), OPTIONAL, POINTER :: se_store_int_env
1189 TYPE(nddo_mpole_type), OPTIONAL, POINTER :: se_nddo_mpole
1190 TYPE(fist_nonbond_env_type), OPTIONAL, POINTER :: se_nonbond_env
1191 TYPE(admm_type), OPTIONAL, POINTER :: admm_env
1192 TYPE(ls_scf_env_type), OPTIONAL, POINTER :: ls_scf_env
1193 LOGICAL, OPTIONAL :: do_transport
1194 TYPE(transport_env_type), OPTIONAL, POINTER :: transport_env
1195 TYPE(lri_environment_type), OPTIONAL, POINTER :: lri_env
1196 TYPE(lri_density_type), OPTIONAL, POINTER :: lri_density
1197 TYPE(excited_energy_type), OPTIONAL, POINTER :: exstate_env
1198 TYPE(energy_correction_type), OPTIONAL, POINTER :: ec_env
1199 TYPE(qs_dispersion_type), OPTIONAL, POINTER :: dispersion_env
1200 TYPE(harris_type), OPTIONAL, POINTER :: harris_env
1201 TYPE(qs_gcp_type), OPTIONAL, POINTER :: gcp_env
1202 TYPE(mp2_type), OPTIONAL, POINTER :: mp2_env
1203 TYPE(post_scf_bandstructure_type), OPTIONAL, &
1204 POINTER :: bs_env
1205 TYPE(kg_environment_type), OPTIONAL, POINTER :: kg_env
1206 TYPE(qs_force_type), DIMENSION(:), OPTIONAL, &
1207 POINTER :: force
1208 TYPE(kpoint_type), OPTIONAL, POINTER :: kpoints
1209 TYPE(wannier_centres_type), DIMENSION(:), &
1210 OPTIONAL, POINTER :: wanniercentres
1211 TYPE(almo_scf_env_type), OPTIONAL, POINTER :: almo_scf_env
1212 REAL(kind=dp), DIMENSION(:, :), OPTIONAL, POINTER :: gradient_history, variable_history
1213 TYPE(pw_r3d_rs_type), OPTIONAL, POINTER :: embed_pot, spin_embed_pot
1214 TYPE(polar_env_type), OPTIONAL, POINTER :: polar_env
1215 TYPE(mo_set_type), DIMENSION(:), OPTIONAL, POINTER :: mos_last_converged
1216 REAL(kind=dp), DIMENSION(:), OPTIONAL, POINTER :: eeq, rhs
1217 LOGICAL, OPTIONAL :: do_rixs
1218 TYPE(tblite_type), OPTIONAL, POINTER :: tb_tblite
1219
1220 TYPE(qs_subsys_type), POINTER :: subsys
1221
1222 IF (PRESENT(mp2_env)) qs_env%mp2_env => mp2_env
1223 IF (PRESENT(bs_env)) qs_env%bs_env => bs_env
1224 IF (PRESENT(kg_env)) qs_env%kg_env => kg_env
1225 IF (PRESENT(super_cell)) THEN
1226 CALL cell_retain(super_cell)
1227 CALL cell_release(qs_env%super_cell)
1228 qs_env%super_cell => super_cell
1229 END IF
1230 !
1231 IF (PRESENT(qmmm)) qs_env%qmmm = qmmm
1232 IF (PRESENT(qmmm_periodic)) qs_env%qmmm_periodic = qmmm_periodic
1233 IF (PRESENT(mimic)) qs_env%mimic = mimic
1234 IF (PRESENT(mos)) qs_env%mos => mos
1235 IF (PRESENT(mos_last_converged)) qs_env%mos_last_converged => mos_last_converged
1236 IF (PRESENT(ls_scf_env)) qs_env%ls_scf_env => ls_scf_env
1237 IF (PRESENT(almo_scf_env)) qs_env%almo_scf_env => almo_scf_env
1238 IF (PRESENT(do_transport)) qs_env%do_transport = do_transport
1239 IF (PRESENT(transport_env)) qs_env%transport_env => transport_env
1240 ! if intels checking (-C) complains here, you have rediscovered a bug in the intel
1241 ! compiler (present in at least 10.0.025). A testcase has been submitted to intel.
1242 IF (PRESENT(oce)) qs_env%oce => oce
1243 IF (PRESENT(outer_scf_history)) qs_env%outer_scf_history => outer_scf_history
1244 IF (PRESENT(gradient_history)) qs_env%gradient_history => gradient_history
1245 IF (PRESENT(variable_history)) qs_env%variable_history => variable_history
1246 IF (PRESENT(outer_scf_ihistory)) qs_env%outer_scf_ihistory = outer_scf_ihistory
1247 IF (PRESENT(requires_mo_derivs)) qs_env%requires_mo_derivs = requires_mo_derivs
1248 IF (PRESENT(has_unit_metric)) qs_env%has_unit_metric = has_unit_metric
1249 IF (PRESENT(mo_derivs)) qs_env%mo_derivs => mo_derivs
1250 IF (PRESENT(mo_loc_history)) qs_env%mo_loc_history => mo_loc_history
1251 IF (PRESENT(run_rtp)) qs_env%run_rtp = run_rtp
1252 IF (PRESENT(rtp)) qs_env%rtp => rtp
1253 IF (PRESENT(efield)) qs_env%efield => efield
1254 IF (PRESENT(active_space)) qs_env%active_space => active_space
1255 IF (PRESENT(do_rixs)) do_rixs = qs_env%do_rixs
1256
1257 IF (PRESENT(ewald_env)) THEN ! accept also null pointers?
1258 IF (ASSOCIATED(qs_env%ewald_env)) THEN
1259 IF (.NOT. ASSOCIATED(qs_env%ewald_env, ewald_env)) THEN
1260 CALL ewald_env_release(qs_env%ewald_env)
1261 DEALLOCATE (qs_env%ewald_env)
1262 END IF
1263 END IF
1264 qs_env%ewald_env => ewald_env
1265 END IF
1266 IF (PRESENT(ewald_pw)) THEN ! accept also null pointers?
1267 IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1268 IF (.NOT. ASSOCIATED(ewald_pw, qs_env%ewald_pw)) THEN
1269 CALL ewald_pw_release(qs_env%ewald_pw)
1270 DEALLOCATE (qs_env%ewald_pw)
1271 END IF
1272 END IF
1273 qs_env%ewald_pw => ewald_pw
1274 END IF
1275 IF (PRESENT(scf_control)) THEN ! accept also null pointers?
1276 IF (ASSOCIATED(qs_env%scf_control)) THEN
1277 IF (.NOT. ASSOCIATED(qs_env%scf_control, scf_control)) THEN
1278 CALL scf_c_release(qs_env%scf_control)
1279 DEALLOCATE (qs_env%scf_control)
1280 END IF
1281 END IF
1282 qs_env%scf_control => scf_control
1283 END IF
1284 IF (PRESENT(rel_control)) THEN ! accept also null pointers?
1285 IF (ASSOCIATED(qs_env%rel_control)) THEN
1286 IF (.NOT. ASSOCIATED(qs_env%rel_control, rel_control)) THEN
1287 CALL rel_c_release(qs_env%rel_control)
1288 DEALLOCATE (qs_env%rel_control)
1289 END IF
1290 END IF
1291 qs_env%rel_control => rel_control
1292 END IF
1293 IF (PRESENT(linres_control)) THEN ! accept also null pointers?
1294 IF (ASSOCIATED(qs_env%linres_control)) THEN
1295 IF (.NOT. ASSOCIATED(qs_env%linres_control, linres_control)) THEN
1296 CALL linres_control_release(qs_env%linres_control)
1297 DEALLOCATE (qs_env%linres_control)
1298 END IF
1299 END IF
1300 qs_env%linres_control => linres_control
1301 END IF
1302 ! ZMP associating variables
1303 IF (PRESENT(rho_external)) THEN
1304 IF (ASSOCIATED(qs_env%rho_external)) THEN
1305 IF (.NOT. ASSOCIATED(qs_env%rho_external, rho_external)) THEN
1306 CALL qs_rho_release(qs_env%rho_external)
1307 DEALLOCATE (qs_env%rho_external)
1308 END IF
1309 END IF
1310 qs_env%rho_external => rho_external
1311 END IF
1312 IF (PRESENT(external_vxc)) qs_env%external_vxc => external_vxc
1313 IF (PRESENT(mask)) qs_env%mask => mask
1314 ! Embedding potential
1315 IF (PRESENT(embed_pot)) qs_env%embed_pot => embed_pot
1316 IF (PRESENT(spin_embed_pot)) qs_env%spin_embed_pot => spin_embed_pot
1317
1318 ! Polarisability tensor
1319 IF (PRESENT(polar_env)) qs_env%polar_env => polar_env
1320
1321 IF (PRESENT(qs_charges)) THEN
1322 IF (ASSOCIATED(qs_env%qs_charges)) THEN
1323 IF (.NOT. ASSOCIATED(qs_env%qs_charges, qs_charges)) THEN
1324 CALL qs_charges_release(qs_env%qs_charges)
1325 DEALLOCATE (qs_env%qs_charges)
1326 END IF
1327 END IF
1328 qs_env%qs_charges => qs_charges
1329 END IF
1330 IF (PRESENT(ks_qmmm_env)) THEN
1331 IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1332 IF (.NOT. ASSOCIATED(qs_env%ks_qmmm_env, ks_qmmm_env)) THEN
1333 CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1334 DEALLOCATE (qs_env%ks_qmmm_env)
1335 END IF
1336 END IF
1337 qs_env%ks_qmmm_env => ks_qmmm_env
1338 END IF
1339 IF (PRESENT(ks_env)) THEN ! accept also null pointers?
1340 IF (ASSOCIATED(qs_env%ks_env)) THEN
1341 IF (.NOT. ASSOCIATED(qs_env%ks_env, ks_env)) THEN
1342 CALL qs_ks_release(qs_env%ks_env)
1343 DEALLOCATE (qs_env%ks_env)
1344 END IF
1345 END IF
1346 qs_env%ks_env => ks_env
1347 END IF
1348 IF (PRESENT(wf_history)) THEN ! accept also null pointers ?
1349 CALL wfi_retain(wf_history)
1350 CALL wfi_release(qs_env%wf_history)
1351 qs_env%wf_history => wf_history
1352 END IF
1353 IF (PRESENT(scf_env)) THEN ! accept also null pointers ?
1354 IF (ASSOCIATED(qs_env%scf_env)) THEN
1355 IF (.NOT. ASSOCIATED(qs_env%scf_env, scf_env)) THEN
1356 CALL scf_env_release(qs_env%scf_env)
1357 DEALLOCATE (qs_env%scf_env)
1358 END IF
1359 END IF
1360 qs_env%scf_env => scf_env
1361 END IF
1362 IF (PRESENT(xas_env)) THEN ! accept also null pointers?
1363 IF (ASSOCIATED(qs_env%xas_env)) THEN
1364 IF (.NOT. ASSOCIATED(qs_env%xas_env, xas_env)) THEN
1365 CALL xas_env_release(qs_env%xas_env)
1366 DEALLOCATE (qs_env%xas_env)
1367 END IF
1368 END IF
1369 qs_env%xas_env => xas_env
1370 END IF
1371 IF (PRESENT(mpools)) THEN
1372 IF (.NOT. ASSOCIATED(qs_env%mpools, mpools)) CALL mpools_release(qs_env%mpools)
1373 qs_env%mpools => mpools
1374 END IF
1375 IF (PRESENT(rho_atom_set)) THEN
1376 CALL set_local_rho(qs_env%local_rho_set, rho_atom_set=rho_atom_set)
1377 END IF
1378 IF (PRESENT(rho0_atom_set)) THEN
1379 CALL set_local_rho(qs_env%local_rho_set, rho0_atom_set=rho0_atom_set)
1380 END IF
1381 IF (PRESENT(rho0_mpole)) THEN
1382 CALL set_local_rho(qs_env%local_rho_set, rho0_mpole=rho0_mpole)
1383 END IF
1384 IF (PRESENT(rhoz_set)) THEN
1385 CALL set_local_rho(qs_env%local_rho_set, rhoz_set=rhoz_set)
1386 END IF
1387 IF (PRESENT(rhoz_cneo_set)) THEN
1388 CALL set_local_rho(qs_env%local_rho_set, rhoz_cneo_set=rhoz_cneo_set)
1389 END IF
1390 IF (PRESENT(rhoz_tot)) qs_env%local_rho_set%rhoz_tot = rhoz_tot
1391 IF (PRESENT(ecoul_1c)) THEN
1392 CALL set_hartree_local(qs_env%hartree_local, ecoul_1c=ecoul_1c)
1393 END IF
1394 IF (PRESENT(input)) THEN
1395 CALL section_vals_retain(input)
1396 CALL section_vals_release(qs_env%input)
1397 qs_env%input => input
1398 END IF
1399 IF (PRESENT(cp_ddapc_env)) THEN
1400 IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1401 IF (.NOT. ASSOCIATED(qs_env%cp_ddapc_env, cp_ddapc_env)) THEN
1402 CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1403 DEALLOCATE (qs_env%cp_ddapc_env)
1404 END IF
1405 END IF
1406 qs_env%cp_ddapc_env => cp_ddapc_env
1407 END IF
1408 IF (PRESENT(cp_ddapc_ewald)) THEN
1409 qs_env%cp_ddapc_ewald => cp_ddapc_ewald
1410 END IF
1411 IF (PRESENT(x_data)) qs_env%x_data => x_data
1412 IF (PRESENT(et_coupling)) qs_env%et_coupling => et_coupling
1413 IF (PRESENT(dftb_potential)) qs_env%dftb_potential => dftb_potential
1414 IF (PRESENT(se_taper)) THEN
1415 CALL se_taper_release(qs_env%se_taper)
1416 qs_env%se_taper => se_taper
1417 END IF
1418 IF (PRESENT(se_store_int_env)) THEN
1419 CALL semi_empirical_si_release(qs_env%se_store_int_env)
1420 qs_env%se_store_int_env => se_store_int_env
1421 END IF
1422 IF (PRESENT(se_nddo_mpole)) THEN
1423 CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1424 qs_env%se_nddo_mpole => se_nddo_mpole
1425 END IF
1426 IF (PRESENT(se_nonbond_env)) THEN
1427 IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1428 IF (.NOT. ASSOCIATED(qs_env%se_nonbond_env, se_nonbond_env)) THEN
1429 CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1430 DEALLOCATE (qs_env%se_nonbond_env)
1431 END IF
1432 END IF
1433 qs_env%se_nonbond_env => se_nonbond_env
1434 END IF
1435 IF (PRESENT(admm_env)) qs_env%admm_env => admm_env
1436 IF (PRESENT(lri_env)) qs_env%lri_env => lri_env
1437 IF (PRESENT(lri_density)) qs_env%lri_density => lri_density
1438 IF (PRESENT(harris_env)) qs_env%harris_env => harris_env
1439 IF (PRESENT(ec_env)) qs_env%ec_env => ec_env
1440 IF (PRESENT(exstate_env)) qs_env%exstate_env => exstate_env
1441 IF (PRESENT(dispersion_env)) qs_env%dispersion_env => dispersion_env
1442 IF (PRESENT(gcp_env)) qs_env%gcp_env => gcp_env
1443 IF (PRESENT(wanniercentres)) qs_env%WannierCentres => wanniercentres
1444 IF (PRESENT(kpoints)) CALL set_ks_env(qs_env%ks_env, kpoints=kpoints)
1445
1446 ! EEQ charges
1447 IF (PRESENT(eeq)) qs_env%eeq => eeq
1448
1449 ! Resp charges
1450 IF (PRESENT(rhs)) qs_env%rhs => rhs
1451
1452 IF (PRESENT(force)) THEN
1453 CALL get_qs_env(qs_env, subsys=subsys)
1454 CALL qs_subsys_set(subsys, force=force)
1455 END IF
1456
1457 IF (PRESENT(tb_tblite)) qs_env%tb_tblite => tb_tblite
1458
1459 END SUBROUTINE set_qs_env
1460
1461! **************************************************************************************************
1462!> \brief allocates and intitializes a qs_env
1463!> \param qs_env the object to create
1464!> \param globenv ...
1465!> \par History
1466!> 12.2002 created [fawzi]
1467!> \author Fawzi Mohamed
1468! **************************************************************************************************
1469 SUBROUTINE qs_env_create(qs_env, globenv)
1470 TYPE(qs_environment_type), INTENT(OUT) :: qs_env
1471 TYPE(global_environment_type), OPTIONAL, POINTER :: globenv
1472
1473 CALL init_qs_env(qs_env, globenv=globenv)
1474 END SUBROUTINE qs_env_create
1475
1476! **************************************************************************************************
1477!> \brief releases the given qs_env (see doc/ReferenceCounting.html)
1478!> \param qs_env the object to release
1479!> \par History
1480!> 12.2002 created [fawzi]
1481!> 06.2018 polar_env added (MK)
1482!> \author Fawzi Mohamed
1483! **************************************************************************************************
1484 SUBROUTINE qs_env_release(qs_env)
1485 TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1486
1487 INTEGER :: i
1488
1489 CALL cell_release(qs_env%super_cell)
1490 IF (ASSOCIATED(qs_env%mos)) THEN
1491 DO i = 1, SIZE(qs_env%mos)
1492 CALL deallocate_mo_set(qs_env%mos(i))
1493 END DO
1494 DEALLOCATE (qs_env%mos)
1495 END IF
1496 IF (ASSOCIATED(qs_env%mos_last_converged)) THEN
1497 DO i = 1, SIZE(qs_env%mos_last_converged)
1498 CALL deallocate_mo_set(qs_env%mos_last_converged(i))
1499 END DO
1500 DEALLOCATE (qs_env%mos_last_converged)
1501 END IF
1502
1503 IF (ASSOCIATED(qs_env%mo_derivs)) THEN
1504 DO i = 1, SIZE(qs_env%mo_derivs)
1505 CALL dbcsr_release_p(qs_env%mo_derivs(i)%matrix)
1506 END DO
1507 DEALLOCATE (qs_env%mo_derivs)
1508 END IF
1509
1510 CALL cp_fm_release(qs_env%mo_loc_history)
1511
1512 IF (ASSOCIATED(qs_env%rtp)) THEN
1513 CALL rt_prop_release(qs_env%rtp)
1514 DEALLOCATE (qs_env%rtp)
1515 END IF
1516 IF (ASSOCIATED(qs_env%outer_scf_history)) THEN
1517 DEALLOCATE (qs_env%outer_scf_history)
1518 qs_env%outer_scf_ihistory = 0
1519 END IF
1520 IF (ASSOCIATED(qs_env%gradient_history)) THEN
1521 DEALLOCATE (qs_env%gradient_history)
1522 END IF
1523 IF (ASSOCIATED(qs_env%variable_history)) THEN
1524 DEALLOCATE (qs_env%variable_history)
1525 END IF
1526 IF (ASSOCIATED(qs_env%oce)) CALL deallocate_oce_set(qs_env%oce)
1527 IF (ASSOCIATED(qs_env%local_rho_set)) THEN
1528 CALL local_rho_set_release(qs_env%local_rho_set)
1529 END IF
1530 IF (ASSOCIATED(qs_env%hartree_local)) THEN
1531 CALL hartree_local_release(qs_env%hartree_local)
1532 END IF
1533 IF (ASSOCIATED(qs_env%scf_control)) THEN
1534 CALL scf_c_release(qs_env%scf_control)
1535 DEALLOCATE (qs_env%scf_control)
1536 END IF
1537 IF (ASSOCIATED(qs_env%rel_control)) THEN
1538 CALL rel_c_release(qs_env%rel_control)
1539 DEALLOCATE (qs_env%rel_control)
1540 END IF
1541
1542 IF (ASSOCIATED(qs_env%linres_control)) THEN
1543 CALL linres_control_release(qs_env%linres_control)
1544 DEALLOCATE (qs_env%linres_control)
1545 END IF
1546
1547 IF (ASSOCIATED(qs_env%almo_scf_env)) THEN
1548 CALL almo_scf_env_release(qs_env%almo_scf_env)
1549 END IF
1550
1551 IF (ASSOCIATED(qs_env%ls_scf_env)) THEN
1552 CALL ls_scf_release(qs_env%ls_scf_env)
1553 END IF
1554 IF (ASSOCIATED(qs_env%molecular_scf_guess_env)) THEN
1555 CALL molecular_scf_guess_env_destroy(qs_env%molecular_scf_guess_env)
1556 DEALLOCATE (qs_env%molecular_scf_guess_env)
1557 END IF
1558
1559 IF (ASSOCIATED(qs_env%transport_env)) THEN
1560 CALL transport_env_release(qs_env%transport_env)
1561 END IF
1562
1563 !Only if do_xas_calculation
1564 IF (ASSOCIATED(qs_env%xas_env)) THEN
1565 CALL xas_env_release(qs_env%xas_env)
1566 DEALLOCATE (qs_env%xas_env)
1567 END IF
1568 IF (ASSOCIATED(qs_env%ewald_env)) THEN
1569 CALL ewald_env_release(qs_env%ewald_env)
1570 DEALLOCATE (qs_env%ewald_env)
1571 END IF
1572 IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1573 CALL ewald_pw_release(qs_env%ewald_pw)
1574 DEALLOCATE (qs_env%ewald_pw)
1575 END IF
1576 IF (ASSOCIATED(qs_env%image_matrix)) THEN
1577 DEALLOCATE (qs_env%image_matrix)
1578 END IF
1579 IF (ASSOCIATED(qs_env%ipiv)) THEN
1580 DEALLOCATE (qs_env%ipiv)
1581 END IF
1582 IF (ASSOCIATED(qs_env%image_coeff)) THEN
1583 DEALLOCATE (qs_env%image_coeff)
1584 END IF
1585 ! ZMP
1586 IF (ASSOCIATED(qs_env%rho_external)) THEN
1587 CALL qs_rho_release(qs_env%rho_external)
1588 DEALLOCATE (qs_env%rho_external)
1589 END IF
1590 IF (ASSOCIATED(qs_env%external_vxc)) THEN
1591 CALL qs_env%external_vxc%release()
1592 DEALLOCATE (qs_env%external_vxc)
1593 END IF
1594 IF (ASSOCIATED(qs_env%mask)) THEN
1595 CALL qs_env%mask%release()
1596 DEALLOCATE (qs_env%mask)
1597 END IF
1598 IF (ASSOCIATED(qs_env%active_space)) THEN
1599 CALL release_active_space_type(qs_env%active_space)
1600 END IF
1601 ! Embedding potentials if provided as input
1602 IF (qs_env%given_embed_pot) THEN
1603 CALL qs_env%embed_pot%release()
1604 DEALLOCATE (qs_env%embed_pot)
1605 IF (ASSOCIATED(qs_env%spin_embed_pot)) THEN
1606 CALL qs_env%spin_embed_pot%release()
1607 DEALLOCATE (qs_env%spin_embed_pot)
1608 END IF
1609 END IF
1610
1611 ! Polarisability tensor
1612 CALL polar_env_release(qs_env%polar_env)
1613
1614 IF (ASSOCIATED(qs_env%qs_charges)) THEN
1615 CALL qs_charges_release(qs_env%qs_charges)
1616 DEALLOCATE (qs_env%qs_charges)
1617 END IF
1618 IF (ASSOCIATED(qs_env%ks_env)) THEN
1619 CALL qs_ks_release(qs_env%ks_env)
1620 DEALLOCATE (qs_env%ks_env)
1621 END IF
1622 IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1623 CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1624 DEALLOCATE (qs_env%ks_qmmm_env)
1625 END IF
1626 CALL wfi_release(qs_env%wf_history)
1627 IF (ASSOCIATED(qs_env%scf_env)) THEN
1628 CALL scf_env_release(qs_env%scf_env)
1629 DEALLOCATE (qs_env%scf_env)
1630 END IF
1631 CALL mpools_release(qs_env%mpools)
1632 CALL section_vals_release(qs_env%input)
1633 IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1634 CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1635 DEALLOCATE (qs_env%cp_ddapc_env)
1636 END IF
1637 CALL cp_ddapc_ewald_release(qs_env%cp_ddapc_ewald)
1638 CALL efield_berry_release(qs_env%efield)
1639 IF (ASSOCIATED(qs_env%x_data)) THEN
1640 CALL hfx_release(qs_env%x_data)
1641 END IF
1642 IF (ASSOCIATED(qs_env%et_coupling)) THEN
1643 CALL et_coupling_release(qs_env%et_coupling)
1644 END IF
1645 IF (ASSOCIATED(qs_env%dftb_potential)) THEN
1646 CALL qs_dftb_pairpot_release(qs_env%dftb_potential)
1647 END IF
1648 IF (ASSOCIATED(qs_env%se_taper)) THEN
1649 CALL se_taper_release(qs_env%se_taper)
1650 END IF
1651 IF (ASSOCIATED(qs_env%se_store_int_env)) THEN
1652 CALL semi_empirical_si_release(qs_env%se_store_int_env)
1653 END IF
1654 IF (ASSOCIATED(qs_env%se_nddo_mpole)) THEN
1655 CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1656 END IF
1657 IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1658 CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1659 DEALLOCATE (qs_env%se_nonbond_env)
1660 END IF
1661 IF (ASSOCIATED(qs_env%admm_env)) THEN
1662 CALL admm_env_release(qs_env%admm_env)
1663 END IF
1664 IF (ASSOCIATED(qs_env%lri_env)) THEN
1665 CALL lri_env_release(qs_env%lri_env)
1666 DEALLOCATE (qs_env%lri_env)
1667 END IF
1668 IF (ASSOCIATED(qs_env%lri_density)) THEN
1669 CALL lri_density_release(qs_env%lri_density)
1670 DEALLOCATE (qs_env%lri_density)
1671 END IF
1672 IF (ASSOCIATED(qs_env%harris_env)) THEN
1673 CALL harris_env_release(qs_env%harris_env)
1674 END IF
1675 IF (ASSOCIATED(qs_env%ec_env)) THEN
1676 CALL ec_env_release(qs_env%ec_env)
1677 END IF
1678 IF (ASSOCIATED(qs_env%exstate_env)) THEN
1679 CALL exstate_release(qs_env%exstate_env)
1680 END IF
1681 IF (ASSOCIATED(qs_env%mp2_env)) THEN
1682 CALL mp2_env_release(qs_env%mp2_env)
1683 DEALLOCATE (qs_env%mp2_env)
1684 NULLIFY (qs_env%mp2_env)
1685 END IF
1686 IF (ASSOCIATED(qs_env%bs_env)) THEN
1687 CALL bs_env_release(qs_env%bs_env)
1688 END IF
1689 IF (ASSOCIATED(qs_env%kg_env)) THEN
1690 CALL kg_env_release(qs_env%kg_env)
1691 END IF
1692
1693 ! dispersion
1694 CALL qs_dispersion_release(qs_env%dispersion_env)
1695 ! gCP
1696 IF (ASSOCIATED(qs_env%gcp_env)) THEN
1697 CALL qs_gcp_release(qs_env%gcp_env)
1698 END IF
1699
1700 IF (ASSOCIATED(qs_env%WannierCentres)) THEN
1701 DO i = 1, SIZE(qs_env%WannierCentres)
1702 DEALLOCATE (qs_env%WannierCentres(i)%WannierHamDiag)
1703 DEALLOCATE (qs_env%WannierCentres(i)%centres)
1704 END DO
1705 DEALLOCATE (qs_env%WannierCentres)
1706 END IF
1707 ! EEQ charges
1708 IF (ASSOCIATED(qs_env%eeq)) DEALLOCATE (qs_env%eeq)
1709 ! Resp chargeqq
1710 IF (ASSOCIATED(qs_env%rhs)) DEALLOCATE (qs_env%rhs)
1711
1712 ! tblite
1713 IF (ASSOCIATED(qs_env%tb_tblite)) THEN
1714 CALL deallocate_tblite_type(qs_env%tb_tblite)
1715 END IF
1716
1717 IF (ASSOCIATED(qs_env%gauxc_cache)) THEN
1718 CALL gauxc_cache_release(qs_env%gauxc_cache)
1719 DEALLOCATE (qs_env%gauxc_cache)
1720 END IF
1721
1722 CALL release_native_grid_cache(qs_env%native_grid_cache)
1723
1724 END SUBROUTINE qs_env_release
1725
1726! **************************************************************************************************
1727!> \brief releases part of the given qs_env in order to save memory
1728!> \param qs_env the object to release
1729!> \par History
1730!> 04.2022 created [JGH]
1731! **************************************************************************************************
1732 SUBROUTINE qs_env_part_release(qs_env)
1733 TYPE(qs_environment_type), INTENT(INOUT) :: qs_env
1734
1735 INTEGER :: i
1736
1737 IF (ASSOCIATED(qs_env%mos_last_converged)) THEN
1738 DO i = 1, SIZE(qs_env%mos_last_converged)
1739 CALL deallocate_mo_set(qs_env%mos_last_converged(i))
1740 END DO
1741 DEALLOCATE (qs_env%mos_last_converged)
1742 END IF
1743
1744 IF (ASSOCIATED(qs_env%mo_derivs)) THEN
1745 DO i = 1, SIZE(qs_env%mo_derivs)
1746 CALL dbcsr_release_p(qs_env%mo_derivs(i)%matrix)
1747 END DO
1748 DEALLOCATE (qs_env%mo_derivs)
1749 END IF
1750
1751 CALL cp_fm_release(qs_env%mo_loc_history)
1752
1753 IF (ASSOCIATED(qs_env%rtp)) THEN
1754 CALL rt_prop_release(qs_env%rtp)
1755 DEALLOCATE (qs_env%rtp)
1756 END IF
1757 IF (ASSOCIATED(qs_env%outer_scf_history)) THEN
1758 DEALLOCATE (qs_env%outer_scf_history)
1759 qs_env%outer_scf_ihistory = 0
1760 END IF
1761 IF (ASSOCIATED(qs_env%gradient_history)) THEN
1762 DEALLOCATE (qs_env%gradient_history)
1763 END IF
1764 IF (ASSOCIATED(qs_env%variable_history)) THEN
1765 DEALLOCATE (qs_env%variable_history)
1766 END IF
1767 IF (ASSOCIATED(qs_env%oce)) CALL deallocate_oce_set(qs_env%oce)
1768 IF (ASSOCIATED(qs_env%local_rho_set)) THEN
1769 CALL local_rho_set_release(qs_env%local_rho_set)
1770 END IF
1771 IF (ASSOCIATED(qs_env%hartree_local)) THEN
1772 CALL hartree_local_release(qs_env%hartree_local)
1773 END IF
1774 IF (ASSOCIATED(qs_env%scf_control)) THEN
1775 CALL scf_c_release(qs_env%scf_control)
1776 DEALLOCATE (qs_env%scf_control)
1777 END IF
1778 IF (ASSOCIATED(qs_env%rel_control)) THEN
1779 CALL rel_c_release(qs_env%rel_control)
1780 DEALLOCATE (qs_env%rel_control)
1781 END IF
1782
1783 IF (ASSOCIATED(qs_env%linres_control)) THEN
1784 CALL linres_control_release(qs_env%linres_control)
1785 DEALLOCATE (qs_env%linres_control)
1786 END IF
1787
1788 IF (ASSOCIATED(qs_env%almo_scf_env)) THEN
1789 CALL almo_scf_env_release(qs_env%almo_scf_env)
1790 END IF
1791
1792 IF (ASSOCIATED(qs_env%ls_scf_env)) THEN
1793 CALL ls_scf_release(qs_env%ls_scf_env)
1794 END IF
1795 IF (ASSOCIATED(qs_env%molecular_scf_guess_env)) THEN
1796 CALL molecular_scf_guess_env_destroy(qs_env%molecular_scf_guess_env)
1797 DEALLOCATE (qs_env%molecular_scf_guess_env)
1798 END IF
1799
1800 IF (ASSOCIATED(qs_env%transport_env)) THEN
1801 CALL transport_env_release(qs_env%transport_env)
1802 END IF
1803
1804 !Only if do_xas_calculation
1805 IF (ASSOCIATED(qs_env%xas_env)) THEN
1806 CALL xas_env_release(qs_env%xas_env)
1807 DEALLOCATE (qs_env%xas_env)
1808 END IF
1809 IF (ASSOCIATED(qs_env%ewald_env)) THEN
1810 CALL ewald_env_release(qs_env%ewald_env)
1811 DEALLOCATE (qs_env%ewald_env)
1812 END IF
1813 IF (ASSOCIATED(qs_env%ewald_pw)) THEN
1814 CALL ewald_pw_release(qs_env%ewald_pw)
1815 DEALLOCATE (qs_env%ewald_pw)
1816 END IF
1817 IF (ASSOCIATED(qs_env%image_matrix)) THEN
1818 DEALLOCATE (qs_env%image_matrix)
1819 END IF
1820 IF (ASSOCIATED(qs_env%ipiv)) THEN
1821 DEALLOCATE (qs_env%ipiv)
1822 END IF
1823 IF (ASSOCIATED(qs_env%image_coeff)) THEN
1824 DEALLOCATE (qs_env%image_coeff)
1825 END IF
1826 ! ZMP
1827 IF (ASSOCIATED(qs_env%rho_external)) THEN
1828 CALL qs_rho_release(qs_env%rho_external)
1829 DEALLOCATE (qs_env%rho_external)
1830 END IF
1831 IF (ASSOCIATED(qs_env%external_vxc)) THEN
1832 CALL qs_env%external_vxc%release()
1833 DEALLOCATE (qs_env%external_vxc)
1834 END IF
1835 IF (ASSOCIATED(qs_env%mask)) THEN
1836 CALL qs_env%mask%release()
1837 DEALLOCATE (qs_env%mask)
1838 END IF
1839 IF (ASSOCIATED(qs_env%active_space)) THEN
1840 CALL release_active_space_type(qs_env%active_space)
1841 END IF
1842 ! Embedding potentials if provided as input
1843 IF (qs_env%given_embed_pot) THEN
1844 CALL qs_env%embed_pot%release()
1845 DEALLOCATE (qs_env%embed_pot)
1846 IF (ASSOCIATED(qs_env%spin_embed_pot)) THEN
1847 CALL qs_env%spin_embed_pot%release()
1848 DEALLOCATE (qs_env%spin_embed_pot)
1849 END IF
1850 END IF
1851
1852 ! Polarisability tensor
1853 CALL polar_env_release(qs_env%polar_env)
1854
1855 IF (ASSOCIATED(qs_env%qs_charges)) THEN
1856 CALL qs_charges_release(qs_env%qs_charges)
1857 DEALLOCATE (qs_env%qs_charges)
1858 END IF
1859 CALL qs_ks_part_release(qs_env%ks_env)
1860 IF (ASSOCIATED(qs_env%ks_qmmm_env)) THEN
1861 CALL qs_ks_qmmm_release(qs_env%ks_qmmm_env)
1862 DEALLOCATE (qs_env%ks_qmmm_env)
1863 END IF
1864 CALL wfi_release(qs_env%wf_history)
1865 IF (ASSOCIATED(qs_env%scf_env)) THEN
1866 CALL scf_env_release(qs_env%scf_env)
1867 DEALLOCATE (qs_env%scf_env)
1868 END IF
1869 IF (ASSOCIATED(qs_env%cp_ddapc_env)) THEN
1870 CALL cp_ddapc_release(qs_env%cp_ddapc_env)
1871 DEALLOCATE (qs_env%cp_ddapc_env)
1872 END IF
1873 CALL cp_ddapc_ewald_release(qs_env%cp_ddapc_ewald)
1874 CALL efield_berry_release(qs_env%efield)
1875 IF (ASSOCIATED(qs_env%x_data)) THEN
1876 CALL hfx_release(qs_env%x_data)
1877 END IF
1878 IF (ASSOCIATED(qs_env%et_coupling)) THEN
1879 CALL et_coupling_release(qs_env%et_coupling)
1880 END IF
1881 IF (ASSOCIATED(qs_env%dftb_potential)) THEN
1882 CALL qs_dftb_pairpot_release(qs_env%dftb_potential)
1883 END IF
1884 IF (ASSOCIATED(qs_env%se_taper)) THEN
1885 CALL se_taper_release(qs_env%se_taper)
1886 END IF
1887 IF (ASSOCIATED(qs_env%se_store_int_env)) THEN
1888 CALL semi_empirical_si_release(qs_env%se_store_int_env)
1889 END IF
1890 IF (ASSOCIATED(qs_env%se_nddo_mpole)) THEN
1891 CALL nddo_mpole_release(qs_env%se_nddo_mpole)
1892 END IF
1893 IF (ASSOCIATED(qs_env%se_nonbond_env)) THEN
1894 CALL fist_nonbond_env_release(qs_env%se_nonbond_env)
1895 DEALLOCATE (qs_env%se_nonbond_env)
1896 END IF
1897 IF (ASSOCIATED(qs_env%admm_env)) THEN
1898 CALL admm_env_release(qs_env%admm_env)
1899 END IF
1900 IF (ASSOCIATED(qs_env%lri_env)) THEN
1901 CALL lri_env_release(qs_env%lri_env)
1902 DEALLOCATE (qs_env%lri_env)
1903 END IF
1904 IF (ASSOCIATED(qs_env%lri_density)) THEN
1905 CALL lri_density_release(qs_env%lri_density)
1906 DEALLOCATE (qs_env%lri_density)
1907 END IF
1908 IF (ASSOCIATED(qs_env%harris_env)) THEN
1909 CALL harris_env_release(qs_env%harris_env)
1910 END IF
1911 IF (ASSOCIATED(qs_env%ec_env)) THEN
1912 CALL ec_env_release(qs_env%ec_env)
1913 END IF
1914 IF (ASSOCIATED(qs_env%exstate_env)) THEN
1915 CALL exstate_release(qs_env%exstate_env)
1916 END IF
1917 IF (ASSOCIATED(qs_env%mp2_env)) THEN
1918 CALL mp2_env_release(qs_env%mp2_env)
1919 DEALLOCATE (qs_env%mp2_env)
1920 NULLIFY (qs_env%mp2_env)
1921 END IF
1922 IF (ASSOCIATED(qs_env%kg_env)) THEN
1923 CALL kg_env_release(qs_env%kg_env)
1924 END IF
1925
1926 ! dispersion
1927 CALL qs_dispersion_release(qs_env%dispersion_env)
1928 ! gCP
1929 IF (ASSOCIATED(qs_env%gcp_env)) THEN
1930 CALL qs_gcp_release(qs_env%gcp_env)
1931 END IF
1932
1933 IF (ASSOCIATED(qs_env%WannierCentres)) THEN
1934 DO i = 1, SIZE(qs_env%WannierCentres)
1935 DEALLOCATE (qs_env%WannierCentres(i)%WannierHamDiag)
1936 DEALLOCATE (qs_env%WannierCentres(i)%centres)
1937 END DO
1938 DEALLOCATE (qs_env%WannierCentres)
1939 END IF
1940 ! EEQ charges
1941 IF (ASSOCIATED(qs_env%eeq)) DEALLOCATE (qs_env%eeq)
1942 ! Resp charges
1943 IF (ASSOCIATED(qs_env%rhs)) DEALLOCATE (qs_env%rhs)
1944
1945 ! tblite
1946 IF (ASSOCIATED(qs_env%tb_tblite)) THEN
1947 CALL deallocate_tblite_type(qs_env%tb_tblite)
1948 END IF
1949
1950 IF (ASSOCIATED(qs_env%gauxc_cache)) THEN
1951 CALL gauxc_cache_release(qs_env%gauxc_cache)
1952 DEALLOCATE (qs_env%gauxc_cache)
1953 END IF
1954
1955 CALL release_native_grid_cache(qs_env%native_grid_cache)
1956
1957 END SUBROUTINE qs_env_part_release
1958
1959END MODULE qs_environment_types
Types and set/get functions for auxiliary density matrix methods.
Definition admm_types.F:15
subroutine, public admm_env_release(admm_env)
releases the ADMM environment, cleans up all types
Definition admm_types.F:430
Types for all ALMO-based methods.
subroutine, public almo_scf_env_release(almo_scf_env)
release the almo scf envirnoment
Define the atomic kind types and their sub types.
Holds information on atomic properties.
Handles all functions related to the CELL.
Definition cell_types.F:15
subroutine, public cell_release(cell)
releases the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:704
subroutine, public cell_retain(cell)
retains the given cell (see doc/ReferenceCounting.html)
Definition cell_types.F:687
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_release_p(matrix)
...
contains information regarding the decoupling/recoupling method of Bloechl
subroutine, public cp_ddapc_release(cp_ddapc_env)
...
subroutine, public cp_ddapc_ewald_release(cp_ddapc_ewald)
...
represent a full matrix distributed on many processors
Definition cp_fm_types.F:15
set of type/routines to handle the storage of results in force_envs
types that represent a subsys, i.e. a part of the system
stores a lists of integer that are local to a processor. The idea is that these integers represent ob...
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
Types needed for a linear scaling quickstep SCF run based on the density matrix.
subroutine, public ls_scf_release(ls_scf_env)
release the LS type.
Types needed for a for a Energy Correction.
subroutine, public ec_env_release(ec_env)
...
Definition and initialisation of the et_coupling data type.
subroutine, public et_coupling_release(et_coupling)
...
calculates the electron transfer coupling elements Wu, Van Voorhis, JCP 125, 164105 (2006)
Definition et_coupling.F:13
subroutine, public ewald_env_release(ewald_env)
releases the given ewald_env (see doc/ReferenceCounting.html)
subroutine, public ewald_pw_release(ewald_pw)
releases the memory used by the ewald_pw
Types for excited states potential energies.
subroutine, public exstate_release(ex_env)
...
subroutine, public fist_nonbond_env_release(fist_nonbond_env)
releases the given fist_nonbond_env (see doc/ReferenceCounting.html)
Define type storing the global information of a run. Keep the amount of stored data small....
subroutine, public get_hartree_local(hartree_local, ecoul_1c)
...
subroutine, public set_hartree_local(hartree_local, ecoul_1c)
...
subroutine, public hartree_local_release(hartree_local)
...
subroutine, public hartree_local_create(hartree_local)
...
Types and set/get functions for HFX.
Definition hfx_types.F:16
subroutine, public hfx_release(x_data)
This routine deallocates all data structures
Definition hfx_types.F:1863
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public energy_run
integer, parameter, public energy_force_run
objects that represent the structure of input sections and the data contained in an input section
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
recursive subroutine, public section_vals_release(section_vals)
releases the given object
Types needed for a Kim-Gordon-like partitioning into molecular subunits.
subroutine, public kg_env_release(kg_env)
...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Types and basic routines needed for a kpoint calculation.
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
subroutine, public lri_density_release(lri_density)
releases the given lri_density
subroutine, public lri_env_release(lri_env)
releases the given lri_env
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
Types needed for MP2 calculations.
Definition mp2_types.F:14
subroutine, public mp2_env_release(mp2_env)
...
Definition mp2_types.F:411
Types used to generate the molecular SCF guess.
Definition mscfg_types.F:14
subroutine, public molecular_scf_guess_env_destroy(env)
Destroyes both data and environment.
Definition mscfg_types.F:94
Define the data structure for the particle information.
subroutine, public bs_env_release(bs_env)
...
container for various plainwaves related things
The types needed for the calculation of active space Hamiltonians.
subroutine, public release_active_space_type(active_space_env)
Releases all quantities in the active space environment.
container for information about total charges on the grids
subroutine, public qs_charges_release(qs_charges)
releases the charges object (see cp2k/doc/ReferenceCounting.html)
Types used by CNEO-DFT (see J. Chem. Theory Comput. 2025, 21, 16, 7865–7877).
Definition of the DFTB parameter types.
subroutine, public qs_dftb_pairpot_release(pairpot)
...
Definition of disperson types for DFT calculations.
subroutine, public qs_dispersion_release(dispersion_env)
...
subroutine, public qs_env_release(qs_env)
releases the given qs_env (see doc/ReferenceCounting.html)
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, matrix_metric, matrix_metric_kp)
Get the QUICKSTEP environment.
subroutine, public qs_env_part_release(qs_env)
releases part of the given qs_env in order to save memory
subroutine, public qs_env_create(qs_env, globenv)
allocates and intitializes a qs_env
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Definition of gCP types for DFT calculations.
subroutine, public qs_gcp_release(gcp_env)
...
Types needed for a for a Harris model calculation.
subroutine, public harris_env_release(harris_env)
...
Define the quickstep kind type and their sub types.
subroutine, public qs_ks_qmmm_release(ks_qmmm_env)
releases the ks_qmmm_env (see doc/ReferenceCounting.html)
subroutine, public qs_ks_release(ks_env)
releases the ks_env (see doc/ReferenceCounting.html)
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, uspp, upf_inverse)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin, uspp, matrix_metric, matrix_metric_kp, upf_inverse)
...
subroutine, public qs_ks_part_release(ks_env)
releases part of the ks_env
Type definitiona for linear response calculations.
subroutine, public polar_env_release(polar_env)
Deallocate the polar environment.
subroutine, public linres_control_release(linres_control)
...
subroutine, public local_rho_set_create(local_rho_set)
...
subroutine, public get_local_rho(local_rho_set, rho_atom_set, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set)
...
subroutine, public local_rho_set_release(local_rho_set)
...
subroutine, public set_local_rho(local_rho_set, rho_atom_set, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set)
...
wrapper for the pools of matrixes
subroutine, public mpools_release(mpools)
releases the given mpools
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.
Bounded geometry-only cache for native atom-grid interpolation.
subroutine, public release_native_grid_cache(cache)
Release geometry storage, including when the QS environment is only partly released.
Define the neighbor list data types and the corresponding functionality.
subroutine, public deallocate_oce_set(oce_set)
Deallocate the matrix set of oce coefficients.
type for berry phase efield matrices. At the moment only used for cosmat and sinmat
subroutine, public efield_berry_release(efield)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_release(rho_struct)
releases a rho_struct by decreasing the reference count by one and deallocating if it reaches 0 (to b...
module that contains the definitions of the scf types
subroutine, public scf_env_release(scf_env)
releases an scf_env (see doc/ReferenceCounting.html)
types that represent a quickstep subsys
subroutine, public qs_subsys_set(subsys, cp_subsys, local_particles, local_molecules, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, nelectron_total, nelectron_spin)
...
interpolate the wavefunctions to speed up the convergence when doing MD
subroutine, public wfi_retain(wf_history)
retains a wf history (see doc/ReferenceCounting.html)
subroutine, public wfi_release(wf_history)
releases a wf_history of a wavefunction (see doc/ReferenceCounting.html)
parameters that control a relativistic calculation
subroutine, public rel_c_release(rel_control)
releases the given rel_control (see cp2k/doc/ReferenceCounting.html)
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public rt_prop_release(rtp)
...
parameters that control an scf iteration
subroutine, public scf_c_release(scf_control)
releases the given scf_control (see cp2k/doc/ReferenceCounting.html)
Definition of the semi empirical multipole integral expansions types.
subroutine, public nddo_mpole_release(nddo_mpole)
Deallocate NDDO multipole type.
Type to store integrals for semi-empirical calculations.
subroutine, public semi_empirical_si_release(store_int_env)
Deallocate the semi-empirical store integrals type.
Definition of the semi empirical parameter types.
subroutine, public se_taper_release(se_taper)
Releases the taper type used in SE calculations.
types for task lists
types for tblite
subroutine, public deallocate_tblite_type(tb_tblite)
...
CP2K transport environment and related C-interoperable types.
subroutine, public transport_env_release(transport_env)
releases the transport_env
defines the type needed for computing wannier states expectations
define create destroy get and put information in xas_env to calculate the x-ray absorption spectra
subroutine, public xas_env_release(xas_env)
...
subroutine, public gauxc_cache_release(cache)
Release all GauXC objects in a cache and deallocate arrays.
stores some data used in wavefunction fitting
Definition admm_types.F:121
Provides all information about an atomic kind.
type for the atomic properties
Type defining parameters related to the simulation cell.
Definition cell_types.F:60
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
represent a full matrix
contains arbitrary information which need to be stored
represents a system: atoms, molecules, their pos,vel,...
structure to store local (to a processor) ordered lists of integers.
distributes pairs on a 2d grid of processors
Contains information on the energy correction functional for KG.
Contains information on the excited states energy.
contains the initially parsed file and the initial parallel environment
stores some data used in construction of Kohn-Sham matrix
Definition hfx_types.F:473
Contains all the info needed for KG runs...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
contained for different pw related things
Container for information about total charges on the grids.
Contains information on the Harris method.
Provides all information about a quickstep kind.
calculation environment to calculate the ks_qmmm matrix, holds the QM/MM potential and all the needed...
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
General settings for linear response calculations.
container for the pools of matrixes used by qs
keeps the density in various representations, keeping track of which ones are valid.
keeps track of the previous wavefunctions and can extrapolate them for the next step of md
contains the parameters needed by a relativistic calculation
Global Multipolar NDDO information type.
Taper type use in semi-empirical calculations.