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 :: &
50
53 private
54 real(real64), allocatable :: dop(:, :, :)
55 complex(real64), allocatable :: zop(:, :, :)
56 type(accel_mem_t) :: op_buffer
57 logical :: real_op
58 logical :: in_device_memory = .false.
59
60 !Parameters used to generate this kernel
61 real(real64), allocatable, public :: qq(:)
62 real(real64), public :: singularity = m_zero
63 real(real64), public :: mu = m_zero
64 real(real64), public :: alpha = m_zero
65 real(real64), public :: beta = m_zero
66
67 contains
68 procedure :: init => fourier_space_op_init
69 procedure :: dset_op => dfourier_space_op_set_op
70 procedure :: zset_op => zfourier_space_op_set_op
71 procedure :: end => fourier_space_op_end
72 end type fourier_space_op_t
73
75 real(real64), parameter, public :: VANISHING_Q = 1.0e-5_real64
76 real(real64), parameter :: TOL_VANISHING_Q = 1e-6_real64
77
78contains
79
87 subroutine fourier_space_op_init(this, space, qvector, cam, singularity)
88 class(fourier_space_op_t), intent(inout) :: this
89 class(space_t), intent(in) :: space
90 real(real64), intent(in) :: qvector(:)
91 type(xc_cam_t), intent(in) :: cam
92 real(real64), optional, intent(in) :: singularity
93
94 push_sub(fourier_space_op_init)
95
96 safe_allocate(this%qq(1:space%dim))
97 this%qq(1:space%periodic_dim) = qvector(1:space%periodic_dim)
98 this%qq(space%periodic_dim+1:space%dim) = vanishing_q
99 ! Note, specific kernel builders will use this but return a different value
100 ! or disregard entirely
101 this%singularity = optional_default(singularity, m_zero)
102 this%mu = cam%omega
103 this%alpha = cam%alpha
104 this%beta = cam%beta
105
106 pop_sub(fourier_space_op_init)
107
108 end subroutine fourier_space_op_init
109
111 subroutine fourier_space_op_end(this)
112 class(fourier_space_op_t), intent(inout) :: this
113
114 push_sub(fourier_space_op_end)
115
116 if (this%in_device_memory) then
117 call accel_free_buffer(this%op_buffer)
118 this%in_device_memory = .false.
119 end if
120 safe_deallocate_a(this%dop)
121 safe_deallocate_a(this%zop)
122 safe_deallocate_a(this%qq)
123
124 pop_sub(fourier_space_op_end)
125 end subroutine fourier_space_op_end
126
127#include "undef.F90"
128#include "real.F90"
129#include "fourier_space_inc.F90"
130
131#include "undef.F90"
132#include "complex.F90"
133#include "fourier_space_inc.F90"
134
135end module fourier_space_oct_m
136
137
138!! Local Variables:
139!! mode: f90
140!! coding: utf-8
141!! End:
subroutine, public accel_free_buffer(this, async)
Definition: accel.F90:941
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 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.
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.