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