53#include "./base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_fod'
70 PURE FUNCTION fod_weights(occupation, eigenvalues, mu, maxocc)
RESULT(weights)
71 REAL(
dp),
DIMENSION(:),
INTENT(IN) :: occupation, eigenvalues
72 REAL(
dp),
INTENT(IN) :: mu, maxocc
73 REAL(
dp),
DIMENSION(SIZE(occupation)) :: weights
75 WHERE (eigenvalues <= mu)
76 weights = maxocc - occupation
100 CALL get_qs_env(qs_env, dft_control=dft_control, scf_control=scf_control, do_kpoints=do_kpoints)
101 IF (do_kpoints) cpabort(
"FOD currently supports Gamma-point calculations only.")
102 IF (.NOT. dft_control%qs_control%gpw) cpabort(
"FOD currently requires the GPW method.")
103 IF (qs_env%run_rtp) cpabort(
"FOD is not supported for real-time propagation.")
104 IF (.NOT. scf_control%smear%do_smear .OR. scf_control%smear%method /=
smear_fermi_dirac)
THEN
105 cpabort(
"FOD requires SCF%SMEAR with METHOD FERMI_DIRAC.")
107 IF (scf_control%smear%electronic_temperature <= 0.0_dp)
THEN
108 cpabort(
"FOD requires a positive electronic temperature.")
123 INTEGER,
INTENT(IN) :: output_unit
125 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_scf_post_fod'
127 INTEGER :: handle, iatom, ikind, ispin, unit_nr
128 LOGICAL :: write_cube
129 REAL(
dp) :: grid_integral, nfod, spin_integral
130 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: weights, zcharge
140 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
149 CALL timeset(routinen, handle)
151 CALL get_qs_env(qs_env, mos=mos, scf_control=scf_control)
152 cpassert(
ASSOCIATED(mos))
156 NULLIFY (rho, rho_ao, ks_env, pw_env, pool, subsys, particles, matrix_fod)
158 CALL get_qs_env(qs_env, rho=rho, ks_env=ks_env, pw_env=pw_env, subsys=subsys, qs_kind_set=qs_kind_set)
161 ALLOCATE (zcharge(particles%n_els))
162 DO iatom = 1, particles%n_els
163 ikind = particles%els(iatom)%atomic_kind%kind_number
164 CALL get_qs_kind(qs_kind_set(ikind), zeff=zcharge(iatom))
167 CALL pool%create_pw(fod_r)
168 CALL pool%create_pw(tmp_r)
169 CALL pool%create_pw(tmp_g)
174 grid_integral = 0.0_dp
175 DO ispin = 1,
SIZE(mos)
176 cpassert(mos(ispin)%nmo > 0)
177 IF (mos(ispin)%occupation_numbers(mos(ispin)%nmo) > &
178 mos(ispin)%maxocc*scf_control%smear%eps_fermi_dirac)
THEN
179 cpwarn(
"FOD: the highest available orbital is occupied; increase ADDED_MOS and check convergence.")
181 ALLOCATE (weights(mos(ispin)%nmo))
182 weights(:) =
fod_weights(mos(ispin)%occupation_numbers, mos(ispin)%eigenvalues, &
183 mos(ispin)%mu, mos(ispin)%maxocc)
184 nfod = nfod + sum(weights)
187 mo_fod%occupation_numbers = weights
188 mo_fod%uniform_occupation = .false.
190 mo_fod%homo = mo_fod%nmo
191 ALLOCATE (matrix_fod)
192 CALL dbcsr_copy(matrix_fod, rho_ao(ispin)%matrix)
195 total_rho=spin_integral, ks_env=ks_env)
196 fod_r%array = fod_r%array + tmp_r%array
198 grid_integral = grid_integral - spin_integral
200 DEALLOCATE (matrix_fod)
206 IF (output_unit > 0)
THEN
207 WRITE (output_unit,
'(T2,A,T61,F20.10)')
"FOD| N_FOD (orbital sum)", nfod
208 IF (write_cube)
WRITE (output_unit,
'(T2,A,T61,F20.10)')
"FOD| Grid integral", grid_integral
212 middle_name=
"FOD", file_position=
"REWIND", log_filename=.false.)
214 CALL cp_pw_to_cube(fod_r, unit_nr,
"FRACTIONAL OCCUPATION DENSITY [e/bohr^3]", &
215 particles=particles, zeff=zcharge, stride=
section_get_ivals(fod_section,
"STRIDE"))
217 CALL pool%give_back_pw(fod_r)
218 CALL pool%give_back_pw(tmp_r)
219 CALL pool%give_back_pw(tmp_g)
222 CALL timestop(handle)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public grimme2015fod
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_release(matrix)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
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,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
A wrapper around pw_to_cube() which accepts particle_list_type.
subroutine, public cp_pw_to_cube(pw, unit_nr, title, particles, zeff, stride, max_file_size_mb, zero_tails, silent, mpi_io)
...
Defines the basic variable types.
integer, parameter, public dp
represent a simple array based list of the given type
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
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_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
collects routines that calculate density matrices
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.
Fractional occupation number weighted density (Grimme and Hansen).
subroutine, public qs_fod_validate(input, logger, qs_env)
Reject unsupported FOD settings before starting an expensive SCF calculation.
pure real(dp) function, dimension(size(occupation)), public fod_weights(occupation, eigenvalues, mu, maxocc)
Hole weights below the chemical potential, particle weights above it.
subroutine, public qs_scf_post_fod(input, logger, qs_env, output_unit)
Print the orbital FOD sum and, optionally, its real-space density.
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.
Definition and initialisation of the mo data type.
subroutine, public duplicate_mo_set(mo_set_new, mo_set_old)
allocate a new mo_set, and copy the old data
subroutine, public deallocate_mo_set(mo_set)
Deallocate a wavefunction data structure.
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...
types that represent a quickstep subsys
subroutine, public qs_subsys_get(subsys, atomic_kinds, atomic_kind_set, particles, particle_set, local_particles, molecules, molecule_set, molecule_kinds, molecule_kind_set, local_molecules, para_env, colvar_p, shell_particles, core_particles, gci, multipoles, natom, nparticle, ncore, nshell, nkind, atprop, virial, results, cell, cell_ref, use_ref_cell, energy, force, qs_kind_set, cp_subsys, nelectron_total, nelectron_spin)
...
parameters that control an scf iteration
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a list of objects
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.