# 1D transient heat equation problem with controller - 2

My question is related to this former question (1D transient heat equation problem with controller), which has already been solved, but the issue is now a different one.

In the already solved question, the controller was acting globally on the bar, compensating perturbations occurring at the left boundary x=0.

Now I would like to implement a controller acting at the left boundary x=0, in order to compensate global perturbations on the bar, so that the temperature at the right boundary x=10 stays constant 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{perturbations}(t)$,

with:

$\operatorname{perturbations}(t)=0,1 \sin \left(\frac{t}{50}\right)$

and

Initial condition: $u(0,x)=25$
Boundary conditions: $u(t,0)=25-Kp*(u(t, 10) - 25)$ and $u^{(0,1)}(t,10)=0$

Here is the code I have tried in Mathematica 11. Just replace 0 by 1 before Kp to activate the controller and get the error, which is now:

NDSolveValue::bcedge: Boundary condition u[t,0]==25-2 (-25+u[t,10]) is not specified on a single edge of the boundary of the computational domain.

Kp = 2;
sol = NDSolveValue[{D[u[t, x], t] == 0.5*D[u[t, x], x, x] + 0.1*Sin[t/50],
u[0, x] == 25,
u[t, 0] == 25 - 0*Kp ((u[t, x] /. x -> 10) - 25),
(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"]}]}

• Apparently the problem is that the boudarry condition for u(t,x) at x=0 is linked to the value of u(t,x) at x=10. Does anyone have some idea how to solve this issue? Would really appreciate some help with that. – daklems Jun 17 '17 at 12:58

Kp=2;
m=0.001;
tEnd = 1000;

pde = {D[u[t, x], t] == 0.5 D[u[t, x], {x, 2}] + 0.25 Sin[t/50] +
NeumannValue[0, x == 10]};


Mathematica doesn't like the mixed BCs but you can approximate the measurement with this integral

c[x_]:= 1/m Piecewise[{{1,10-m<=x<=10}},0]
bc = {DirichletCondition[
u[t, x] == Kp(25 - Integrate[u[t, xx] c[xx], {xx, 0, 10}]),
x == 0]};


I basically approximate the measurement for the controller through the mean value over a small region.

ic={u[0,x]==25};


If I compute the solution Mathematica still complains but it works

sol=First@NDSolveValue[Flatten[{pde,bc,ic}],{u},{t,0,1000},{x,0,10},InterpolationOrder->All]


The plot looks OK to me.

Grid[{{Plot3D[sol[t,x],{t,0,tEnd},{x,0,10}],
Plot[sol[t,10],{t,0,tEnd},PlotRange->{Automatic,{0,40}}]}}]


But I think Mathematica doesn't understand the Diriclet BC right because Kp has no effect on the response.

Edit:

I got the same result with the normal BC

bc = {DirichletCondition[u[t, x] == Kp (25 - u[t, 10]), x == 0]};


If you change the IC to

ic={u[0,x]==0};


you see the controller in action

• since then I have been using the feedbackcontrol-functions after discretising the model in the x-component and building a state space model with a state for the temperature at each discrete x-position. Still thanks for your effort! – daklems Sep 29 '17 at 17:16