(git:374b731)
Loading...
Searching...
No Matches
excited_states.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 Routines for total energy and forces of excited states
10!> \par History
11!> 01.2020 created
12!> \author JGH
13! **************************************************************************************************
34 USE qs_p_env_types, ONLY: p_env_release,&
39#include "./base/base_uses.f90"
40
41 IMPLICIT NONE
42
43 PRIVATE
44
45! *** Global parameters ***
46
47 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'excited_states'
48
49 PUBLIC :: excited_state_energy
50
51CONTAINS
52
53! **************************************************************************************************
54!> \brief Excited state energy and forces
55!>
56!> \param qs_env ...
57!> \param calculate_forces ...
58!> \par History
59!> 03.2014 created
60!> \author JGH
61! **************************************************************************************************
62 SUBROUTINE excited_state_energy(qs_env, calculate_forces)
63 TYPE(qs_environment_type), POINTER :: qs_env
64 LOGICAL, INTENT(IN), OPTIONAL :: calculate_forces
65
66 CHARACTER(len=*), PARAMETER :: routinen = 'excited_state_energy'
67
68 INTEGER :: handle, unit_nr
69 INTEGER, ALLOCATABLE, DIMENSION(:) :: natom_of_kind
70 TYPE(atomic_kind_type), DIMENSION(:), POINTER :: atomic_kind_set
71 TYPE(cp_logger_type), POINTER :: logger
72 TYPE(dft_control_type), POINTER :: dft_control
73 TYPE(excited_energy_type), POINTER :: ex_env
74 TYPE(qs_energy_type), POINTER :: energy
75 TYPE(qs_force_type), DIMENSION(:), POINTER :: ks_force, lr_force
76 TYPE(qs_p_env_type) :: p_env
77 TYPE(section_vals_type), POINTER :: tdlr_section
78
79 CALL timeset(routinen, handle)
80
81 ! Check for energy correction
82 IF (qs_env%excited_state) THEN
83 logger => cp_get_default_logger()
84 IF (logger%para_env%is_source()) THEN
85 unit_nr = cp_logger_get_default_unit_nr(logger, local=.true.)
86 ELSE
87 unit_nr = -1
88 END IF
89
90 CALL get_qs_env(qs_env, exstate_env=ex_env, energy=energy)
91
92 energy%excited_state = ex_env%evalue
93 energy%total = energy%total + ex_env%evalue
94 IF (calculate_forces) THEN
95 IF (unit_nr > 0) THEN
96 WRITE (unit_nr, '(T2,A,A,A,A,A)') "!", repeat("-", 27), &
97 " Excited State Forces ", repeat("-", 28), "!"
98 END IF
99 ! prepare force array
100 CALL get_qs_env(qs_env, force=ks_force, atomic_kind_set=atomic_kind_set)
101 CALL get_atomic_kind_set(atomic_kind_set=atomic_kind_set, natom_of_kind=natom_of_kind)
102 NULLIFY (lr_force)
103 CALL allocate_qs_force(lr_force, natom_of_kind)
104 DEALLOCATE (natom_of_kind)
105 CALL zero_qs_force(lr_force)
106 CALL set_qs_env(qs_env, force=lr_force)
107 !
108 tdlr_section => section_vals_get_subs_vals(qs_env%input, "PROPERTIES%TDDFPT%LINRES")
109 CALL response_equation(qs_env, p_env, ex_env%cpmos, unit_nr, tdlr_section)
110 !
111 CALL get_qs_env(qs_env, dft_control=dft_control)
112 IF (dft_control%qs_control%semi_empirical) THEN
113 cpabort("Not available")
114 ELSEIF (dft_control%qs_control%dftb) THEN
115 cpabort("Not available")
116 ELSEIF (dft_control%qs_control%xtb) THEN
117 CALL response_force_xtb(qs_env, p_env, ex_env%matrix_hz, ex_env, debug=ex_env%debug_forces)
118 ELSE
119 ! KS-DFT
120 CALL response_force(qs_env=qs_env, vh_rspace=ex_env%vh_rspace, &
121 vxc_rspace=ex_env%vxc_rspace, vtau_rspace=ex_env%vtau_rspace, &
122 vadmm_rspace=ex_env%vadmm_rspace, matrix_hz=ex_env%matrix_hz, &
123 matrix_pz=ex_env%matrix_px1, matrix_pz_admm=p_env%p1_admm, &
124 matrix_wz=p_env%w1, &
125 p_env=p_env, ex_env=ex_env, &
126 debug=ex_env%debug_forces)
127 END IF
128 ! add TD and KS forces
129 CALL get_qs_env(qs_env, force=lr_force)
130 CALL sum_qs_force(ks_force, lr_force)
131 CALL set_qs_env(qs_env, force=ks_force)
132 CALL deallocate_qs_force(lr_force)
133 !
134 CALL ex_properties(qs_env, ex_env%matrix_pe, p_env)
135 !
136 CALL p_env_release(p_env)
137 !
138 ELSE
139 IF (unit_nr > 0) THEN
140 WRITE (unit_nr, '(T2,A,A,A,A,A)') "!", repeat("-", 27), &
141 " Excited State Energy ", repeat("-", 28), "!"
142 WRITE (unit_nr, '(T2,A,T75,I6)') "Results for Excited State Nr.", abs(ex_env%state)
143 WRITE (unit_nr, '(T2,A,T65,F16.10)') "Excitation Energy [Hartree] ", ex_env%evalue
144 WRITE (unit_nr, '(T2,A,T65,F16.10)') "Total Energy [Hartree]", energy%total
145 END IF
146 END IF
147
148 IF (unit_nr > 0) THEN
149 WRITE (unit_nr, '(T2,A,A,A)') "!", repeat("-", 77), "!"
150 END IF
151
152 END IF
153
154 CALL timestop(handle)
155
156 END SUBROUTINE excited_state_energy
157
158! **************************************************************************************************
159
160END MODULE excited_states
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Routines for property calculations of excited states.
subroutine, public ex_properties(qs_env, matrix_pe, p_env)
...
Routines for total energy and forces of excited states.
subroutine, public excited_state_energy(qs_env, calculate_forces)
Excited state energy and forces.
Types for excited states potential energies.
objects that represent the structure of input sections and the data contained in an input section
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 set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Set the QUICKSTEP environment.
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.
subroutine, public sum_qs_force(qs_force_out, qs_force_in)
Sum up two qs_force entities qs_force_out = qs_force_out + qs_force_in.
subroutine, public deallocate_qs_force(qs_force)
Deallocate a Quickstep force data structure.
subroutine, public zero_qs_force(qs_force)
Initialize a Quickstep force data structure.
subroutine, public allocate_qs_force(qs_force, natom_of_kind)
Allocate a Quickstep force data structure.
basis types for the calculation of the perturbation of density theory.
subroutine, public p_env_release(p_env)
relases the given p_env (see doc/ReferenceCounting.html)
Calculate the CPKS equation and the resulting forces.
subroutine, public response_force_xtb(qs_env, p_env, matrix_hz, ex_env, debug)
...
subroutine, public response_force(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, matrix_hz, matrix_pz, matrix_pz_admm, matrix_wz, zehartree, zexc, zexc_aux_fit, rhopz_r, p_env, ex_env, debug)
...
subroutine, public response_equation(qs_env, p_env, cpmos, iounit, lr_section)
Initializes vectors for MO-coefficient based linear response solver and calculates response density,...
Provides all information about an atomic kind.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information on the excited states energy.
Represent a qs system that is perturbed. Can calculate the linear operator and the rhs of the system ...