# [✓] Solve and Plot a 2D heat conduction problem (laser heating)?

Posted 2 years ago
3152 Views
|
9 Replies
|
0 Total Likes
|
 Hi, all, I am trying to get a temperature field for laser heating process. I manage to get the PDE equation (guess the PDE code is OK since I ran it successfully without plot command), but I can't plot the result. Hope someone can help me with this. p = 2931.5; c = 335; k = 1.45; \[Alpha] = 0.64; \[Beta] = 1/(260*10^-6); w = 0.0018; L = 0.005; tend = 10; P = 20; M = 0.005; dd = NDSolve[{cp*\!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$T1[t, x, z]$$\) == k*(\!$$\*SubscriptBox[\(\[PartialD]$$, $${z, 2}$$]$$T1[t, x, z]$$\) + \!$$\*SubscriptBox[\(\[PartialD]$$, $${x, 2}$$]$$T1[t, x, z]$$\)) + \[Beta]*\[Alpha]*(2*P)/(Pi*w^2)* Exp[-((2*(x - 0.0025)^2)/w^2)]*Exp[-\[Beta]*z], T1[0, x, z] == 293.13, - \!$$\*SuperscriptBox[\(T1$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, 0] == 0.64*5.67*10^-8*(293.13^4 - T1^4), \!$$\*SuperscriptBox[\(T1$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, L] == 0, \!$$\*SuperscriptBox[\(T1$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, 0, z] == 0, \!$$\*SuperscriptBox[\(T1$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, M, z] == 0}, T1, {t, 0, tend}, {z, 0, L}, {x, 0, M}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 2000, "MaxPoints" -> 9999}}]; Plot[Evaluate[T1[t, x, z] /. dd /. t -> 2], {x, 0, M}, {z, 0, L}] There are errors like : ReplaceAll::reps: {NDSolve[{cp (T1^(1,0,0))[t,x,z]==9.67323*10^9 E^Plus[<<2>>]+1.45 ((<<1>>^(<<3>>))[<<3>>]+(<<1>>^(<<3>>))[<<3>>]),T1[0,x,z]==293.13,-(T1^(0,0,1))[t,x,0]==3.6288*10^-8 (7.38314*10^9-Power[<<2>>]),(T1^(0,0,1))[t,x,0.005]==0,(T1^(0,1,0))[t,0,z]==0,(T1^(0,1,0))[t,0.005,z]==0},T1,{t,0,10},{z,0,0.005},{x,0,0.005},Method->{MethodOfLines,SpatialDiscretization->{TensorProductGrid,MinPoints->2000,MaxPoints->9999}}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. NDSolve::dsvar: 2 cannot be used as a variable. I need to draw a 3D figure of temperature field at certain moment and also the temperature history at certain point. The code: Evaluate[T1[t, x, z] /. dd /. {x -> 0.0025,z -> 0} ], {t, 0, tend}] doesn't work either.
Answer
9 Replies
Sort By:
Posted 2 years ago
 You have a problem with the term T1^4 in the second equation. It does not make sense for the PDE. Also, you typed cp when I think you meant c * p so that is not defined numerically.
Answer
Posted 2 years ago
 Thanks, Neil. I used T to replace T1. And changed a little bit about the BCs since the NDsolve shows BCs are inconsistent. The errors didn't show anymore, but one weird thing is that there is no figure shown. p = 2931.5; c = 335; k = 1.45; \[Alpha] = 0.64; \[Beta] = 1/(260*10^-6); w = 0.0018; L = 0.005; tend = 10; P = 20; M = 0.005; dd = NDSolve[{c*p*\!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$T[t, x, z]$$\) == k*(\!$$\*SubscriptBox[\(\[PartialD]$$, $${z, 2}$$]$$T[t, x, z]$$\) + \!$$\*SubscriptBox[\(\[PartialD]$$, $${x, 2}$$]$$T[t, x, z]$$\)) + \[Beta]*\[Alpha]*(2*P)/(Pi*w^2)* Exp[-((2*(x - 0.0025)^2)/w^2)]*Exp[-\[Beta]*z], T[0, x, z] == 293.13, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, 0] == 0, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, L] == 0, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, 0, z] == 0, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, M, z] == 0}, T[t, x, z], {t, 0, tend}, {z, 0, L}, {x, 0, M}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 2000, "MaxPoints" -> 9999}}]; Plot3D[Evaluate[T[t, x, z] /. dd /. t -> 2], {x, 0, M}, {z, 0, L}] 
Answer
Posted 2 years ago
 It worked for me. I deleted the "MinPoints" -> 2000, "MaxPoints" -> 9999 Because it was taking a long time but you can slowly add more resolution until it brings your computer to its knees.Regards
