56 LOGICAL,
INTENT(in) :: calculate_forces, just_energy
58 POINTER :: ext_ks_matrix
60 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tblite_ks_matrix'
62 INTEGER :: handle, img, ispin, nimg, ns, nspins
64 REAL(kind=
dp) :: pc_ener, qmmm_el
65 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p1, mo_derivs
66 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_matrix, matrix_h
74 CALL timeset(routinen, handle)
76 NULLIFY (dft_control, ks_env, ks_matrix, rho, energy)
77 cpassert(
ASSOCIATED(qs_env))
80 dft_control=dft_control, &
81 matrix_h_kp=matrix_h, &
84 matrix_ks_kp=ks_matrix, &
88 IF (
PRESENT(ext_ks_matrix))
THEN
91 ns =
SIZE(ext_ks_matrix)
92 ks_matrix(1:ns, 1:1) => ext_ks_matrix(1:ns)
95 energy%qmmm_el = 0.0_dp
97 nspins = dft_control%nspins
98 nimg = dft_control%nimages
99 cpassert(
ASSOCIATED(matrix_h))
100 cpassert(
ASSOCIATED(rho))
101 cpassert(
SIZE(ks_matrix) > 0)
106 CALL dbcsr_copy(ks_matrix(ispin, img)%matrix, matrix_h(1, img)%matrix)
110 IF (dft_control%apply_period_efield .OR. dft_control%apply_efield .OR. &
111 dft_control%apply_efield_field)
THEN
113 cpabort(
"Not implemented yet. Use CP2K routines for GFN1")
118 CALL tb_update_charges(qs_env, dft_control, qs_env%tb_tblite, calculate_forces, .true.)
122 IF (qs_env%qmmm)
THEN
123 cpassert(
SIZE(ks_matrix, 2) == 1)
126 CALL dbcsr_add(ks_matrix(ispin, 1)%matrix, qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
130 CALL dbcsr_dot(qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
131 matrix_p1(ispin)%matrix, qmmm_el)
132 energy%qmmm_el = energy%qmmm_el + qmmm_el
134 pc_ener = qs_env%ks_qmmm_env%pc_ener
135 energy%qmmm_el = energy%qmmm_el + pc_ener
139 IF (qs_env%requires_mo_derivs .AND. .NOT. just_energy)
THEN
140 cpassert(
SIZE(ks_matrix, 2) == 1)
142 TYPE(
mo_set_type),
DIMENSION(:),
POINTER :: mo_array
143 CALL get_qs_env(qs_env, mo_derivs=mo_derivs, mos=mo_array)
144 DO ispin = 1,
SIZE(mo_derivs)
145 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff_b=mo_coeff)
146 IF (.NOT. mo_array(ispin)%use_mo_coeff_b)
THEN
149 CALL dbcsr_multiply(
'n',
'n', 1.0_dp, ks_matrix(ispin, 1)%matrix, mo_coeff, &
150 0.0_dp, mo_derivs(ispin)%matrix)
155 CALL timestop(handle)
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_pp, 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, 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, tb_tblite)
Get the QUICKSTEP environment.