14 USE ieee_arithmetic,
ONLY: ieee_is_finite
31#include "./base/base_uses.f90"
38 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_electrons_ne_electrode'
70 REAL(kind=
dp),
INTENT(IN) :: target_nelect, neutral_electrons_ref
72 CHARACTER(LEN=*),
PARAMETER :: routinen =
'apply_ne_core_correction'
73 REAL(kind=
dp),
PARAMETER :: core_corr_refresh_tol = 1.0e-12_dp
75 CHARACTER(LEN=2) :: elem
76 INTEGER :: handle, ikind, iparticle, n_ne_atoms, &
78 LOGICAL :: core_corr_changed, found_ne
79 REAL(kind=
dp) :: base_zeff, core_corr_ne, delta_q, &
80 new_zeff, old_zeff, zeff_scale
92 CALL timeset(routinen, handle)
94 IF (.NOT. ieee_is_finite(target_nelect) .OR. target_nelect <= 0.0_dp)
THEN
95 cpabort(
"target electron count must be positive.")
97 IF (.NOT. ieee_is_finite(neutral_electrons_ref) .OR. neutral_electrons_ref <= 0.0_dp)
THEN
98 cpabort(
"neutral_electrons_ref must be positive.")
105 IF (.NOT.
ASSOCIATED(qs_env))
THEN
106 cpabort(
"Ne correction requires a QS force environment.")
111 IF (.NOT.
ASSOCIATED(cp_subsys))
THEN
112 cpabort(
"Ne correction could not access CP2K subsys.")
115 NULLIFY (atomic_kind_set)
116 NULLIFY (qs_kind_set)
118 CALL get_qs_env(qs_env=qs_env, atomic_kind_set=atomic_kind_set, &
119 qs_kind_set=qs_kind_set, ks_env=ks_env)
121 IF (.NOT. (
ASSOCIATED(atomic_kind_set) .AND.
ASSOCIATED(qs_kind_set)))
THEN
122 cpabort(
"Ne correction could not access kind sets.")
125 nkind =
SIZE(atomic_kind_set, 1)
127 core_corr_changed = .false.
130 DO iparticle = 1, cp_subsys%particles%n_els
131 atomic_kind => cp_subsys%particles%els(iparticle)%atomic_kind
132 IF (
ASSOCIATED(atomic_kind))
THEN
133 elem = atomic_kind%element_symbol
135 IF (trim(elem) ==
'Ne' .OR. trim(elem) ==
'NE')
THEN
136 n_ne_atoms = n_ne_atoms + 1
141 IF (n_ne_atoms <= 0)
THEN
142 cpabort(
"Ne mode requested but no Ne atoms found.")
145 delta_q = target_nelect - neutral_electrons_ref
146 core_corr_ne = delta_q/real(n_ne_atoms, kind=
dp)
149 atomic_kind => atomic_kind_set(ikind)
150 qs_kind => qs_kind_set(ikind)
155 elem = atomic_kind%element_symbol
158 IF (trim(elem) ==
'Ne' .OR. trim(elem) ==
'NE')
THEN
160 NULLIFY (all_potential)
161 NULLIFY (gth_potential)
162 NULLIFY (sgp_potential)
164 CALL get_qs_kind(qs_kind, all_potential=all_potential, gth_potential=gth_potential, &
165 sgp_potential=sgp_potential)
167 IF (
ASSOCIATED(all_potential))
THEN
168 IF (abs(all_potential%zeff_correction - core_corr_ne) > core_corr_refresh_tol)
THEN
169 old_zeff = all_potential%zeff
170 base_zeff = old_zeff - all_potential%zeff_correction
171 new_zeff = base_zeff + core_corr_ne
172 IF (abs(old_zeff) > epsilon(1.0_dp))
THEN
173 zeff_scale = new_zeff/old_zeff
174 all_potential%ccore_charge = all_potential%ccore_charge*zeff_scale
176 all_potential%zeff = new_zeff
177 all_potential%zeff_correction = core_corr_ne
178 core_corr_changed = .true.
181 IF (
ASSOCIATED(gth_potential))
THEN
182 IF (abs(gth_potential%zeff_correction - core_corr_ne) > core_corr_refresh_tol)
THEN
183 old_zeff = gth_potential%zeff
184 base_zeff = old_zeff - gth_potential%zeff_correction
185 new_zeff = base_zeff + core_corr_ne
186 IF (abs(old_zeff) > epsilon(1.0_dp))
THEN
187 zeff_scale = new_zeff/old_zeff
188 gth_potential%ccore_charge = gth_potential%ccore_charge*zeff_scale
189 gth_potential%cerf_ppl = gth_potential%cerf_ppl*zeff_scale
191 gth_potential%zeff = new_zeff
192 gth_potential%zeff_correction = core_corr_ne
193 core_corr_changed = .true.
196 IF (
ASSOCIATED(sgp_potential))
THEN
197 IF (abs(sgp_potential%zeff_correction - core_corr_ne) > core_corr_refresh_tol)
THEN
198 old_zeff = sgp_potential%zeff
199 base_zeff = old_zeff - sgp_potential%zeff_correction
200 new_zeff = base_zeff + core_corr_ne
201 IF (abs(old_zeff) > epsilon(1.0_dp))
THEN
202 zeff_scale = new_zeff/old_zeff
203 sgp_potential%ccore_charge = sgp_potential%ccore_charge*zeff_scale
205 sgp_potential%zeff = new_zeff
206 sgp_potential%zeff_correction = core_corr_ne
207 core_corr_changed = .true.
213 IF (.NOT. found_ne)
THEN
214 cpabort(
"no Ne atomic kind was found.")
218 IF (output_unit > 0)
THEN
219 WRITE (output_unit, *)
" @ DRIVER MODE: Ne-electrode target_nelect = ", target_nelect, &
220 " neutral_electrons = ", neutral_electrons_ref
221 WRITE (output_unit, *)
" @ DRIVER MODE: Ne atoms = ", n_ne_atoms, &
222 " CORE_CORRECTION per Ne = ", core_corr_ne
223 IF (.NOT. core_corr_changed)
THEN
224 WRITE (output_unit, *)
" @ DRIVER MODE: Ne CORE_CORRECTION refresh skipped; change <= ", &
225 core_corr_refresh_tol
229 IF (core_corr_changed)
THEN
230 CALL get_qs_kind_set(qs_kind_set, total_zeff_corr=qs_env%total_zeff_corr)
233 IF (core_corr_changed .AND.
ASSOCIATED(ks_env))
THEN
234 CALL set_ks_env(ks_env, potential_changed=.true., &
235 forces_up_to_date=.false.)
238 CALL timestop(handle)
Define the atomic kind types and their sub types.
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
types that represent a subsys, i.e. a part of the system
Definition of the atomic potential types.
Interface for the force calculations.
recursive subroutine, public force_env_get(force_env, in_use, fist_env, qs_env, meta_env, fp_env, subsys, para_env, potential_energy, additional_potential, kinetic_energy, harmonic_shell, kinetic_shell, cell, sub_force_env, qmmm_env, qmmmx_env, eip_env, pwdft_env, globenv, input, force_env_section, method_name_id, root_section, mixed_env, nnp_env, embed_env, ipi_env)
returns various attributes about the force environment
Defines the basic variable types.
integer, parameter, public dp
Ne-electrode core-charge correction for constant-potential MD: adjusts the Ne pseudopotential core ch...
subroutine, public apply_ne_core_correction(force_env, target_nelect, neutral_electrons_ref)
Apply Ne core correction update from the current total electron number.
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.
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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, 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.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, 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_vhxc, 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, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, 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, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
Provides all information about an atomic kind.
represents a system: atoms, molecules, their pos,vel,...
wrapper to abstract the force evaluation of the various methods
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...