class TestSetTotals(unittest.TestCase): def setUp(self): """Initialization function called before every test function""" self.fs = CanteraFS() self.fs.W = 100 self.fs.setDryAir() self.fs.setTotalTP(518, 15) def tearDown(self): """Clean up function called after every test function""" pass #nothing to do for this test #all test function have to start with "test_" as the function name def test_setTotalTP(self): self.assertAlmostEqual(self.fs.Pt, 15.0, places=2) self.assertAlmostEqual(self.fs.Tt, 518, places=2) self.assertAlmostEqual(self.fs.ht, -6.32816, places=4) #Tom says the ht values will be different self.assertAlmostEqual(self.fs.W, 100, places=2) self.assertAlmostEqual(self.fs.rhot, .07812, places=4) self.assertAlmostEqual(self.fs.gamt, 1.40, places=2) def test_setTotal_hP(self): ht = self.fs.ht self.fs.setTotalTP(1000, 40) #just to move things around a bit self.fs.setTotal_hP(ht, 15) self.test_setTotalTP() #just call this since it has all the checks we need def test_setTotal_SP(self): s = self.fs.s self.fs.setTotalTP(1000, 40) #just to move things around a bit self.fs.setTotalSP(s, 15) self.test_setTotalTP() #just call this since it has all the checks we need def test_delh(self): ht = self.fs.ht self.fs.setTotalTP(1000, 40) diffh = self.fs.ht - ht self.assertAlmostEqual(diffh, 117.4544, places=2) def test_dels(self): s = self.fs.s self.fs.setTotalTP(1000, 40) diffs = self.fs.s - s self.assertAlmostEqual(diffs, .092609, places=4) def test_set_WAR(self): self.fs.setWAR( 0.02 ) self.fs.setTotalTP(1000, 15) self.assertAlmostEqual(self.fs.Pt, 15., places=2) self.assertAlmostEqual(self.fs.Tt, 1000, places=2) self.assertAlmostEqual(self.fs.WAR, 0.02, places=2) self.assertAlmostEqual(self.fs.FAR, 0, places=2) def test_setDryAir(self): self.fs.setDryAir() self.fs.setTotalTP(1000, 15) self.assertAlmostEqual(self.fs.WAR, 0, places=2) self.assertAlmostEqual(self.fs.FAR, 0, places=2)
class Duct(Component): dP = Float(0.0, iotype='in', desc='') FSin= Slot(CanteraFS, iotype="in", copy=None) FSout = Slot(CanteraFS, iotype="out", copy=None) def __init__(self): super(Duct, self).__init__() self.FSin = CanteraFS() self.FSout = CanteraFS() def execute(self): self.FSin.W = 100 self.FSout.copy(self.FSin) #print "self.dp " + str(self.dP) self.FSout.setTotal_hP(self.FSin.ht, self.FSin.Pt*(1 - self.dP))