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