43#include "./base/base_uses.f90"
49 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tddfpt2_smearing_methods'
51 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
69 INTENT(IN),
POINTER :: gs_mos
70 INTEGER,
INTENT(in) :: log_unit
72 CHARACTER(len=*),
PARAMETER :: routinen =
'tddfpt_smeared_occupation'
74 INTEGER :: handle, iocc, ispin, nspins
75 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nocc, nvirt
76 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_evals, occup
81 CALL timeset(routinen, handle)
85 NULLIFY (mos, scf_control)
86 CALL get_qs_env(qs_env, mos=mos, scf_control=scf_control)
88 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
89 smear => qs_env%scf_control%smear
91 cpabort(
"Smeared input section no longer associated.")
94 IF (debug_this_module)
THEN
95 NULLIFY (mo_evals, occup)
96 ALLOCATE (nocc(nspins), nvirt(nspins))
98 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, occupation_numbers=occup)
99 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=nocc(ispin))
100 CALL cp_fm_get_info(gs_mos(ispin)%mos_virt, ncol_global=nvirt(ispin))
101 IF (log_unit > 0)
THEN
102 DO iocc = 1, nocc(ispin)
103 WRITE (log_unit,
'(A,F14.5)')
"Occupation numbers", occup(iocc)
109 CALL allocate_fermi_params(qs_env, gs_mos)
110 CALL compute_fermia(qs_env, gs_mos, log_unit)
112 CALL timestop(handle)
121 SUBROUTINE compute_fermia(qs_env, gs_mos, log_unit)
125 INTENT(IN),
POINTER :: gs_mos
126 INTEGER,
INTENT(IN) :: log_unit
128 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_fermia'
130 INTEGER :: handle, iocc, ispin, nspins
131 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: nocc
132 REAL(kind=
dp) :: maxvalue, mu
133 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia, mo_evals, occup
140 CALL timeset(routinen, handle)
142 NULLIFY (mos, dft_control, tddfpt_control, scf_control)
143 CALL get_qs_env(qs_env, dft_control=dft_control, scf_control=scf_control)
144 tddfpt_control => dft_control%tddfpt2_control
150 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
151 smear => qs_env%scf_control%smear
153 cpabort(
"Smeared input section no longer associated.")
156 IF (debug_this_module .AND. (log_unit > 0))
THEN
157 WRITE (log_unit,
'(A,F14.5)')
"Smearing temperature", smear%electronic_temperature
160 NULLIFY (mo_evals, occup)
161 ALLOCATE (nocc(nspins))
163 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, occupation_numbers=occup, mu=mu)
164 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, ncol_global=nocc(ispin))
168 fermia => tddfpt_control%smeared_occup(ispin)%fermia
169 DO iocc = 1, nocc(ispin)
170 maxvalue = mu + 3.0_dp*smear%electronic_temperature - mo_evals(iocc)
172 fermia(iocc) = max(0.0_dp, maxvalue)
173 IF (debug_this_module)
THEN
174 IF (log_unit > 0)
WRITE (log_unit,
'(A,F14.5)')
"Fermi smearing parameter alpha", fermia(iocc)
179 CALL timestop(handle)
180 END SUBROUTINE compute_fermia
196 TYPE(
cp_fm_type),
INTENT(in) :: aop_evects, evects, s_evects, mos_occ
197 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia
200 CHARACTER(len=*),
PARAMETER :: routinen =
'add_smearing_aterm'
202 INTEGER :: handle, iounit, nactive, nao
204 TYPE(
cp_fm_type) :: ccsxvec, csxvec, cvec, sccsxvec
209 CALL timeset(routinen, handle)
215 NULLIFY (dft_control, tddfpt_control)
216 CALL get_qs_env(qs_env, dft_control=dft_control)
217 tddfpt_control => dft_control%tddfpt2_control
220 nrow_global=nao, ncol_global=nactive)
225 NULLIFY (matrix_struct_tmp)
227 ncol_global=nactive, template_fmstruct=matrix_struct)
231 CALL parallel_gemm(
'T',
'N', nactive, nactive, nao, 1.0_dp, &
232 mos_occ, s_evects, 0.0_dp, csxvec)
236 CALL parallel_gemm(
'N',
'N', nao, nactive, nactive, 1.0_dp, &
237 cvec, csxvec, 0.0_dp, ccsxvec)
241 sccsxvec, ncol=nactive, alpha=1.0_dp, beta=0.0_dp)
249 CALL timestop(handle)
262 REAL(kind=
dp),
INTENT(in) :: evals
264 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_fermib'
266 INTEGER :: handle, iocc, iounit, ispin, jocc, &
268 REAL(kind=
dp) :: dummykts, nelec
269 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: interocc, occup_im
270 REAL(kind=
dp),
DIMENSION(:),
POINTER :: fermia, mo_evals, occup, occuptmp
271 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: fermib
279 CALL timeset(routinen, handle)
285 NULLIFY (mos, scf_control)
286 CALL get_qs_env(qs_env, mos=mos, scf_control=scf_control)
288 IF (
ASSOCIATED(qs_env%scf_control%smear))
THEN
289 smear => qs_env%scf_control%smear
291 cpabort(
"Smeared input section no longer associated.")
294 NULLIFY (dft_control, tddfpt_control)
295 CALL get_qs_env(qs_env, dft_control=dft_control)
296 tddfpt_control => dft_control%tddfpt2_control
298 NULLIFY (fermib, fermia)
299 nspins =
SIZE(gs_mos)
303 fermib => dft_control%tddfpt2_control%smeared_occup(ispin)%fermib
304 fermia => dft_control%tddfpt2_control%smeared_occup(ispin)%fermia
308 NULLIFY (mo_evals, occup)
309 CALL get_mo_set(mos(ispin), eigenvalues=mo_evals, occupation_numbers=occup)
312 IF (smear%fixed_mag_mom == -1.0_dp)
THEN
313 nelec = real(mos(ispin)%nelectron,
dp)
315 nelec = mos(ispin)%n_el_f
320 CALL get_mo_set(mos(ispin), occupation_numbers=occuptmp)
321 ALLOCATE (occup_im(nactive, nactive), interocc(nactive, nactive))
326 CALL fermi(occuptmp, nelec, dummykts, mos(ispin)%eigenvalues, mos(ispin)%eigenvalues(iocc), &
327 smear%electronic_temperature, mos(ispin)%maxocc)
329 cpabort(
"TDDFT with smearing only works with Fermi-Dirac distribution.")
332 occup_im(iocc, jocc) = occuptmp(jocc)
339 interocc(iocc, jocc) = (occup(iocc) - occup(jocc))/(mo_evals(iocc) - mo_evals(jocc) - evals)
340 fermib(iocc, jocc) = fermib(iocc, jocc) + occup(iocc)*occup_im(iocc, jocc) &
341 + occup(jocc)*occup_im(jocc, iocc) &
342 + fermia(jocc)*interocc(iocc, jocc)*occup_im(jocc, iocc)
346 IF (debug_this_module .AND. (iounit > 0))
THEN
349 WRITE (iounit,
'(A,F14.5)')
"Fermi smearing parameter beta,", fermib(iocc, jocc)
354 DEALLOCATE (occup_im)
355 DEALLOCATE (interocc)
359 CALL timestop(handle)
366 SUBROUTINE allocate_fermi_params(qs_env, gs_mos)
370 INTENT(IN),
POINTER :: gs_mos
372 CHARACTER(len=*),
PARAMETER :: routinen =
'allocate_fermi_params'
374 INTEGER :: handle, ispin, nocc, nspins
376 TYPE(
smeared_type),
DIMENSION(:),
POINTER :: smeared_occup
379 CALL timeset(routinen, handle)
381 NULLIFY (dft_control, tddfpt_control)
382 CALL get_qs_env(qs_env, dft_control=dft_control)
383 tddfpt_control => dft_control%tddfpt2_control
385 NULLIFY (smeared_occup)
386 smeared_occup => dft_control%tddfpt2_control%smeared_occup
387 nspins =
SIZE(gs_mos)
388 ALLOCATE (smeared_occup(nspins))
392 ALLOCATE (smeared_occup(ispin)%fermia(nocc))
393 ALLOCATE (smeared_occup(ispin)%fermib(nocc, nocc))
395 dft_control%tddfpt2_control%smeared_occup => smeared_occup
397 CALL timestop(handle)
398 END SUBROUTINE allocate_fermi_params
405 TYPE(
smeared_type),
DIMENSION(:),
POINTER :: smeared_occup
409 IF (
ASSOCIATED(smeared_occup))
THEN
410 DO ispin = 1,
SIZE(smeared_occup)
411 IF (
ASSOCIATED(smeared_occup(ispin)%fermia))
THEN
412 DEALLOCATE (smeared_occup(ispin)%fermia)
413 DEALLOCATE (smeared_occup(ispin)%fermib)
414 NULLIFY (smeared_occup(ispin)%fermia, smeared_occup(ispin)%fermib)
417 DEALLOCATE (smeared_occup)
418 NULLIFY (smeared_occup)
431 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(in) :: evects
433 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(in) :: mos_occ, s_c0
435 CHARACTER(LEN=*),
PARAMETER :: routinen =
'orthogonalize_smeared_occupation'
437 INTEGER :: handle, iocc, iounit, ispin, nactive, &
439 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: bscale
440 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: evortholocal, subevects, subevectsresult
441 REAL(kind=
dp),
DIMENSION(:),
POINTER :: occup
442 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: fermib
445 TYPE(
cp_fm_type) :: betascc, cvec, evortho, subevectsfm, &
454 CALL timeset(routinen, handle)
462 NULLIFY (dft_control, tddfpt_control)
463 CALL get_qs_env(qs_env, dft_control=dft_control)
464 tddfpt_control => dft_control%tddfpt2_control
466 CALL cp_fm_get_info(matrix=evects(1), matrix_struct=matrix_struct, &
467 nrow_global=nao, ncol_global=nactive)
470 nspins =
SIZE(evects)
472 CALL cp_fm_get_info(evects(1), para_env=para_env, context=blacs_env_global)
474 NULLIFY (matrix_struct)
475 CALL cp_fm_struct_create(matrix_struct, nrow_global=nao, ncol_global=nao, context=blacs_env_global)
479 ALLOCATE (evortholocal(nao, nactive))
480 ALLOCATE (bscale(nactive))
483 NULLIFY (matrix_struct)
484 CALL cp_fm_get_info(matrix=mos_occ(ispin), matrix_struct=matrix_struct)
488 CALL get_mo_set(mos(ispin), occupation_numbers=occup, mo_coeff=mo_coeff)
491 IF (.NOT.
ASSOCIATED(dft_control%tddfpt2_control%smeared_occup))
THEN
492 cpabort(
"Smeared occupation intermediates not associated.")
494 fermib => dft_control%tddfpt2_control%smeared_occup(ispin)%fermib
498 bscale(:) = fermib(iocc, :)
501 CALL parallel_gemm(
'N',
'T', nao, nao, nactive, 1.0_dp, cvec, s_c0(ispin), 0.0_dp, betascc)
504 NULLIFY (matrix_struct)
505 CALL cp_fm_struct_create(matrix_struct, nrow_global=nao, ncol_global=1, context=blacs_env_global)
510 ALLOCATE (subevects(nao, 1))
511 ALLOCATE (subevectsresult(nao, 1))
513 start_row=1, start_col=iocc, n_rows=nao, n_cols=1)
515 start_row=1, start_col=1, n_rows=nao, n_cols=1)
518 subevectsfm, 0.0_dp, subevectsresultfm)
521 start_row=1, start_col=1, n_rows=nao, n_cols=1)
523 start_row=1, start_col=iocc, n_rows=nao, n_cols=1)
524 DEALLOCATE (subevects, subevectsresult)
534 DEALLOCATE (evortholocal)
541 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_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
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....
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_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
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
deal with the Fermi distribution, compute it, fix mu, get derivs
subroutine, public fermi(f, n, kts, e, mu, t, maxocc, estate, festate)
returns occupations according to Fermi-Dirac statistics for a given set of energies and fermi level....
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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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)
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)
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
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