41#include "./base/base_uses.f90"
47 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tddfpt2_smearing_methods'
49 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
67 INTENT(IN),
POINTER :: gs_mos
68 INTEGER,
INTENT(in) :: log_unit
70 CHARACTER(len=*),
PARAMETER :: routinen =
'tddfpt_smeared_occupation'
72 INTEGER :: handle, iocc, ispin, nspins
73 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nocc, nvirt
74 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_evals, occup
79 CALL timeset(routinen, handle)
83 NULLIFY (mos, scf_control)
84 CALL get_qs_env(qs_env, mos=mos, scf_control=scf_control)
86 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
87 smear => qs_env%scf_control%smear
89 cpabort(
"Smeared input section no longer associated.")
92 IF (debug_this_module)
THEN
93 NULLIFY (mo_evals, occup)
94 ALLOCATE (nocc(nspins), nvirt(nspins))
96 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, occupation_numbers=occup)
97 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=nocc(ispin))
98 CALL cp_fm_get_info(gs_mos(ispin)%mos_virt, ncol_global=nvirt(ispin))
99 IF (log_unit > 0)
THEN
100 DO iocc = 1, nocc(ispin)
101 WRITE (log_unit,
'(A,F14.5)')
"Occupation numbers", occup(iocc)
107 CALL allocate_fermi_params(qs_env, gs_mos)
108 CALL compute_fermia(qs_env, gs_mos, log_unit)
110 CALL timestop(handle)
119 SUBROUTINE compute_fermia(qs_env, gs_mos, log_unit)
123 INTENT(IN),
POINTER :: gs_mos
124 INTEGER,
INTENT(IN) :: log_unit
126 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_fermia'
128 INTEGER :: handle, iocc, ispin, nocc, nspins
129 REAL(kind=
dp) :: maxvalue, mu
130 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia, mo_evals
137 CALL timeset(routinen, handle)
139 NULLIFY (mos, dft_control, tddfpt_control, scf_control)
140 CALL get_qs_env(qs_env, dft_control=dft_control, scf_control=scf_control)
141 tddfpt_control => dft_control%tddfpt2_control
147 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
148 smear => qs_env%scf_control%smear
150 cpabort(
"Smeared input section no longer associated.")
153 IF (debug_this_module .AND. (log_unit > 0))
THEN
154 WRITE (log_unit,
'(A,F14.5)')
"Smearing temperature", smear%electronic_temperature
159 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, mu=mu)
161 fermia => tddfpt_control%smeared_occup(ispin)%fermia
163 maxvalue = mu + 3.0_dp*smear%electronic_temperature - mo_evals(iocc)
165 fermia(iocc) = max(0.0_dp, maxvalue)
166 IF (debug_this_module)
THEN
167 IF (log_unit > 0)
WRITE (log_unit,
'(A,F14.5)')
"Fermi smearing parameter alpha", fermia(iocc)
172 CALL timestop(handle)
173 END SUBROUTINE compute_fermia
189 TYPE(
cp_fm_type),
INTENT(in) :: aop_evects, evects, s_evects, mos_occ
190 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia
193 CHARACTER(len=*),
PARAMETER :: routinen =
'add_smearing_aterm'
195 INTEGER :: handle, iounit, nactive, nao
197 TYPE(
cp_fm_type) :: ccsxvec, csxvec, cvec, sccsxvec
202 CALL timeset(routinen, handle)
208 NULLIFY (dft_control, tddfpt_control)
209 CALL get_qs_env(qs_env, dft_control=dft_control)
210 tddfpt_control => dft_control%tddfpt2_control
213 nrow_global=nao, ncol_global=nactive)
218 NULLIFY (matrix_struct_tmp)
220 ncol_global=nactive, template_fmstruct=matrix_struct)
224 CALL parallel_gemm(
'T',
'N', nactive, nactive, nao, 1.0_dp, &
225 mos_occ, s_evects, 0.0_dp, csxvec)
229 CALL parallel_gemm(
'N',
'N', nao, nactive, nactive, 1.0_dp, &
230 cvec, csxvec, 0.0_dp, ccsxvec)
234 sccsxvec, ncol=nactive, alpha=1.0_dp, beta=0.0_dp)
242 CALL timestop(handle)
255 REAL(kind=
dp),
INTENT(in) :: evals
257 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_fermib'
259 INTEGER :: handle, iocc, iounit, ispin, jocc, &
261 REAL(kind=
dp) :: dummykts, interocc, nelec
262 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: occuptmp
263 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: occup_im
264 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia, mo_evals, occup
265 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: fermib
273 CALL timeset(routinen, handle)
279 NULLIFY (mos, scf_control)
280 CALL get_qs_env(qs_env, mos=mos, scf_control=scf_control)
282 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
283 smear => qs_env%scf_control%smear
285 cpabort(
"Smeared input section no longer associated.")
288 NULLIFY (dft_control, tddfpt_control)
289 CALL get_qs_env(qs_env, dft_control=dft_control)
290 tddfpt_control => dft_control%tddfpt2_control
292 NULLIFY (fermib, fermia)
293 nspins =
SIZE(gs_mos)
297 fermib => dft_control%tddfpt2_control%smeared_occup(ispin)%fermib
298 fermia => dft_control%tddfpt2_control%smeared_occup(ispin)%fermia
302 NULLIFY (mo_evals, occup)
303 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, occupation_numbers=occup)
308 ALLOCATE (occuptmp(
SIZE(mo_evals)), occup_im(nactive, nactive))
313 CALL smearocc(occuptmp, nelec, dummykts, mos(ispin)%eigenvalues, mos(ispin)%eigenvalues(iocc), &
316 cpabort(
"TDDFT with smearing only works with Fermi-Dirac distribution.")
318 occup_im(iocc, :) = occuptmp(:nactive)
324 interocc = (occup(iocc) - occup(jocc))/(mo_evals(iocc) - mo_evals(jocc) - evals)
325 fermib(iocc, jocc) = fermib(iocc, jocc) + occup(iocc)*occup_im(iocc, jocc) &
326 + occup(jocc)*occup_im(jocc, iocc) &
327 + fermia(jocc)*interocc*occup_im(jocc, iocc)
331 IF (debug_this_module .AND. (iounit > 0))
THEN
334 WRITE (iounit,
'(A,F14.5)')
"Fermi smearing parameter beta,", fermib(iocc, jocc)
339 DEALLOCATE (occuptmp, occup_im)
343 CALL timestop(handle)
350 SUBROUTINE allocate_fermi_params(qs_env, gs_mos)
354 INTENT(IN),
POINTER :: gs_mos
356 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_fermi_params'
358 INTEGER :: handle, ispin, nocc, nspins
360 TYPE(
smeared_type),
DIMENSION(:),
POINTER :: smeared_occup
363 CALL timeset(routinen, handle)
365 NULLIFY (dft_control, tddfpt_control)
366 CALL get_qs_env(qs_env, dft_control=dft_control)
367 tddfpt_control => dft_control%tddfpt2_control
369 NULLIFY (smeared_occup)
370 smeared_occup => dft_control%tddfpt2_control%smeared_occup
371 nspins =
SIZE(gs_mos)
372 ALLOCATE (smeared_occup(nspins))
376 ALLOCATE (smeared_occup(ispin)%fermia(nocc))
377 ALLOCATE (smeared_occup(ispin)%fermib(nocc, nocc))
379 dft_control%tddfpt2_control%smeared_occup => smeared_occup
381 CALL timestop(handle)
382 END SUBROUTINE allocate_fermi_params
389 TYPE(
smeared_type),
DIMENSION(:),
POINTER :: smeared_occup
393 IF (
ASSOCIATED(smeared_occup))
THEN
394 DO ispin = 1,
SIZE(smeared_occup)
395 IF (
ASSOCIATED(smeared_occup(ispin)%fermia))
THEN
396 DEALLOCATE (smeared_occup(ispin)%fermia)
397 DEALLOCATE (smeared_occup(ispin)%fermib)
398 NULLIFY (smeared_occup(ispin)%fermia, smeared_occup(ispin)%fermib)
401 DEALLOCATE (smeared_occup)
402 NULLIFY (smeared_occup)
415 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(in) :: evects
417 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(in) :: mos_occ, s_c0
419 CHARACTER(LEN=*),
PARAMETER :: routinen =
'orthogonalize_smeared_occupation'
421 INTEGER :: handle, iocc, ispin, nactive, nao, nspins
422 REAL(kind=
dp),
DIMENSION(:),
POINTER :: occup
423 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: fermib
432 CALL timeset(routinen, handle)
436 NULLIFY (dft_control, tddfpt_control)
437 CALL get_qs_env(qs_env, dft_control=dft_control)
438 tddfpt_control => dft_control%tddfpt2_control
442 nspins =
SIZE(evects)
444 CALL cp_fm_get_info(evects(1), para_env=para_env, context=blacs_env_global)
446 NULLIFY (matrix_struct)
447 CALL cp_fm_struct_create(matrix_struct, nrow_global=nao, ncol_global=nao, context=blacs_env_global)
452 CALL cp_fm_get_info(matrix=evects(ispin), matrix_struct=matrix_struct, ncol_global=nactive)
454 NULLIFY (matrix_struct)
455 CALL cp_fm_get_info(matrix=mos_occ(ispin), matrix_struct=matrix_struct)
459 CALL get_mo_set(mos(ispin), occupation_numbers=occup)
462 IF (.NOT.
ASSOCIATED(dft_control%tddfpt2_control%smeared_occup))
THEN
463 cpabort(
"Smeared occupation intermediates not associated.")
465 fermib => dft_control%tddfpt2_control%smeared_occup(ispin)%fermib
471 CALL parallel_gemm(
'N',
'T', nao, nao, nactive, 1.0_dp, cvec, s_c0(ispin), 0.0_dp, betascc)
475 evects(ispin), 0.0_dp, evortho, b_first_col=iocc, c_first_col=iocc)
485 CALL timestop(handle)
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
subroutine, public cp_fm_column_scale(matrixa, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_copy_general(source, destination, para_env)
General copy of a fm matrix to another fm matrix. Uses non-blocking MPI rather than ScaLAPACK.
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
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
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.
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, cmo_coeff)
Get the components of a MO set data structure.
subroutine, public add_smearing_aterm(qs_env, aop_evects, evects, s_evects, mos_occ, fermia, matrix_s)
...
subroutine, public compute_fermib(qs_env, gs_mos, evals)
...
subroutine, public tddfpt_smeared_occupation(qs_env, gs_mos, log_unit)
...
subroutine, public deallocate_fermi_params(smeared_occup)
...
subroutine, public orthogonalize_smeared_occupation(evects, qs_env, mos_occ, s_c0)
...
parameters that control an scf iteration
Unified smearing module supporting four methods: smear_fermi_dirac — Fermi-Dirac distribution smear_g...
subroutine, public smearocc(f, n, kts, e, mu, sigma, maxocc, method, estate, festate)
Returns occupations and smearing correction for a given set of energies and chemical potential,...
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
stores all the informations relevant to an mpi environment
Ground state molecular orbitals.
contains the parameters needed by a scf run