How to solve a non linear problem with bv4c?

I have to solve the following heat conduction steady-state non-linear problem using the function bvp4c in matlab:
λ∙(1/r)∙d/dr(r∙dT/dr)+5∙10^6-100T^2=0
with the boundary conditions: T(r1)=T1=300K, T(r2)=T2=350K
r1=0.8 m ; r2=1 m λ=400 W/(m⋅K)
How can I write the code?

Respuestas (1)

Torsten
Torsten el 9 de Mayo de 2017
Your equation reads
λ∙(T''(r)+T'(r)/r)+5e6-100*(T(r))^2 = 0.
or - rewritten as a system of 1st order equations -
T1' = T2
T2' = (100*T1^2-5e6)/λ - T2/r
Can you take it from here ?
Best wishes
Torsten.

3 comentarios

Arianna Serpi
Arianna Serpi el 9 de Mayo de 2017
I'm looking for the solution in the grid points defined by r=linspace(r1,r2,n). I create an external function, this is the code that I've written, but I don't know what to write inside the parenthesis with '???', and i'm not sure that the code is correct.
Thank you very much!
n=31
r=linspace(r1,r2,n);
function T=bvp4c_nonlin(r1,r2,n,T1,T2,lambda)
solinit = bvpinit(?????);
sol = bvp4c(@odefun,@bcfun,solinit);
r = linspace(r1,r2,n);
T = deval(sol,r);
plot(r,T(1,:))
grid on;
function dTdr = odefun(r,T)
dTdr = [T(2); (100/lambda)*((T(1)).^2)-r*T(2)+(5e06)/lambda];
end
function res = bcfun(Ta,Tb) % Define boundary conditions
res = [Ta(1)-T1; Tb(1)-T2];
end
end
function main
r1=0.8;
r2=1;
T1=300;
T2=350;
lambda=400;
n=31;
r=linspace(r1,r2,n);
solinit = bvpinit(r,@(r)guess(r,r1,r2,T1,T2));
sol = bvp4c(@(r,T)twoode(r,T,lambda),@(Tl,Tr)twobc(Tl,Tr,T1,T2),solinit);
T=deval(sol,r);
plot(r,T(1,:))
function dTdr = twoode(r,T,lambda)
dTdr=[T(2);(100*T(1)^2-5e6)/lambda-T(2)/r];
function res=twobc(Tl,Tr,T1,T2)
res=[Tl(1)-T1;Tr(1)-T2];
function T0=guess(r,r1,r2,T1,T2)
T0(1) = T1*(r-r2)/(r1-r2)+T2*(r-r1)/(r2-r1);
T0(2) = (T2-T1)/(r2-r1);
end
Best wishes
Torsten.
Arianna Serpi
Arianna Serpi el 9 de Mayo de 2017
thank you very very much now it works

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Mayo de 2017

Comentada:

el 9 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by