Skip to content

Commit

Permalink
fix bug related to dynamic stoichiometry
Browse files Browse the repository at this point in the history
  • Loading branch information
joyxyz1994 committed Mar 12, 2024
1 parent 8788a40 commit f3c3e07
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qsdsan/_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,9 +1207,17 @@ def _lambdify_stoichio(self):
if dct:
sbs = [i.symbol for i in dct.values()]
lamb = lambdify(sbs, self._stoichiometry, 'numpy')
static_params = {k:v for k,v in dct_vals.items() if k not in dct}
stoichio = []
isa = isinstance
for row in self._stoichiometry:
stoichio.append([v.evalf(subs=static_params) if not isa(v, (float, int)) else v for v in row])
sbs = [symbols(i) for i in dct.keys()]
lamb = lambdify(sbs, stoichio, 'numpy')
arr = np.empty((self.size, len(self._components)))
def f():
v = [v for k,v in dct_vals.items() if k in dct.keys()]
v = [dct_vals[k] for k in dct.keys()]
arr[:,:] = lamb(*v)
return arr
self.__dict__['_stoichio_lambdified'] = f
Expand Down

0 comments on commit f3c3e07

Please sign in to comment.