13
$\begingroup$

I would appreciate some help with following issue:

I am trying to solve a 1D transient heat equation problem with a control loop in order to compensate a time variable boundary condition at one extremity, so that the temperature at the other extremity stays stable around 25.

$u(t,x)$ obeys to following PDE on a x-line from 0 to 10:

$u^{(0,1)}(x,t)=u^{(2,0)}(x,t)+ \operatorname{compensator}(t)$,

with:

Initial condition: $u(0,x)=25$
Boundary conditions: $u(t,0)=25+ 3 \sin \left(\frac{t}{50}\right)$ and $u^{(0,1)}(t,10)=0$

the compensator is the output from a P-controller: $\operatorname{compensator}(t)=-0.05(u(t, 10) - 25)$
If that works, I would then like to try with a PI or PID-controller.

Here is the code I have tried in Mathematica 11 (just replace 0 by 1 before 0.05 to activate the controller and get the error):

sol = NDSolveValue[{D[u[t, x], t] == 0.5*D[u[t, x], x, x] - 0*0.05*(u[t, 10] - 25),
u[0, x] == 25,
u[t, 0] == 25 + 3*Sin[t/50],
(D[u[t, x], x] /. x -> 10) == 0},
u,{t, 0, 1000}, {x, 0, 10}]

{Plot3D[sol[t, x], {t, 0, 1000}, {x, 0, 10}, PlotRange -> All, 
AxesLabel -> {"Time", "x"}, PlotLegends -> {"usol(t,x)"}, PlotTheme ->"Detailed",ImageSize -> 300],

Plot[Evaluate[sol[t, x] /. x -> {0, 10}, {t, 0, 1000}],ImageSize -> 300,   PlotLegends -> Table[Style[StringJoin["x=", ToString[i]], 
  FontSize -> 12, FontFamily -> "Cambria Math"], {i, {0, 10}}], 
PlotStyle -> Table[RGBColor[0.1, j, 0.5], {j, 0, 1, 1/2}], PlotTheme ->"Detailed", 
PlotRange -> All, FrameLabel -> {Style["Time", 12, FontFamily -> "Cambria Math"]}]}
$\endgroup$
7
  • $\begingroup$ Maybe this is useful. $\endgroup$
    – user21
    May 11, 2017 at 15:49
  • $\begingroup$ Delay partial differential equations are not supported $\endgroup$ May 11, 2017 at 16:27
  • 1
    $\begingroup$ @DavidBaghdasaryan, what makes this a delay PDE? I fail to see that. $\endgroup$
    – user21
    May 11, 2017 at 18:27
  • $\begingroup$ You can solve this problem by discretizing space and using the method of lines. I don't have time now to write this explicitly, but perhaps you can get the idea from this (note that in the example there they discretize time and not space and you need to do the opposite). $\endgroup$
    – yohbs
    May 11, 2017 at 21:11
  • 2
    $\begingroup$ NDSolve is just moody today.... $\endgroup$
    – user21
    May 11, 2017 at 21:39

1 Answer 1

9
$\begingroup$

Here is a way to do it:

f[tt_?NumericQ, u_] := If[tt <= 0., 25, u /. {t -> tt, x -> 10}]
sol = NDSolveValue[{D[u[t, x], t] == 
    0.5*D[u[t, x], x, x] - 0.05*(f[t, u[t, x]] - 25), u[0, x] == 25, 
   u[t, 0] == 25 + 3*Sin[t/50], (D[u[t, x], x] /. x -> 10) == 0}, 
  u, {t, 0, 1000}, {x, 0, 10}]

Which gives me these plots:

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks for the amazing f(t,u(t,x))-trick, this kind of thing always looks to me like pulling a rabbit out of a hat. I'll try with PI and PID-controller now. $\endgroup$
    – daklems
    May 12, 2017 at 6:51

Your Answer

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

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