Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ jobs:
py=python3; command -v python3 >/dev/null || py=python
out="$RUNNER_TEMP/out"; mkdir -p "$out"
cd tests/reference
for input in cvode_simple.cvodeInput cvode_events.cvodeInput ida_dae.idaInput; do
for input in cvode_simple.cvodeInput cvode_events.cvodeInput cvode_delayed_events.cvodeInput ida_dae.idaInput; do
name="${input%.*}"
"$exe" "$input" "$out/$name.ida" -tid 0 > "$out/$name.log" 2>&1 || { cat "$out/$name.log"; exit 1; }
$py compare_ida.py "$name.ida.ref" "$out/$name.ida"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
set -euxo pipefail
work="$RUNNER_TEMP/docker"; mkdir -p "$work"; cp tests/reference/*Input "$work/"
chmod 0777 "$work" # writable by the arbitrary uid below, as /simdata is for the job's user
for input in cvode_simple.cvodeInput cvode_events.cvodeInput ida_dae.idaInput; do
for input in cvode_simple.cvodeInput cvode_events.cvodeInput cvode_delayed_events.cvodeInput ida_dae.idaInput; do
name="${input%.*}"
docker run --rm --read-only --user 12345:12345 -v "$work:/simdata" vcell-ode:ci \
"$EXE" "/simdata/$input" "/simdata/$name.ida" -tid 0
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
test "$(id -u)" != 0
apptainer run --containall "$sif" --help
work="$RUNNER_TEMP/sif"; mkdir -p "$work"; cp tests/reference/*Input "$work/"
for input in cvode_simple.cvodeInput cvode_events.cvodeInput ida_dae.idaInput; do
for input in cvode_simple.cvodeInput cvode_events.cvodeInput cvode_delayed_events.cvodeInput ida_dae.idaInput; do
name="${input%.*}"
apptainer run --containall --bind "$work:/simdata" "$sif" \
"$EXE" "/simdata/$input" "/simdata/$name.ida" -tid 0
Expand Down
8 changes: 6 additions & 2 deletions IDAWin/VCellSundialsSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,13 @@ void VCellSundialsSolver::testEventTriggers(realtype Time) {
auto compLambda = [](const EventExecution *e1, const EventExecution *e2) {
return e1->timeToExecuteEventAt < e2->timeToExecuteEventAt;
};
std::ranges::sort(eventExecutions, compLambda);
// eventExeList is ordered by execution time, and executeEvents only ever looks at its front, so the new
// executions must be merged into it, not appended: an event triggered now with a short delay can be due
// before one already waiting. stable_sort + merge keep equal times in the order they were queued (existing
// executions first, then the new ones in event order), as the legacy insertion did.
std::ranges::stable_sort(eventExecutions, compLambda);
std::list eventExecutionsSorted(std::make_move_iterator(eventExecutions.begin()), std::make_move_iterator(eventExecutions.end()));
eventExeList.splice(eventExeList.end(), eventExecutionsSorted);
eventExeList.merge(eventExecutionsSorted, compLambda);
}

bool VCellSundialsSolver::executeEvents(const realtype realTimeVar) {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "uv_build"

[project]
name = "pyvcell_odesolver"
version = "0.9.5"
version = "0.9.6"
description="Virtual Cell CVODE / IDA based ODE solver"
readme = "README.md"
authors = [
Expand Down
28 changes: 28 additions & 0 deletions tests/reference/cvode_delayed_events.cvodeInput
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SOLVER CVODE
STARTING_TIME 0.0
ENDING_TIME 2.0
RELATIVE_TOLERANCE 1.0E-9
ABSOLUTE_TOLERANCE 1.0E-9
MAX_TIME_STEP 0.1
KEEP_EVERY 1
DISCONTINUITIES 2
__D_B_0 (t > 0.1); (-0.1 + t);
__D_B_1 (t > 0.2); (-0.2 + t);
EVENTS 2
EVENT late
TRIGGER (__D_B_0 == 1.0);
DELAY false 1.0;
EVENTASSIGNMENTS 1
1 1.0;
EVENT early
TRIGGER (__D_B_1 == 1.0);
DELAY false 0.3;
EVENTASSIGNMENTS 1
2 1.0;
NUM_EQUATIONS 3
ODE x INIT 0.0;
RATE 1.0;
ODE y INIT 0.0;
RATE 0.0;
ODE z INIT 0.0;
RATE 0.0;
40 changes: 40 additions & 0 deletions tests/reference/cvode_delayed_events.ida.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
t:x:y:z:
0.00000000000000000E+00 0.00000000000000000E+00 0.00000000000000000E+00 0.00000000000000000E+00
4.08166690049085712E-11 4.08166690049085712E-11 0.00000000000000000E+00 0.00000000000000000E+00
4.08207506718090637E-07 4.08207506718090637E-07 0.00000000000000000E+00 0.00000000000000000E+00
4.48987440720894779E-06 4.48987440720894779E-06 0.00000000000000000E+00 0.00000000000000000E+00
4.53065434121175192E-05 4.53065434121175192E-05 0.00000000000000000E+00 0.00000000000000000E+00
4.53473233461203196E-04 4.53473233461203196E-04 0.00000000000000000E+00 0.00000000000000000E+00
4.53514013395205952E-03 4.53514013395205952E-03 0.00000000000000000E+00 0.00000000000000000E+00
4.53518091388606243E-02 4.53518091388606243E-02 0.00000000000000000E+00 0.00000000000000000E+00
1.00000000000000019E-01 1.00000000000000019E-01 0.00000000000000000E+00 0.00000000000000000E+00
1.00007258344806615E-01 1.00007258344806615E-01 0.00000000000000000E+00 0.00000000000000000E+00
1.72590706410743311E-01 1.72590706410743311E-01 0.00000000000000000E+00 0.00000000000000000E+00
2.00000000000000011E-01 2.00000000000000011E-01 0.00000000000000000E+00 0.00000000000000000E+00
2.00000000000002232E-01 2.00000000000002232E-01 0.00000000000000000E+00 0.00000000000000000E+00
2.00012207031801559E-01 2.00012207031801559E-01 0.00000000000000000E+00 0.00000000000000000E+00
3.22082525024966593E-01 3.22082525024966593E-01 0.00000000000000000E+00 0.00000000000000000E+00
4.00012207031802514E-01 4.00012207031802514E-01 0.00000000000000000E+00 0.00000000000000000E+00
5.00000000000002220E-01 5.00000000000002220E-01 0.00000000000000000E+00 1.00000000000000000E+00
5.00024269737143978E-01 5.00024269737143978E-01 0.00000000000000000E+00 1.00000000000000000E+00
7.00000000000003064E-01 7.00000000000003064E-01 0.00000000000000000E+00 1.00000000000000000E+00
7.00024269737144933E-01 7.00024269737144933E-01 0.00000000000000000E+00 1.00000000000000000E+00
7.00266967108563620E-01 7.00266967108563620E-01 0.00000000000000000E+00 1.00000000000000000E+00
7.02693940822750496E-01 7.02693940822750496E-01 0.00000000000000000E+00 1.00000000000000000E+00
7.26963677964619248E-01 7.26963677964619248E-01 0.00000000000000000E+00 1.00000000000000000E+00
9.02693940822751451E-01 9.02693940822751451E-01 0.00000000000000000E+00 1.00000000000000000E+00
9.26963677964620314E-01 9.26963677964620314E-01 0.00000000000000000E+00 1.00000000000000000E+00
1.10000000000000009E+00 1.10000000000000009E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.10003771546284024E+00 1.10003771546284024E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.30000000000000093E+00 1.30000000000000093E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.30003771546284130E+00 1.30003771546284130E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.30041487009124501E+00 1.30041487009124501E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.30418641637528210E+00 1.30418641637528210E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.34190187921565296E+00 1.34190187921565296E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.50418641637528294E+00 1.50418641637528294E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.54190187921565403E+00 1.54190187921565403E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.70418641637528379E+00 1.70418641637528379E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.74190187921565509E+00 1.74190187921565509E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.90418641637528463E+00 1.90418641637528463E+00 1.00000000000000000E+00 1.00000000000000000E+00
1.94190187921565616E+00 1.94190187921565616E+00 1.00000000000000000E+00 1.00000000000000000E+00
2.00000000000000000E+00 2.00000000000000000E+00 1.00000000000000000E+00 1.00000000000000000E+00
Loading