DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
sphericalHarmonicUtils.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16//
17// @author Vishal Subramanian, Kartick Ramakrishnan, Sambit Das
18//
19#ifndef DFTFE_SPHERICALHARMONICUTILS_H
20#define DFTFE_SPHERICALHARMONICUTILS_H
21#include <interpolation.h>
22namespace dftfe
23{
25 {
26 inline void
27 getRadialFunctionVal(const double radialCoordinate,
28 double & splineVal,
29 const alglib::spline1dinterpolant *spline)
30 {
31 splineVal = alglib::spline1dcalc(*spline, radialCoordinate);
32 return;
33 }
34
35 inline void
36 getSphericalHarmonicVal(const double theta,
37 const double phi,
38 const int l,
39 const int m,
40 double & sphericalHarmonicVal)
41 {
42 if (m < 0)
43 sphericalHarmonicVal =
44 std::sqrt(2.0) * boost::math::spherical_harmonic_i(l, -m, theta, phi);
45
46 else if (m == 0)
47 sphericalHarmonicVal =
48 boost::math::spherical_harmonic_r(l, m, theta, phi);
49
50 else if (m > 0)
51 sphericalHarmonicVal =
52 std::sqrt(2.0) * boost::math::spherical_harmonic_r(l, m, theta, phi);
53
54 return;
55 }
56
57 inline void
59 double &r,
60 double &theta,
61 double &phi)
62 {
63 double tolerance = 1e-12;
64 r = std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
65
66 if (std::fabs(r - 0.0) <= tolerance)
67 {
68 theta = 0.0;
69 phi = 0.0;
70 }
71 else
72 {
73 theta = std::acos(x[2] / r);
74 //
75 // check if theta = 0 or PI (i.e, whether the point is on the Z-axis)
76 // If yes, assign phi = 0.0.
77 // NOTE: In case theta = 0 or PI, phi is undetermined. The actual
78 // value of phi doesn't matter in computing the enriched function
79 // value or its gradient. We assign phi = 0.0 here just as a dummy
80 // value
81 //
82 if (fabs(theta - 0.0) >= tolerance && fabs(theta - M_PI) >= tolerance)
83 phi = std::atan2(x[1], x[0]);
84 else
85 phi = 0.0;
86 }
87 }
88 } // end of namespace sphericalHarmonicUtils
89} // end of namespace dftfe
90#endif // DFTFE_SPHERICALHARMONICUTILS_H
Definition sphericalHarmonicUtils.h:25
void convertCartesianToSpherical(double *x, double &r, double &theta, double &phi)
Definition sphericalHarmonicUtils.h:58
void getRadialFunctionVal(const double radialCoordinate, double &splineVal, const alglib::spline1dinterpolant *spline)
Definition sphericalHarmonicUtils.h:27
void getSphericalHarmonicVal(const double theta, const double phi, const int l, const int m, double &sphericalHarmonicVal)
Definition sphericalHarmonicUtils.h:36
Definition pseudoPotentialToDftfeConverter.cc:34
@ e
Definition ExcSSDFunctionalBaseClass.h:52