def test_progress_rate_01(): """Test progress rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(1500).get_progress_rate(np.array([2.0, 1.0, 0.5, 1.0, 1.0])) test1 = [2.811803e+08, 5.000000e+03, 4.485138e+06] np.testing.assert_allclose(rate, test1, 1e-06)
def test_reaction_rate_reversible_results_01(): """Test reaction rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_reversible.xml').set_temp(750).get_reaction_rate(np.array([2.0, 1.0, 0.5, 1.0, 1.0, 1.5, 0.5, 1])) test1 = np.array([ 3.421869e+16, -3.381907e+16, -3.528628e+16, 4.070991e+13, 5.865465e+14, 3.439104e+16, -7.635885e+13, -5.528322e+13] ) np.testing.assert_allclose(rate, test1, 1e-06)
def test_read_XML_02(): """Test XML file import: New Arrhenius coefficient included.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_02.xml') return f except NotImplementedError as err: assert(type(err) == NotImplementedError)
def test_read_XML_10(): """Test XML file import: Unit Conversion I.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_10.xml', verify_integrity=False, convert_units=True) return f except NotImplementedError as err: assert(type(err) == NotImplementedError)
def test_read_XML_09(): """Test XML file import: Additional species.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_09.xml') return f except ValueError as err: assert(type(err) == ValueError)
def test_read_XML_08(): """Test XML file import: Multiple reaction systems.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_08.xml') return f except NotImplementedError as err: assert(type(err) == NotImplementedError)
def test_read_XML_07(): """Test XML file import: Input b in Arrhenius reaction coefficient.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_07.xml') return f except ValueError as err: assert(type(err) == ValueError)
def test_read_XML_06(): """Test XML file import: Missing reaction coefficients.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_06.xml') return f except ValueError as err: assert(type(err) == ValueError)
def test_read_XML_05(): """Test XML file import: Missing param for modified Arrhenius.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_05.xml') return f except ValueError as err: assert(type(err) == ValueError)
def test_read_XML_04(): """Test XML file import: Includes duplicate reaction.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_04.xml') return f except NotImplementedError as err: assert(type(err) == NotImplementedError)
def test_reaction_rate__input_04(): """Test reaction rate input checks: Negative concentrations.""" rc = chemkin.ReactionRate() try: rate = rc.read_XML('./data/rxns_reversible.xml').set_temp(150).get_reaction_rate(np.array([-0.5, 1, 1, 1, 1])) return rate except ValueError as err: assert(type(err) == ValueError)
def test_instance(): """Test progress rate values.""" a = chemkin.ReactionRate() a.read_XML('./data/rxns_units.xml', verify_integrity=True, convert_units=True) test = "Number_of_reactions:3 \nNumber_of_species:6 \nNumber_of_reversible_reactions:0 \nReversible:No \nReaction_type:Elementary \nSpecies_list:['H', 'O', 'OH', 'H2', 'H2O', 'O2']\n" test = test.replace('\n', '').replace(' ', '') res = str(a).replace('\n', '').replace(' ', '') assert (res == test)
def test_reaction_rate__input_01(): """Test reaction rate input checks: Incorrect concentration array dimension.""" rc = chemkin.ReactionRate() try: rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(1500).get_reaction_rate(np.array([0, 0, 0])) return rate except ValueError as err: assert(type(err) == ValueError)
def test_read_XML_01(): """Test XML file import: Phase tag not included.""" rc = chemkin.ReactionRate() try: f = rc.read_XML('./data/rxns_test/rxns_test_01.xml') return f except ValueError as err: assert(type(err) == ValueError)
def test_reaction_rate__input_02(): """Test reaction rate input checks: Negative temperature.""" rc = chemkin.ReactionRate() try: rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(1500).get_reaction_rate(np.array([1, 1, 1, 1, 1])) return rate except ValueError as err: assert(type(err) == ValueError)
def test_reaction_rate_reversible_results_02(): """Test reaction rate values.""" rc = chemkin.ReactionRate() cwd = os.getcwd() print (cwd) rate = rc.read_XML('./data/rxns_reversible.xml').set_temp(1500).get_reaction_rate(np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])) test1 = np.array([ 0., 0., 0., 0., 0., 0., 0., 0.]) np.testing.assert_allclose(rate, test1, 1e-06)
def test_progress_rate_02(): """Test progress rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_reversible.xml').set_temp(750).get_progress_rate(np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])) test1 = [-6.878908e+16, -5.886229e+11, 2.734270e+12, -2.208086e+15, 1.454757e+13, 6.751911e+13, 3.250000e+13, 3.129762e+13, 1.275050e+13, 1.347004e+13, 2.842058e+12] np.testing.assert_allclose(rate, test1, 1e-06)
"""Module to run chemical kintetics library.""" from flamespeed import chemkin # ===================== # Elementary reactions # ===================== # Specie concentrations x = [0.5, 0, 0, 2, 0, 1] # Import reaction data a = chemkin.ReactionRate() a.read_XML('./flamespeed/data/rxns_units.xml', verify_integrity=False, convert_units=True) print(a) # Set temperature a.set_temp(900) # Progress rate r = a.get_reaction_rate(x) print("\nReaction rate:") print(r) # Set temperature a.set_temp(2500) # Progress rate r = a.get_reaction_rate(x)
def test_reaction_rate__results_03(): """Test reaction rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(1500).get_reaction_rate(np.array([0, 0, 0, 0, 0])) test1 = np.array([0, 0, 0, 0, 0]) np.testing.assert_allclose(rate, test1, 1e-06)
def test_reaction_rate_results_02(): """Test reaction rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(1500).get_reaction_rate(np.array([2.0, 1.0, 0.5, 1.0, 1.0])) test1 = np.array([ -2.811803e+08, -2.856604e+08, 5.668407e+08, 4.480138e+06, -4.480138e+06]) np.testing.assert_allclose(rate, test1, 1e-06)
def test_reaction_rate_results_01(): """Test reaction rate values.""" rc = chemkin.ReactionRate() rate = rc.read_XML('./data/rxns_hw5.xml').set_temp(750).get_reaction_rate(np.array([2.0, 1.0, 0.5, 1.0, 1.0])) test1 = np.array([-3608685.749817, -5615332.353438, 9224018.103256, 2006646.603621, -2006646.603621]) np.testing.assert_allclose(rate, test1, 1e-06)