58 LOGICAL,
INTENT(in) :: calculate_forces, just_energy
60 POINTER :: ext_ks_matrix
62 CHARACTER(len=*),
PARAMETER :: routinen =
'build_tblite_ks_matrix'
64 INTEGER :: handle, img, ispin, nimg, ns, nspins
66 REAL(kind=
dp) :: pc_ener, qmmm_el
67 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p1, mo_derivs
68 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: ks_matrix, matrix_h
76 CALL timeset(routinen, handle)
78 NULLIFY (dft_control, ks_env, ks_matrix, rho, energy)
79 cpassert(
ASSOCIATED(qs_env))
82 dft_control=dft_control, &
83 matrix_h_kp=matrix_h, &
86 matrix_ks_kp=ks_matrix, &
90 IF (
PRESENT(ext_ks_matrix))
THEN
93 ns =
SIZE(ext_ks_matrix)
94 ks_matrix(1:ns, 1:1) => ext_ks_matrix(1:ns)
97 energy%qmmm_el = 0.0_dp
99 nspins = dft_control%nspins
100 nimg = dft_control%nimages
101 cpassert(
ASSOCIATED(matrix_h))
102 cpassert(
ASSOCIATED(rho))
103 cpassert(
SIZE(ks_matrix) > 0)
108 CALL dbcsr_copy(ks_matrix(ispin, img)%matrix, matrix_h(1, img)%matrix)
112 IF (dft_control%apply_period_efield .OR. dft_control%apply_efield .OR. &
113 dft_control%apply_efield_field)
THEN
115 cpabort(
"Not implemented yet. Use CP2K routines for GFN1")
120 CALL tb_update_charges(qs_env, dft_control, qs_env%tb_tblite, calculate_forces, .true.)
124 IF (qs_env%qmmm)
THEN
125 cpassert(
SIZE(ks_matrix, 2) == 1)
128 CALL dbcsr_add(ks_matrix(ispin, 1)%matrix, qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
132 CALL dbcsr_dot(qs_env%ks_qmmm_env%matrix_h(1)%matrix, &
133 matrix_p1(ispin)%matrix, qmmm_el)
134 energy%qmmm_el = energy%qmmm_el + qmmm_el
136 pc_ener = qs_env%ks_qmmm_env%pc_ener
137 energy%qmmm_el = energy%qmmm_el + pc_ener
140 IF (calculate_forces)
THEN
146 IF (qs_env%requires_mo_derivs .AND. .NOT. just_energy)
THEN
147 cpassert(
SIZE(ks_matrix, 2) == 1)
149 TYPE(
mo_set_type),
DIMENSION(:),
POINTER :: mo_array
150 CALL get_qs_env(qs_env, mo_derivs=mo_derivs, mos=mo_array)
151 DO ispin = 1,
SIZE(mo_derivs)
152 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff_b=mo_coeff)
153 IF (.NOT. mo_array(ispin)%use_mo_coeff_b)
THEN
156 CALL dbcsr_multiply(
'n',
'n', 1.0_dp, ks_matrix(ispin, 1)%matrix, mo_coeff, &
157 0.0_dp, mo_derivs(ispin)%matrix)
162 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, do_rixs, tb_tblite)
Get the QUICKSTEP environment.