30 use,
intrinsic :: iso_fortran_env
55 type(derivatives_t),
intent(in) :: this
56 type(namespace_t),
intent(in) :: namespace
58 real(real64),
allocatable :: ff(:), grad(:,:), resgrad(:, :), lapl(:), reslapl(:)
59 real(real64) :: kvec(3)
61 safe_allocate(ff(1:this%mesh%np_part))
62 safe_allocate(grad(1:this%mesh%np, 1:this%mesh%box%dim))
63 safe_allocate(lapl(1:this%mesh%np))
64 safe_allocate(reslapl(1:this%mesh%np))
65 safe_allocate(resgrad(1:this%mesh%np, 1:this%mesh%box%dim))
68 kvec = [0.5_real64, 0.0_real64, 0.0_real64]
72 kvec = [1.0_real64, 1.0_real64, 0.0_real64]
76 kvec = [
m_pi/this%mesh%spacing(1), 0.0_real64, 0.0_real64]
80 kvec = [
m_pi/this%mesh%spacing(1),
m_pi/this%mesh%spacing(2), 0.0_real64]
101 safe_deallocate_a(ff)
102 safe_deallocate_a(grad)
103 safe_deallocate_a(lapl)
104 safe_deallocate_a(resgrad)
105 safe_deallocate_a(reslapl)
109 character(len=*),
intent(in) :: label
114 resgrad = resgrad - grad
115 write(
message(2),
'(a, es17.10)')
'Gradient err = ',
dmf_nrm2(this%mesh, this%mesh%box%dim, resgrad)
118 reslapl = reslapl - lapl
119 write(
message(3),
'(a, es17.10)')
'Laplacian err = ',
dmf_nrm2(this%mesh, reslapl)
127 type(mesh_t),
intent(in) :: mesh
128 real(real64),
intent(out) :: ff(:), grad(:, :), lapl(:)
129 real(real64),
intent(in) :: kvec(3)
131 integer :: ip, dim, idir
132 real(real64) :: phase, kdotx, kk
136 kk = dot_product(kvec(1:dim), kvec(1:dim))
138 kdotx = dot_product(kvec(1:dim), mesh%x(1:dim, ip))
144 do idir = 1, mesh%box%dim
145 grad(ip, idir) = -kvec(idir)*
sin(kdotx)
149 lapl(ip) = -kk * phase
152 do ip = mesh%np+1, mesh%np_part
153 kdotx = dot_product(kvec(1:dim), mesh%x(1:dim, ip))
162 type(
mesh_t),
intent(in) :: mesh
163 real(real64),
intent(out) :: ff(:), grad(:, :), lapl(:)
164 integer,
intent(in) :: p
165 integer :: ip, d, dim
166 real(real64) :: x(3), r2
172 x(1:dim) = mesh%x(1:dim, ip)
175 r2 = dot_product(x(1:dim), x(1:dim))
176 ff(ip) = r2**(0.5_real64*p)
181 grad(ip,d) = p * r2**(0.5_real64*p - 1.0_real64) * x(d)
184 grad(ip,:) = 0.0_real64
189 lapl(ip) = p * (p + dim - 2) * r2**(0.5_real64*p - 1.0_real64)
191 lapl(ip) = 0.0_real64
195 do ip = mesh%np+1, mesh%np_part
197 x(1:dim) = mesh%x(1:dim, ip)
200 r2 = dot_product(x(1:dim), x(1:dim))
201 ff(ip) = r2**(0.5_real64*p)
208#include "derivatives_test_inc.F90"
211#include "complex.F90"
212#include "derivatives_test_inc.F90"
subroutine test_function(label)
double sin(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
This module implements batches of mesh functions.
This module implements common operations on batches of mesh functions.
Module implementing boundary conditions in Octopus.
This module calculates the derivatives (gradients, Laplacians, etc.) of a function.
subroutine, public dderivatives_grad(der, ff, op_ff, ghost_update, set_bc, to_cartesian)
apply the gradient to a mesh function
subroutine, public dderivatives_lapl(der, ff, op_ff, ghost_update, set_bc, factor)
apply the Laplacian to a mesh function
This module provides unit tests for the derivatives.
subroutine, public zderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
subroutine testfunc_plane_wave(mesh, ff, grad, lapl, kvec)
Generate a plane-wave given its momentum, as well as the gradient and the Laplacian.
subroutine testfunc_polynomial(mesh, ff, grad, lapl, p)
Generate a polyomial of degree p, as well as the gradient and the Laplacian.
subroutine, public dderivatives_test(this, namespace, repetitions, min_blocksize, max_blocksize)
unit test for derivatives
subroutine, public derivatives_advanced_benchmark(this, namespace)
Further unit tests design to challenge numerical stability of the finite differences.
real(real64), parameter, public m_pi
some mathematical constants
System information (time, memory, sysname)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module is intended to contain simple general-purpose utility functions and procedures.
Describes mesh distribution to nodes.