29 USE dbcsr_api,
ONLY: dbcsr_type
57 #include "./base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'hfx_pw_methods'
83 SUBROUTINE pw_hfx(qs_env, ehfx, hfx_section, poisson_env, auxbas_pw_pool, irep)
84 TYPE(qs_environment_type),
POINTER :: qs_env
85 REAL(kind=
dp),
INTENT(IN) :: ehfx
86 TYPE(section_vals_type),
POINTER :: hfx_section
87 TYPE(pw_poisson_type),
POINTER :: poisson_env
88 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
91 CHARACTER(*),
PARAMETER :: routinen =
'pw_hfx'
93 INTEGER :: blocksize, handle, ig, iloc, iorb, &
94 iorb_block, ispin, iw, jloc, jorb, &
95 jorb_block, norb, potential_type
96 LOGICAL :: do_kpoints, do_pw_hfx, explicit
97 REAL(kind=
dp) :: exchange_energy, fraction, g2, g3d, gg, &
98 omega, pair_energy, rcut, scaling
99 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
100 TYPE(cell_type),
POINTER :: cell
101 TYPE(cp_fm_type),
POINTER :: mo_coeff
102 TYPE(cp_logger_type),
POINTER :: logger
103 TYPE(dbcsr_type),
POINTER :: mo_coeff_b
104 TYPE(dft_control_type),
POINTER :: dft_control
105 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mo_array
106 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
107 TYPE(pw_c1d_gs_type) :: greenfn, pot_g, rho_g
108 TYPE(pw_env_type),
POINTER :: pw_env
109 TYPE(pw_grid_type),
POINTER :: grid
110 TYPE(pw_r3d_rs_type) :: rho_r
111 TYPE(pw_r3d_rs_type),
ALLOCATABLE,
DIMENSION(:) :: rho_i, rho_j
112 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
113 TYPE(section_vals_type),
POINTER :: ip_section
115 CALL timeset(routinen, handle)
124 CALL get_qs_env(qs_env, mos=mo_array, pw_env=pw_env, dft_control=dft_control, &
125 cell=cell, particle_set=particle_set, do_kpoints=do_kpoints, &
126 atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
127 IF (do_kpoints) cpabort(
"PW HFX not implemented with K-points")
130 CALL get_mo_set(mo_set=mo_array(1), mo_coeff=mo_coeff)
132 blocksize = max(1, min(blocksize, norb))
134 CALL auxbas_pw_pool%create_pw(rho_r)
135 CALL auxbas_pw_pool%create_pw(rho_g)
136 CALL auxbas_pw_pool%create_pw(pot_g)
138 ALLOCATE (rho_i(blocksize))
139 ALLOCATE (rho_j(blocksize))
141 CALL auxbas_pw_pool%create_pw(greenfn)
149 CALL pw_copy(poisson_env%green_fft%influence_fn, greenfn)
152 grid => poisson_env%green_fft%influence_fn%pw_grid
153 DO ig = grid%first_gne0, grid%ngpts_cut_local
157 greenfn%array(ig) = g3d*(1.0_dp - cos(rcut*gg))
160 greenfn%array(1) = 0.5_dp*
fourpi*rcut*rcut
163 IF (omega > 0.0_dp) omega = 0.25_dp/(omega*omega)
164 grid => poisson_env%green_fft%influence_fn%pw_grid
165 DO ig = grid%first_gne0, grid%ngpts_cut_local
169 greenfn%array(ig) = g3d*(1.0_dp - exp(gg))
171 IF (grid%have_g0) greenfn%array(1) = 0.0_dp
173 cpwarn(
"PW_SCF: Potential type not supported, calculation uses Coulomb potential.")
176 DO iorb_block = 1, blocksize
177 CALL rho_i(iorb_block)%create(rho_r%pw_grid)
178 CALL rho_j(iorb_block)%create(rho_r%pw_grid)
181 exchange_energy = 0.0_dp
183 DO ispin = 1,
SIZE(mo_array)
184 CALL get_mo_set(mo_set=mo_array(ispin), mo_coeff=mo_coeff, mo_coeff_b=mo_coeff_b)
186 IF (mo_array(ispin)%use_mo_coeff_b)
THEN
192 DO iorb_block = 1, norb, blocksize
194 DO iorb = iorb_block, min(iorb_block + blocksize - 1, norb)
196 iloc = iorb - iorb_block + 1
198 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
203 DO jorb_block = iorb_block, norb, blocksize
205 DO jorb = jorb_block, min(jorb_block + blocksize - 1, norb)
207 jloc = jorb - jorb_block + 1
209 atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, &
214 DO iorb = iorb_block, min(iorb_block + blocksize - 1, norb)
215 iloc = iorb - iorb_block + 1
216 DO jorb = jorb_block, min(jorb_block + blocksize - 1, norb)
217 jloc = jorb - jorb_block + 1
218 IF (jorb < iorb) cycle
222 CALL pw_multiply(rho_r, rho_i(iloc), rho_j(jloc))
225 CALL pw_transfer(rho_r, rho_g)
226 CALL pw_poisson_solve(poisson_env, rho_g, pair_energy, pot_g, &
231 IF (
SIZE(mo_array) == 1) scaling = scaling*2.0_dp
232 IF (iorb /= jorb) scaling = scaling*2.0_dp
234 exchange_energy = exchange_energy - scaling*pair_energy
243 DO iorb_block = 1, blocksize
244 CALL rho_i(iorb_block)%release()
245 CALL rho_j(iorb_block)%release()
248 CALL auxbas_pw_pool%give_back_pw(rho_r)
249 CALL auxbas_pw_pool%give_back_pw(rho_g)
250 CALL auxbas_pw_pool%give_back_pw(pot_g)
251 CALL auxbas_pw_pool%give_back_pw(greenfn)
257 WRITE (unit=iw, fmt=
"((T3,A,T61,F20.10))") &
258 "HF_PW_HFX| PW exchange energy:", exchange_energy
259 WRITE (unit=iw, fmt=
"((T3,A,T61,F20.10),/)") &
260 "HF_PW_HFX| Gaussian exchange energy:", ehfx
267 CALL timestop(handle)
Define the atomic kind types and their sub types.
Handles all functions related to the CELL.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
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
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Test routines for HFX caclulations using PW.
subroutine, public pw_hfx(qs_env, ehfx, hfx_section, poisson_env, auxbas_pw_pool, irep)
computes the Hartree-Fock energy brute force in a pw basis
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public fourpi
Define the data structure for the particle information.
container for various plainwaves related things
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_wavefunction(mo_vectors, ivector, rho, rho_gspace, atomic_kind_set, qs_kind_set, cell, dft_control, particle_set, pw_env, basis_type, external_vector)
maps a given wavefunction on the grid
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.
Define the quickstep kind type and their sub types.
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.