From 3eeb04520a40a7f0a5eee71ac015020fafdbd2cd Mon Sep 17 00:00:00 2001 From: Joy Zhang Date: Wed, 11 Oct 2023 11:35:36 -0700 Subject: [PATCH] scale stoichiometric coefficients to match default rate equation --- qsdsan/_process.py | 5 +++-- qsdsan/processes/_madm1.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qsdsan/_process.py b/qsdsan/_process.py index df1a812b..35ae8ff1 100644 --- a/qsdsan/_process.py +++ b/qsdsan/_process.py @@ -706,8 +706,9 @@ def _normalize_stoichiometry(self, new_ref): self._stoichiometry = [v/factor for v in stoich] def _normalize_rate_eq(self, new_ref): - factor = abs(self._stoichiometry[self._components.index(str(new_ref))]) - self._rate_equation *= factor + if self._rate_equation: + factor = abs(self._stoichiometry[self._components.index(str(new_ref))]) + self._rate_equation *= factor def show(self): info = f"Process: {self.ID}" diff --git a/qsdsan/processes/_madm1.py b/qsdsan/processes/_madm1.py index 66038651..47d06dd9 100644 --- a/qsdsan/processes/_madm1.py +++ b/qsdsan/processes/_madm1.py @@ -567,6 +567,10 @@ def __new__(cls, components=None, path=None, parameters=cls._stoichio_params, compile=False) + for i in ('fast_P_binding', 'slow_P_sorption', 'dissolution_HFO_HP', 'dissolution_HFO_LP'): + p = getattr(self, i) + p.ref_component = 'S_IP' + precipitation = [] for i in cls._precipitate_IDs[:-3]: new_p = Process('precipitation_%s' % i.lstrip('X_'),