Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f96107a
Use sbmlmath package for sympification of SBML math
dweindl Apr 1, 2025
431ac26
..
dweindl Apr 1, 2025
609808e
fix rateof
dweindl Apr 1, 2025
f2013ca
log_as_log10
dweindl Apr 1, 2025
cd55a97
time
dweindl Apr 1, 2025
59169a1
log10; hardcoded symbols
dweindl Apr 1, 2025
63122aa
units, XOR
dweindl Apr 1, 2025
6f3cd27
evalf, heaviside where needed
dweindl Apr 1, 2025
4a14498
fixup; avogadro
dweindl Apr 1, 2025
accc25a
Merge branch 'develop' into sbmlmath_gh-2146
dweindl Apr 1, 2025
c970f3a
simplify, trigger==False, exception type
dweindl Apr 2, 2025
3455ba4
bool, None
dweindl Apr 2, 2025
e592b5b
expr/basic
dweindl Apr 2, 2025
73bec7b
redundant formula
dweindl Apr 2, 2025
2e8c01b
Revert "redundant formula"
dweindl Apr 2, 2025
e93bdb8
Revert "expr/basic"
dweindl Apr 2, 2025
2a635ff
BooleanFunction to Piecewise
dweindl Apr 2, 2025
0b2e35e
Fix passenv
dweindl Apr 2, 2025
73ec65a
cleanup avogadro
dweindl Apr 2, 2025
ac418ba
evaluate / simplify
dweindl Apr 2, 2025
d1aee5e
cleanup
dweindl Apr 2, 2025
a626a77
-git+https
dweindl Apr 2, 2025
b814146
simplify still needed?
dweindl Apr 3, 2025
3757729
..
dweindl Apr 3, 2025
09ace91
cleanup
dweindl Apr 4, 2025
9726308
..
dweindl Apr 4, 2025
204f2c3
exception type; DRY
dweindl Apr 4, 2025
e59e37b
Merge branch 'develop' into sbmlmath_gh-2146
dweindl Apr 4, 2025
55480bd
none
dweindl Apr 4, 2025
866668a
Merge branch 'develop' into sbmlmath_gh-2146
dweindl Apr 22, 2025
73ba2e5
Merge branch 'develop' into sbmlmath_gh-2146
dweindl Apr 22, 2025
ecd3462
doc
dweindl Apr 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions python/sdist/amici/de_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ def states(self) -> list[State]:

def _process_sbml_rate_of(self) -> None:
"""Substitute any SBML-rateOf constructs in the model equations"""
rate_of_func = sp.core.function.UndefinedFunction("rateOf")
from sbmlmath import rate_of as rate_of_func

species_sym_to_xdot = dict(
zip(self.sym("x"), self.sym("xdot"), strict=True)
)
Expand Down Expand Up @@ -449,25 +450,21 @@ def get_rate(symbol: sp.Symbol):

# replace rateOf-instances in x0 by xdot equation
for i_state in range(len(self.eq("x0"))):
if rate_ofs := self._eqs["x0"][i_state].find(rate_of_func):
self._eqs["x0"][i_state] = self._eqs["x0"][i_state].subs(
{
rate_of: get_rate(rate_of.args[0])
for rate_of in rate_ofs
}
)
new, replacement = self._eqs["x0"][i_state].replace(
rate_of_func, get_rate, map=True
)
if replacement:
self._eqs["x0"][i_state] = new

# replace rateOf-instances in w by xdot equation
# here we may need toposort, as xdot may depend on w
made_substitutions = False
for i_expr in range(len(self.eq("w"))):
if rate_ofs := self._eqs["w"][i_expr].find(rate_of_func):
self._eqs["w"][i_expr] = self._eqs["w"][i_expr].subs(
{
rate_of: get_rate(rate_of.args[0])
for rate_of in rate_ofs
}
)
new, replacement = self._eqs["w"][i_expr].replace(
rate_of_func, get_rate, map=True
)
if replacement:
self._eqs["w"][i_expr] = new
made_substitutions = True

if made_substitutions:
Expand Down
3 changes: 3 additions & 0 deletions python/sdist/amici/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ def _parse_heaviside_trigger(trigger: sp.Expr) -> sp.Expr:
]
)

# TODO: x XOR y = (A & ~B) | (~A & B)
# TODO: x == y
if isinstance(trigger, sp.And):
return sp.Mul(*[_parse_heaviside_trigger(arg) for arg in trigger.args])

Expand Down Expand Up @@ -598,6 +600,7 @@ def _check_unsupported_functions(
sp.functions.factorial,
sp.functions.ceiling,
sp.functions.floor,
sp.functions.tan,
sp.functions.sec,
sp.functions.csc,
sp.functions.cot,
Expand Down
Loading
Loading