Octopus
xc_oep_photon.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!! Copyright (C) 2012-2013 M. Gruning, P. Melo, M. Oliveira
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
23 use comm_oct_m
24 use debug_oct_m
28 use global_oct_m
29 use grid_oct_m
32 use, intrinsic :: iso_fortran_env
39 use mesh_oct_m
41 use mpi_oct_m
45 use parser_oct_m
49 use space_oct_m
56 use xc_oct_m
57 use xc_oep_oct_m
58 use xc_f03_lib_m
60
61 implicit none
62
63 private
64 public :: &
70
71 type, extends(xc_oep_t) :: xc_oep_photon_t
72 private
73 logical :: coc_translation
74 type(photon_mode_t), public :: pt
75 type(lr_t) :: photon_lr
76 logical, public :: rm_ee_interaction
77 end type xc_oep_photon_t
78
79contains
80
81 ! ---------------------------------------------------------
82 subroutine xc_oep_photon_init(oep, namespace, family, gr, st, mc, space)
83 type(xc_oep_photon_t), intent(inout) :: oep
84 type(namespace_t), intent(in) :: namespace
85 integer, intent(in) :: family
86 type(grid_t), intent(inout) :: gr
87 type(states_elec_t), intent(in) :: st
88 type(multicomm_t), intent(in) :: mc
89 class(space_t), intent(in) :: space
90
91 push_sub(xc_oep_photon_init)
92
93 if(bitand(family, xc_family_oep) == 0) then
94 oep%level = oep_level_none
95 pop_sub(xc_oep_photon_init)
96 return
97 end if
98
99 oep%type = oep_type_photons
100
101 call messages_obsolete_variable(namespace, 'OEP_Level', 'OEPLevel')
102 call parse_variable(namespace, 'OEPLevel', oep_level_kli, oep%level)
103 if(.not. varinfo_valid_option('OEPLevel', oep%level)) call messages_input_error(namespace, 'OEPLevel')
104
105 if(oep%level /= oep_level_none) then
106 call messages_experimental("EnablePhotons = yes")
107 call photon_mode_init(oep%pt, namespace, space%dim)
108 call photon_mode_set_n_electrons(oep%pt, st%qtot)
109 if (oep%pt%nmodes > 1) then
110 call messages_not_implemented('Photon OEP for more than one photon mode.')
111 end if
112 if (oep%level == oep_level_full .and. st%d%nspin /= unpolarized) then
113 call messages_not_implemented('Spin-polarized calculations with photon OEP.')
114 end if
116 if (states_are_complex(st)) then
117 call messages_not_implemented('Photon OEP with complex wavefunctions.')
118 end if
119
120 if (st%nik > st%d%ispin .and. oep%level == oep_level_full) then
121 call messages_not_implemented("Full OEP for periodic systems", namespace=namespace)
122 end if
123 if (st%nik > st%d%ispin .and. st%d%ispin==spinors) then
124 call messages_not_implemented("OEP for periodic systems with spinors", namespace=namespace)
125 end if
126
127 safe_allocate(oep%pt%correlator(1:gr%np, 1:oep%pt%nmodes))
128 oep%pt%correlator = m_zero
129
130 call photon_mode_compute_dipoles(oep%pt, gr)
131 end if
132
133 if(oep%level == oep_level_full) then
134
135 call messages_experimental("Full OEP")
136 !%Variable OEPMixing
137 !%Type float
138 !%Default 1.0
139 !%Section Hamiltonian::XC
140 !%Description
141 !% The linear mixing factor used to solve the Sternheimer
142 !% equation in the full OEP procedure.
143 !%End
144 call messages_obsolete_variable(namespace, 'OEP_Mixing', 'OEPMixing')
145 call parse_variable(namespace, 'OEPMixing', m_one, oep%mixing)
146
147 !%Variable OEPMixingScheme
148 !%Type integer
149 !%Default 1.0
150 !%Section Hamiltonian::XC
151 !%Description
152 !%Different Mixing Schemes are possible
153 !%Option OEP_MIXING_SCHEME_CONST 1
154 !%Use a constant
155 !%Reference: S. Kuemmel and J. Perdew, <i>Phys. Rev. Lett.</i> <b>90</b>, 4, 043004 (2003)
156 !%Option OEP_MIXING_SCHEME_BB 2
157 !%Use the Barzilai-Borwein (BB) Method
158 !%Reference: T. W. Hollins, S. J. Clark, K. Refson, and N. I. Gidopoulos,
159 !%<i>Phys. Rev. B</i> <b>85<\b>, 235126 (2012)
160 !%Option OEP_MIXING_SCHEME_DENS 3
161 !%Use the inverse of the electron density
162 !%Reference: S. Kuemmel and J. Perdew, <i>Phys. Rev. B</i> <b>68</b>, 035103 (2003)
163 !%End
164 call parse_variable(namespace, 'OEPMixingScheme', oep_mixing_scheme_const, oep%mixing_scheme)
165
166 if (oep%mixing_scheme == oep_mixing_scheme_bb) then
167 safe_allocate(oep%vxc_old(1:gr%np,st%d%ispin))
168 safe_allocate(oep%ss_old(1:gr%np,st%d%ispin))
169 oep%vxc_old = m_zero
170 oep%ss_old = m_zero
171 end if
172
173 oep%norm2ss = m_zero
174 end if
176 ! obtain the spin factors
177 call xc_oep_spinfactor(oep, st%d%nspin)
178
179 ! This variable will keep vxc across iterations
180 if ((st%d%ispin==3) .or. oep%level == oep_level_full) then
181 safe_allocate(oep%vxc(1:gr%np,st%d%nspin))
182 else
183 safe_allocate(oep%vxc(1:gr%np,1:min(st%d%nspin, 2)))
184 end if
185 oep%vxc = m_zero
186
187 !%Variable KLIPhotonCOC
188 !%Type logical
189 !%Default .false.
190 !%Section Hamiltonian::XC
191 !%Description
192 !% Activate the center of charge translation of the electric dipole operator which should avoid the dependence of the photon KLI on an permanent dipole.
193 !%End
194
195 ! when performing full OEP, we need to solve a linear equation
196 call scf_tol_init(oep%scftol, namespace, st%qtot, def_maximumiter=10)
197 call linear_solver_init(oep%solver, namespace, gr, states_are_real(st), mc, space)
198 call lr_init(oep%lr)
199 call lr_init(oep%photon_lr)
200 call parse_variable(namespace, 'KLIPhotonCOC', .false., oep%coc_translation)
201
202 !%Variable OEPRemoveElectron
203 !%Type logical
204 !%Default .false.
205 !%Section Hamiltonian::XC
206 !%Description
207 !% Remove electron-electron interaction in OEP-Photon calculations
208 !%End
209
210 call parse_variable(namespace, 'OEPRemoveElectron', .false., oep%rm_ee_interaction)
211
212 ! the linear equation has to be more converged if we are to attain the required precision
213 !oep%lr%conv_abs_dens = oep%lr%conv_abs_dens / (oep%mixing)
214
215 if(st%d%kpt%parallel) then
216 call messages_not_implemented("OEP parallel in spin/k-points", namespace=namespace)
217 end if
218
219 pop_sub(xc_oep_photon_init)
220 end subroutine xc_oep_photon_init
221
222
223 ! ---------------------------------------------------------
224 subroutine xc_oep_photon_end(oep)
225 type(xc_oep_photon_t), intent(inout) :: oep
226
227 push_sub(xc_oep_photon_end)
228
229 call xc_oep_end(oep)
230
231 if(oep%level /= oep_level_none) then
232 call lr_dealloc(oep%photon_lr)
233 call photon_mode_end(oep%pt)
234 end if
235
236 pop_sub(xc_oep_photon_end)
237 end subroutine xc_oep_photon_end
238
239#include "xc_oep_qed_inc.F90"
240
241#include "undef.F90"
242#include "real.F90"
243#include "xc_kli_photon_inc.F90"
244#include "xc_oep_photon_inc.F90"
245
246#include "undef.F90"
247#include "complex.F90"
248#include "xc_kli_photon_inc.F90"
249#include "xc_oep_photon_inc.F90"
250
251end module xc_oep_photon_oct_m
252
253!! Local Variables:
254!! mode: f90
255!! coding: utf-8
256!! End:
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
integer, parameter, public unpolarized
Parameters...
integer, parameter, public spinors
real(real64), parameter, public m_zero
Definition: global.F90:187
real(real64), parameter, public m_one
Definition: global.F90:188
This module implements the underlying real-space grid.
Definition: grid.F90:117
subroutine, public lr_init(lr)
subroutine, public lr_dealloc(lr)
subroutine, public linear_solver_init(this, namespace, gr, states_are_real, mc, space)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:118
subroutine, public messages_not_implemented(feature, namespace)
Definition: messages.F90:1125
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:1057
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:723
subroutine, public messages_experimental(name, namespace)
Definition: messages.F90:1097
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
subroutine, public photon_mode_compute_dipoles(this, mesh)
Computes the polarization dipole.
subroutine, public photon_mode_end(this)
subroutine, public photon_mode_set_n_electrons(this, qtot)
subroutine, public photon_mode_init(this, namespace, dim, photon_free)
subroutine, public scf_tol_init(this, namespace, qtot, def_maximumiter, tol_scheme)
Definition: scf_tol.F90:160
pure logical function, public states_are_complex(st)
pure logical function, public states_are_real(st)
This module handles spin dimensions of the states and the k-point distribution.
Definition: xc.F90:114
integer, parameter, public oep_level_none
the OEP levels
Definition: xc_oep.F90:172
subroutine, public xc_oep_spinfactor(oep, nspin)
A couple of auxiliary functions for oep.
Definition: xc_oep.F90:396
subroutine, public xc_oep_end(oep)
Definition: xc_oep.F90:356
integer, parameter, public oep_type_photons
Definition: xc_oep.F90:184
integer, parameter, public oep_mixing_scheme_bb
Definition: xc_oep.F90:178
integer, parameter, public oep_level_full
Definition: xc_oep.F90:172
integer, parameter, public oep_mixing_scheme_const
Mixing schemes.
Definition: xc_oep.F90:178
integer, parameter, public oep_level_kli
Definition: xc_oep.F90:172
subroutine, public zxc_oep_photon_calc(oep, namespace, xcs, gr, hm, st, space, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....
subroutine, public xc_oep_photon_init(oep, namespace, family, gr, st, mc, space)
subroutine, public xc_oep_photon_end(oep)
subroutine, public dxc_oep_photon_calc(oep, namespace, xcs, gr, hm, st, space, ex, ec, vxc)
This file handles the evaluation of the OEP potential, in the KLI or full OEP as described in S....