Skip to content

Commit

Permalink
minor update to improve numerical stability
Browse files Browse the repository at this point in the history
  • Loading branch information
joyxyz1994 committed Dec 4, 2024
1 parent 38a791b commit 68a3ae1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions qsdsan/sanunits/_junction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,8 @@ def adm1p2masm2d(adm_vals):
fraction_dissolve = max(0, min(1, - S_IC / xc_mmp))
asm_vals -= fraction_dissolve * X_CaCO3 * cac_sto
asm_vals -= fraction_dissolve * X_MgCO3 * mgc_sto
if asm_vals[8] < 0:
asm_vals[8] = 0
if S_IN < 0:
xn_mmp = sum(asm_vals[_mmp_idx] * mmp_in)
if xn_mmp > 0:
Expand Down Expand Up @@ -3022,6 +3024,8 @@ def masm2d2adm1p(asm_vals):
fraction_dissolve = max(0, min(1, - S_IC / xc_mmp))
adm_vals -= fraction_dissolve * X_CaCO3 * cac_sto
adm_vals -= fraction_dissolve * X_MgCO3 * mgc_sto
if adm_vals[9] < 0:
adm_vals[9] = 0
if S_IN < 0:
xn_mmp = sum(adm_vals[_mmp_idx] * mmp_in)
if xn_mmp > 0:
Expand Down
2 changes: 1 addition & 1 deletion qsdsan/sanunits/_suspended_growth_bioreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ def _init_state(self):
def _update_state(self):
out, = self.outs
ncol = self._ncol
self._state[self._state < 2.2e-16] = 0.
self._state[self._state < 1e-16] = 0.
self._state[self._Qs_idx] = self._Qs
if out.state is None: out.state = np.zeros(ncol)
out.state[:-1] = self._state[-ncol:-1]
Expand Down

0 comments on commit 68a3ae1

Please sign in to comment.