From d3c4fc4ef1261ba3982fbf25bcedc57efe69a5a8 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 23 Apr 2024 10:54:08 +0200 Subject: [PATCH] .. --- python/sdist/amici/de_model.py | 3 ++- python/sdist/amici/sbml_import.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/python/sdist/amici/de_model.py b/python/sdist/amici/de_model.py index 8168b4199d..4995976dcf 100644 --- a/python/sdist/amici/de_model.py +++ b/python/sdist/amici/de_model.py @@ -1400,7 +1400,8 @@ def _compute_equation(self, name: str) -> None: if not s.has_conservation_law() ), self.sym("dx"), - strict=True, + # dx contains extra elements for algebraic states + strict=False, ) ] + [eq.get_val() for eq in self._algebraic_equations] diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 5c42b351ca..a54f8ebe0b 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -556,9 +556,13 @@ def _build_ode_model( dxdt = smart_multiply( self.stoichiometric_matrix, MutableDenseMatrix(fluxes) ) + # there may be an additional 0-entry at the end of the + # stoichiometric matrix / flux vector + assert dxdt.shape[0] - len(self.symbols[SymbolId.SPECIES]) in (0, 1) + # correct time derivatives for compartment changes for ix, ((species_id, species), formula) in enumerate( - zip(self.symbols[SymbolId.SPECIES].items(), dxdt, strict=True) + zip(self.symbols[SymbolId.SPECIES].items(), dxdt, strict=False) ): # rate rules and amount species don't need to be updated if "dt" in species: