Skip to content

Avoid CV_TOO_CLOSE error by increasing minimum variable step size #165

Description

@brunomaga

Hi Michael @nrnhines:

I realised that if one makes a call to

CVode(cvode mem, tout, yout, &tret, itask);

and tout (the target time instant) and t0 (the current time instant) are too close, the following error message will show up:

[CV_TOO_CLOSE]
tout too close to t0 to start  integration. 

This will fail from stepping, and if called inside a while (t<tout) loop, it will hang the execution indefinitely. This issue is hard to reproduce and occurred to me only on very large networks, above 32K neurons.

A quick fix is to enforce an initial minimum step size, e.g. a call to:

CVodeSetInitStep(cvode_mem_f, step_size); 

for having a larger first step, or ideally

CVodeSetMinStep(cvode_mem_f, step_size); 

to guarantee that state is always advanced by some minimum timestep value. However, if step_size is too large, then the following error may occur:

[CV_CONV_FAILURE]
the corrector convergence failed repeatedly or with |h| = hmin. 

So the trick is to pick a step size big enough to advance the state, while being small enough to make the solver converge within the tolerance values provided. From my testing, 1e-5 is a good value.

This ticket requests the default minimum or initial variable step size in NEURON to be increased from the actual value of 0, to avoid CV_TOO_CLOSE errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions