forked from reilleya/openMotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
66 lines (48 loc) · 1.94 KB
/
test.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
import motorlib
import unittest
class TestMotorMethods(unittest.TestCase):
def test_calcKN(self):
tm = motorlib.motor()
bg = motorlib.batesGrain()
bg.setProperties({'diameter':0.083058,
'length':0.1397,
'coreDiameter':0.05,
'inhibitedEnds':'Neither'
})
tm.grains.append(bg)
tm.nozzle.setProperties({'throat': 0.01428})
self.assertAlmostEqual(tm.calcKN([0]), 180, 0)
self.assertAlmostEqual(tm.calcKN([0.0025]), 183, 0)
self.assertAlmostEqual(tm.calcKN([0.005]), 185, 0)
def test_calcPressure(self):
tm = motorlib.motor()
bg = motorlib.batesGrain()
bg.setProperties({'diameter':0.083058,
'length':0.1397,
'coreDiameter':0.05,
'inhibitedEnds':'Neither'
})
tm.grains.append(bg)
tm.nozzle.setProperties({'throat': 0.01428})
tm.propellant.setProperties({
'name': 'KNSU',
'density': 1890,
'a': 0.000101,
'n': 0.319,
't': 1720,
'm': 41.98,
'k': 1.133})
self.assertAlmostEqual(tm.calcIdealPressure([0]), 4050030, 0)
class TestGeometryMethods(unittest.TestCase):
def test_circle(self):
self.assertAlmostEqual(motorlib.circleArea(0.5), 0.19634954)
def test_tubeArea(self):
self.assertAlmostEqual(motorlib.tubeArea(0.5, 2), 3.14159265)
def test_cylinderArea(self):
self.assertAlmostEqual(motorlib.cylinderArea(0.5, 2), 3.53429174)
def test_cylinderVolume(self):
self.assertAlmostEqual(motorlib.cylinderVolume(0.5, 2), 0.39269908)
class TestNozzleMethods(unittest.TestCase):
def test_expansionRatio(self):
self.assertAlmostEqual(motorlib.eRatioFromPRatio(1.15, 0.0156), 0.10650602)
unittest.main()