37#include "./base/base_uses.f90"
43 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_dispersion_utils'
59 LOGICAL :: exfun, explicit
60 REAL(
dp),
POINTER :: params(:), scal(:)
64 cpassert(
ASSOCIATED(dispersion_env))
67 dispersion_env%doabc = .false.
68 dispersion_env%c9cnst = .false.
69 dispersion_env%lrc = .false.
70 dispersion_env%srb = .false.
71 dispersion_env%verbose = .false.
72 dispersion_env%nd3_exclude_pair = 0
73 NULLIFY (dispersion_env%c6ab, dispersion_env%maxci, dispersion_env%r0ab, dispersion_env%rcov, &
74 dispersion_env%r2r4, dispersion_env%cn, dispersion_env%cnkind, dispersion_env%cnlist, &
75 dispersion_env%d3_exclude_pair)
76 NULLIFY (dispersion_env%q_mesh, dispersion_env%kernel, dispersion_env%d2phi_dk2, &
77 dispersion_env%d2y_dx2)
78 NULLIFY (dispersion_env%sab_vdw, dispersion_env%sab_cn)
79 NULLIFY (dispersion_env%dftd_section)
80 NULLIFY (vdw_section, xc_fun_section)
93 IF (.NOT. explicit)
THEN
96 CALL cp_abort(__location__,
"D2 vdW REFERENCE_FUNCTIONAL expected a second parameter "// &
97 "(example REFERENCE_FUNCTIONAL PBE). "// &
98 "Go to https://www.chemie.uni-bonn.de/grimme/de/software/dft-d3/ "// &
99 "for a full list of supported functionals")
101 CALL qs_scaling_dftd2(dispersion_env%scaling, vdw_section)
106 dispersion_env%exp_pre = 0._dp
107 dispersion_env%scaling = 0._dp
118 dispersion_env%srb_params(1:4) = params(1:4)
127 IF (.NOT. explicit)
THEN
129 IF (.NOT. exfun)
THEN
130 CALL cp_abort(__location__,
"D3 vdW REFERENCE_FUNCTIONAL expected a second parameter "// &
131 "(example REFERENCE_FUNCTIONAL PBE). "// &
132 "Go to https://www.chemie.uni-bonn.de/grimme/de/software/dft-d3/ for a full "// &
133 "list of supported functionals")
136 "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", &
137 c_val=dispersion_env%ref_functional)
140 CALL qs_scaling_dftd3(dispersion_env%s6, dispersion_env%sr6, &
141 dispersion_env%s8, vdw_section)
143 CALL qs_scaling_dftd3bj(dispersion_env%s6, dispersion_env%a1, dispersion_env%s8, &
144 dispersion_env%a2, vdw_section)
150 dispersion_env%s6 = scal(1)
151 dispersion_env%sr6 = scal(2)
152 dispersion_env%s8 = scal(3)
153 dispersion_env%a1 = 0.0_dp
154 dispersion_env%a2 = 0.0_dp
158 dispersion_env%s6 = scal(1)
159 dispersion_env%a1 = scal(2)
160 dispersion_env%s8 = scal(3)
161 dispersion_env%a2 = scal(4)
162 dispersion_env%sr6 = 0.0_dp
166 dispersion_env%s6 = 0._dp
167 dispersion_env%sr6 = 0._dp
168 dispersion_env%s8 = 0._dp
169 dispersion_env%s9 = 0._dp
170 dispersion_env%a1 = 0._dp
171 dispersion_env%a2 = 0._dp
172 dispersion_env%eps_cn = 0._dp
176 IF (.NOT. explicit)
THEN
178 IF (.NOT. exfun)
THEN
179 cpabort(
"Missing REFERENCE_FUNCTIONAL or D4_SCALING for D4")
182 "PAIR_POTENTIAL%REFERENCE_FUNCTIONAL", &
183 c_val=dispersion_env%ref_functional)
187 dispersion_env%s6 = scal(1)
188 dispersion_env%a1 = scal(2)
189 dispersion_env%s8 = scal(3)
190 dispersion_env%a2 = scal(4)
191 dispersion_env%sr6 = 0.0_dp
192 dispersion_env%ref_functional =
"none"
194 IF (trim(adjustl(dispersion_env%ref_functional)) ==
"none")
THEN
195 cpabort(
"Missing REFERENCE_FUNCTIONAL or D4_SCALING for D4")
199 l_val=dispersion_env%d4_reference_code)
209 dispersion_env%doabc = .true.
214 c_val=dispersion_env%parameter_file_name)
216 dispersion_env%dftd_section => pp_section
222 c_val=dispersion_env%kernel_file_name)
227 dispersion_env%b_value = params(1)
228 dispersion_env%c_value = params(2)
241 INTEGER,
INTENT(in),
OPTIONAL :: ounit
243 CHARACTER(LEN=2) :: symbol
244 INTEGER :: i, ikind, nkind, output_unit
248 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
251 IF (
PRESENT(ounit))
THEN
259 "PRINT%DFT_CONTROL_PARAMETERS", extension=
".Log")
262 IF (output_unit > 0)
THEN
265 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T67,'Pair Potential')")
268 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T35,'DFT-D2')")
269 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T35,'Potential Form: S. Grimme, JCC 27: 1787 (2006)')")
270 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T35,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
271 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T35,'Scaling Factor:',T73,F8.4)") dispersion_env%scaling
272 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T35,'Exp Prefactor for Damping:',T73,F8.1)") dispersion_env%exp_pre
273 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
274 nkind =
SIZE(atomic_kind_set)
277 CALL get_qs_kind(qs_kind_set(ikind), dispersion=disp)
278 IF (disp%defined)
THEN
279 WRITE (output_unit, fmt=
"(' vdW PARAMETER| ',T18,'Atom=',A2, "// &
280 "T28,'C6[J*nm^6*mol^-1]=',F8.4,T63,'r(vdW)[A]=',F8.4)") &
281 symbol, disp%c6/(1000._dp*
bohr**6/
kjmol), disp%vdw_radii/
bohr
283 WRITE (output_unit, fmt=
"(' vdW PARAMETER| ',T20,'Atom=',A2,T70,'not defined')")
287 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'DFT-D3 (Version 3.1)')")
288 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Potential Form: S. Grimme et al, JCP 132: 154104 (2010)')")
289 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Zero Damping')")
290 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
291 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'s6 Scaling Factor:',T73,F8.4)") dispersion_env%s6
292 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'sr6 Scaling Factor:',T73,F8.4)") dispersion_env%sr6
293 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'s8 Scaling Factor:',T73,F8.4)") dispersion_env%s8
294 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Cutoff for CN calculation:',T69,E12.4)") dispersion_env%eps_cn
295 IF (dispersion_env%nd3_exclude_pair > 0)
THEN
296 DO i = 1, dispersion_env%nd3_exclude_pair
297 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Excluded Pairs: ',T76,I2,' ',I2)") &
298 dispersion_env%d3_exclude_pair(i, :)
302 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'DFT-D3 (Version 3.1)')")
303 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Potential Form: S. Grimme et al, JCP 132: 154104 (2010)')")
304 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'BJ Damping: S. Grimme et al, JCC 32: 1456 (2011)')")
305 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Cutoff Radius [Bohr]:',T73,F8.2)") dispersion_env%rc_disp
306 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'s6 Scaling Factor:',T73,F8.4)") dispersion_env%s6
307 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'a1 Damping Factor:',T73,F8.4)") dispersion_env%a1
308 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'s8 Scaling Factor:',T73,F8.4)") dispersion_env%s8
309 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'a2 Damping Factor:',T73,F8.4)") dispersion_env%a2
310 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Cutoff for CN calculation:',T69,E12.4)") dispersion_env%eps_cn
311 IF (dispersion_env%nd3_exclude_pair > 0)
THEN
312 DO i = 1, dispersion_env%nd3_exclude_pair
313 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'Excluded Kind Pairs: ',T76,I2,' ',I2)") &
314 dispersion_env%d3_exclude_pair(i, :)
318#if defined(__DFTD4_V3)
319 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'DFT-D4(Version 3.7)')")
321 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'DFT-D4(Version 4.0)')")
323 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'see https://github.com/dftd4/dftd4')")
324 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, PCCP 22: 8499 (2020)')")
325 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, JCP 150: 154122 (2019)')")
326 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T26,'E. Caldeweyher et al, JCP 147: 034112 (2017)')")
329 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ',T61,'Non-local Functional')")
330 WRITE (output_unit, &
331 fmt=
"(' vdW POTENTIAL| ','Implementation: G. Roman-Perez, J. Soler, PRL 103: 096102 (2009)')")
332 WRITE (output_unit, &
333 fmt=
"(' vdW POTENTIAL| ',T38,' T. Thonhauser et al, PRB 76: 125112 (2007)')")
334 WRITE (output_unit, &
335 fmt=
"(' vdW POTENTIAL| ',T22,' R. Sabatini et al, J.Phys:Condens Matter 24: 424209 (2012)')")
336 WRITE (output_unit, &
337 fmt=
"(' vdW POTENTIAL| ',T16,' Based on QE implementation by Brian Kolb, Timo Thonhauser (2009)')")
338 SELECT CASE (dispersion_env%nl_type)
343 WRITE (output_unit, &
344 fmt=
"(' vdW POTENTIAL| ','DRSLL Functional: M. Dion et al, PRL 92: 246401 (2004)')")
346 WRITE (output_unit, &
347 fmt=
"(' vdW POTENTIAL| ','LMKLL Functional: K. Lee et al, PRB 82: 081101 (2010)')")
349 WRITE (output_unit, &
350 fmt=
"(' vdW POTENTIAL| ','RVV10 Functional: R. Sabatini et al, PRB 87: 041108(R) (2013)')")
352 IF (dispersion_env%verbose)
THEN
353 WRITE (output_unit, &
354 fmt=
"(' vdW POTENTIAL| ',' Carrying out vdW-DF run using the following parameters:')")
355 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ','Nqs =',I8,' Nr_points =',I8,' r_max =',F10.3)") &
356 dispersion_env%nqs, dispersion_env%nr_points, dispersion_env%r_max
357 WRITE (output_unit, fmt=
"(' vdW POTENTIAL| ','q_mesh =')")
358 WRITE (output_unit, fmt=
"(8X,4F18.8)") (dispersion_env%q_mesh(i), i=1, dispersion_env%nqs)
359 WRITE (output_unit, &
360 fmt=
"(' vdW POTENTIAL| ','Density cutoff for convolution [a.u.]:',T71,F10.1)") &
361 dispersion_env%pw_cutoff
365 IF (.NOT.
PRESENT(ounit))
THEN
367 "PRINT%DFT_CONTROL_PARAMETERS")
377 SUBROUTINE qs_scaling_dftd2(scaling, vdw_section)
378 REAL(kind=
dp),
INTENT(inout) :: scaling
381 CHARACTER(LEN=default_string_length) :: functional
385 SELECT CASE (trim(functional))
388 cpabort(
"No DFT-D2 s6 value available for this functional:"//trim(functional))
407 END SUBROUTINE qs_scaling_dftd2
416 SUBROUTINE qs_scaling_dftd3(s6, sr6, s8, vdw_section)
418 REAL(kind=
dp),
INTENT(inout) :: s6, sr6, s8
421 CHARACTER(LEN=default_string_length) :: functional
428 SELECT CASE (trim(functional))
431 cpabort(
"No DFT-D3 values available for this functional:"//trim(functional))
780 END SUBROUTINE qs_scaling_dftd3
790 SUBROUTINE qs_scaling_dftd3bj(s6, a1, s8, a2, vdw_section)
791 REAL(kind=
dp),
INTENT(inout) :: s6, a1, s8, a2
794 CHARACTER(LEN=default_string_length) :: functional
801 SELECT CASE (trim(functional))
804 cpabort(
"No DFT-D3(BJ) values available for this functional:"//trim(functional))
1197 END SUBROUTINE qs_scaling_dftd3bj
1206 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell, ncell
1209 INTEGER :: ix, iy, iz, nx, ny, nz
1211 cpassert(all(abs(cell) <= ncell))
1215 ix = 2*abs(ix) - (1 + sign(1, ix))/2
1219 iy = 2*abs(iy) - (1 + sign(1, iy))/2
1223 iz = 2*abs(iz) - (1 + sign(1, iz))/2
1230 hash = ix*ny*nz + iy*nz + iz + 1
static unsigned int hash(const dbm_task_t task)
Private hash function based on Szudzik's elegant pairing. Using unsigned int to return a positive num...
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
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,...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Definition of physical constants:
real(kind=dp), parameter, public kjmol
real(kind=dp), parameter, public bohr
Definition of disperson types for DFT calculations.
Set disperson types for DFT calculations.
subroutine, public qs_dispersion_env_set(dispersion_env, xc_section)
...
integer function, public cellhash(cell, ncell)
...
subroutine, public qs_write_dispersion(qs_env, dispersion_env, ounit)
...
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, 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.
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, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Utilities for string manipulations.
elemental subroutine, public uppercase(string)
Convert all lower case characters in a string to upper case.
Provides all information about an atomic kind.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Provides all information about a quickstep kind.