How do I find this particular boundary element for solving differential equations

2 views (last 30 days)
Hello, I'm trying to find the solution for this equation
(d^2T/dr^2) + (1/r)*(dT/dr) + S= 0;
they give us S=20; T(r=1)=1 and (dT/dr)=0 when r=0
The problem is if you replace the derivatives by zero you get S=0, each is not true.
At the moment I have T(r=0)=20 because it makes the most sense for me but i dont know.
I have to solve this equation through matrices in matlab but to do so i need two boundary values. my code is
S=20; dr=0.01; r=0:dr:1; n=length(r);
%boundary conditions cfe=20; cfd=1;
M=zeros(n,n); y=zeros(n,1);
A=r-dr/2; %after
B=r+dr/2; %before
C=-2*r; %center
J=-S*dr^2;%right side of equation
% ptos interiores
for i=2:n-1
M(i,i)=C(i);
M(i,i-1)=B(i);
M(i,i+1)=A(i);
y(i)=J*r(i);
end
%Primeiro valor
M(1,1)=1;M(1,2)=0;
M(n,n)=1;M(n,n-1)=0;
y(1)=cfe;y(n)=cfd;
% T=y/M; T=M\y;
figure(1)
plot(r,T,'r')
xlabel('Raio'); ylabel('K');
title('Temperatura em função do raio');
grid on

Answers (0)

Categories

Find more on Computational Fluid Dynamics (CFD) in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!