How to solve a non linear problem with bv4c?
Afficher commentaires plus anciens
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?
Réponses (1)
Torsten
le 9 Mai 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 commentaires
Arianna Serpi
le 9 Mai 2017
Torsten
le 9 Mai 2017
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
le 9 Mai 2017
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!