4 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/ edited Apr 13 '17 at 12:55 Albert Retey has demonstrated in a similar situationsimilar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. 3 improved formatting edited May 27 '16 at 5:50 Alexey Popkov 39.9k44 gold badges113113 silver badges274274 bronze badges Albert Retey has demonstrated in a similar situation that you can use "EventLocator""EventLocator" to detect an event in NDSolveNDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at 5.741306825597143*^13 at t = 0.44505185346820554450518534682055 in the direction of independent variable xx is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. 2 added 811 characters in body edited May 27 '16 at 2:24 xslittlegrass 17.9k55 gold badges7575 silver badges159159 bronze badges Albert Retey has demonstrated in a similar situationsimilar situation that you can use "EventLocator" to detect an event in NDSolve. For example: NDSolve[eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, 0{t,   0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, stepsizeu, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: NDSolve[{\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}, u, {t, 0, 2}, {x, 0,   1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}]  NDSolve::eerr: Warning: scaled local spatial error estimate of 5.741306825597143*^13 at t = 0.4450518534682055 in the direction of independent variable x is much greater than the prescribed error tolerance. When the stiffness happens, Mathematica will try to take an effectively zero stepsize. You can see that by NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t; stepsize = thisstep - laststep; Print[stepsize];)] (* 0.0000115314 0.0000115314 8.70237*10^-6 ... ... 7.88258*10^-15 *)  So we can use the small step size as a criteria to test the stiffness, and stop the integration  NDSolve[eqn, u, {t, 0, 2}, {x, 0, 1}, StepMonitor :> (laststep = thisstep; thisstep = t;stepsize = thisstep - laststep;), Method -> {"EventLocator", "Event" :> (If[stepsize < 10^-4, 0, 1])}]  Then the integration will stop when the step size is less than 10^-4, and the variable thisstep will be the point you are looking for. 1 answered May 27 '16 at 2:17 xslittlegrass 17.9k55 gold badges7575 silver badges159159 bronze badges