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