# How to solve heat equation with Robin type conditions with NDSolve?

Could you help me please to solve following problem! I need to solve one-dimensional heat equation with Robin type boundary conditions. But Mathematica find only constant solution with no dependence on time and space coordinates. My code:

NDSolve[{
D[T[x, t], t] - D[D[ T[x, t], x], x] == 0,
(D[T[x, t], x] - (T[x, t] - 100) == 0) /. x -> 0,
(D[T[x, t], x] + (T[x, t] - 20) == 0) /. x -> 1,
T[x, 0] == 20
}, T, {x, 0, 1}, {t, 0, 1}]


Mathematica returns that temperature will be constant in all region: T[x,t]=20 (but in steady state solution we will have the liner low for the T(x)).

• When trying to run your code, I get a warning, complaining that boundary and initial conditions are inconsistent. Do you see the same? Have you looked into that? – MarcoB Jul 9 '15 at 17:24
• Are you sure of your boundary conditions? This example has Robin boundary conditions. (it is a link to a pdf file) – dearN Jul 9 '15 at 18:24
• Thanks to MarcoB. I try to use good initial conditions (exponential low or Piecewise[] function), and it works now. – Yury Jul 10 '15 at 11:15
• Yuri, I'm glad to hear you got it working. Would you please summarize your working solution as an answer? This way the question will be more valuable to other people experiencing similar problems. – MarcoB Jul 11 '15 at 3:27

Something like this:

NDSolve[{D[T[x, t], t] - D[D[T[x, t], x], x] ==
NeumannValue[T[x, t] - 100, x == 0] -
NeumannValue[T[x, t] - 20, x == 1], T[x, 0] == 20
}, T, {x, 0, 1}, {t, 0, 1},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> "FiniteElement"}]

• Comment please, if I understand correctly: the method option you apply is due to the fact that the equation is time dependent, not because of the Robin condition. The Robin condition is treated automatically, right? – Alexei Boulbitch Nov 6 '15 at 10:46
• Yes, this tells NDSolve to treat this as a time dependent problem with x as a spatial variable and t as time. Otherwise it tries to solve this as a purely spatial problems with both x and t as spatial coordinates. – user21 Nov 6 '15 at 12:26
• @user21 I checked the two Neumann conditions -Derivative[1, 0][T][0, t] == T[0, t] - 100 and Derivative[1, 0][T][1, t] == T[1, t] - 20 in your answer. The solution only fullfills the first . What could be the reason? Thanks! – Ulrich Neumann Sep 20 '19 at 8:22
• @UlrichNeumann, a missing - sign in your second equation? – user21 Sep 20 '19 at 8:28
• @user21 Thanks. I assumed a positiv flux in x-direction at x==1 and a negativ flux at x==0, this assumption seems to be wrong. – Ulrich Neumann Sep 20 '19 at 8:35