14 #ifndef QMCPLUSPLUS_YLM_H 15 #define QMCPLUSPLUS_YLM_H 20 #include "config/stdlib/Constants.h" 34 for (
int i = 1; i <= l; i++)
51 T
sign = (
m % 2 == 0) ? 1.0 : -1.0;
53 for (
int i = 2; i <= (l -
m); i++)
54 mfact *= static_cast<T>(i);
56 for (
int i = 2; i <= (l +
m); i++)
57 pfact *= static_cast<T>(i);
58 return posval *
sign * mfact / pfact;
62 T pmp1m = x * (2 *
m + 1) * pmm;
65 else if (l == (
m + 1))
73 for (
int i =
m + 2; i <= l; i++)
75 Pl = (1.0 /
static_cast<T
>(i -
m)) * (x * (2 * i - 1) * Plm1m - (i +
m - 1) * Plm2m);
97 for (
int i = lmm; i > 0; i--)
98 mfact *= static_cast<T>(i);
99 for (
int i = lpm; i > 0; i--)
100 pfact *= static_cast<T>(i);
101 T prefactor =
std::sqrt(static_cast<T>(2 * l + 1) * mfact / (4.0 * M_PI * pfact));
118 std::complex<T>& theta_deriv,
119 std::complex<T>& phi_deriv,
125 theta_deriv =
static_cast<T
>(
m) /
std::tan(theta) *
Ylm(l,
m, r);
126 theta_deriv +=
std::sqrt(static_cast<T>((l -
m) * (l +
m + 1))) * emiphi *
Ylm(l,
m + 1, r);
127 phi_deriv = std::complex<T>(0.0,
static_cast<T
>(
m)) *
Ylm(l,
m, r);
145 unit[0] = r[2] /
norm;
146 unit[1] = r[0] /
norm;
147 unit[2] = r[1] /
norm;
148 return Ylm(l,
m, unit);
165 unit[0] = r[2] /
norm;
166 unit[1] = r[0] /
norm;
167 unit[2] = r[1] /
norm;
168 std::complex<T> dth, dph;
172 T dph_dx = -r[1] / (r[0] * r[0] + r[1] * r[1]);
174 T dph_dy = r[0] / (r[0] * r[0] + r[1] * r[1]);
178 grad[0] = dth * dth_dx + dph * dph_dx;
179 grad[1] = dth * dth_dy + dph * dph_dy;
180 grad[2] = dth * dth_dz + dph * dph_dz;
T LegendrePlm(int l, int m, T x)
helper functions for EinsplineSetBuilder
std::complex< T > Ylm(int l, int m, const TinyVector< T, 3 > &r)
calculates Ylm param[in] l angular momentum param[in] m magnetic quantum number param[in] r position ...
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
MakeReturn< UnaryNode< FnSin, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sin(const Vector< T1, C1 > &l)
void sphericalHarmonicGrad(const int l, const int m, const TinyVector< T, 3 > &r, TinyVector< std::complex< T >, 3 > &grad)
get cartesian derivatives of spherical Harmonics.
MakeReturn< UnaryNode< FnCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t cos(const Vector< T1, C1 > &l)
double norm(const zVec &c)
MakeReturn< UnaryNode< FnArcCos, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t acos(const Vector< T1, C1 > &l)
MakeReturn< BinaryNode< FnArcTan2, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t, typename CreateLeaf< Vector< T2, C2 > >::Leaf_t > >::Expression_t atan2(const Vector< T1, C1 > &l, const Vector< T2, C2 > &r)
MakeReturn< UnaryNode< FnTan, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t tan(const Vector< T1, C1 > &l)
float conj(const float &c)
Workaround to allow conj on scalar to return real instead of complex.
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
void derivYlmSpherical(const int l, const int m, const TinyVector< T, 3 > &r, std::complex< T > &theta_deriv, std::complex< T > &phi_deriv, const bool conj)
calculate the derivative of a Ylm with respect to theta and phi param[in] l: angular momentum param[i...
T LegendrePll(int l, T x)
std::complex< T > sphericalHarmonic(const int l, const int m, const TinyVector< T, 3 > &r)
wrapper for Ylm, which can take any normal position vector as an argument param[in] l angular momentu...