58#include "./base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_matrix_w'
84 LOGICAL,
INTENT(IN) :: calc_forces
85 LOGICAL,
INTENT(IN),
OPTIONAL :: include_lowdin_forces
87 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_matrix_w'
89 INTEGER :: handle, is, ispin, nao, nspin
90 LOGICAL :: do_kpoints, has_unit_metric
91 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s, matrix_w, &
99 CALL timeset(routinen, handle)
102 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
104 IF (calc_forces .AND. .NOT. has_unit_metric)
THEN
105 CALL get_qs_env(qs_env, do_kpoints=do_kpoints)
112 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_kp, matrix_s_kp, &
119 matrix_w_kp=matrix_w_kp, &
120 matrix_ks_kp=matrix_ks_kp, &
121 matrix_s_kp=matrix_s_kp, &
124 dft_control=dft_control, &
126 scf_control=scf_control)
128 CALL get_mo_set(mos(1), mo_coeff=mo_coeff, nao=nao)
130 template_fmstruct=mo_coeff%matrix_struct)
132 DO is = 1,
SIZE(fmwork)
133 CALL cp_fm_create(fmwork(is), matrix_struct=ao_ao_fmstruct)
138 IF (scf_control%use_ot)
THEN
139 IF (
ALLOCATED(kpoints%lowdin_v))
CALL plus_u(qs_env, matrix_h=matrix_ks_kp)
140 CALL kpoint_ot_energy_weighted_matrices(kpoints, matrix_ks_kp, fmwork(1))
146 IF (
PRESENT(include_lowdin_forces))
THEN
147 IF (include_lowdin_forces .AND. dft_control%dft_plus_u .AND. &
149 CALL plus_u(qs_env, matrix_w=matrix_w_kp)
154 matrix_s_kp(1, 1)%matrix, sab_nl, fmwork)
156 DO is = 1,
SIZE(fmwork)
163 NULLIFY (dft_control, rho_ao)
166 matrix_ks=matrix_ks, &
168 mo_derivs=mo_derivs, &
169 scf_control=scf_control, &
172 dft_control=dft_control)
179 IF (dft_control%roks)
THEN
180 IF (scf_control%use_ot)
THEN
183 CALL dbcsr_set(matrix_w(ispin)%matrix, 0.0_dp)
186 matrix_w(ispin)%matrix, matrix_s(1)%matrix)
190 matrix_ks=matrix_ks(ispin)%matrix, &
191 matrix_p=rho_ao(ispin)%matrix, &
192 matrix_w=matrix_w(ispin)%matrix)
195 IF (scf_control%use_ot)
THEN
197 matrix_w(ispin)%matrix, matrix_s(1)%matrix)
208 CALL timestop(handle)
218 SUBROUTINE kpoint_ot_energy_weighted_matrices(kpoint, matrix_ks, ao_ao_fm)
220 TYPE(kpoint_type),
POINTER :: kpoint
221 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks
222 TYPE(cp_fm_type),
INTENT(IN) :: ao_ao_fm
224 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_ot_energy_weighted_matrices'
225 COMPLEX(KIND=dp),
PARAMETER :: zone = (1.0_dp, 0.0_dp), &
226 zzero = (0.0_dp, 0.0_dp)
228 INTEGER :: handle, ikpgr, ispin, kplocal, kpmax, &
230 REAL(kind=dp),
DIMENSION(:),
POINTER :: occupation
231 TYPE(cp_cfm_type) :: h_k, hc, wmat
232 TYPE(cp_fm_pool_type),
POINTER :: ao_ao_fm_pool
233 TYPE(cp_fm_struct_type),
POINTER :: h_k_struct
234 TYPE(kpoint_env_type),
POINTER :: kp
235 TYPE(kpoint_operator_context_type) :: op_ctx
237 CALL timeset(routinen, handle)
238 NULLIFY (ao_ao_fm_pool, h_k_struct, occupation)
239 cpassert(.NOT. kpoint%use_real_wfn)
240 cpassert(
ASSOCIATED(matrix_ks))
242 nspin =
SIZE(matrix_ks, 1)
243 kplocal =
SIZE(kpoint%kp_env)
244 kpmax = maxval(kpoint%kp_dist(2, :) - kpoint%kp_dist(1, :) + 1)
245 CALL kpoint_operator_context_create(op_ctx, kpoint, ao_ao_fm, nspin)
247 CALL kpoint_operator_prepare(op_ctx, matrix_ks, kpoint_slot_ks)
248 CALL mpools_get(kpoint%mpools, ao_ao_fm_pool=ao_ao_fm_pool)
249 h_k_struct => fm_pool_get_el_struct(ao_ao_fm_pool)
250 CALL cp_cfm_create(h_k, h_k_struct)
256 CALL kpoint_operator_get(op_ctx, ikpgr, ispin, matrix_ks, &
258 matrix_row=ispin, slot=kpoint_slot_ks)
259 IF (ikpgr <= kplocal)
THEN
260 kp => kpoint%kp_env(ikpgr)%kpoint_env
261 CALL get_mo_set(kp%mos(ispin), nmo=nmo, &
262 occupation_numbers=occupation)
263 CALL cp_cfm_get_info(kp%mos(ispin)%cmo_coeff, nrow_global=nao)
265 cpassert(
SIZE(occupation) >= nmo)
268 CALL cp_cfm_create(hc, kp%mos(ispin)%cmo_coeff%matrix_struct, set_zero=.true.)
269 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, zone, h_k, &
270 kp%mos(ispin)%cmo_coeff, zzero, hc)
271 IF (
ALLOCATED(kpoint%lowdin_v))
THEN
272 CALL lowdin_kp_apply_mo(kp, kpoint%lowdin_v(:, ispin), &
273 kp%mos(ispin)%cmo_coeff, hc)
276 CALL cp_cfm_create(wmat, kp%wmat(1, ispin)%matrix_struct)
277 CALL kpoint_ot_energy_weighted_density( &
278 kp%mos(ispin)%cmo_coeff, hc, occupation, wmat)
280 CALL cp_cfm_to_fm(wmat, kp%wmat(1, ispin), kp%wmat(2, ispin))
282 CALL cp_cfm_release(wmat)
283 CALL cp_cfm_release(hc)
288 CALL cp_cfm_release(h_k)
289 CALL kpoint_operator_context_release(op_ctx)
290 CALL timestop(handle)
292 END SUBROUTINE kpoint_ot_energy_weighted_matrices
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_set(matrix, alpha)
...
pool for for elements that are retained and released
type(cp_fm_struct_type) function, pointer, public fm_pool_get_el_struct(pool)
returns the structure of the elements in this pool
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
Add the DFT+U contribution to the Hamiltonian matrix.
subroutine, public lowdin_kp_apply_mo(kp, v, coeff, hc)
Add B diag(v) B**H C to the complex orbital gradient, without forming an AO matrix.
subroutine, public plus_u(qs_env, matrix_h, matrix_w)
Add the DFT+U contribution to the Hamiltonian matrix. Wrapper routine for all "+U" methods.
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext, overlap_rs, mixed_aux_orb)
generate real space density matrices in DBCSR format
subroutine, public kpoint_ot_energy_weighted_density(coeff, hc, occupation, wmat)
Build W(k) for noncanonical complex OT orbitals from H(k) C(k). The occupied-space Lagrange multiplie...
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups).
Types and basic routines needed for a kpoint calculation.
basic linear algebra operations for full matrixes
collects routines that calculate density matrices
subroutine, public calculate_w_matrix_ot(mo_set, mo_deriv, w_matrix, s_matrix)
Calculate the W matrix from the MO coefs, MO derivs could overwrite the mo_derivs for increased memor...
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, matrix_vhxc, 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.
Assembly of real and complex k-point operators from real-space DBCSR matrices. Outputs use the distri...
subroutine, public kpoint_operator_context_create(ctx, kpoints, ao_ao_fm, nspin)
Create an empty operator context. The context owns no buffers after this call; they are created on fi...
subroutine, public kpoint_operator_prepare(ctx, rsmat, slot, prepared, matrix_row, target)
Prepare an immutable operator slot for group-local assembly. Refresh after the source values change,...
subroutine, public kpoint_operator_get(ctx, ikp, ispin, rsmat, cmat, fm_re, fm_im, mat_re, mat_im, matrix_row, slot, grid)
Assemble one operator for one global round and spin in one call: run the single-group transfer of the...
integer, parameter, public kpoint_slot_ks
subroutine, public kpoint_operator_context_release(ctx)
Release the context together with every buffer it created. Call once, at the end of the fixed-layout ...
wrapper for the pools of matrixes
subroutine, public mpools_get(mpools, ao_mo_fm_pools, ao_ao_fm_pool, mo_mo_fm_pools, ao_mosub_fm_pools, mosub_mosub_fm_pools, maxao_maxmo_fm_pool, maxao_maxao_fm_pool, maxmo_maxmo_fm_pool)
returns various attributes of the mpools (notably the pools contained in it)
Utility subroutine for qs energy calculation.
subroutine, public compute_matrix_w(qs_env, calc_forces, include_lowdin_forces)
Refactoring of qs_energies_scf. Moves computation of matrix_w into separate subroutine.
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, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
superstucture that hold various representations of the density and keeps track of which ones are vali...
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...
parameters that control an scf iteration
Represent a complex full matrix.
represent a pool of elements with the same structure
keeps the information about the structure of a full matrix
Keeps information about a specific k-point.
Contains information about kpoints.
Caller-owned assembly context for a fixed geometry and parallel layout. OT retains it for one inner S...
keeps the density in various representations, keeping track of which ones are valid.