57#include "./base/base_uses.f90"
62 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
63 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_environment_methods'
86 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_env_setup'
88 INTEGER :: handle, nhistory, nvariables
89 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: gradient_history, outer_scf_history, &
102 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
106 CALL timeset(routinen, handle)
108 NULLIFY (qs_kind_set, atomic_kind_set, dft_control, scf_control, qs_charges, para_env, &
109 distribution_2d, molecule_kind_set, molecule_set, particle_set, cell, &
113 qs_kind_set=qs_kind_set, &
114 atomic_kind_set=atomic_kind_set, &
115 dft_control=dft_control, &
116 molecule_kind_set=molecule_kind_set, &
117 molecule_set=molecule_set, &
118 particle_set=particle_set, &
119 scf_control=scf_control, &
121 blacs_env=blacs_env, &
125 cpassert(
ASSOCIATED(qs_kind_set))
126 cpassert(
ASSOCIATED(atomic_kind_set))
127 cpassert(
ASSOCIATED(dft_control))
128 cpassert(
ASSOCIATED(scf_control))
130 ALLOCATE (qs_charges)
132 CALL set_qs_env(qs_env, qs_charges=qs_charges)
135 IF (scf_control%outer_scf%have_scf)
THEN
137 nhistory = scf_control%outer_scf%extrapolation_order
138 ALLOCATE (outer_scf_history(nvariables, nhistory))
139 ALLOCATE (gradient_history(nvariables, 2))
140 gradient_history = 0.0_dp
141 ALLOCATE (variable_history(nvariables, 2))
142 variable_history = 0.0_dp
143 CALL set_qs_env(qs_env, outer_scf_history=outer_scf_history, &
144 gradient_history=gradient_history, &
145 variable_history=variable_history)
155 IF (
ASSOCIATED(qs_env%mos))
THEN
157 blacs_env=blacs_env, para_env=para_env)
163 atomic_kind_set=atomic_kind_set, &
164 qs_kind_set=qs_kind_set, &
165 particle_set=particle_set, &
166 molecule_kind_set=molecule_kind_set, &
167 molecule_set=molecule_set, &
168 distribution_2d=distribution_2d, &
169 blacs_env=blacs_env, &
170 force_env_section=qs_env%input)
173 ALLOCATE (dbcsr_dist)
175 CALL set_ks_env(ks_env, dbcsr_dist=dbcsr_dist)
178 CALL set_ks_env(ks_env, distribution_2d=distribution_2d)
181 CALL timestop(handle)
195 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_env_rebuild_pw_env'
206 TYPE(
pw_r3d_rs_type),
POINTER :: embed_pot, external_vxc, rho_nlcc, &
207 spin_embed_pot, v_hartree_rspace, vee, &
209 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
213 CALL timeset(routinen, handle)
215 NULLIFY (dft_control, cell, ks_env, v_hartree_rspace, auxbas_pw_pool)
217 NULLIFY (ewald_env, ewald_pw, new_pw_env, external_vxc, rho_core, rho_nlcc, rho_nlcc_g, vee, vppl, &
218 embed_pot, spin_embed_pot, xcint_weights)
220 CALL get_qs_env(qs_env, ks_env=ks_env, pw_env=new_pw_env)
221 IF (.NOT.
ASSOCIATED(new_pw_env))
THEN
227 CALL get_qs_env(qs_env, pw_env=new_pw_env, dft_control=dft_control, &
230 IF (any(new_pw_env%cell_hmat /= cell%hmat))
THEN
232 new_pw_env%cell_hmat = cell%hmat
236 CALL get_qs_env(qs_env, pw_env=new_pw_env, rho_core=rho_core)
237 cpassert(
ASSOCIATED(new_pw_env))
238 IF (dft_control%qs_control%gapw)
THEN
239 IF (
ASSOCIATED(rho_core))
THEN
240 CALL rho_core%release()
241 DEALLOCATE (rho_core)
243 IF (dft_control%qs_control%gapw_control%nopaw_as_gpw)
THEN
245 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
246 CALL auxbas_pw_pool%create_pw(rho_core)
249 CALL get_qs_env(qs_env=qs_env, rho0_mpole=rho0_mpole)
251 ELSE IF (dft_control%qs_control%semi_empirical)
THEN
252 IF (dft_control%qs_control%se_control%do_ewald .OR. &
253 dft_control%qs_control%se_control%do_ewald_gks)
THEN
255 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw)
258 ELSE IF (dft_control%qs_control%dftb)
THEN
259 IF (dft_control%qs_control%dftb_control%do_ewald)
THEN
261 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw)
264 ELSE IF (dft_control%qs_control%xtb .AND. &
265 (.NOT. dft_control%qs_control%xtb_control%do_tblite))
THEN
266 IF (dft_control%qs_control%xtb_control%do_ewald)
THEN
268 CALL get_qs_env(qs_env=qs_env, ewald_env=ewald_env, ewald_pw=ewald_pw)
272 IF (
ASSOCIATED(rho_core))
THEN
273 CALL rho_core%release()
274 DEALLOCATE (rho_core)
277 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
278 CALL auxbas_pw_pool%create_pw(rho_core)
283 IF (dft_control%qs_control%do_ppl_method ==
do_ppl_grid)
THEN
285 CALL get_qs_env(qs_env, pw_env=new_pw_env, vppl=vppl)
286 IF (
ASSOCIATED(vppl))
THEN
291 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
292 CALL auxbas_pw_pool%create_pw(vppl)
297 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set)
302 CALL get_qs_env(qs_env, pw_env=new_pw_env, rho_nlcc=rho_nlcc)
303 IF (
ASSOCIATED(rho_nlcc))
THEN
304 CALL rho_nlcc%release()
308 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
309 CALL auxbas_pw_pool%create_pw(rho_nlcc)
313 CALL get_qs_env(qs_env, pw_env=new_pw_env, rho_nlcc_g=rho_nlcc_g)
314 IF (
ASSOCIATED(rho_nlcc_g))
THEN
315 CALL rho_nlcc_g%release()
317 ALLOCATE (rho_nlcc_g)
319 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
320 CALL auxbas_pw_pool%create_pw(rho_nlcc_g)
321 CALL set_ks_env(ks_env, rho_nlcc_g=rho_nlcc_g)
325 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc)
THEN
326 IF (dft_control%qs_control%gapw_control%accurate_xcint)
THEN
328 NULLIFY (xcint_weights)
329 CALL get_qs_env(qs_env, pw_env=new_pw_env, xcint_weights=xcint_weights)
330 IF (
ASSOCIATED(xcint_weights))
THEN
331 CALL xcint_weights%release()
333 ALLOCATE (xcint_weights)
335 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
336 CALL auxbas_pw_pool%create_pw(xcint_weights)
337 CALL set_ks_env(ks_env, xcint_weights=xcint_weights)
342 IF (dft_control%apply_external_potential .AND. .NOT. qs_env%mimic)
THEN
344 CALL get_qs_env(qs_env, pw_env=new_pw_env, vee=vee)
345 IF (
ASSOCIATED(vee))
THEN
350 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
351 CALL auxbas_pw_pool%create_pw(vee)
353 dft_control%eval_external_potential = .true.
357 IF (dft_control%apply_external_vxc)
THEN
358 NULLIFY (external_vxc)
359 CALL get_qs_env(qs_env, pw_env=new_pw_env, external_vxc=external_vxc)
360 IF (
ASSOCIATED(external_vxc))
THEN
361 CALL external_vxc%release()
363 ALLOCATE (external_vxc)
365 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
366 CALL auxbas_pw_pool%create_pw(external_vxc)
367 CALL set_qs_env(qs_env, external_vxc=external_vxc)
368 dft_control%read_external_vxc = .true.
372 IF (dft_control%apply_embed_pot)
THEN
374 CALL get_qs_env(qs_env, pw_env=new_pw_env, embed_pot=embed_pot)
375 IF (
ASSOCIATED(embed_pot))
THEN
376 CALL embed_pot%release()
380 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
381 CALL auxbas_pw_pool%create_pw(embed_pot)
384 NULLIFY (spin_embed_pot)
385 CALL get_qs_env(qs_env, pw_env=new_pw_env, spin_embed_pot=spin_embed_pot)
386 IF (
ASSOCIATED(spin_embed_pot))
THEN
387 CALL spin_embed_pot%release()
388 DEALLOCATE (spin_embed_pot)
390 ALLOCATE (spin_embed_pot)
392 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
393 CALL auxbas_pw_pool%create_pw(spin_embed_pot)
394 CALL set_qs_env(qs_env, spin_embed_pot=spin_embed_pot)
397 CALL get_ks_env(ks_env, v_hartree_rspace=v_hartree_rspace)
398 IF (
ASSOCIATED(v_hartree_rspace))
THEN
399 CALL v_hartree_rspace%release()
400 DEALLOCATE (v_hartree_rspace)
403 CALL pw_env_get(new_pw_env, auxbas_pw_pool=auxbas_pw_pool)
404 ALLOCATE (v_hartree_rspace)
405 CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
406 CALL set_ks_env(ks_env, v_hartree_rspace=v_hartree_rspace)
410 new_pw_env%poisson_env%parameters%dbc_params%time = qs_env%sim_time
412 CALL timestop(handle)
424 REAL(kind=
dp),
INTENT(IN) :: time
425 INTEGER,
INTENT(IN) :: itimes
429 qs_env%sim_time = time
430 qs_env%sim_step = itimes
432 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
434 IF (dft_control%apply_external_potential)
THEN
435 IF (.NOT. dft_control%expot_control%static)
THEN
436 dft_control%eval_external_potential = .true.
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_dist2d_to_dist(dist2d, dist)
Creates a DBCSR distribution from a distribution_2d.
stores a mapping of 2D info (e.g. matrix) on a 2D processor distribution (i.e. blacs grid) where cpus...
subroutine, public distribution_2d_release(distribution_2d)
...
Distribution methods for atoms, particles, or molecules.
subroutine, public distribute_molecules_2d(cell, atomic_kind_set, particle_set, qs_kind_set, molecule_kind_set, molecule_set, distribution_2d, blacs_env, force_env_section)
Distributes the particle pairs creating a 2d distribution optimally suited for quickstep.
subroutine, public ewald_pw_grid_update(ewald_pw, ewald_env, cell_hmat)
Rescales pw_grids for given box, if necessary.
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Define the molecule kind structure types and the corresponding functionality.
Define the data structure for the molecule information.
Define the data structure for the particle information.
methods of pw_env that have dependence on qs_env
subroutine, public pw_env_rebuild(pw_env, qs_env, external_para_env)
rebuilds the pw_env data (necessary if cell or cutoffs change)
subroutine, public pw_env_create(pw_env)
creates a pw_env, if qs_env is given calls pw_env_rebuild
container for various plainwaves related things
subroutine, public pw_env_release(pw_env, para_env)
releases the given pw_env (see doc/ReferenceCounting.html)
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
container for information about total charges on the grids
subroutine, public qs_charges_create(qs_charges, nspins, total_rho_core_rspace, total_rho_gspace)
creates a charges object
qs_environment methods that use many other modules
subroutine, public qs_env_time_update(qs_env, time, itimes)
...
subroutine, public qs_env_setup(qs_env)
initializes various components of the qs_env, that need only atomic_kind_set, cell,...
subroutine, public qs_env_rebuild_pw_env(qs_env)
rebuilds the pw_env in the given qs_env, allocating it if necessary
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
wrapper for the pools of matrixes
subroutine, public mpools_rebuild_fm_pools(mpools, mos, blacs_env, para_env, nmosub)
rebuilds the pools of the (ao x mo, ao x ao , mo x mo) full matrixes
Routines for performing an outer scf loop.
integer function, public outer_loop_variables_count(scf_control, cdft_control)
returns the number of variables that is employed in the outer loop. with a CDFT constraint this value...
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
parameters that control an scf iteration
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
distributes pairs on a 2d grid of processors
to build arrays of pointers
stores all the informations relevant to an mpi environment
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Container for information about total charges on the grids.
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...