I try to solve a partial differential equation by NDSolve
. At some point, I want to stop the integrating by a condition that compares the min value of the function with a threshold. I tried to use StopIntegration
in the WhenEvent
, and tried using NMinimize
to find the min value of the function. But it does not seem stop the evaluation. From the warning message, I think the conditions of NMinimize[h[x, t], {x, t}] <= 0.01
I set for whenevent
may be wrong. Could someone explain to me what is going on? How could I handle this problem? Is there any better or simpler way to do that?
mdfun = First[h /. NDSolve[{D[h[x, t], t] + D[h[x, t]^-1*D[h[x, t], x], x] +
D[h[x, t]^3*D[h[x, t], {x, 3}], x] == 0,
h[0, t] == h[2 Sqrt[2] \[Pi], t],
h[x, 0] == 1 + 1/10*Sin[x/Sqrt[2]],
WhenEvent[NMinimize[h[x, t], {x, t}] <= 0.01,
"StopIntegration"]}, h, {x, 0, 2 Sqrt[2] \[Pi]}, {t, 0, 10},
StepMonitor :> Print[t]]]