113#include "./base/base_uses.f90"
119 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_core_matrices'
140 SUBROUTINE core_matrices(qs_env, matrix_h, matrix_p, calculate_forces, nder, ec_env, dcdr_env, &
141 ec_env_matrices, basis_type, debug_forces, debug_stress, atcore)
144 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_h, matrix_p
145 LOGICAL,
INTENT(IN) :: calculate_forces
146 INTEGER,
INTENT(IN) :: nder
149 LOGICAL,
INTENT(IN),
OPTIONAL :: ec_env_matrices
150 CHARACTER(LEN=*),
OPTIONAL :: basis_type
151 LOGICAL,
INTENT(IN),
OPTIONAL :: debug_forces, debug_stress
152 REAL(kind=
dp),
DIMENSION(:),
OPTIONAL :: atcore
154 CHARACTER(LEN=default_string_length) :: my_basis_type
155 INTEGER :: iounit, natom, nimages
156 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
157 LOGICAL :: all_present, debfor, debstr, my_gt_nl, &
158 ppl_present, ppnl_present, use_lrigpw, &
160 REAL(kind=
dp) :: eps_ppnl, fconv
161 REAL(kind=
dp),
DIMENSION(3) :: fodeb
162 REAL(kind=
dp),
DIMENSION(3, 3) :: stdeb
163 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: deltar
167 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_hloc, matrix_ploc
173 POINTER :: sab_orb, sac_ae, sac_ppl, sap_ppnl
176 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
181 IF (logger%para_env%is_source())
THEN
187 NULLIFY (dft_control)
188 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, para_env=para_env)
191 IF (
PRESENT(basis_type))
THEN
192 my_basis_type = basis_type
194 my_basis_type =
"ORB"
197 IF (
PRESENT(dcdr_env) .AND.
PRESENT(ec_env))
THEN
198 cpabort(
"core_matrices: conflicting options")
202 IF (
PRESENT(atcore))
THEN
204 cpassert(
SIZE(atcore) >= natom)
209 IF (qs_env%run_rtp)
THEN
210 cpassert(
ASSOCIATED(dft_control%rtp_control))
211 IF (dft_control%rtp_control%velocity_gauge)
THEN
212 my_gt_nl = dft_control%rtp_control%nl_gauge_transform
217 nimages = dft_control%nimages
218 NULLIFY (cell_to_index)
219 IF (nimages > 1)
THEN
221 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
227 IF (
PRESENT(dcdr_env))
THEN
228 deltar => dcdr_env%delta_basis_function
229 matrix_hloc(1:3, 1:1) => dcdr_env%matrix_hc(1:3)
232 matrix_hloc => matrix_h
234 matrix_ploc => matrix_p
237 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc)
THEN
243 IF (calculate_forces)
CALL get_qs_env(qs_env=qs_env, force=force)
246 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
252 IF (
PRESENT(debug_forces)) debfor = debug_forces
253 debfor = debfor .AND. calculate_forces
255 IF (
PRESENT(debug_stress)) debstr = debug_stress
256 debstr = debstr .AND. use_virial
259 fconv = 1.0e-9_dp*
pascal/cell%deth
262 NULLIFY (qs_kind_set, atomic_kind_set, particle_set)
263 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set, &
264 particle_set=particle_set)
266 NULLIFY (sab_orb, sac_ae, sac_ppl, sap_ppnl)
267 IF (
PRESENT(ec_env))
THEN
268 sab_orb => ec_env%sab_orb
269 sac_ae => ec_env%sac_ae
270 sac_ppl => ec_env%sac_ppl
271 sap_ppnl => ec_env%sap_ppnl
280 IF (
PRESENT(ec_env) .AND.
PRESENT(ec_env_matrices))
THEN
281 IF (ec_env_matrices)
THEN
282 matrix_hloc => ec_env%matrix_h
283 matrix_ploc => ec_env%matrix_p
288 all_present =
ASSOCIATED(sac_ae)
289 IF (all_present)
THEN
290 IF (
PRESENT(dcdr_env))
THEN
291 cpabort(
"ECP/AE functionality for dcdr missing")
293 IF (debfor) fodeb(1:3) = force(1)%all_potential(1:3, 1)
294 IF (debstr) stdeb = virial%pv_ppl
295 CALL build_core_ae(matrix_hloc, matrix_ploc, force, virial, calculate_forces, use_virial, nder, &
296 qs_kind_set, atomic_kind_set, particle_set, sab_orb, sac_ae, &
297 nimages, cell_to_index, my_basis_type, atcore=atcore)
299 fodeb(1:3) = force(1)%all_potential(1:3, 1) - fodeb(1:3)
300 CALL para_env%sum(fodeb)
301 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: P*dHae ", fodeb
304 stdeb = fconv*(virial%pv_ppl - stdeb)
305 CALL para_env%sum(stdeb)
306 IF (iounit > 0)
WRITE (unit=iounit, fmt=
"(T2,A,T41,2(1X,ES19.11))") &
312 ppl_present =
ASSOCIATED(sac_ppl)
313 IF (ppl_present)
THEN
316 IF (
ASSOCIATED(lri_env))
THEN
317 use_lrigpw = (dft_control%qs_control%lrigpw .AND. lri_env%ppl_ri)
320 IF (lri_env%exact_1c_terms)
THEN
321 cpabort(
"not implemented")
324 IF (debfor) fodeb(1:3) = force(1)%gth_ppl(1:3, 1)
325 IF (debstr) stdeb = virial%pv_ppl
327 virial, calculate_forces, use_virial, nder, &
328 qs_kind_set, atomic_kind_set, particle_set, &
329 sab_orb, sac_ppl, nimages, cell_to_index, my_basis_type, &
330 deltar=deltar, atcore=atcore)
332 fodeb(1:3) = force(1)%gth_ppl(1:3, 1) - fodeb(1:3)
333 CALL para_env%sum(fodeb)
334 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: P*dHppl ", fodeb
337 stdeb = fconv*(virial%pv_ppl - stdeb)
338 CALL para_env%sum(stdeb)
339 IF (iounit > 0)
WRITE (unit=iounit, fmt=
"(T2,A,T41,2(1X,ES19.11))") &
347 eps_ppnl = dft_control%qs_control%eps_ppnl
348 ppnl_present =
ASSOCIATED(sap_ppnl)
349 IF (ppnl_present)
THEN
350 IF (
PRESENT(dcdr_env))
THEN
351 matrix_hloc(1:3, 1:1) => dcdr_env%matrix_ppnl_1(1:3)
353 IF (.NOT. my_gt_nl)
THEN
354 IF (debfor) fodeb(1:3) = force(1)%gth_ppnl(1:3, 1)
355 IF (debstr) stdeb = virial%pv_ppnl
357 virial, calculate_forces, use_virial, nder, &
358 qs_kind_set, atomic_kind_set, particle_set, &
359 sab_orb, sap_ppnl, eps_ppnl, nimages, cell_to_index, my_basis_type, &
360 deltar=deltar, atcore=atcore)
362 fodeb(1:3) = force(1)%gth_ppnl(1:3, 1) - fodeb(1:3)
363 CALL para_env%sum(fodeb)
364 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: P*dHppnl ", fodeb
367 stdeb = fconv*(virial%pv_ppnl - stdeb)
368 CALL para_env%sum(stdeb)
369 IF (iounit > 0)
WRITE (unit=iounit, fmt=
"(T2,A,T41,2(1X,ES19.11))") &
394 matrix_name, calculate_forces, nderivative, &
395 sab_orb, eps_filter, basis_type, debug_forces, debug_stress)
399 POINTER :: matrixkp_t
404 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: matrix_name
405 LOGICAL,
INTENT(IN) :: calculate_forces
406 INTEGER,
INTENT(IN),
OPTIONAL :: nderivative
408 OPTIONAL,
POINTER :: sab_orb
409 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: eps_filter
410 CHARACTER(LEN=*),
OPTIONAL :: basis_type
411 LOGICAL,
INTENT(IN),
OPTIONAL :: debug_forces, debug_stress
413 CHARACTER(LEN=default_string_length) :: my_basis_type
414 INTEGER :: ic, img, iounit, nimages
415 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
416 LOGICAL :: debfor, debstr, use_virial
417 REAL(kind=
dp) :: fconv
418 REAL(kind=
dp),
DIMENSION(3) :: fodeb
419 REAL(kind=
dp),
DIMENSION(3, 3) :: stdeb
429 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
434 IF (logger%para_env%is_source())
THEN
440 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control, para_env=para_env)
442 IF (dft_control%qs_control%ofgpw)
RETURN
445 nimages = dft_control%nimages
448 IF (
PRESENT(basis_type))
THEN
449 my_basis_type = basis_type
451 my_basis_type =
"ORB"
455 IF (
PRESENT(debug_forces)) debfor = debug_forces
456 debfor = debfor .AND. calculate_forces
459 use_virial = virial%pv_availability .AND. (.NOT. virial%pv_numer)
462 IF (
PRESENT(debug_stress)) debstr = debug_stress
463 debstr = debstr .AND. use_virial
466 fconv = 1.0e-9_dp*
pascal/cell%deth
472 IF (
PRESENT(sab_orb))
THEN
475 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_nl)
478 IF (calculate_forces)
THEN
479 IF (
SIZE(matrix_p, 1) == 2)
THEN
481 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
482 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
489 fodeb(1:3) = force(1)%kinetic(1:3, 1)
492 stdeb = virial%pv_ekinetic
497 matrix_name=matrix_name, &
498 basis_type=my_basis_type, &
500 calculate_forces=calculate_forces, &
501 matrixkp_p=matrix_p, &
502 nderivative=nderivative, &
503 eps_filter=eps_filter)
506 fodeb(1:3) = force(1)%kinetic(1:3, 1) - fodeb(1:3)
507 CALL para_env%sum(fodeb)
508 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: P*dT ", fodeb
511 stdeb = fconv*(virial%pv_ekinetic - stdeb)
512 CALL para_env%sum(stdeb)
513 IF (iounit > 0)
WRITE (unit=iounit, fmt=
"(T2,A,T41,2(1X,ES19.11))") &
517 IF (calculate_forces)
THEN
518 IF (
SIZE(matrix_p, 1) == 2)
THEN
520 CALL dbcsr_add(matrix_p(1, img)%matrix, matrix_p(2, img)%matrix, &
521 alpha_scalar=1.0_dp, beta_scalar=-1.0_dp)
527 IF (qs_env%rel_control%rel_method /=
rel_none)
THEN
529 CALL get_qs_env(qs_env=qs_env, qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
530 IF (nimages == 1)
THEN
533 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
535 ic = cell_to_index(0, 0, 0)
537 IF (my_basis_type /=
"ORB")
THEN
538 cpabort(
"Basis mismatch for relativistic correction")
540 IF (
PRESENT(matrixkp_t))
THEN
541 CALL build_atomic_relmat(matrixkp_t(1, ic)%matrix, atomic_kind_set, qs_kind_set)
542 ELSEIF (
PRESENT(matrix_t))
THEN
543 CALL build_atomic_relmat(matrix_t(1)%matrix, atomic_kind_set, qs_kind_set)
546 cpabort(
"Relativistic corrections of this type are currently not implemented")
558 SUBROUTINE build_atomic_relmat(matrix_t, atomic_kind_set, qs_kind_set)
561 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
563 INTEGER :: iatom, ikind, jatom
564 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
565 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: reltmat, tblock
573 IF (iatom == jatom)
THEN
574 ikind = kind_of(iatom)
575 CALL get_qs_kind(qs_kind_set(ikind), reltmat=reltmat)
576 IF (
ASSOCIATED(reltmat)) tblock = tblock + reltmat
581 END SUBROUTINE build_atomic_relmat
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.
Handles all functions related to the CELL.
Calculation of the nuclear attraction contribution to the core Hamiltonian <a|erfc|b> :we only calcul...
subroutine, public build_core_ae(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sac_ae, nimages, cell_to_index, basis_type, atcore)
...
Calculation of the local pseudopotential contribution to the core Hamiltonian <a|V(local)|b> = <a|Sum...
subroutine, public build_core_ppl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sac_ppl, nimages, cell_to_index, basis_type, deltar, atcore)
...
Calculation of the non-local pseudopotential contribution to the core Hamiltonian <a|V(non-local)|b> ...
subroutine, public build_core_ppnl(matrix_h, matrix_p, force, virial, calculate_forces, use_virial, nder, qs_kind_set, atomic_kind_set, particle_set, sab_orb, sap_ppnl, eps_ppnl, nimages, cell_to_index, basis_type, deltar, matrix_l, atcore)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Types needed for a for a Energy Correction.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
Collection of simple mathematical functions and subroutines.
Interface to the message passing library MPI.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public pascal
Calculation of the core Hamiltonian integral matrix <a|H|b> over Cartesian Gaussian-type functions.
subroutine, public kinetic_energy_matrix(qs_env, matrixkp_t, matrix_t, matrix_p, matrix_name, calculate_forces, nderivative, sab_orb, eps_filter, basis_type, debug_forces, debug_stress)
Calculate kinetic energy matrix and possible relativistic correction.
subroutine, public core_matrices(qs_env, matrix_h, matrix_p, calculate_forces, nder, ec_env, dcdr_env, ec_env_matrices, basis_type, debug_forces, debug_stress, atcore)
...
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, 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, 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, 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.
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, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, 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_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_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Calculation of kinetic energy matrix and forces.
subroutine, public build_kinetic_matrix(ks_env, matrix_t, matrixkp_t, matrix_name, basis_type, sab_nl, calculate_forces, matrix_p, matrixkp_p, eps_filter, nderivative)
Calculation of the kinetic energy matrix over Cartesian Gaussian functions.
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_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, 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)
...
Type definitiona for linear response calculations.
Define the neighbor list data types and the corresponding functionality.
pure real(kind=dp) function, public one_third_sum_diag(a)
...
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information on the energy correction functional for KG.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...