-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathSphericalFunctionUtil.h
183 lines (169 loc) · 8.07 KB
/
SphericalFunctionUtil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// ---------------------------------------------------------------------
//
// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
// authors.
//
// This file is part of the DFT-FE code.
//
// The DFT-FE code is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the DFT-FE distribution.
//
// ---------------------------------------------------------------------
//
// @author Bikash Kanungo
//
#ifndef DFTFE_SPHERICALFUNCTIONUTIL_H
#define DFTFE_SPHERICALFUNCTIONUTIL_H
#include <vector>
namespace dftfe
{
namespace utils
{
namespace sphUtils
{
/*
* @brief Function to convert cartesian coordinates into spherical coordinates
* @param[in] x Vector of size 3 containing the cartesian coordinates of
* the point
* @param[out] r Stores the computed radius of the point
* @param[out]theta Stores the computed polar angle of the point
* @param[out] phiStores the computed azimuthal angle of the point
* @param[in] rTol Defines a tolerance for the radius,
* below which theta and phi are set to zero.
* To elaborate, for radius->0, the angles are undefined.
* We set them to zero as a convenient choice
* @param[in] angleTol Defines a tolerance for the polar angle (theta)
* approching the poles, below which the azimuthal angle is
* set to zero. To elaborate, for a point on the pole
* (theta = 0 or theta = pi), the azimuthal angle is undefined.
* We set phi to zero if |theta - 0| < angleTol or |theta - pi|
* < angleTol.
*/
void
convertCartesianToSpherical(const std::vector<double> &x,
double & r,
double & theta,
double & phi,
const double rTol,
const double angleTol);
double
Clm(const int l, const int m);
/*
* @brief Function to compute the azimuthal angle (phi) dependent
* part of the real spherical harmonics. It does not include
* any normalization constant
* Q(m,phi) = cos(m*phi) if m > 0
* Qm(m,phi) = 1 , if m = 0
* Qm(m, phi = sin(|m|phi), if m < 0
* @param[in] m order of the spherical harmonic (m-quantum number) for
* which Qm is to be evaluated
* @param[in] phi Azimuthal angle at which Qm is to be evaluated
* @return Value of the Qm function
*/
double
Qm(const int m, const double phi);
/*
* @brief Function to compute derivative of the Qm(m,phi) function (defined above) with respect to phi.
* @param[in] m order of the spherical harmonic (m-quantum number) for
* which the derivative of Qm is to be evaluated
* @param[in] phi Azimuthal angle at which the derivative of Qm is to be
* evaluated
* @return Value of the derivative of Qm with respect to phi function
*/
double
dQmDPhi(const int m, const double phi);
/*
* @brief Function to compute double derivative of the Qm(m,phi) function (defined above) with respect to phi.
* @param[in] m order of the spherical harmonic (m-quantum number) for
* which the double derivative of Qm is to be evaluated
* @param[in] phi Azimuthal angle at which the double derivative of Qm is
* to be evaluated
* @return Value of the double derivative of Qm with respect to phi function
*/
double
d2QmDPhi2(const int m, const double phi);
/*
* @brief Function to compute the polar angle (theta) dependent
* part of the real spherical harmonics. Given the degree l and
* order m (i.e., l and m quantum numbers), this amounts to just the
* P_{l,|m|}, that is the associated Legendre function evaluated at
* |m|. It does not include any normalization constant or Condon-Shockley
* factor.
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @return Value of the P_{l,|m|}
*/
double
Plm(const int l, const int m, const double theta);
/*
* @brief Function to compute the derivative of the P_{l,|m|} function (defined above)
* with respect to the polar angle (theta).
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @return Value of the derivative of P_{l,|m|} with respect to theta
*/
double
dPlmDTheta(const int l, const int m, const double theta);
/*
* @brief Function to compute the double derivative of the P_{l,|m|} function (defined above)
* with respect to the polar angle (theta).
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @return Value of the double derivative of P_{l,|m|} with respect to theta
*/
double
d2PlmDTheta2(const int l, const int m, const double theta);
/*
* @brief Function to evaluate the real spherical harmonics YlmReal for a
* given degree (l), order (m), polar angle (theta), azimuthal
* angle (phi)
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @param[in] phi Azimuthal angle
* @return Value of YlmReal
*/
double
YlmReal(const int l, const int m, const double theta, const double phi);
/*
* @brief Function to evaluate the parial derivatives of the YlmReal function defined above with respect to
* polar angle (theta) and azimuthal angle (phi).
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @param[in] phi Azimuthal angle
* @return Vector containing the partial derivatives of YlmReal with respect to theta and phi, in that order.
*/
std::vector<double>
dYlmReal(const int l, const int m, const double theta, const double phi);
/*
* @brief Function to evaluate the second-order parial derivatives of the YlmReal function defined above with respect to
* polar angle (theta) and azimuthal angle (phi).
* @param[in] l degree of the spherical harmonic (l-quantum number)
* @param[in] m order of the spherical harmonic (m-quantum number)
* @param[in] theta Polar angle
* @param[in] phi Azimuthal angle
* @return Vector containing the second-order partial derivatives of YlmReal with respect to theta and phi, in that order.
*/
std::vector<double>
d2YlmReal(const int l, const int m, const double theta, const double phi);
/*
* @brief Function to evaluate the inverse of the Jacobian for the transform from cartesian to spherical coordinates
* @param[in] r Radius of the point
* @param[in] theta Polar angle of the point
* @param[in] phi Azimuthal angle of the point
* @return 2D Vector containing the inverse of the Jacobian
*/
std::vector<std::vector<double>>
getJInv(const double r, const double theta, const double phi);
} // end of namespace sphUtils
} // end of namespace utils
} // end of namespace dftfe
#endif // DFTFE_SPHERICALFUNCTIONUTIL_H