Skip to content

Abort simulation and raise error if NaN is encountered #379

@ronald-jaepel

Description

@ronald-jaepel

Is your feature request related to a problem? Please describe.
Consider a model with an Isotherm in which a concentration is raised to a fractional power (such as the SMA, the MPML, or the colloidal isotherm) and the column is not initialized with a non-zero salt concentrations. Then during simulations due to numerical reasons said concentration can become negative for short periods of time. This will produce NaN values in the fluxImpl and jacobianImpl (because we are taking the root of a negative number) and will cause CADET-Core to get stuck, because it keeps re-trying these functions indefinitely.

Describe the solution you'd like
Check for NaN outputs and terminate the simulation.

Describe alternatives you've considered
All models could be implemented with linearizations around c=0, this introduces a lot of extra work.
Users could be encouraged to add a time_limit, but this could lead to user frustration.

MRE with working and stuck example:
SMA_stuck.zip

Metadata

Metadata

Assignees

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions