Can MATLAB Handle Finite Difference Modeling for Spherical Heat Transfer?

In summary, it seems that there may be some issues with the implementation of the boundary conditions and the matrix calculations in your code that may be causing the incorrect results.
  • #1
cayusbonus
3
0
Hello,

I'm triying to solve the unidimensional heat transfer equation in transient scheme for an sphere with Crank Nicholson discretization. Because I must to obtain the Heisler Charts, I'm triying to solve the adimensional equation, that is this equation:
equation.jpg
Where 4.1 is the equation, 4.2 the initial condition and 4.3 and 4.4 the boundary conditions (Neumann). In this equation, the Fo is an adimensional time, R is an adimensional radius and theta, an adimensional temperature. Then, the objective is to obtain Theta in all the grid points. The grid is the discretization of R in x-axe and Fo (time) in y-axe.

I've used the fictitious point system for implement the boundary conditions, and after a hard work, I've made this code:

Code:
M=8;
N=15;
DR=1/M;
DFo=0.2/N;
a=DFo/(2*DR);
hold on
for j=0.01:0.05:0.8
Bi=j;
c=-2*DR*Bi;
for m=1:M+1
    dA0(m)=-1-2*a;
    if m>1
        dA1(m-1)=a*(1+1/(m-1));
        dA_1(m-1)=a*(1-1/m);
    end
end
A=diag(dA0,0)+diag(dA1,1)+diag(dA_1,-1);
A(1,1)=-1-6*a;
A(1,2)=6*a;
a1=a*(1+1/M);
a2=-1-2*a;
a3=a*(1-1/M);
A(M+1,M)=a1+a3;
A(M+1,M+1)=a1*c+a2;
for m=1:M+1
    dB0(m)=1-2*a;
    if m>1
        dB1(m-1)=a*(1+1/(m-1));
        dB_1(m-1)=a*(1-1/m);
    end
end
B=diag(dB0,0)+diag(dB1,1)+diag(dB_1,-1);
B(1,1)=1-6*a;
B(1,2)=6*a;
b1=a1;
b2=1-2*a;
b3=a3;
B(M+1,M)=b1+b3;
B(M+1,M+1)=b1*c+b2;
Th=ones(M+1,N+1);
C=-inv(A)*B;
for k=1:N
    Th(:,k+1)=C*Th(:,k);
end
Tita=Th(1,:);
Fo=(0:DFo:0.2);
plot(Fo,Tita)
end

With this code, I'm triying to plot the center sphere temperature evolution, this mean to plot the Theta in R=0 for all the times (Fo). But the problem is that it's not ploting correct, and my question is if you can see anything incorrrect in the code (matrix implementations, index evolutions, discretizations...). An extrange issue is that when the number of points is increased (N and M), the integration goes more and more away from the correct expected result.

Thanks.
 
Physics news on Phys.org
  • #2


Hello,

Thank you for sharing your code. After reviewing it, I noticed a few potential issues that may be causing the incorrect results you are experiencing. First, it seems that your implementation of the boundary conditions may not be correct. In your code, you are using the fictitious point method, but it looks like you are only applying it to the first and last points in your grid. However, for a sphere, you will need to apply the boundary conditions at all points on the surface. This may be why your results are not matching the expected outcome.

Additionally, I noticed that your code only accounts for the Neumann boundary conditions, but it does not include the initial condition (4.2) or the Dirichlet boundary condition (4.3). These conditions are also important in accurately solving the heat transfer equation for a sphere.

Finally, I would suggest checking your matrix implementations and making sure they are correct. It's possible that there may be an error in your code that is causing the incorrect results.

I hope this helps and good luck with your research. If you have any further questions or concerns, please feel free to reach out.
 

Related to Can MATLAB Handle Finite Difference Modeling for Spherical Heat Transfer?

1. What is the purpose of using Finite Differences in MATLAB?

The purpose of using Finite Differences in MATLAB is to approximate derivatives or to solve differential equations numerically. It allows for a faster and more efficient way to calculate derivatives compared to using analytical methods.

2. How does MATLAB perform Finite Differences?

MATLAB performs Finite Differences by using the central difference formula, which calculates the derivative by taking the slope between two points on a curve. It also has built-in functions and tools specifically designed for performing Finite Differences.

3. Can Finite Differences be used for higher-order derivatives?

Yes, Finite Differences can be used for higher-order derivatives by increasing the number of data points and using appropriate formulas. However, as the order of the derivative increases, the accuracy of the approximation decreases.

4. Are there any limitations to using Finite Differences in MATLAB?

Yes, there are limitations to using Finite Differences in MATLAB. The accuracy of the approximation depends on the number of data points and the spacing between them. If the spacing is too large, the approximation may be inaccurate. Additionally, if the function being approximated is very complex, the results may not be accurate.

5. Can Finite Differences be used for solving differential equations with boundary conditions?

Yes, Finite Differences can be used to solve differential equations with boundary conditions. MATLAB provides functions such as bvp4c and bvp5c specifically for solving boundary value problems using Finite Differences. It allows for a more efficient and convenient way to solve differential equations compared to traditional methods.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
41
Views
8K
  • Differential Equations
Replies
2
Views
2K
  • Thermodynamics
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Differential Equations
Replies
23
Views
4K
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top