Пример #1
0
    def test_corespeciesRate(self):
        """
        Test if a specific core species rate is equal to 0 over time.
        """
                
        c0 = {self.C2H5: 0.1, self.CH3: 0.1, self.CH4: 0.4, self.C2H6: 0.4}
        rxn1 = Reaction(
            reactants=[self.C2H6, self.CH3],
            products=[self.C2H5, self.CH4],
            kinetics=Arrhenius(A=(686.375*6, 'm^3/(mol*s)'), n=4.40721, Ea=(7.82799, 'kcal/mol'), T0=(298.15, 'K'))
        )
 
        coreSpecies = [self.CH4, self.CH3, self.C2H6, self.C2H5]
        edgeSpecies = []
        coreReactions = [rxn1]
        edgeReactions = []
        sensitivity = []
        terminationConversion = []
        sensitivityThreshold = 0.001
        ConstSpecies = ["CH4"]
        
        rxnSystem = LiquidReactor(self.T, c0, terminationConversion, sensitivity, sensitivityThreshold, ConstSpecies)
        # The test regarding the writing of constantSPCindices from input file is check with the previous test.
        rxnSystem.constSPCIndices = [0]
        
        rxnSystem.initializeModel(coreSpecies, coreReactions, edgeSpecies, edgeReactions)
 
        tlist = numpy.array([10**(i/10.0) for i in range(-130, -49)], numpy.float64)
 
        # Integrate to get the solution at each time point
        t, y, reactionRates, speciesRates = [], [], [], []
        for t1 in tlist:
            rxnSystem.advance(t1)
            t.append(rxnSystem.t)
            self.assertEqual(rxnSystem.coreSpeciesRates[0], 0, "Core species rate has to be equal to 0 for species hold constant. Here it is equal to {0}".format(rxnSystem.coreSpeciesRates[0]))
Пример #2
0
    def test_corespeciesRate(self):
        "Test if a specific core species rate is equal to 0 over time"    
                
        c0={self.C2H5: 0.1, self.CH3: 0.1, self.CH4: 0.4, self.C2H6: 0.4}
        rxn1 = Reaction(reactants=[self.C2H6,self.CH3], products=[self.C2H5,self.CH4], kinetics=Arrhenius(A=(686.375*6,'m^3/(mol*s)'), n=4.40721, Ea=(7.82799,'kcal/mol'), T0=(298.15,'K')))
 
        coreSpecies = [self.CH4,self.CH3,self.C2H6,self.C2H5]
        edgeSpecies = []
        coreReactions = [rxn1]
        edgeReactions = []
        sensitivity=[]
        terminationConversion = []
        sensitivityThreshold=0.001
        ConstSpecies = ["CH4"]
        
        rxnSystem = LiquidReactor(self.T, c0, terminationConversion, sensitivity,sensitivityThreshold,ConstSpecies)
        ##The test regarding the writting of constantSPCindices from input file is check with the previous test.
        rxnSystem.constSPCIndices=[0]
        
        rxnSystem.initializeModel(coreSpecies, coreReactions, edgeSpecies, edgeReactions)
 
        tlist = numpy.array([10**(i/10.0) for i in range(-130, -49)], numpy.float64)
 
        # Integrate to get the solution at each time point
        t = []; y = []; reactionRates = []; speciesRates = []
        for t1 in tlist:
            rxnSystem.advance(t1)
            t.append(rxnSystem.t)
            self.assertEqual(rxnSystem.coreSpeciesRates[0], 0,"Core species rate has to be equal to 0 for species hold constant. Here it is equal to {0}".format(rxnSystem.coreSpeciesRates[0]))