Octopus
exchange_operator.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2018 M. Marques, A. Castro, A. Rubio, G. Bertsch, N. Tancogne-Dejean
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22 use batch_oct_m
24 use comm_oct_m
25 use debug_oct_m
29 use global_oct_m
30 use grid_oct_m
34 use math_oct_m
35 use mesh_oct_m
39 use mpi_oct_m
43 use parser_oct_m
44 use phase_oct_m
49 use space_oct_m
57 use unit_oct_m
60
61 implicit none
62
63 private
64 public :: &
82
83
84 type ace_t
85 integer :: nst
86 real(real64), allocatable :: dchi(:,:,:,:)
87 complex(real64), allocatable :: zchi(:,:,:,:)
88 end type ace_t
89
91 type(states_elec_t), public, pointer :: st => null()
92 real(real64) :: cam_omega = m_zero
93 real(real64) :: cam_alpha = m_zero
94 real(real64) :: cam_beta = m_zero
95
96 type(poisson_t) :: psolver
97
98 type(singularity_t) :: singul
99
100 logical :: useACE = .false.
101 type(ACE_t) :: ace
102 end type exchange_operator_t
103
104 type(fourier_space_op_t) :: coulb
105 ! Saved as we avoid then to recompute it,
106 ! for instance in the case of CAM functionals in isolated systems
107
108 real(real64), parameter, private :: TOL_EXX_WEIGHT = 1.0e-3_real64
109
110contains
111
112 subroutine exchange_operator_init(this, namespace, space, st, der, mc, stencil, kpoints, omega, alpha, beta)
113 type(exchange_operator_t), intent(inout) :: this
114 type(namespace_t), intent(in) :: namespace
115 class(space_t), intent(in) :: space
116 type(states_elec_t), intent(in) :: st
117 type(derivatives_t), intent(in) :: der
118 type(multicomm_t), intent(in) :: mc
119 type(stencil_t), intent(in) :: stencil
120 type(kpoints_t), intent(in) :: kpoints
121 real(real64), intent(in) :: alpha, beta, omega
122
123 push_sub(exchange_operator_init)
124
125 this%cam_omega = omega
126 this%cam_alpha = alpha
127 this%cam_beta = beta
128
129 !%Variable AdaptivelyCompressedExchange
130 !%Type logical
131 !%Default false
132 !%Section Hamiltonian
133 !%Description
134 !% (Experimental) If set to yes, Octopus will use the adaptively compressed exchange
135 !% operator (ACE) for HF and hybrid calculations, as defined in
136 !% Lin, J. Chem. Theory Comput. 2016, 12, 2242.
137 !%End
138 call parse_variable(namespace, 'AdaptivelyCompressedExchange', .false., this%useACE)
139 if (this%useACE) call messages_experimental('AdaptivelyCompressedExchange', namespace=namespace)
140
141 call singularity_init(this%singul, namespace, space, st, kpoints)
142 if (states_are_real(st)) then
143 call poisson_init(this%psolver, namespace, space, der, mc, stencil, st%qtot, &
144 force_serial = .true., verbose = .false.)
145 else
146 call poisson_init(this%psolver, namespace, space, der, mc, stencil, st%qtot, &
147 force_serial = .true., verbose = .false., force_cmplx = .true.)
148 end if
149
151 end subroutine exchange_operator_init
152
153 subroutine exchange_operator_reinit(this, omega, alpha, beta, st)
154 type(exchange_operator_t), intent(inout) :: this
155 real(real64), intent(in) :: omega, alpha, beta
156 type(states_elec_t), target, optional, intent(in) :: st
157
159
160 if (present(st)) then
161 this%st => st
162 end if
163
164 this%cam_omega = omega
165 this%cam_alpha = alpha
166 this%cam_beta = beta
167
169 end subroutine exchange_operator_reinit
170
171 subroutine exchange_operator_end(this)
172 type(exchange_operator_t), intent(inout) :: this
173
174 push_sub(exchange_operator_end)
175
176 if (associated(this%st)) then
177 if (this%st%parallel_in_states) call states_elec_parallel_remote_access_stop(this%st)
178 call states_elec_end(this%st)
179 safe_deallocate_p(this%st)
180 end if
181 nullify(this%st)
182
183 this%ace%nst = 0
184 safe_deallocate_a(this%ace%dchi)
185 safe_deallocate_a(this%ace%zchi)
187 call singularity_end(this%singul)
188 call fourier_space_op_end(coulb)
189 call poisson_end(this%psolver)
190
192 end subroutine exchange_operator_end
194 subroutine exchange_operator_rdmft_occ_apply(this, mesh, hpsib)
195 type(exchange_operator_t), intent(in) :: this
196 type(mesh_t), intent(in) :: mesh
197 class(wfs_elec_t), intent(inout) :: hpsib
198
200
201 ! multiply linear terms in hamiltonian with occupation number
202 ! nonlinear occupation number dependency occurs only in the exchange, which is treated there
203 call batch_scal(mesh%np, this%st%occ(:, hpsib%ik), hpsib)
204
207
208
209#include "undef.F90"
210#include "real.F90"
211#include "exchange_operator_inc.F90"
212
213#include "undef.F90"
214#include "complex.F90"
215#include "exchange_operator_inc.F90"
216
218
219!! Local Variables:
220!! mode: f90
221!! coding: utf-8
222!! End:
scale a batch by a constant or vector
Definition: batch_ops.F90:160
This module implements batches of mesh functions.
Definition: batch.F90:133
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:116
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dexchange_operator_hartree_apply(this, namespace, mesh, st_d, kpoints, exx_coef, psib, hpsib)
subroutine, public dexchange_operator_apply(this, namespace, space, mesh, st_d, kpoints, psib, hpsib, rdmft)
subroutine, public dexchange_operator_ace(this, namespace, mesh, st, xst, phase)
subroutine, public zexchange_operator_commute_r(this, namespace, mesh, st_d, ik, psi, gpsi)
subroutine, public zexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
subroutine, public dexchange_operator_compute_potentials(this, namespace, space, gr, st, xst, kpoints, ex, F_out)
subroutine, public dexchange_operator_commute_r(this, namespace, mesh, st_d, ik, psi, gpsi)
subroutine, public dexchange_operator_single(this, namespace, space, mesh, st_d, kpoints, ist, ik, psi, hpsi, rdmft)
subroutine, public exchange_operator_init(this, namespace, space, st, der, mc, stencil, kpoints, omega, alpha, beta)
subroutine, public zexchange_operator_hartree_apply(this, namespace, mesh, st_d, kpoints, exx_coef, psib, hpsib)
subroutine, public exchange_operator_end(this)
subroutine, public zexchange_operator_single(this, namespace, space, mesh, st_d, kpoints, ist, ik, psi, hpsi, rdmft)
subroutine, public zexchange_operator_ace(this, namespace, mesh, st, xst, phase)
subroutine, public exchange_operator_rdmft_occ_apply(this, mesh, hpsib)
subroutine, public exchange_operator_reinit(this, omega, alpha, beta, st)
subroutine, public zexchange_operator_apply(this, namespace, space, mesh, st_d, kpoints, psib, hpsib, rdmft)
subroutine, public fourier_space_op_end(this)
real(real64), parameter, public m_zero
Definition: global.F90:187
This module implements the underlying real-space grid.
Definition: grid.F90:117
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
This module defines functions over batches of mesh functions.
Definition: mesh_batch.F90:116
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_experimental(name, namespace)
Definition: messages.F90:1097
This module handles the communicators for the various parallelization strategies.
Definition: multicomm.F90:145
Some general things and nomenclature:
Definition: par_vec.F90:171
subroutine, public poisson_init(this, namespace, space, der, mc, stencil, qtot, label, solver, verbose, force_serial, force_cmplx)
Definition: poisson.F90:238
subroutine, public poisson_end(this)
Definition: poisson.F90:714
This module is an helper to perform ring-pattern communications among all states.
subroutine, public singularity_end(this)
subroutine, public singularity_init(this, namespace, space, st, kpoints)
pure logical function, public states_are_real(st)
This module provides routines for communicating all batches in a ring-pattern scheme.
This module handles spin dimensions of the states and the k-point distribution.
subroutine, public states_elec_end(st)
finalize the states_elec_t object
This module provides routines for communicating states when using states parallelization.
subroutine, public states_elec_parallel_remote_access_stop(this)
stop remote memory access for states on other processors
This module defines stencils used in Octopus.
Definition: stencil.F90:135
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
This module defines the unit system, used for input and output.
Describes mesh distribution to nodes.
Definition: mesh.F90:186
batches of electronic states
Definition: wfs_elec.F90:138
int true(void)