1
$\begingroup$

I have the heat equation on the invervall $[0,1]$, therefore I define

heqn = D[u[x, t], t] == D[u[x, t], {x, 2}];

and I define my initial data which can be boring, since the BC are not,

init= u[x,0]==0.5

Now I'd like to impose Robin-Boundary Condtions of the form

$$ u'(0,t)=1-u(0,t)\\ -u'(1,t)=1-u(1,t) $$

However while scrolling through the help-parts of DSolve and NDSolve, I found NeumannValue however I am totally honest, I have no Idea what is going on and how I impose those BCs on my PDE. However, I am not completely new to Mathematica, just to solving PDEs with it, I can manage doing stuff like Dirichlet on the intervall $[0,1]$

NDSolve[{
      D[u[t, x], t] == D[u[t, x], x, x],
      u[0, x] == Sin[Pi x]+0.5,
      u[t, 0] == 0.5,
      u[t, 1] == 0.5},
     u, {t, 0, 3}, {x, 0, 1}]
    Plot3D[Evaluate[u[t, x] /. %], {t, 0, 3}, {x, 0, 1}, PlotRange -> All]
$\endgroup$
2
  • $\begingroup$ Something like this, {D[u[t, x], t] - D[u[t, x], x, x] == NeumannValue[1 - u[t, x], x == 0] - NeumannValue[1 - u[t, x], x == 1], u[0, x] == Sin[Pi x] + 0.5} but make sure that your initial and boundary conditions are consistent. $\endgroup$
    – user21
    Nov 17 '21 at 16:05
  • $\begingroup$ Should it not read: NeumannValue[-1 + u[t, x], x == 1] $\endgroup$ Nov 17 '21 at 16:12
0
$\begingroup$

To long for a comment:

A consistent initial condition is u[0,t]==Sin[Pi x]+1-Pi

{Derivative[0, 1][u][t, 0] - (1 - u[t, 0]), 
-Derivative[0, 1][u][t, 1] - (1 - u[t, 1])} /.u -> Function[{t, x},  Sin[Pi x] + 1 - Pi]
(* {0,0}*)

But the solution proposed by @user21

U = NDSolveValue[{D[u[t, x], t] == 
D[u[t, x], x, x] + NeumannValue[ -(1 - u[t, x]),x == 0] - 
NeumannValue[ (1 - u[t, x]), x == 1], 
u[0, x] == Sin[Pi x] + 1 - Pi }, u, {t, 0, 3},{x, 0, 1}] 

unfortunately doesn't fullfill the Robin boundary conditions for all t

Plot[{Derivative[0, 1][U][t, 0] - (1 - U[t, 0]), -Derivative[0, 1][U][t, 1] - (1 -U[t, 1])}, {t, 0, 3}, PlotRange -> All, PlotLabel -> "Robin bc[t]"]    

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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