# Inconsistent Boundary Conditions on Transient Heat Equation Partial Differential Equation

I am attempting to solve the equation

with the Wolfram one-liner

NDSolve[{D[ρ[y, t]] == D[D[ρ[y, t], y], y], ρ[-1, t] == 10, ρ[1, t] == 10,ρ[y, 0] == 0},
ρ, {y, -1, 1}, {t, 0, 10}]


However, this threw a NDSolve::ibcinc warning that the initial and boundary conditions conflicted, as I didn't properly implement the inequalities on the initial and boundary conditions. How could I specify the inequalities on "t" properly to return a physical solution? I have searched through the Mathematica Stack Exchange to no avail for this issue.

• Use damping as [Rho][-1, t] == 10 (1-Exp[-10 t]), [Rho][1, t] == 10 (1-Exp[-10 t]) Commented Mar 20, 2020 at 14:13
• Version 12.1 has a tutorial on Heat Transfer Modeling Commented Mar 20, 2020 at 20:02
• First of all, the D[\[Rho][y, t]] should be D[\[Rho][y, t],t]. Then, "I have searched through the Mathematica Stack Exchange to no avail for this issue." you should have searched harder. Strongly related, if not duplicate: mathematica.stackexchange.com/a/127411/1871 To be more specific, add e.g. Method -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 100}} to NDSolve. Commented Mar 21, 2020 at 2:38

This can be solved analytically. Using V 12.1

ClearAll[y, t, u]
pde = D[u[y, t], t] == D[u[y, t], {y, 2}];
ic = u[y, 0] == 0;
bc = {u[-1, t] == 10, u[1, t] == 10};
sol = DSolve[{pde, ic, bc}, u[y, t], {y, t}];
sol = sol /. K[1] -> n;


$$\left\{\left\{u(y,t)\to 10-\frac{2 \underset{n=1}{\overset{\infty }{\sum }}\frac{\left(10-10 (-1)^n\right) e^{-\frac{1}{4} n^2 \pi ^2 t} \sin \left(\frac{1}{2} n \pi (y+1)\right)}{n}}{\pi }\right\}\right\}$$

sol = sol /. Infinity -> 10; (*more than enough terms*)
Manipulate[
Quiet@Plot[Activate@Evaluate[(u[y, t] /. sol) /. t -> t0], {y, -1, 1},
PlotRange -> {Automatic, {-0.5, 11}},
GridLines -> Automatic, GridLinesStyle -> LightGray,
PlotStyle -> Red,
AxesLabel -> {"space", "solution u"},
BaseStyle -> 12
],
{{t0, 0.01, "time"}, 0.01, 5, .01, Appearance -> "Labeled"},
TrackedSymbols :> {t0}
]


Remove the square-brackets!

Try

rho=NDSolveValue[{Derivative[0, 1][Rho][y, t] ==Derivative[2, 0][Rho][y, t]
, Rho [-1, t] == 10, Rho [1, t] == 10,Rho [y, 0] == 0}, Rho , {y, -1, 1}, {t, 0, 10}]


which evaluates with an errormessage "NDSolveValue::ibcinc: Warning: boundary and initial conditions are inconsistent.".

Plot3D[rho[y, t], {y, -1, 1}, {t, 0, 10}]


With Rho [-1, t] == 10 (1 - Exp[-10 t]), Rho [1, t] == 10 (1 - Exp[-10 t]) (Thanks @AlexTrounev ) error message disappears!

rho1 = NDSolveValue[{Derivative[0, 1][Rho][y, t] ==Derivative[2, 0][Rho][y, t]
, Rho [-1, t] == 10 (1 - Exp[-10 t]),Rho [1, t] == 10 (1 - Exp[-10 t]), Rho [y, 0] ==0},Rho , {y, -1, 1}, {t, 0, 10}]
Plot3D[rho1[y, t], {y, -1, 1}, {t, 0,10}, PlotRange -> All]


• The solution doesn't satisfy the Rho[-1,t], Rho[1,t] = 10, is this solvable? Commented Mar 20, 2020 at 14:39
• Change the boundary conditions as @AlexTrounev suggested. Commented Mar 20, 2020 at 14:44

In order to satisfy boundary conditions, change initial condition to \[Rho][y, 0] == 10 UnitStep[Abs[y] - 1] .

ndsol2 = NDSolve[{D[\[Rho][y, t], t] ==
D[\[Rho][y, t], y, y], \[Rho][-1, t] == 10, \[Rho][1, t] ==
10, \[Rho][y, 0] == 10 UnitStep[Abs[y] - 1]}, \[Rho],
{y, -1, 1}, {t, 0, 10}, MaxStepSize -> 0.001, MaxSteps -> 10^5,
StartingStepSize -> 0.0002]

Plot3D[\[Rho][y, t] /. ndsol2[[1]], {y, -1, 1}, {t, 0, 2},
PlotRange -> All]


Test for error in diffequation and initial condition.

Plot3D[Evaluate[
D[\[Rho][y, t], t] - D[\[Rho][y, t], y, y] /. ndsol2[[1]]],
{y, -1, 1}, {t, 0, 2}, PlotRange -> 10^-4]

Plot[Evaluate[\[Rho][y, 0] - 10 UnitStep[Abs[y] - 1] /.
ndsol2[[1]]], {y, .99, 1},
PlotRange -> 15, GridLines -> Automatic]