4
$\begingroup$

I have a PDE describing a bending beam which I want to solve numerically.

a=1;

b=0.1;

Approx[x_, ϵ_] := Approx[x, ϵ] = ϵ/(Pi*(x^2 + ϵ^2)) 

Initial = {p[x, 0] == 0.5, q[x, 0] == 0.5};

CisTrans = 
  {Derivative[0, 1][p][x, t] == 10*(1 - p[x, t]) - p[x, t], 
   Derivative[0, 1][q][x, t] == -q[x, t]};

Deflection = 
  {Derivative[0, 2][w][x, t] + a*Derivative[0, 1][w][x, t] + 
   Derivative[2, 0][u][x, t] == -b*(p[x, t] - q[x, t]) *
   Approx[x - 1, 10^(-1000)]};

s = 
   NDSolveValue[
    {Initial, CisTrans, Deflection,  Derivative[2, 0][w][x, t] == u[x, t], 
     u[1, t] == 0, u[x, 0] == 1, w[x, 0] == 0, w[0, t] == 0, 
     WhenEvent[t == 0.5, Print[t]]}, 
    w, {x, 0, 1}, {t, 0, 1}]

This NDSolveValue solves the PDE, but ignores my WhenEvent, so 0.5 is not printed, while in other PDE's the WhenEvent is not ignored. Does anyone know how to solve this?

$\endgroup$
5
  • $\begingroup$ aside to your actual question, your system produces vastly different results if you adjust the limit of the time domain ( see what you get if you just solve over t,0,1/2 ) . This tells me the default solution method is a poor choice, although I didn't have any luck doing better. $\endgroup$
    – george2079
    Commented May 2, 2018 at 16:25
  • $\begingroup$ another aside I cant make any sense of what Approx is supposed to do. It is essentially zero everywhere and then blows up exactly on the x=1 boundary. (off hand I think it never gets evaluated exactly at the boundary ) $\endgroup$
    – george2079
    Commented May 2, 2018 at 16:32
  • 1
    $\begingroup$ IIFC, you have to have explicit time integration (e.g., with the method of lines) for WhenEvent to work, and then it only applies to the time-stepping. (While you may call your variable t, it is being treated as one of the spatial variables in NDSolve above.) $\endgroup$
    – Michael E2
    Commented May 2, 2018 at 16:40
  • $\begingroup$ @george2079 Approx seems to be an approximate Dirac delta. $\endgroup$ Commented May 2, 2018 at 19:32
  • 1
    $\begingroup$ @AccidentalFourierTransform good call, so it is. NDSolve will not integrate it properly however. $\endgroup$
    – george2079
    Commented May 2, 2018 at 20:22

1 Answer 1

1
$\begingroup$

This is not a solution to your problem, but a possible source of the problem. Sometimes, when the method to obtain the InterpolatingFunction type solution is Unstructured, it seems that WhenEvent[] call doesn't trigger any response. This is most likely the case for complicated PDE or system of PDE's.

Couple of examples from the docs(ref/NDSolve):

One where WhenEvent[] doesn't work:

\[CapitalOmega] = 
  RegionDifference[RegionUnion[Disk[], Rectangle[{0, -1}, {2, 1}]], 
   Disk[{2, 0}]];
ufun = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 1., 
       PeriodicBoundaryCondition[u[x, y], (x - 2)^2 + y^2 == 1, 
         Function[x, x - {2, 0}]], DirichletCondition[u[x, y] == 0, 
         0 < x < 2 - 10^(-6) && (y <= -1 || y >= 1)], 
   WhenEvent[x == 0, Print[x]]}, u, 
     Element[{x, y}, \[CapitalOmega]]] 

However, in this one it works just fine(even if the method utilised was Unstructured):

\[CapitalOmega] = 
  RegionDifference[
   RegionDifference[Rectangle[{0, 0}, {2, 1}], 
    Rectangle[{9/10, 0}, {11/10, 4/10}]], 
   Rectangle[{9/10, 6/10}, {11/10, 1}]];
sol = First[
  NDSolve[{D[u[t, x, y], {t, 2}] - Laplacian[u[t, x, y], {x, y}] == 0,
     DirichletCondition[u[t, x, y] == 0, True], 
    u[0, x, y] == 2*Exp[-125 ((x - 0.25)^2 + (y - 0.5)^2)], 
    Derivative[1, 0, 0][u][0, x, y] == 0, 
    WhenEvent[t == 0.1, Print@t]}, 
   u, {t, 0, 2}, {x, y} \[Element] \[CapitalOmega]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.