22 USE dbcsr_api,
ONLY: dbcsr_copy,&
60 #include "./base/base_uses.f90"
68 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_basis_gradient'
85 TYPE(qs_environment_type),
POINTER :: qs_env
87 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_basis_center_gradient'
89 INTEGER :: handle, i, iatom, ikind, img, ispin, &
90 natom, nimg, nkind, nspin
91 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atom_of_kind, kind_of, natom_of_kind
92 LOGICAL :: floating, has_unit_metric
93 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: gradient
94 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
95 TYPE(cp_logger_type),
POINTER :: logger
96 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s, matrix_w_kp
97 TYPE(dbcsr_type),
POINTER :: matrix
98 TYPE(dft_control_type),
POINTER :: dft_control
99 TYPE(mp_para_env_type),
POINTER :: para_env
100 TYPE(qs_force_type),
DIMENSION(:),
POINTER :: basis_force, force,
qs_force
101 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
102 TYPE(qs_ks_env_type),
POINTER :: ks_env
103 TYPE(qs_scf_env_type),
POINTER :: scf_env
104 TYPE(qs_subsys_type),
POINTER :: subsys
106 CALL timeset(routinen, handle)
111 CALL get_qs_env(qs_env, scf_env=scf_env, natom=natom)
112 IF (
ASSOCIATED(scf_env%floating_basis%gradient))
THEN
113 gradient => scf_env%floating_basis%gradient
114 cpassert(
SIZE(gradient) == 3*natom)
116 ALLOCATE (gradient(3, natom))
117 scf_env%floating_basis%gradient => gradient
122 CALL get_qs_env(qs_env, force=force, subsys=subsys, atomic_kind_set=atomic_kind_set)
123 IF (
ASSOCIATED(force))
THEN
129 nkind =
SIZE(atomic_kind_set)
130 ALLOCATE (natom_of_kind(nkind))
133 DEALLOCATE (natom_of_kind)
138 ALLOCATE (atom_of_kind(natom), kind_of(natom))
139 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, atom_of_kind=atom_of_kind, kind_of=kind_of)
142 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
143 IF (.NOT. has_unit_metric)
THEN
144 CALL get_qs_env(qs_env, matrix_w_kp=matrix_w_kp)
145 IF (.NOT.
ASSOCIATED(matrix_w_kp))
THEN
146 NULLIFY (matrix_w_kp)
147 CALL get_qs_env(qs_env, ks_env=ks_env, matrix_s_kp=matrix_s, dft_control=dft_control)
148 nspin = dft_control%nspins
149 nimg = dft_control%nimages
150 matrix => matrix_s(1, 1)%matrix
154 ALLOCATE (matrix_w_kp(ispin, img)%matrix)
155 CALL dbcsr_copy(matrix_w_kp(ispin, img)%matrix, matrix, name=
"W MATRIX")
156 CALL dbcsr_set(matrix_w_kp(ispin, img)%matrix, 0.0_dp)
159 CALL set_ks_env(ks_env, matrix_w_kp=matrix_w_kp)
172 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
174 ikind = kind_of(iatom)
175 i = atom_of_kind(iatom)
176 CALL get_qs_kind(qs_kind_set(ikind), floating=floating)
177 IF (floating) gradient(1:3, iatom) = -basis_force(ikind)%total(1:3, i)
183 CALL set_ks_env(ks_env, forces_up_to_date=.false.)
185 DEALLOCATE (atom_of_kind, kind_of)
187 CALL timestop(handle)
199 TYPE(qs_environment_type),
POINTER :: qs_env
200 REAL(kind=
dp) :: norm
202 INTEGER :: iatom, ikind, natom, nfloat
204 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: gradient
205 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
206 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
207 TYPE(qs_scf_env_type),
POINTER :: scf_env
210 CALL get_qs_env(qs_env, scf_env=scf_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
211 gradient => scf_env%floating_basis%gradient
212 natom =
SIZE(particle_set)
215 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
216 CALL get_qs_kind(qs_kind_set(ikind), floating=floating)
219 norm = norm + sum(abs(gradient(1:3, iatom)))
223 norm = norm/(3.0_dp*real(nfloat, kind=
dp))
234 TYPE(qs_environment_type),
POINTER :: qs_env
236 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_update_basis_center_pos'
238 INTEGER :: handle, iatom, ikind, natom
240 REAL(kind=
dp) :: alpha
241 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: gradient
242 TYPE(cp_logger_type),
POINTER :: logger
243 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
244 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
245 TYPE(qs_scf_env_type),
POINTER :: scf_env
247 CALL timeset(routinen, handle)
252 CALL get_qs_env(qs_env, scf_env=scf_env, particle_set=particle_set, qs_kind_set=qs_kind_set)
253 gradient => scf_env%floating_basis%gradient
254 natom =
SIZE(particle_set)
257 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
258 CALL get_qs_kind(qs_kind_set(ikind), floating=floating)
260 particle_set(iatom)%r(1:3) = particle_set(iatom)%r(1:3) + alpha*gradient(1:3, iatom)
264 CALL qs_basis_reinit_energy(qs_env)
266 CALL timestop(handle)
277 SUBROUTINE qs_basis_reinit_energy(qs_env)
278 TYPE(qs_environment_type),
POINTER :: qs_env
280 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_basis_reinit_energy'
282 INTEGER :: handle, ispin, nmo
283 LOGICAL :: ks_is_complex
284 TYPE(cp_fm_type),
POINTER :: mo_coeff
285 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, rho_ao_kp
286 TYPE(dft_control_type),
POINTER :: dft_control
287 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
288 TYPE(mp_para_env_type),
POINTER :: para_env
289 TYPE(qs_ks_env_type),
POINTER :: ks_env
290 TYPE(qs_rho_type),
POINTER :: rho
291 TYPE(qs_scf_env_type),
POINTER :: scf_env
292 TYPE(section_vals_type),
POINTER :: input
294 CALL timeset(routinen, handle)
296 NULLIFY (input, para_env, ks_env)
298 CALL get_qs_env(qs_env, input=input, para_env=para_env, ks_env=ks_env)
300 force_env_section=input)
306 CALL get_ks_env(ks_env, complex_ks=ks_is_complex)
310 CALL get_qs_env(qs_env, scf_env=scf_env, dft_control=dft_control)
311 IF (scf_env%mixing_method > 0)
THEN
312 CALL mixing_allocate(qs_env, scf_env%mixing_method, scf_env%p_mix_new, &
313 scf_env%p_delta, dft_control%nspins, &
314 scf_env%mixing_store)
316 NULLIFY (scf_env%p_mix_new)
318 CALL get_qs_env(qs_env, mos=mos, rho=rho, matrix_s_kp=matrix_s_kp)
320 DO ispin = 1,
SIZE(mos)
321 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
325 CALL calculate_density_matrix(mos(ispin), rho_ao_kp(ispin, 1)%matrix)
327 CALL qs_rho_set(rho, rho_r_valid=.false., drho_r_valid=.false., rho_g_valid=.false., &
328 drho_g_valid=.false., tau_r_valid=.false., tau_g_valid=.false.)
331 CALL timestop(handle)
333 END SUBROUTINE qs_basis_reinit_energy
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
represent a full matrix distributed on many processors
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
Define the data structure for the particle information.
subroutine, public qs_basis_center_gradient(qs_env)
...
real(kind=dp) function, public return_basis_center_gradient_norm(qs_env)
... returns the norm of the gradient vector, taking only floating components into account
subroutine, public qs_update_basis_center_pos(qs_env)
move atoms with kind float according to gradient
Calculation of the core Hamiltonian integral matrix <a|H|b> over Cartesian Gaussian-type functions.
subroutine, public build_core_hamiltonian_matrix(qs_env, calculate_forces)
Cosntruction of the QS Core Hamiltonian Matrix.
collects routines that calculate density matrices
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_compute_w(qs_env, calc_forces)
Refactoring of qs_energies_scf. Moves computation of matrix_w into separate subroutine.
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
subroutine, public replicate_qs_force(qs_force, para_env)
Replicate and sum up the force.
subroutine, public deallocate_qs_force(qs_force)
Deallocate a Quickstep force data structure.
subroutine, public zero_qs_force(qs_force)
Initialize a Quickstep force data structure.
subroutine, public allocate_qs_force(qs_force, natom_of_kind)
Allocate a Quickstep force data structure.
Quickstep force driver routine.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_r3d_rs_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, U_of_dft_plus_u, J_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, J0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, floating, name, element_symbol, pao_basis_size, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public qs_ks_allocate_basics(qs_env, is_complex)
Allocate ks_matrix if necessary, take current overlap matrix as template.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, 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, 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_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, 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)
...
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, 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, 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_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public mixing_allocate(qs_env, mixing_method, p_mix_new, p_delta, nspins, mixing_store)
allocation needed when density mixing is used
collects routines that perform operations directly related to MOs
subroutine, public make_basis_sm(vmatrix, ncol, matrix_s)
returns an S-orthonormal basis v (v^T S v ==1)
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kTS, mu, flexible_electron_count)
Get the components of a MO set data structure.
Generate the atomic neighbor lists.
subroutine, public build_qs_neighbor_lists(qs_env, para_env, molecular, force_env_section)
Build all the required neighbor lists for Quickstep.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
module that contains the definitions of the scf types
types that represent a quickstep subsys
subroutine, public qs_subsys_set(subsys, cp_subsys, local_particles, local_molecules, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, nelectron_total, nelectron_spin)
...
qs_environment methods that use many other modules
subroutine, public qs_env_update_s_mstruct(qs_env)
updates the s_mstruct to reflect the new overlap structure, and also updates rho_core distribution....