xolotl icon indicating copy to clipboard operation
xolotl copied to clipboard

integer overflow prevents running long simulations

Open sg-s opened this issue 6 years ago • 6 comments

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.

sg-s avatar Nov 29 '18 20:11 sg-s

~~the way around this is long long int~~

still doesn't work. n_steps is -2 now

sg-s avatar Nov 29 '18 20:11 sg-s

one workaround: intercept long sims in x.integrate, and break it up into smaller runs.

sg-s avatar Nov 29 '18 20:11 sg-s

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.

sg-s avatar Nov 29 '18 20:11 sg-s

this is hard to fix. for now, x.integrate will throw an error when it detects integer overflow

sg-s avatar Nov 29 '18 21:11 sg-s

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)

sg-s avatar Nov 29 '18 21:11 sg-s

Stale issue message

github-actions[bot] avatar Aug 14 '19 15:08 github-actions[bot]