Esempio n. 1
0
def test_bad_coeff():
    """test that input parser correctly identifies that species array is missing"""
    try:
        input_ = InputParser('tests/test_xml/rxns_bad_coeff.xml')
    except ValueError as e:
        assert type(e) == ValueError
        print(e)
Esempio n. 2
0
def test_missing_equation():
    """test that input parser correctly identifies that species array is missing"""
    try:
        input_ = InputParser('tests/test_xml/rxns_missing_attribute.xml')
    except AttributeError as e:
        assert type(e) == AttributeError
        print(e)
Esempio n. 3
0
def test_extradata():
    """test that input parser correctly identifies too many reaction systems present"""
    try:
        input_ = InputParser('tests/test_xml/rxns_doubleddata.xml')
    except ValueError as e:
        assert type(e) == ValueError
        print(e)
Esempio n. 4
0
def test_no_reversible():
    """
    Check that the empty case can be handled
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    assert len(bc.backward_coeffs(np.array([]), 500)) == 0
Esempio n. 5
0
def test_missingcoeffdata():
    """test that input parser correctly identifies that coefficient data is missing"""
    try:
        input_ = InputParser('tests/test_xml/rxns_missingcoeffdata.xml')
    except AttributeError as e:
        assert type(e) == AttributeError
        print(e)
    try:
        input_ = InputParser('tests/test_xml/rxns_missing_k.xml')
    except AttributeError as e:
        assert type(e) == AttributeError
        print(e)
    try:
        input_ = InputParser('tests/test_xml/rxns_missing_A.xml')
    except AttributeError as e:
        assert type(e) == AttributeError
        print(e)
Esempio n. 6
0
def test_singlerxn():
    """test that input parser correctly handles the single reaction case"""
    input_ = InputParser('tests/test_xml/rxns_single.xml')
    assert len(input_) == 1
    assert np.array_equal(input_.nu_prod, np.array([[0], [0], [1], [1]]))
    assert np.array_equal(input_.nu_react, np.array([[1], [1], [0], [0]]))
    assert input_.rate_coeff_params[0]['k'] == 10000.0
    assert input_.rate_coeff_params[0]['type'] == 'Constant'
    print(repr(input_))
Esempio n. 7
0
def test_CPcalc_single():
    """
    Test that single reaction case is handled correctly
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    Cp_r = bc.Cp_over_R(500.)
    assert np.all(
        np.isclose(Cp_r, np.array([2.5, 3.73848592, 2.55540662, 3.54595678])))
Esempio n. 8
0
def test_Hcalc_single():
    """
    Test that single reaction case is handled correctly
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    H_ = bc.H_over_RT(500.)
    assert np.all(
        np.isclose(
            H_, np.array([53.4473198, 1.46400033, 60.98145063, 10.90244139])))
Esempio n. 9
0
def test_dimension():
    """
    Check that incompatible input array sizes are correctly caught
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    try:
        bc.backward_coeffs(np.array([1, 2, 3]), 500)
    except ValueError as e:
        assert type(e) == ValueError
        print(e)
Esempio n. 10
0
def test_coeffs_single():
    """
    Test that single reaction case is handled correctly
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    rc_list = [ReactionCoeffs(**params) for params in ip.rate_coeff_params]
    for rc in rc_list:
        rc.set_params(T=500)
    kf = np.array([rc.k_forward() for rc in rc_list])
    kb = bc.backward_coeffs(kf, 500)
    assert np.isclose(kb[0], 6.03552730e+18)
Esempio n. 11
0
def test_coeffs_None():
    """
    Check that coefficients are being set correctly
    """
    ip = InputParser('tests/test_xml/rxns_singlereversible.xml')
    sql = SQLParser()
    bc = BackwardCoeffs(ip.nu_react, ip.nu_prod, ip.species)
    bc.coeffs = None
    H_ = bc.H_over_RT(500)
    assert np.all(
        np.isclose(
            H_, np.array([53.4473198, 1.46400033, 60.98145063, 10.90244139])))
    bc.coeffs = None
    S_ = bc.S_over_R(500)
    assert np.all(
        np.isclose(
            S_, np.array([15.08983739, 26.54400129, 20.70986963,
                          23.94106991])))
Esempio n. 12
0
def test_correct():
    """test of standard usage"""
    input_ = InputParser('tests/test_xml/rxns.xml')
    assert len(input_) == 3
    assert len(eval(repr(input_))) == 3
    print(repr(input_))