Skip to content

Commit c741385

Browse files
committed
..
1 parent 5d3dbbc commit c741385

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

include/amici/model_dae.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ class Model_DAE : public Model {
446446
* @param x Vector with the states
447447
* @param p parameter vector
448448
* @param k constants vector
449-
* @param h heavyside vector
449+
* @param h Heaviside vector
450450
* @param dx Vector with the derivative states
451451
* @param w vector with helper variables
452452
*/

python/sdist/amici/de_model.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ def num_events_solver(self) -> int:
652652
:return:
653653
number of event symbols (length of the root vector in AMICI)
654654
"""
655+
# TODO(performance): we could include constant `x` here as well
656+
# (dx/dt = 0 AND not target of event assignments)
657+
# this will require passing `x` to `fexplicit_roots`
655658
static_syms = self._static_symbols(["k", "p", "w"])
656659
return sum(
657660
not event.has_explicit_trigger_times(static_syms)
@@ -1138,6 +1141,7 @@ def generate_basic_variables(self) -> None:
11381141
Generates the symbolic identifiers for all variables in
11391142
``DEModel._variable_prototype``
11401143
"""
1144+
self.parse_events()
11411145
self._reorder_events()
11421146

11431147
for var in self._variable_prototype:
@@ -1164,11 +1168,6 @@ def parse_events(self) -> None:
11641168
for expr in self._expressions:
11651169
expr.set_val(self._process_heavisides(expr.get_val(), roots))
11661170

1167-
# remove all possible Heavisides from roots, which may arise from
1168-
# the substitution of `'w'` in `_collect_heaviside_roots`
1169-
for root in roots:
1170-
root.set_val(self._process_heavisides(root.get_val(), roots))
1171-
11721171
# Now add the found roots to the model components
11731172
for root in roots:
11741173
# skip roots of SBML events, as these have already been added

python/sdist/amici/importers/pysb/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ def ode_model_from_pysb_importer(
398398

399399
_process_stoichiometric_matrix(model, ode, fixed_parameters)
400400

401-
ode.parse_events()
402401
ode.generate_basic_variables()
403402

404403
return ode

python/sdist/amici/importers/sbml/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,7 @@ def _build_ode_model(
700700
if hybridization:
701701
ode_model._process_hybridization(hybridization)
702702

703-
ode_model.parse_events()
704703
# substitute SBML-rateOf constructs
705-
# must be done after parse_events, but before generate_basic_variables
706704
self._process_sbml_rate_of(ode_model)
707705

708706
# fill in 'self._sym' based on prototypes and components in ode_model

python/tests/test_pysb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_names_and_ids(pysb_example_presimulation_module):
328328

329329

330330
@skip_on_valgrind
331-
def test_heavyside_and_special_symbols():
331+
def test_heaviside_and_special_symbols():
332332
pysb.SelfExporter.cleanup() # reset pysb
333333
pysb.SelfExporter.do_export = True
334334

src/model_dae.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ void Model_DAE::froot(
9595
) {
9696
std::ranges::fill(root, 0.0);
9797
auto const x_pos = compute_x_pos(x);
98-
// TODO too costly? only dynamic expressions?
98+
// TODO(performance) only dynamic expressions? consider storing a flag
99+
// for whether froot actually depends on `w`.
99100
fw(t, N_VGetArrayPointerConst(x_pos));
100101
froot(
101102
root.data(), t, N_VGetArrayPointerConst(x_pos),

src/model_ode.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ void Model_ODE::froot(
8484
realtype const t, const_N_Vector x, gsl::span<realtype> root
8585
) {
8686
auto const x_pos = compute_x_pos(x);
87-
// TODO too costly? only dynamic expressions?
87+
// TODO(performance) only dynamic expressions? consider storing a flag
88+
// for whether froot actually depends on `w`.
8889
fw(t, N_VGetArrayPointerConst(x_pos));
8990
std::ranges::fill(root, 0.0);
9091
froot(

0 commit comments

Comments
 (0)