From ea0df7d17bd6a9d2e1adba62c12f22059f5df3d7 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 7 May 2024 10:28:19 +0200 Subject: [PATCH] Fix execution of multiple event assignments from the same event Fixes #2430 --- python/sdist/amici/sbml_import.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index a26c6e7d4a..233b91af1c 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -1660,21 +1660,16 @@ def get_empty_bolus_value() -> sp.Float: for species_sym in concentration_species_by_compartment[ compartment_sym ]: - # If the species was not affected by an event assignment - # then the old value should be updated. + # Only if the species was not affected by any other event + # assignment, the old value should be updated. if ( bolus[state_vector.index(species_sym)] == get_empty_bolus_value() ): - species_value = species_sym - # else the species was affected by an event assignment, - # hence the updated value should be updated further. - else: - species_value = bolus[state_vector.index(species_sym)] - # New species value is old amount / new volume. - bolus[state_vector.index(species_sym)] = ( - species_value * compartment_sym / formula - ) + # New species value is old amount / new volume. + bolus[state_vector.index(species_sym)] = ( + species_sym * compartment_sym / formula + ) # Subtract the current species value from each species with an # update, as the bolus will be added on to the current species