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