-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_disturbance_1U.py
67 lines (57 loc) · 2.56 KB
/
test_disturbance_1U.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import numpy as np
import disturbance_1U as dist
import unittest
from satellite import Satellite
from constants_1U import m_INERTIA
from ddt import data, ddt , unpack
@ddt
class TestGravityGradient(unittest.TestCase):
#Test the data type of output
def test_gg_data_type(self):
sat = Satellite(np.array([1.,0.,0.,0.,0.,0.,0.]),13.)
sat.setPos(np.array([7070e3,0.,0.]))
result = dist.gg_torque(sat)
self.assertEqual(type(result),np.ndarray)
#Take position vector to be eigen vector of m_INERTIA along with q =[1,0,0,0] thus torque will be zero
l, w = np.linalg.eig(m_INERTIA)
@data(7070e3*w[:,0],7070e3*w[:,1],7070e3*w[:,2])
def test_inertia_eigenvec(self,value):
state = np.array([1.,0.,0.,0.,0.1,-0.02,-0.2])
mySat = Satellite(state,128.05)
mySat.setPos(value)
mySat.setVel(np.array([5.60,-5.0,0.0]))
result = dist.gg_torque(mySat)
print result
self.assertTrue(np.allclose(result,[0.,0.,0.]))
class TestAeroDrag(unittest.TestCase):
#test the data type of the output
def test_aero_type(self):
sat = Satellite(np.array([np.sqrt(0.5),-np.sqrt(0.5),0.,0.,0.1,0.23,0.]),13.)
sat.setPos(np.array([0.,0.,7e6]))
sat.setVel(np.array([0,2e3,6e3]))
result = dist.aero_torque(sat)
self.assertEqual(type(result),np.ndarray)
def test_aero_value(self):
sat = Satellite(np.array([np.sqrt(0.5),-np.sqrt(0.5),0.,0.,0.1,0.23,0.]),13.)
sat.setPos(np.array([0.,0.,7e6]))
sat.setVel(np.array([0,2e3,6e3]))
result = dist.aero_torque(sat)
print result
self.assertTrue(np.allclose(result, [2.99654080e-10,-2.57065600e-11,-7.71196800e-11]))
class TestSolarTorque(unittest.TestCase):
#test the data type of the output
def test_solar_torque_type(self):
sat = Satellite(np.array([1.,0.,0.,0.,0.,0.,0.]),13.)
sat.setPos(np.array([7070e3,0.,0.]))
result = dist.gg_torque(sat)
self.assertEqual(type(result),np.ndarray)
def test_solar_torque_value(self):
state = np.array([1.,0.,0.,0.,0.1,-0.02,-0.2])
mySat = Satellite(state,128.05)
v_sv_i=np.array([1.0,0.0,0.0]) #sun vector in eci frame
mySat.setSun_i(v_sv_i)
result = dist.solar_torque(mySat)
print result
self.assertTrue(np.allclose(result,[ 0.00000000e+00,-3.66624000e-11,3.17376000e-10]))
if __name__=="__main__":
unittest.main(verbosity=2)