(git:374b731)
Loading...
Searching...
No Matches
qs_tddfpt_module.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief Performs density functional perturbation theory (tddfpt) calculations.
10!> Uses the self consistent approach. The tddfpt calculation uses the ground
11!> state of the unperturbed system as the initial state.
12! **************************************************************************************************
14 USE bibliography, ONLY: iannuzzi2005,&
15 cite_reference
21 USE dbcsr_api, ONLY: dbcsr_p_type
22 USE header, ONLY: tddfpt_header
23 USE input_constants, ONLY: oe_gllb,&
24 oe_lb,&
25 oe_none,&
26 oe_saop,&
27 oe_sic,&
41 USE qs_ks_types, ONLY: qs_ks_env_type,&
44 USE qs_rho_types, ONLY: qs_rho_type
51 USE xc_pot_saop, ONLY: add_saop_pot
52#include "./base/base_uses.f90"
53
54 IMPLICIT NONE
55
56 PRIVATE
57 PUBLIC :: tddfpt_calculation
58
59 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_tddfpt_module'
60
61CONTAINS
62
63! **************************************************************************************************
64!> \brief Performs the perturbation calculation
65!> \param qs_env ...
66! **************************************************************************************************
67 SUBROUTINE tddfpt_calculation(qs_env)
68
69 TYPE(qs_environment_type), POINTER :: qs_env
70
71 CHARACTER(LEN=*), PARAMETER :: routinen = 'tddfpt_calculation'
72
73 INTEGER :: handle, iw
74 TYPE(cp_logger_type), POINTER :: logger
75 TYPE(qs_ks_env_type), POINTER :: ks_env
76 TYPE(qs_p_env_type) :: p_env
77 TYPE(section_vals_type), POINTER :: dft_section, input
78 TYPE(tddfpt_env_type) :: t_env
79
80 NULLIFY (logger)
81 logger => cp_get_default_logger()
82 NULLIFY (input, ks_env)
83 CALL get_qs_env(qs_env, ks_env=ks_env, input=input)
84 dft_section => section_vals_get_subs_vals(input, "DFT")
85
86 IF (section_get_ival(dft_section, "EXCITATIONS") /= tddfpt_excitations) RETURN
87 CALL cite_reference(iannuzzi2005)
88
89 CALL timeset(routinen, handle)
90
91 IF (section_get_ival(dft_section, "TDDFPT%OE_CORR") /= oe_none) THEN
92 CALL orbital_eigenvalue_correction(qs_env)
93 END IF
94
95 iw = cp_print_key_unit_nr(logger, dft_section, "PRINT%PROGRAM_BANNER", &
96 extension=".Log")
97 CALL tddfpt_header(iw)
98 CALL cp_print_key_finished_output(iw, logger, dft_section, &
99 "PRINT%PROGRAM_BANNER")
100
101 !---------------------------------------!
102 ! we don't want to update the KS matrix !
103 !---------------------------------------!
104 CALL set_ks_env(ks_env, rho_changed=.false.)
105
106 CALL tddfpt_init(p_env, t_env, qs_env)
107
108 CALL eigensolver(p_env, qs_env, t_env)
109
110 CALL find_contributions(qs_env, t_env)
111
112 CALL tddfpt_cleanup(t_env, p_env)
113
114 CALL timestop(handle)
115
116 END SUBROUTINE tddfpt_calculation
117
118! **************************************************************************************************
119!> \brief Apply a special potential to obtain better
120!> orbital eigenvalues.
121!> \param qs_env ...
122! **************************************************************************************************
123 SUBROUTINE orbital_eigenvalue_correction(qs_env)
124
125 TYPE(qs_environment_type), POINTER :: qs_env
126
127 INTEGER :: oe_corr, output_unit
128 TYPE(cp_logger_type), POINTER :: logger
129 TYPE(dbcsr_p_type), DIMENSION(:), POINTER :: matrix_ks
130 TYPE(qs_energy_type), POINTER :: energy
131 TYPE(qs_rho_type), POINTER :: rho
132 TYPE(qs_scf_env_type), POINTER :: scf_env
133 TYPE(section_vals_type), POINTER :: input, xc_fun_orig, xc_fun_tmp
134
135 cpassert(ASSOCIATED(qs_env))
136
137 NULLIFY (logger, scf_env, input, energy, matrix_ks, rho)
138 logger => cp_get_default_logger()
139 output_unit = cp_logger_get_default_io_unit(logger)
140
141 IF (output_unit > 0) THEN
142 WRITE (output_unit, "(2X,A)") "", &
143 "-----------------------------------------------------------------------------", &
144 "- orbital eigenvalue correction started -", &
145 "-----------------------------------------------------------------------------", &
146 ""
147 END IF
148
149 CALL get_qs_env(qs_env, &
150 scf_env=scf_env, &
151 input=input, &
152 matrix_ks=matrix_ks, &
153 rho=rho)
154
155 !----------------------!
156 ! KS matrix without XC !
157 !----------------------!
158 xc_fun_orig => section_vals_get_subs_vals(input, "DFT%XC%XC_FUNCTIONAL")
159 CALL section_vals_retain(xc_fun_orig)
160 NULLIFY (xc_fun_tmp)
161 CALL section_vals_create(xc_fun_tmp, xc_fun_orig%section)
162 CALL section_vals_set_subs_vals(input, "DFT%XC%XC_FUNCTIONAL", xc_fun_tmp)
163 CALL section_vals_release(xc_fun_tmp)
164
165 CALL get_qs_env(qs_env, energy=energy)
166 CALL qs_ks_build_kohn_sham_matrix(qs_env, calculate_forces=.false., &
167 just_energy=.false.)
168
169 CALL section_vals_set_subs_vals(input, "DFT%XC%XC_FUNCTIONAL", xc_fun_orig)
170 CALL section_vals_release(xc_fun_orig)
171
172 CALL section_vals_val_get(input, "DFT%TDDFPT%OE_CORR", i_val=oe_corr)
173 IF (oe_corr == oe_saop .OR. &
174 oe_corr == oe_lb .OR. &
175 oe_corr == oe_gllb) THEN
176 CALL add_saop_pot(matrix_ks, qs_env, oe_corr)
177 ELSE IF (oe_corr == oe_sic) THEN
178 END IF
179
180 END SUBROUTINE orbital_eigenvalue_correction
181
182END MODULE qs_tddfpt_module
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public iannuzzi2005
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
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,...
subroutine, public tddfpt_header(iw)
...
Definition header.F:122
collects all constants needed in input so that they can be used without circular dependencies
integer, parameter, public oe_saop
integer, parameter, public tddfpt_excitations
integer, parameter, public oe_none
integer, parameter, public oe_lb
integer, parameter, public oe_sic
integer, parameter, public oe_gllb
objects that represent the structure of input sections and the data contained in an input section
recursive subroutine, public section_vals_create(section_vals, section)
creates a object where to store the values of a section
integer function, public section_get_ival(section_vals, keyword_name)
...
subroutine, public section_vals_retain(section_vals)
retains the given section values (see doc/ReferenceCounting.html)
recursive type(section_vals_type) function, pointer, public section_vals_get_subs_vals(section_vals, subsection_name, i_rep_section, can_return_null)
returns the values of the requested subsection
subroutine, public section_vals_set_subs_vals(section_vals, subsection_name, new_section_vals, i_rep_section)
replaces of the requested subsection with the one given
subroutine, public section_vals_val_get(section_vals, keyword_name, i_rep_section, i_rep_val, n_rep_val, val, l_val, i_val, r_val, c_val, l_vals, i_vals, r_vals, c_vals, explicit)
returns the requested value
recursive subroutine, public section_vals_release(section_vals)
releases the given object
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_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, 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, rhs)
Get the QUICKSTEP environment.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_build_kohn_sham_matrix(qs_env, calculate_forces, just_energy, print_active, ext_ks_matrix)
routine where the real calculations are made: the KS matrix is calculated
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, 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_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, 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_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
basis types for the calculation of the perturbation of density theory.
superstucture that hold various representations of the density and keeps track of which ones are vali...
module that contains the definitions of the scf types
subroutine, public eigensolver(p_env, qs_env, t_env)
...
Performs density functional perturbation theory (tddfpt) calculations. Uses the self consistent appro...
subroutine, public tddfpt_calculation(qs_env)
Performs the perturbation calculation.
subroutine, public find_contributions(qs_env, t_env)
...
subroutine, public tddfpt_init(p_env, t_env, qs_env)
Initialize some necessary structures for a tddfpt calculation.
subroutine, public tddfpt_cleanup(t_env, p_env)
...
Calculate the saop potential.
Definition xc_pot_saop.F:11
subroutine, public add_saop_pot(ks_matrix, qs_env, oe_corr)
...
type of a logger, at the moment it contains just a print level starting at which level it should be l...
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
Represent a qs system that is perturbed. Can calculate the linear operator and the rhs of the system ...
keeps the density in various representations, keeping track of which ones are valid.