# Set of 2 region-based, coupled one dimension Heat equations

The problem is very basic, however I could not find a topic to implement this in Mathematica. It is a 1D Heat equation. On one side is the heating system a temperature 1, on the other side the environment a temperature 0. I just want to have the evolution of temperature with time and space.

So I edited the problem. After correction the implementation for a plane looks so:

ClearAll["Global*"]
k[x_] := 0.002 /; 1 < x < 10;
k[x_] := 0.0001 /; 10 <= x < 12;
b[t_ /; t < 30*60] = 1/(30*60)*t;
b[t_ /; t >= 30*60] = 1;
solutionN = NDSolve[{D[u[x, t], t] == k[x]*D[u[x, t], x, x], u[x, 0] == 0, u[12, t] == 0, u[1, t] == b[t]}, u[x, t], {x, 1, 12}, {t, 0, 10000000}];
distributionN[x_, t_] = Evaluate[First[u[x, t] /. solutionN]]


It gives such a solution: Making some trials, I discovered that the system took only the first value of k, not the second one. The temperature profile should be linear in the case of a unique material, but should bend in the case of two materials. Could someone explain that?

Regards

• Hi everyone, I come back to my topic after a break. I indeed did the changes suggested by @andre (laplacian, boundaries...) before seeing his post, it was quite clear. However, the temperature profile is not the one expected. It should be a difference between the two materials, but I only have a line in the steady state – Vassili Briodeau Nov 24 '17 at 14:20
• Hi, it did take into account the change of K, but this change is very progressive in the final solution. So problem solved – Vassili Briodeau Nov 27 '17 at 9:06

You can define k as a piecewise function:

k[r_]:=0.002/; 1<r<10;
k[r_]:=0.001/; 10<=r<12;
b[t_/;t<30*60]=1/(30*60)*t;
b[t_/;t>=30*60]=1;
solutionN=NDSolve[{D[u[r,t],t]==k[r]*Laplacian[u[r,t],{r}],u[r,0]==0,u[10,t]==0,u[1,t]==b[t]},u[r,t],{r,1,10},{t,0,100000}];
distributionN[r_,t_]=Evaluate[First[u[r,t]/.solutionN]]


That should be about the smallest modification to your code to make it work.

• Hi @Boson, thanks for your quick answer. This is a nice and simple idea, however it seems that the solver does not consider the second value of k. Indeed, change of k for r>=10 does no influence the solution, and the temperature profile is not the one expected. I got the same problem when I tried to define piecewise equations: only the first equation was taken into account. (Ps: i changed in you code the domain of calculation to make it work u[12,t]=0 and domain {r, 1, 12}) – Vassili Briodeau Nov 7 '17 at 12:47
• Sorry, it works:) It is only that the temperature profile is not the one expected, so I need to check my assumptions and equations. – Vassili Briodeau Nov 7 '17 at 14:56
• @VassiliBriodeau I am glad that I could help. Best regards. – Boson Nov 8 '17 at 10:09
• This doesn't give the solution of the problem. {r,1,10} should be {r,1,12} and the boundary condition u[10,t]==0 should be u[12,t]==0 – andre314 Nov 8 '17 at 16:46
• Thank you for pointing that out @andre. This is a valid point. Best regards. – Boson Dec 1 '17 at 10:46

After correction with the remarks: The solver does take into account the change of K, this is just not what was expected

Temperature profile with one material (starting directly at 150):

k[x_] := 0.002 /; 0 <= x < 6;
k[x_] := 0.002 /; 6 <= x < 12;


Graph solution[ Temperature as function of x at different times

Temperature profile with two materials (starting directly at 150):

k[x_] := 0.002 /; 0 <= x < 6;
k[x_] := 0.0002 /; 6 <= x < 12; In another case the difference is also visible

k[x_] := 0.0002 /; 0 <= x < 6;
k[x_] := 0.002 /; 6 <= x < 12;
` So there is an impact of the change of k. However, the temperature profile for a infinite time should not be a straight line. Because of the change of materials, there should be, in the case K1=0.002 and k2=0.0002, first a straight line quite flat, and second, starting at x=6, a straight line with a higher slope. Of course, the temperature curve should stay continuous at x=6, and it can be that the lines curve at x=6 This is the expected profile

• Is this an answer? Can you elaborate, show example? – Kuba Nov 27 '17 at 9:40
• Hi @Kuba, I dedited the post to elaborate my "answer". I am still working to figure out my problem and its cause. – Vassili Briodeau Nov 29 '17 at 9:06