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

Current implementation of builtin time() function in BNGL gives inaccurate results #222

Open
jrfaeder opened this issue May 26, 2020 · 2 comments

Comments

@jrfaeder
Copy link
Contributor

The example file shows that the builtin time() function that can be invoked in the functions block (although gives an error if invoked in a rate law) give inaccurate results. The builtin time() function and the user-defined t() function give identical values at all of the points at which they are output, but the results of integrating a rate law that invokes them differ by an amount that greatly exceeds the expected integration error. The most likely cause of the problem is that the time() function is not correctly being used at intermediate points of the integration.
test_time2.bngl.txt

@lh64
Copy link
Contributor

lh64 commented May 26, 2020

Yeah, the time() function wraps around the time variable t in run_network.cpp. For ODE simulations, CVODE has its own time variable, which can't be accessed (or at least I couldn't). So the time() function doesn't get updated while CVODE is running in between output steps. If you increase n_steps, I bet the results of the built-in time() and user-defined t() will converge.

Note that this isn't a problem for SSA simulations, so it should work fine for those.

@lh64
Copy link
Contributor

lh64 commented May 26, 2020

BTW, this is why it says NOT FULLY TESTED for the time function in the "Built-in operators and functions" table we had on the BNG Wiki: https://web.archive.org/web/20131113212908/http://www.bionetgen.org/index.php/BNGManual:Table_2.

I could never figure out how to get around this issue for ODE sims.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants