def test_rsystem_build_from_xml_fail(): try: concs = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_reversible.xml", concs) except ValueError as err: assert (type(err) == ValueError)
def test_system_progress_rates(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) assert (np.allclose( rsystem.getProgressRate(), np.array([2.81117621e+08, 5.00000000e+03, 4.48493847e+06])))
def test_system_update_coeff(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) rsystem.reactionList[2].updateCoeff(type="modifiedArrhenius", A=100000000.0, b=0.5, E=50000.0) assert (rsystem.reactionList[2].k == rsystem.reactionList[0].k)
def test_equilibrium_1(): T = 900 R = 8.314 concs = np.array([0.5, 0, 0, 2, 0, 1, 0, 0]) rsystem = ck.ReactionSystem(T, R, "tests/data/db/nasa.sqlite") rsystem.buildFromXml("tests/data/xml/rxns_reversible.xml", concs) s = sim.Simulator(rsystem, 0.1) s.solveODE() assert (s.check_equilibrium(5, 0.99) == True)
def test_rsystem_reaction_rates(): concs = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_reversible.xml", concs) assert (np.allclose( rsystem.getReactionRate(), np.array([ 6.22261584e+14, -7.10493349e+14, -7.28739230e+14, 2.97882825e+13, 1.35132846e+14, 8.16829127e+14, -1.06193909e+14, -5.85853515e+13 ])))
def test_system_reaction_rates(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) assert (np.allclose( rsystem.getReactionRate(), np.array([ -2.81117621e+08, -2.85597559e+08, 5.66715180e+08, 4.47993847e+06, -4.47993847e+06 ])))
def test_solve_ODE(): T = 900 R = 8.314 concs = np.array([0.5, 0, 0, 2, 0, 1, 0, 0]) rsystem = ck.ReactionSystem(T, R, "tests/data/db/nasa.sqlite") rsystem.buildFromXml("tests/data/xml/rxns_reversible.xml", concs) s = sim.Simulator(rsystem, 0.05) try: s.solveODE() except ValueError as err: assert (type(err) == ValueError)
def test_system_rebuild(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) rsystem.reactionList[2].updateCoeff(type="modifiedArrhenius", A=100000000.0, b=0.5, E=50000.0) rsystem.buildFromList(rsystem.reactionList, rsystem.species, concs) print(rsystem) assert (len(rsystem) == 3) assert (np.allclose( rsystem.getProgressRate(), np.array([2.81117621e+08, 5.00000000e+03, 7.02794052e+07])))
from chemkin_g10 import chemkin as ck import numpy as np T = 2500.0 R = 8.314 concs = np.array([0.5, 0, 0, 2, 0, 1, 0, 0]) rsystem = ck.ReactionSystem(T, R, "../tests/data/db/nasa.sqlite") rsystem.buildFromXml("../tests/data/xml/rxns_reversible.xml", concs) print("Reaction rate: \n", rsystem.getReactionRate(), "\n") print("System info: \n", rsystem, "\n") T = 900.0 rsystem = ck.ReactionSystem(T, R, "../tests/data/db/nasa.sqlite") rsystem.buildFromXml("../tests/data/xml/rxns_reversible.xml", concs) print("Reaction rate: \n", rsystem.getReactionRate(), "\n") print("System info: \n", rsystem, "\n")
def test_rsystem_build_from_xml(): concs = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_reversible.xml", concs) assert (len(rsystem) == 11)
def test_system_update_reaction(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) rsystem.reactionList[2].updateReaction(reversible='yes') assert (rsystem.reactionList[2].reactMeta['reversible'] == 'yes')
def test_system_build_from_xml(): concs = np.array([2.0, 1.0, 0.5, 1.0, 1.0]) rsystem = ck.ReactionSystem(1500, 8.314, path2 + 'nasa.sqlite') rsystem.buildFromXml(path + "rxns_short_2.xml", concs) assert (len(rsystem) == 3)