Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

4 of 4 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/

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.