Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
joyxyz1994 committed Aug 13, 2024
1 parent cb6139c commit 93eded7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exposan/bsm2/system_P.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
8 changes: 5 additions & 3 deletions tests/test_bsm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93eded7

Please sign in to comment.