MATLAB: How to specify a uneven initial temperature condition

conditionheatinitialPartial Differential Equation Toolboxpdepdetooltemperatureuneven

How do I specify a uneven initial temperature condition?
I plan to solve a linear parabolic heat transfer problem by using PDE tool box. I understand that MATLAB PDETOOL can not solve nonlinear parabolic heat transfer problems.
For my practical problem, the initial temperature is not homogeneous, nor can it be given by an (x,y) expression. What I have is an initial temperature map which gives temperature distribution at, say, 64 by 64 grids of pixels of the geometry.
In other words, I know the initial temperature of every point, but I do not know to input it into PDE Toolbox. I can transfer my initial temperature map into a MATLAB variable which is a 64 by 64 (or 128 by 128) array.

Best Answer

Using the command line solver PARABOLIC, you can specify the initial condition for each node of the mesh using a column vector. In your case, you have the initial values of the geometry, but PARABOLIC needs the initial values of each node in the mesh. However, we can find the initial value of each node by interpolating the values from the initial values of the geometry using INTERP2. Once we have the initial value for each node, we can solve the PDE.
The following steps will demonstrate how to export the relevant PDE parameters, interpolate to find the initial values of each node, and then solve the PDE.
1. Export the Mesh (p, e, t) Boundary Conditions (g, b) and PDE Coefficients (c, a, d, f). The p matrix is a matrix of coordinates for each node.
2. Use INTERP2 to find initial values for each node. If you have a temperature map, MP, with a size 64 X 64, you will need to pass INTERP2 two vectors, X and Y, each with a length of 64, that correspond to the X and Y values for each point of the temperature map, MP.
For example, if the temperature map values were defined for the region X = -1 to 1 and Y = -1 to 1, you could use the following syntax:
X = -1:2/63:1;
Y = -1:2/63:1;
initvect = interp2(X,Y,MP,p(1,:)',p(2,:)');
3. Call PARABOLIC with the following syntax:
u1=parabolic(initvect,0:10,b,p,e,t,c,a,d,f);
For more information on PARABOLIC or INTERP2, please type the following at the MATLAB prompt:
doc parabolic
or
doc interp2
Related Question