diff --git a/exposan/bsm2/system_P.py b/exposan/bsm2/system_P.py index 38c83400..69ac3b14 100644 --- a/exposan/bsm2/system_P.py +++ b/exposan/bsm2/system_P.py @@ -143,7 +143,7 @@ def create_system(flowsheet=None, default_init_conds=True): adm1_model=adm, asm2d_model=asm) AD = su.AnaerobicCSTR('AD', ins=J1.outs[0], outs=('biogas', 'AD_eff'), isdynamic=True, V_liq=3400, V_gas=300, T=T_ad, model=adm,) - AD.algebraic_h2 = False + AD.algebraic_h2 = True J2 = su.ADM1ptomASM2d('J2', upstream=AD-1, thermo=thermo_asm, isdynamic=True, adm1_model=adm, asm2d_model=asm) # Switch back to ASM1 components @@ -290,7 +290,7 @@ def run(sys, t, t_step, method=None, **kwargs): dct = globals() dct.update(sys.flowsheet.to_dict()) - t = 30 + t = 15 t_step = 1 # method = 'RK45' method = 'RK23' diff --git a/tests/test_bsm2.py b/tests/test_bsm2.py index d8c4053e..2ea6d98f 100644 --- a/tests/test_bsm2.py +++ b/tests/test_bsm2.py @@ -27,8 +27,9 @@ def test_bsm2(): t_span = (0, 20) # just 20 days to make the test faster sys.simulate(method='RK23', t_span=t_span, - # state_reset_hook='reset_cache') - ) + # state_reset_hook='reset_cache', + # print_t=True, + ) u = sys.flowsheet.unit s = sys.flowsheet.stream @@ -75,7 +76,7 @@ def test_bsm2(): [28.0643, 0.67336, 1532.2609, 31.9144, 2242.1274, 167.8482, 970.3678, 1.3748, 9.1948, 0.15845, 0.55943, 2.3926, 4.5646*12] ]) concs = np.vstack((u.A1._state[:13], u.A2._state[:13], u.O1._state[:13], u.O2._state[:13], u.O3._state[:13])) - ac(concs, as_ss_concs, rtol=rtol) + ac(concs, as_ss_concs, rtol=8e-2) clarifier_tss = np.array([14.3255, 20.8756, 34.2948, 81.0276, 423.2035, 423.2035, 423.2035, 423.2035, @@ -133,6 +134,7 @@ def test_bsm2(): ) ad_ss = np.array([*ad_ss.values()]) ad_state = np.delete(u.AD1._state, 26) # remove "H2O" + # ad_state[ad_state < 1e-16] = 0. ac(ad_state, ad_ss, rtol=rtol) assert np.isclose(s.AD_eff.pH, 7.2631, rtol=rtol) assert np.isclose(s.biogas.imass['S_h2']*24 * h2.i_mass, 0.0035541, rtol=rtol)