예제 #1
0
class TestBurn(unittest.TestCase): 
        
    def test_burn(self):
            self.fs = CanteraFS()
            self.fs.setDryAir()
            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)
            self.assertAlmostEqual(self.fs.W, 102.5, places=2)
            self.assertAlmostEqual(self.fs.FAR, .025, places=2)
            self.assertAlmostEqual(self.fs.Pt, 400, places=2)
            self.assertAlmostEqual(self.fs.Tt, 2669.69, places=0)
            self.assertAlmostEqual(self.fs.ht, 117.16, places=1)
            self.assertAlmostEqual(self.fs.rhot, .401845715, places=2)
            self.assertAlmostEqual(self.fs.gamt, 1.293, places=3)

    def test_burn_rich(self):
            self.fs = CanteraFS()
            self.fs.setDryAir()
            self.fs.setTotalTP(1100, 400)
            self.fs.W = 100.
            self.fs.add_reactant("Jet-A(g)")
            self.fs.burn("Jet-A(g)", 10, -642)
            self.assertAlmostEqual(self.fs.W, 110., places=2)
            self.assertAlmostEqual(self.fs.FAR, .1, places=2)
            self.assertAlmostEqual(self.fs.Pt, 400, places=2)
            self.assertAlmostEqual(self.fs.Tt, 3979.6, places=0)
            self.assertAlmostEqual(self.fs.ht, 65.405, places=1) 
            self.assertAlmostEqual(self.fs.rhot, .249, places=2)
            self.assertAlmostEqual(self.fs.gamt, 1.266, places=3)  
            
    def test_add_vitiated(self):
            self.fs = CanteraFS()
            self.fs.setDryAir()
            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)
            self.fs1 = CanteraFS()
            self.fs1.setDryAir()
            self.fs1.W = 5.
            self.fs1.setWAR( .02 )
            self.fs1.setTotalTP(1100, 400)
            self.fs.add(self.fs1)
            self.assertAlmostEqual(self.fs.Tt, 2602.7, places=1)
            self.assertAlmostEqual(self.fs.W, 107.5, places=2)
            self.assertAlmostEqual(self.fs.FAR, .0238, places=4)
            self.assertAlmostEqual(self.fs.WAR, .000934, places=4)
            self.assertAlmostEqual(self.fs.Pt, 400, places=2)
            self.fs1.copy(self.fs)
            self.assertAlmostEqual(self.fs1.Tt, 2602.7, places=1)
            self.assertAlmostEqual(self.fs1.W, 107.5, places=2)
            self.assertAlmostEqual(self.fs1.FAR, .0238, places=4)
            self.assertAlmostEqual(self.fs1.WAR, .000934, places=4)
            self.assertAlmostEqual(self.fs1.Pt, 400, places=2)            
예제 #2
0
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))
예제 #3
0
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

    def test_copyFS(self): 

        #print "TESTING"

        self.new_fs = CanteraFS()

        self.new_fs.copy(self.fs)

        self.assertAlmostEqual(self.new_fs.Tt, 518)
        self.assertAlmostEqual(self.new_fs.Pt, 15)

     #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)
 
    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.WAR = 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.assertAlmostEqual(self.fs.WAR, 0, places=2)
        self.assertAlmostEqual(self.fs.FAR, 0, places=2)