xolotl
xolotl copied to clipboard
integer overflow prevents running long simulations
the maximum value of int
is 2147483647 source
This means that if t_end
is very large, nsteps
can exceed this bound. which causes nsteps
to be negative, which means the simulation exits without integrating anything, silently, with no error.
~~the way around this is long long int
~~
still doesn't work. n_steps
is -2 now
one workaround: intercept long sims in x.integrate
, and break it up into smaller runs.
we can use a while
loop, and the counter can be float
, but we still have the problem of using an integer to save the output states. the safest thing to do is to refuse to integrate for longer than INT_MAX
, or break up integrations into smaller chunks.
this is hard to fix. for now, x.integrate
will throw an error when it detects integer overflow
still to do:
- there are other cases when an integer overflow can happen. need to check all of them, and throw errors either in the C++ code or before integrating
- some way of running very long simulations (at least without any outputs in closed loop mode)
Stale issue message