Octopus
perturbation_electric.F90
Go to the documentation of this file.
1!! Copyright (C) 2007 X. Andrade
2!! Copyright (C) 2021 N. Tancogne-Dejean
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 batch_oct_m
25 use comm_oct_m
26 use debug_oct_m
27 use global_oct_m
28 use grid_oct_m
30 use mesh_oct_m
35 use space_oct_m
38 use types_oct_m
40
41 implicit none
42
43 private
44 public :: &
47
49 private
50 contains
51 procedure :: copy => perturbation_electric_copy
52 generic :: assignment(=) => copy
53 procedure :: info => perturbation_electric_info
54 procedure :: dapply => dperturbation_electric_apply
55 procedure :: zapply => zperturbation_electric_apply
56 procedure :: apply_batch => perturbation_electric_apply_batch
57 procedure :: dapply_order_2 => dperturbation_electric_apply_order_2
58 procedure :: zapply_order_2 => zperturbation_electric_apply_order_2
61
63 procedure perturbation_electric_constructor
64 end interface perturbation_electric_t
65
66contains
67
68 ! ---------------------------------------------------------
73 function perturbation_electric_constructor(namespace) result(pert)
74 class(perturbation_electric_t), pointer :: pert
75 type(namespace_t), intent(in) :: namespace
76
78
79 safe_allocate(pert)
80
81 call perturbation_electric_init(pert, namespace)
82
85
86 ! --------------------------------------------------------------------
87 subroutine perturbation_electric_init(this, namespace)
88 type(perturbation_electric_t), intent(out) :: this
89 type(namespace_t), intent(in) :: namespace
90
92
93 this%dir = -1
94 this%dir2 = -1
95
97 end subroutine perturbation_electric_init
98
99 ! --------------------------------------------------------------------
100 subroutine perturbation_electric_finalize(this)
101 type(perturbation_electric_t), intent(inout) :: this
102
104
106 end subroutine perturbation_electric_finalize
107
108 ! --------------------------------------------------------------------
109 subroutine perturbation_electric_copy(this, source)
110 class(perturbation_electric_t), intent(out) :: this
111 class(perturbation_electric_t), intent(in) :: source
112
114
115 call perturbation_copy(this, source)
116
118 end subroutine perturbation_electric_copy
119
120
121 ! --------------------------------------------------------------------
122 subroutine perturbation_electric_info(this)
123 class(perturbation_electric_t), intent(in) :: this
124
126
128 end subroutine perturbation_electric_info
129
130 ! --------------------------------------------------------------------------
131 subroutine perturbation_electric_apply_batch(this, namespace, space, gr, hm, f_in, f_out)
132 class(perturbation_electric_t), intent(in) :: this
133 type(namespace_t), intent(in) :: namespace
134 class(space_t), intent(in) :: space
135 type(grid_t), intent(in) :: gr
136 type(hamiltonian_elec_t), intent(in) :: hm
137 type(wfs_elec_t), intent(in) :: f_in
138 type(wfs_elec_t), intent(inout) :: f_out
139
140 integer :: ii, ip
143
144 ! electric does not need it since (e^-ikr)r(e^ikr) = r
146 assert(f_in%status() == f_out%status())
148 select case (f_in%status())
152 if (f_in%type() == type_float) then
153
154 do ii = 1, f_in%nst_linear
155 !$omp parallel do private(ip)
156 do ip = 1, gr%np
157 f_out%dff_linear(ip, ii) = gr%x(ip, this%dir)*f_in%dff_linear(ip, ii)
158 end do
159 end do
160
161 else
162
163 do ii = 1, f_in%nst_linear
164 !$omp parallel do private(ip)
165 do ip = 1, gr%np
166 f_out%zff_linear(ip, ii) = gr%x(ip, this%dir)*f_in%zff_linear(ip, ii)
167 end do
168 end do
169
170 end if
171
172 case (batch_packed)
173
174 if (f_in%type() == type_float) then
175
176 !$omp parallel do private(ip, ii)
177 do ip = 1, gr%np
178 do ii = 1, f_in%nst_linear
179 f_out%dff_pack(ii, ip) = gr%x(ip, this%dir)*f_in%dff_pack(ii, ip)
180 end do
181 end do
182
183 else
184
185 !$omp parallel do private(ip, ii)
186 do ip = 1, gr%np
187 do ii = 1, f_in%nst_linear
188 f_out%zff_pack(ii, ip) = gr%x(ip, this%dir)*f_in%zff_pack(ii, ip)
189 end do
190 end do
191
192 end if
195
196 call messages_not_implemented("perturbation_electric_apply_batch on GPUs", namespace = namespace)
197
198 end select
199
203
204#include "undef.F90"
205#include "real.F90"
206#include "perturbation_electric_inc.F90"
207
208#include "undef.F90"
209#include "complex.F90"
210#include "perturbation_electric_inc.F90"
211
213
214!! Local Variables:
215!! mode: f90
216!! coding: utf-8
217!! End:
This module implements batches of mesh functions.
Definition: batch.F90:133
integer, parameter, public batch_not_packed
functions are stored in CPU memory, unpacked order
Definition: batch.F90:276
integer, parameter, public batch_device_packed
functions are stored in device memory in packed order
Definition: batch.F90:276
integer, parameter, public batch_packed
functions are stored in CPU memory, in transposed (packed) order
Definition: batch.F90:276
This module implements common operations on batches of mesh functions.
Definition: batch_ops.F90:116
This module implements the underlying real-space grid.
Definition: grid.F90:117
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 perturbation_electric_init(this, namespace)
subroutine zperturbation_electric_apply(this, namespace, space, gr, hm, ik, f_in, f_out, set_bc)
Returns f_out = H' f_in, where H' is perturbation Hamiltonian Note that e^ikr phase is applied to f_i...
subroutine perturbation_electric_finalize(this)
class(perturbation_electric_t) function, pointer perturbation_electric_constructor(namespace)
The factory routine (or constructor) allocates a pointer of the corresponding type and then calls the...
subroutine zperturbation_electric_apply_order_2(this, namespace, space, gr, hm, ik, f_in, f_out)
subroutine perturbation_electric_copy(this, source)
subroutine perturbation_electric_apply_batch(this, namespace, space, gr, hm, f_in, f_out)
subroutine dperturbation_electric_apply(this, namespace, space, gr, hm, ik, f_in, f_out, set_bc)
Returns f_out = H' f_in, where H' is perturbation Hamiltonian Note that e^ikr phase is applied to f_i...
subroutine dperturbation_electric_apply_order_2(this, namespace, space, gr, hm, ik, f_in, f_out)
subroutine, public perturbation_copy(this, source)
This module handles spin dimensions of the states and the k-point distribution.
type(type_t), public type_float
Definition: types.F90:133