class TestStatics(unittest.TestCase): def setUp(self): self.fs = CanteraFS() self.fs.W = 100. self.fs.setDryAir() self.fs.setTotalTP(1100, 400) #print (self.fs._flow) #all test cases use the same checks here, so just re-use def _assert(self): self.assertAlmostEqual(self.fs.area, 32.0066, places=1) self.assertAlmostEqual(self.fs.Mach, .3, places=1) self.assertAlmostEqual(self.fs.Ps, 376.219, places=1) self.assertAlmostEqual(self.fs.Ts, 1081.732, places=0) self.assertAlmostEqual(self.fs.Vflow, 479.298, places=0) self.assertAlmostEqual(self.fs.rhos, .9347, places=2) self.assertAlmostEqual(self.fs.Mach, .3, places=2) def test_set_Mach(self): self.fs.Mach = .3 self._assert() def test_set_area(self): self.fs.area = 32.0066 self._assert() def test_set_Ps(self): self.fs.Ps = 376.219 self._assert() def test_setStaticTsPsMN(self): self.fs.setStaticTsPsMN(1081.802, 376.219, .3) self._assert()
class TestStatics(unittest.TestCase): def setUp(self): self.fs = CanteraFS() self.fs.W = 100. self.fs.setDryAir() self.fs.setTotalTP(1100, 400) self.fs.setTotalTP(1100, 400) self.fs.W = 100. self.fs.add_reactant("Jet-A(g)") self.fs.burn("Jet-A(g)", 2.5, -642.) def test_set_Mach(self): self.fs.Mach = .3 self.assertAlmostEqual(self.fs.Mach, .3, places=1) self.assertAlmostEqual(self.fs.area, 52.60, places=1) self.assertAlmostEqual(self.fs.Ps, 377.52, places=1) self.assertAlmostEqual(self.fs.Ts, 2635.2, places=0) self.assertAlmostEqual(self.fs.Vflow, 725.81, places=0) self.assertAlmostEqual(self.fs.rhos, .386, places=2) self.assertAlmostEqual(self.fs.gams, 1.294, places=2) self.fs.Mach =1.3 self.assertAlmostEqual(self.fs.Mach, 1.3, places=1) self.assertAlmostEqual(self.fs.area, 27.40, places=1) self.assertAlmostEqual(self.fs.Ps, 149.66, places=1) self.assertAlmostEqual(self.fs.Ts, 2131, places=0) self.assertAlmostEqual(self.fs.Vflow, 2842, places=0) self.assertAlmostEqual(self.fs.rhos, .189, places=2) self.assertAlmostEqual(self.fs.gams, 1.306, places=2) self.fs.Mach=1.0 self.assertAlmostEqual(self.fs.Mach, 1.0, places=1) self.assertAlmostEqual(self.fs.area, 25.59, places=1) self.assertAlmostEqual(self.fs.Ps, 218.15, places=1) self.assertAlmostEqual(self.fs.Ts, 2325.9, places=0) self.assertAlmostEqual(self.fs.Vflow, 2279.3, places=0) self.assertAlmostEqual(self.fs.rhos, .253, places=2) self.assertAlmostEqual(self.fs.gams, 1.301, places=2) def test_set_area(self): self.fs.area = 52.06 self.assertAlmostEqual(self.fs.Mach, .3, places=1) self.assertAlmostEqual(self.fs.area, 52.06, places=1) self.assertAlmostEqual(self.fs.Ps, 377.01, places=1) self.assertAlmostEqual(self.fs.Ts, 2634.45, places=0) self.assertAlmostEqual(self.fs.Vflow, 734.24, places=0) self.assertAlmostEqual(self.fs.rhos, .386, places=2) def test_set_Ps(self): self.fs.Ps = 377.52 self.assertAlmostEqual(self.fs.Mach, .3, places=1) self.assertAlmostEqual(self.fs.area, 52.6, places=1) self.assertAlmostEqual(self.fs.Ps, 377.5, places=1) self.assertAlmostEqual(self.fs.Ts, 2635, places=0) self.assertAlmostEqual(self.fs.Vflow, 725.94, places=0) self.assertAlmostEqual(self.fs.rhos, .386, places=2) def test_setStaticTsPsMN(self): self.fs.setStaticTsPsMN(1081.802, 376.219, .3) self.assertAlmostEqual(self.fs.Mach, .3, places=1) self.assertAlmostEqual(self.fs.area, 33.0, places=1) self.assertAlmostEqual(self.fs.Ps, 376.219, places=1) self.assertAlmostEqual(self.fs.Ts, 1081.732, places=0) self.assertAlmostEqual(self.fs.Vflow, 476.58, places=0) self.assertAlmostEqual(self.fs.rhos, .9347, places=2) def test_chokeFlow(self): self.fs.Mach = 1 self.fs.area=self.fs.area/2 print self.fs.Mach