Coverage for src/gncpy/dynamics/basic/karlgaard_orbit.py: 28%

39 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-19 05:48 +0000

1import numpy as np 

2from .nonlinear_dynamics_base import NonlinearDynamicsBase 

3 

4 

5class KarlgaardOrbit(NonlinearDynamicsBase): 

6 """Implements the non-linear Karlgaar elliptical orbit model. 

7 

8 Notes 

9 ----- 

10 It uses the numerical integration of the second order approximation in 

11 dimensionless sphereical coordinates. See 

12 :cite:`Karlgaard2003_SecondOrderRelativeMotionEquations` for details. 

13 """ 

14 

15 state_names = ( 

16 "non-dim radius", 

17 "non-dim az angle", 

18 "non-dim elv angle", 

19 "non-dim radius ROC", 

20 "non-dim az angle ROC", 

21 "non-dim elv angle ROC", 

22 ) 

23 

24 def __init__(self, **kwargs): 

25 super().__init__(**kwargs) 

26 

27 @property 

28 def control_model(self): 

29 return self._control_model 

30 

31 @control_model.setter 

32 def control_model(self, model): 

33 self._control_model = model 

34 

35 @property 

36 def cont_fnc_lst(self): 

37 """Continuous time dynamics. 

38 

39 Returns 

40 ------- 

41 list 

42 functions of the form :code:`(t, x, *args)`. 

43 """ 

44 

45 # returns non-dim radius ROC 

46 def f0(t, x, *args): 

47 return x[3] 

48 

49 # returns non-dim az angle ROC 

50 def f1(t, x, *args): 

51 return x[4] 

52 

53 # returns non-dim elv angle ROC 

54 def f2(t, x, *args): 

55 return x[5] 

56 

57 # returns non-dim radius ROC ROC 

58 def f3(t, x, *args): 

59 r = x[0] 

60 phi = x[2] 

61 theta_d = x[4] 

62 phi_d = x[5] 

63 return ( 

64 (-3 * r**2 + 2 * r * theta_d - phi**2 + theta_d**2 + phi_d**2) 

65 + 3 * r 

66 + 2 * theta_d 

67 ) 

68 

69 # returns non-dim az angle ROC ROC 

70 def f4(t, x, *args): 

71 r = x[0] 

72 theta = x[1] 

73 r_d = x[3] 

74 theta_d = x[4] 

75 return (2 * r * r_d + 2 * theta * theta_d - 2 * theta_d * r_d) - 2 * r_d 

76 

77 # returns non-dim elv angle ROC ROC 

78 def f5(t, x, *args): 

79 phi = x[2] 

80 r_d = x[3] 

81 theta_d = x[4] 

82 phi_d = x[5] 

83 return (-2 * theta_d * phi - 2 * phi_d * r_d) - phi 

84 

85 return [f0, f1, f2, f3, f4, f5]