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