MATLAB: Integration Tolerance Not Met in SimBiology after sbioaccelerate

SimBiologytolerance

I'm receiving this error when trying to simulate my model after using s sbioaccelerate using some dose objects, but not others:
Error using SBCompiler.SimulationObject/simulate Integration Tolerance Not Met.
Error in sbiosimulate (line 140) [t, x] = simobj.simulate(mobj, cs, variants, doses);
I can simulate the model fine before using simbioaccelerate. I am receiving these warnings as well, and I know which equations they are coming from. Although, The equations shouldnt be producing complex numbers.
The right-hand side of the system of SimBiology ODEs results in complex numbers. The imaginary part of the result will be ignored. The repeated assignment rules of the SimBiology model result in complex numbers. The imaginary part of the result will be ignored.
I'm not sure what sbioaccelerate could be doing that is causing this; any help on how to troubleshoot this would be appreciated.

Best Answer

In addition to Joe's excellent suggestion, here are my thoughts:
The complex numbers are the source of the problem. The accelerated version of the model likely results in NaNs in cases where the unaccelerated model results in complex numbers. These NaNs then lead to the integration errors.
Are you using sqrt or some sort or raising a number to a fractional exponent? If so, then you could get a complex number if the argument is ever negative. This can happen when a concentration is close to zero, but solver tolerances allow it to go slightly negative. One solution there is to replace x^n with max(0,x)^n.
If you are still unable to find the cause of the complex numbers, please feel free to share additional details or contact Technical Support. I may not see updates you post here, so also feel free to contact me via my user page if you don't get a response to a comment here.
Good luck!
-Arthur