diff --git a/bluemira/equilibria/optimisation/harmonics/toroidal_harmonics_approx_functions.py b/bluemira/equilibria/optimisation/harmonics/toroidal_harmonics_approx_functions.py new file mode 100644 index 0000000000..7ad8516496 --- /dev/null +++ b/bluemira/equilibria/optimisation/harmonics/toroidal_harmonics_approx_functions.py @@ -0,0 +1,86 @@ +# SPDX-FileCopyrightText: 2021-present M. Coleman, J. Cook, F. Franza +# SPDX-FileCopyrightText: 2021-present I.A. Maione, S. McIntosh +# SPDX-FileCopyrightText: 2021-present J. Morris, D. Short +# +# SPDX-License-Identifier: LGPL-2.1-or-later + +""" +A collection of functions used to approximate toroidal harmonics. +""" + +from math import factorial + +import numpy as np +from scipy.special import gamma, poch + + +def f_hypergeometric(a, b, c, z, n_max): + """Evaluates the hypergeometric power series up to n_max. + + .. math:: + F(a, b; c; z) = \\sum_0^{n_max} \\frac{(a)_{s} (b)_{s}}{Gamma(c + s) s!} z^{s} + + See https://dlmf.nist.gov/15.2#E2 and https://dlmf.nist.gov/5.2#iii for more + information. + """ + F = 0 + for s in range(n_max + 1): + F += (poch(a, s) * poch(b, s)) / (gamma(c + s) * factorial(s)) * z**s + return F + + +def my_legendre_p(lam, mu, x, n_max=20): + """Evaluates the associated Legendre function of the first kind of degree lambda and order + minus mu as a function of x. See https://dlmf.nist.gov/14.3#E18 for more information. + + TODO check domain of validity? Assumed validity is 1