Answer
Posted 2 years ago
 As general debugging advice: If you do any numerical solve or numerical plot, make sure the expression is ALL numerical. If it has one variable left in it (like you had cp above) it will fail. I always do this test on complicated expressions. For your equation there should be nothing but T[] and its derivatives in the PDE (this is how I found the two problems -- I just evaluated the expression and looked for extra variables) Evaluate your problem at low resolution so it solves quickly, make sure everything works and then increase to your required resolution and you can let it run for a long time. Regards
Answer
Posted 2 years ago
 Neil, thanks for the advices. Somehow, it worked on my another PC.I still have a question about your saying 'the term T^4 doesn't make sense to the PDE'. I don't understand how this works. Here what I am trying to interpret is on the top surface, there is a radiation heat flow/loss (from the material to the environment), which is relevant to the material temperature.The other three boundaries don't have heat loss. But once I add it into my code, the result shows those errors again including 'the function T appears with no arguments'. p = 2931.5; c = 335; k = 1.45; \[Alpha] = 0.64; \[Beta] = 1/(260*10^-6); w = 0.0018; L = 0.005; tend = 10; P = 20; M = 0.005; dd = NDSolve[{c*p*\!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$T[t, x, z]$$\) == k*(\!$$\*SubscriptBox[\(\[PartialD]$$, $${z, 2}$$]$$T[t, x, z]$$\) + \!$$\*SubscriptBox[\(\[PartialD]$$, $${x, 2}$$]$$T[t, x, z]$$\)) + \[Beta]*\[Alpha]*(2*P)/(Pi*w^2)* Exp[-((2*(x - 0.0025)^2)/w^2)]*Exp[-\[Beta]*z], T[0, x, z] == 293.13, - \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, 0] == 0.64*5.67*10^-8*(293.13^4 - T^4), \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "0", ",", "1"}], ")"}], Derivative], MultilineFunction->None]\)[t, x, L] == 0, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, 0, z] == 0, \!$$\*SuperscriptBox[\(T$$, TagBox[ RowBox[{"(", RowBox[{"0", ",", "1", ",", "0"}], ")"}], Derivative], MultilineFunction->None]\)[t, M, z] == 0}, T[t, x, z], {t, 0, tend}, {z, 0, L}, {x, 0, M}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid"}}]; Plot3D[Evaluate[T[t, x, z] /. dd /. t -> 2], {x, 0, M}, {z, 0, L}] 
Answer
Posted 2 years ago
 Xing,You define T as a function of three variables-- you must use it that way. T by itself will cause Mathematica to fail because it wants it to be a function of three variables (it is treated as a pure function waiting to be applied to three arguments). If you do not mean the same variable,T, you should give it a new name such as Tambient and then give it a value. If the temperature there is not a constant and you really want the T specified in the PDE then you must specify T[t,x,z] with the t,x, and z having the appropriate values for that end condition. I assumed from your equations -- maybe incorrectly that you want the temperature change to depend on the 4th power of the instantaneous temperature at that position and time. I changed your T^4 to T[t, x, 0]^4) and it integrated properly and gave an answer. (of course, I do not know if that is what you intended)I hope this helps.Regards
Answer
Posted 2 years ago
 That makes so much sense. And I indeed need the instantaneous temperature for the BC. Do you have any idea why the temperature changes so much with z length (the material thickness) changing? It could stay at room temperature if I changed L to 0.05. Physically speaking, the temperature shouldn't change much with the material thickness increasing.
Answer
Posted 2 years ago
 Xing,I have not studied the physics of your problem in detail so I can't say if your equations are correct. However, I ran bot L = 0.005 and L=0.01 and I see that the extra thickness pulls more heat from the boundary -- this may be reasonable since you are warming that extra material and your boundary condition on the far end is perfectly insulated. I would expect the extra material to draw more heat. To better visualize your problem you can see how it changes over time: Manipulate[ Plot3D[Evaluate[T[t, x, z] /. dd /. t -> tt], {x, 0, M}, {z, 0, L}, ImageSize -> {500, 400}, PlotRange -> {{0, M}, {0, L}, {200, 1500}}], {tt, 0, tend}] `This will show you how the heat moves through the material. You can verify your equation (since it is a simple heat transfer PDE with a textbook. If you still have some doubts, my next step would be to try a simplified, lumped parameter model to see if it also behaves that same way. If your two models converge than you have a second check on your PDE. I hope that helps.
Answer
Posted 2 years ago
 Hi, Neil,Yes. The extra thickness will pull more heat but definitely not that much. I ran this model on COMSOL and the result is good, the thickness will not affect much once it exceeds certain point (except there is nothing to 'code'). Maybe there is something wrong with my PDEs, guess I have to check that.Thanks for your help and detailed explanation.
Answer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments