1#ifndef dftefeSphericalHarmonicFunctions_h
2#define dftefeSphericalHarmonicFunctions_h
89 Plm(
const int l,
const int m,
const double theta)
const;
92 dPlmDTheta(
const int l,
const int m,
const double theta)
const;
95 d2PlmDTheta2(
const int l,
const int m,
const double theta)
const;
97 template <dftefe::utils::MemorySpace memorySpace>
102 const double * theta,
106 template <dftefe::utils::MemorySpace memorySpace>
111 const double * theta,
115 template <dftefe::utils::MemorySpace memorySpace>
120 const double * theta,
129 std::vector<std::vector<std::shared_ptr<const utils::Spline>>>
140 double polarAngleTolerance);
148 double polarAngleTolerance);
150 template <dftefe::utils::MemorySpace memorySpace>
158 double polarAngleTolerance,
164 Clm(
const int l,
const int m);
167 Qm(
const int m,
const double phi);
169 template <dftefe::utils::MemorySpace memorySpace>
178 dQmDPhi(
const int m,
const double phi);
180 template <dftefe::utils::MemorySpace memorySpace>
203 Rlm(
const int l,
const int m)
207 return Rlm(l, m - 1) / ((l - m + 1.0) * (l + m));
211 plm(
int l,
int absm,
double cosTheta)
215 double somx2 = sqrt(1.0 - cosTheta * cosTheta);
218 for (
int i = 0; i < absm; i++)
220 cxM = -cxM * fact * somx2;
226 double cxMPlus1 = cosTheta * (2 * absm + 1) * cxM;
228 double cxPrev = cxMPlus1;
229 double cxPrevPrev = cxM;
230 for (
int jj = absm + 2; jj < l + 1; jj++)
232 cx = ((2 * jj - 1) * cosTheta * cxPrev +
233 (-jj - absm + 1) * cxPrevPrev) /
239 return ((absm % 2 == 0) ? 1.0 : -1.0) * cx;
243 dplmDTheta(
int l,
int absm,
double cosTheta)
250 return -1.0 * plm(l, 1, cosTheta);
252 return (
double)l * plm(l, l - 1, cosTheta);
254 (double)((l + absm) * (l - absm + 1)) * plm(l, absm - 1, cosTheta);
255 double term2 = plm(l, absm + 1, cosTheta);
256 return 0.5 * (term1 - term2);
260 d2plmDTheta2(
int l,
int absm,
double cosTheta)
267 return -1.0 * dplmDTheta(l, 1, cosTheta);
269 return (
double)l * dplmDTheta(l, l - 1, cosTheta);
270 double term1 = (double)((l + absm) * (l - absm + 1)) *
271 dplmDTheta(l, absm - 1, cosTheta);
272 double term2 = dplmDTheta(l, absm + 1, cosTheta);
273 return 0.5 * (term1 - term2);
283 double polarAngleTolerance)
288 r = sqrt(px * px + py * py + pz * pz);
296 theta = acos(pz / r);
297 if (fabs(theta - 0.0) >= polarAngleTolerance &&
298 fabs(theta - M_PI) >= polarAngleTolerance)
306 Qm(
const int m,
const double phi)
310 v = cos((
double)m * phi);
314 v = sin((
double)(-m) * phi);
323 v = -(double)m * sin((
double)m * phi);
327 v = (double)(-m) * cos((
double)(-m) * phi);
334 const double theta)
const
336 const int absm = (m < 0) ? -m : m;
337 const double factor = (m < 0) ? pow(-1.0, m) * Rlm(l, absm) : 1.0;
340 return factor * plm(l, absm, cos(theta));
346 const double theta)
const
348 const int absm = (m < 0) ? -m : m;
349 if (absm > l || l == 0)
351 const double factor = (m < 0) ? pow(-1.0, m) * Rlm(l, absm) : 1.0;
352 return factor * dplmDTheta(l, absm, cos(theta));
358 const double theta)
const
360 const int absm = (m < 0) ? -m : m;
361 if (absm > l || l == 0)
363 const double factor = (m < 0) ? pow(-1.0, m) * Rlm(l, absm) : 1.0;
364 return factor * d2plmDTheta2(l, absm, cos(theta));
#define DFTEFE_HOST_DEVICE_FUNC
Definition: DeviceKernelLauncherHelpers.h:306
#define DFTEFE_HOST_DEVICE
Definition: DeviceKernelLauncherHelpers.h:301
Definition: SphericalHarmonicFunctions.h:19
bool d_isAssocLegendreSplineEval
Definition: SphericalHarmonicFunctions.h:131
DFTEFE_HOST_DEVICE_FUNC double d2PlmDTheta2(const int l, const int m, const double theta) const
Definition: SphericalHarmonicFunctions.h:356
std::vector< std::vector< std::shared_ptr< const utils::Spline > > > d_assocLegendreSpline
Definition: SphericalHarmonicFunctions.h:130
void Plm(size_type numPoints, const int l, const int m, const double *theta, double *out, utils::deviceStream_t streamId=utils::defaultStream) const
void d2PlmDTheta2(size_type numPoints, const int l, const int m, const double *theta, double *out, utils::deviceStream_t streamId=utils::defaultStream) const
DFTEFE_HOST_DEVICE_FUNC double Plm(const int l, const int m, const double theta) const
Definition: SphericalHarmonicFunctions.h:332
~SphericalHarmonicFunctions()=default
DFTEFE_HOST_DEVICE_FUNC double dPlmDTheta(const int l, const int m, const double theta) const
Definition: SphericalHarmonicFunctions.h:344
void dPlmDTheta(size_type numPoints, const int l, const int m, const double *theta, double *out, utils::deviceStream_t streamId=utils::defaultStream) const
Definition: PointImpl.h:13
void convertCartesianToSpherical(const utils::Point &x, double &r, double &theta, double &phi, double polarAngleTolerance)
Definition: SphericalHarmonicFunctions.cpp:251
double Dm(const int m)
Definition: SphericalHarmonicFunctions.cpp:413
DFTEFE_HOST_DEVICE_FUNC double dQmDPhi(const int m, const double phi)
Definition: SphericalHarmonicFunctions.h:319
DFTEFE_HOST_DEVICE_FUNC double Qm(const int m, const double phi)
Definition: SphericalHarmonicFunctions.h:306
double Clm(const int l, const int m)
Definition: SphericalHarmonicFunctions.cpp:444
static cudaStream_t defaultStream
Definition: DeviceTypeConfig.cu.h:62
cudaStream_t deviceStream_t
Definition: DeviceTypeConfig.cu.h:27
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9