Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Live graphing in ODECSolver using wrong decoder #755

Merged
merged 4 commits into from
Apr 13, 2022
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
7 changes: 1 addition & 6 deletions gillespy2/solvers/cpp/c_base/ode_cpp_solver/ODESolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,13 @@ namespace Gillespy
realtype end_time = simulation->end_time;
realtype step_length = increment;

// The time reached by the solver for output.
realtype tret = 0;

int current_time = 0;
for (tout = step_length; !interrupted && tout < end_time || cmpf(tout, end_time); tout += step_length)
{
// CV_NORMAL causes the solver to take internal steps until it has reached or just passed the `tout`
// parameter. The solver interpolates in order to return an approximate value of `y(tout)`.
// CVode() returns a vector `y0` (or `y(tout)`), and corresponding variable value `t` = `tret` (return time).
// With CV_NORMAL `tret` is equal to `tout` and `y0` = `y(tout)`.
flag = CVode(cvode_mem, tout, y0, &tret, CV_NORMAL);
current_time++;
flag = CVode(cvode_mem, tout, y0, &simulation->current_time, CV_NORMAL);

for (sunindextype species = 0; species < N; species++)
{
Expand Down
4 changes: 2 additions & 2 deletions gillespy2/solvers/cpp/ode_c_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""
import numpy as np

from gillespy2.solvers.cpp.c_decoder import BasicSimDecoder
from gillespy2.solvers.cpp.c_decoder import IterativeSimDecoder
from gillespy2.solvers.utilities import solverutils as cutils
from gillespy2.core import GillesPySolver, Model
from gillespy2.core.gillespyError import *
Expand Down Expand Up @@ -117,7 +117,7 @@ def run(self=None, model: Model = None, t: int = None, number_of_trajectories: i
display_args = None

args = self._make_args(args)
decoder = BasicSimDecoder.create_default(number_of_trajectories, number_timesteps, len(self.model.listOfSpecies))
decoder = IterativeSimDecoder.create_default(number_of_trajectories, number_timesteps, len(self.model.listOfSpecies))

sim_exec = self._build(self.model, self.target, self.variable, False)
sim_status = self._run(sim_exec, args, decoder, timeout, display_args)
Expand Down
1 change: 1 addition & 0 deletions gillespy2/solvers/cpp/tau_hybrid_c_solver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import gillespy2
from gillespy2.solvers.cpp.c_decoder import IterativeSimDecoder
from gillespy2.solvers.utilities import solverutils as cutils
Expand Down