Octopus
fourier_space.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch.
2!! Copyright (C) 2026 A. Buccheri.
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 accel_oct_m
24 use cube_oct_m
26 use debug_oct_m
27 use global_oct_m
28 use, intrinsic :: iso_fortran_env
29 use math_oct_m
32 use fft_oct_m
33#ifdef HAVE_OPENMP
34 use omp_lib
35#endif
36#ifdef HAVE_PFFT
37 use pfft_oct_m
38#endif
40 use space_oct_m
41 use types_oct_m
42 use xc_cam_oct_m
43
44 implicit none
45 private
46 public :: &
52
55 private
56 real(real64), allocatable :: dop(:, :, :)
57 complex(real64), allocatable :: zop(:, :, :)
58 ! Single-precision copies of the (constant) kernel, built once when the cube
59 ! is single precision, so the single-precision apply avoids casting dop/zop
60 ! on every call.
61 real(real32), allocatable :: sop(:, :, :)
62 complex(real32), allocatable :: cop(:, :, :)
63 type(accel_mem_t) :: op_buffer
64 logical :: real_op
65 logical :: in_device_memory = .false.
66
67 !Parameters used to generate this kernel
68 real(real64), allocatable, public :: qq(:)
69 real(real64), public :: singularity = m_zero
70 real(real64), public :: mu = m_zero
71 real(real64), public :: alpha = m_zero
72 real(real64), public :: beta = m_zero
73
74 contains
75 procedure :: init => fourier_space_op_init
76 procedure :: dset_op => dfourier_space_op_set_op
77 procedure :: zset_op => zfourier_space_op_set_op
78 procedure :: end => fourier_space_op_end
79 end type fourier_space_op_t
80
82 real(real64), parameter, public :: VANISHING_Q = 1.0e-5_real64
83 real(real64), parameter :: TOL_VANISHING_Q = 1e-6_real64
84
85contains
86
94 subroutine fourier_space_op_init(this, space, qvector, cam, singularity)
95 class(fourier_space_op_t), intent(inout) :: this
96 class(space_t), intent(in) :: space
97 real(real64), intent(in) :: qvector(:)
98 type(xc_cam_t), intent(in) :: cam
99 real(real64), optional, intent(in) :: singularity
100
101 push_sub(fourier_space_op_init)
102
103 safe_allocate(this%qq(1:space%dim))
104 this%qq(1:space%periodic_dim) = qvector(1:space%periodic_dim)
105 this%qq(space%periodic_dim+1:space%dim) = vanishing_q
106 ! Note, specific kernel builders will use this but return a different value
107 ! or disregard entirely
108 this%singularity = optional_default(singularity, m_zero)
109 this%mu = cam%omega
110 this%alpha = cam%alpha
111 this%beta = cam%beta
112
113 pop_sub(fourier_space_op_init)
114
115 end subroutine fourier_space_op_init
116
118 subroutine fourier_space_op_end(this)
119 class(fourier_space_op_t), intent(inout) :: this
120
121 push_sub(fourier_space_op_end)
122
123 if (this%in_device_memory) then
124 call accel_free_buffer(this%op_buffer)
125 this%in_device_memory = .false.
126 end if
127 safe_deallocate_a(this%dop)
128 safe_deallocate_a(this%zop)
129 safe_deallocate_a(this%sop)
130 safe_deallocate_a(this%cop)
131 safe_deallocate_a(this%qq)
132
133 pop_sub(fourier_space_op_end)
134 end subroutine fourier_space_op_end
135
136#include "undef.F90"
137#include "real.F90"
138#include "fourier_space_inc.F90"
139
140#include "undef.F90"
141#include "complex.F90"
142#include "fourier_space_inc.F90"
143
144#include "undef.F90"
145#include "real32.F90"
146#include "fourier_space_inc.F90"
147
148#include "undef.F90"
149#include "complex32.F90"
150#include "fourier_space_inc.F90"
153
154
155!! Local Variables:
156!! mode: f90
157!! coding: utf-8
158!! End:
subroutine, public accel_free_buffer(this, async)
Definition: accel.F90:990
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
Definition: fft.F90:120
subroutine, public zfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
subroutine, public dfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
subroutine fourier_space_op_end(this)
Finalize an instance of fourier_space_op_t.
subroutine zfourier_space_op_set_op(this, cube, op, in_device, op_move)
Set the op buffer, which defines the kernel on the cube, in Fourier space.
subroutine, public sfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
subroutine fourier_space_op_init(this, space, qvector, cam, singularity)
Initialise a Fourier space Op instance.
subroutine dfourier_space_op_set_op(this, cube, op, in_device, op_move)
Set the op buffer, which defines the kernel on the cube, in Fourier space.
subroutine, public cfourier_space_op_apply(this, cube, cf)
Applies a multiplication factor to the Fourier space grid. This is a local function.
real(real64), parameter, public m_zero
Definition: global.F90:200
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:117
The low level module to work with the PFFT library. http:
Definition: pfft.F90:128
Definition of a Fourier Space Coulomb Kernel.