22from numba import jit
33
44__all__ = [
5- "calcC2C3 "
5+ "calcStumpff "
66]
77
8- @jit ("UniTuple(f8, 2 )(f8)" , nopython = True )
9- def calcC2C3 (psi ):
8+ @jit ("UniTuple(f8, 6 )(f8)" , nopython = True )
9+ def calcStumpff (psi ):
1010 """
11- Calculate the second and third Stumpff functions.
11+ Calculate the first 6 Stumpff functions for universal variable psi .
1212
1313 .. math::
14+
15+ c_0(\Psi) = \b egin{cases}
16+ \cos{\sqrt{\Psi}} & \t ext{ if } \Psi > 0 \\
17+ \cosh{\sqrt{-\Psi}} & \t ext{ if } \Psi < 0 \\
18+ 1 & \t ext{ if } \Psi= 0
19+ \end{cases}
1420
15- c_2 (\Psi) = \b egin{cases}
16- \f rac{1 - \cos {\sqrt{\Psi}}}{\ Psi} & \t ext{ if } \Psi > 0 \\
17- \f rac{1 - \cosh {\sqrt{-\Psi}}}{\ Psi} & \t ext{ if } \Psi < 0 \\
18- \f rac{1}{2} & \t ext{ if } \Psi= 0
21+ c_1 (\Psi) = \b egin{cases}
22+ \f rac{\sin {\sqrt{\Psi}}{\sqrt{\ Psi} } & \t ext{ if } \Psi > 0 \\
23+ \f rac{\sinh {\sqrt{-\Psi}}{\sqrt{-\ Psi} } & \t ext{ if } \Psi < 0 \\
24+ 1 & \t ext{ if } \Psi= 0
1925 \end{cases}
2026
21- c_3(\Psi) = \b egin{cases}
22- \f rac{\sqrt{\Psi} - \sin{\sqrt{\Psi}}}{\sqrt{\Psi^3}} & \t ext{ if } \Psi > 0 \\
23- \f rac{\sinh{\sqrt{-\Psi}} - \sqrt{-\Psi}}{\sqrt{(-\Psi)^3}} & \t ext{ if } \Psi < 0 \\
24- \f rac{1}{6} & \t ext{ if } \Psi= 0
25- \end{cases}
27+ \Psi c_{n+2} = \f rac{1}{k!} - c_n(\Psi)
2628
27- For more details on theory see Chapter 2 in David A. Vallado's "Fundamentals of Astrodynamics
29+ For more details on the universal variable formalism see Chapter 2 in David A. Vallado's "Fundamentals of Astrodynamics
2830 and Applications" or Chapter 3 in Howard Curtis' "Orbital Mechanics for Engineering Students".
2931
3032 Parameters
@@ -34,17 +36,29 @@ def calcC2C3(psi):
3436
3537 Returns
3638 -------
37- c2, c3 : float, float
38- Second and third Stumpff functions.
39+ s0, s1, s2, s3, s4, s5 : 6 x float
40+ First six Stumpff functions.
3941 """
4042 if psi > 0.0 :
41- c2 = (1 - np .cos (np .sqrt (psi ))) / psi
42- c3 = (np .sqrt (psi ) - np .sin (np .sqrt (psi ))) / np .sqrt (psi )** 3
43+ c0 = np .cos (np .sqrt (psi ))
44+ c1 = np .sin (np .sqrt (psi )) / np .sqrt (psi )
45+ c2 = (1. - c0 ) / psi
46+ c3 = (1. - c1 ) / psi
47+ c4 = (1 / 2. - c2 ) / psi
48+ c5 = (1 / 6. - c3 ) / psi
4349 elif psi < 0.0 :
44- c2 = (np .cosh (np .sqrt (- psi )) - 1 ) / (- psi )
45- c3 = (np .sinh (np .sqrt (- psi )) - np .sqrt (- psi )) / np .sqrt (- psi )** 3
50+ c0 = np .cosh (np .sqrt (- psi ))
51+ c1 = np .sinh (np .sqrt (- psi )) / np .sqrt (- psi )
52+ c2 = (1. - c0 ) / psi
53+ c3 = (1. - c1 ) / psi
54+ c4 = (1 / 2. - c2 ) / psi
55+ c5 = (1 / 6. - c3 ) / psi
4656 else :
57+ c0 = 1.
58+ c1 = 1.
4759 c2 = 1 / 2.
4860 c3 = 1 / 6.
61+ c4 = 1 / 24.
62+ c5 = 1 / 120.
4963
50- return c2 , c3
64+ return c0 , c1 , c2 , c3 , c4 , c5
0 commit comments