bvp4c (Compressible boundary layer)
5 views (last 30 days)
Show older comments
Hi, i hope someone can help me. I want to find the solution to the compressible boundary layer equations, this problem is part of my thesis project, but I'm running into some problems.
To make it easier to read, here is the coupled set of ODE that I'm trying to solve;
y(4)=1/C*(-C'*y(3)-y(1)*y(3))
y(7)=1/C*(-P*y(1)*y(6)-P*C*(g-1)M^2*y(3)^2-C'*y(6))
Where C and C' are;
C=(y(5)^0.5*(h+c*s)/(y(5)*h+c*s))
C'=(y(6)*((T/s)+1)*(1-(T/s)*y(5))/(2*y(5)^0.5*(y(5)*(T/s)+1)^2))
My code
function Compressible_Boundary_Layer
h=301350; c=1004.5; s=120; T=300; P=1; g=1.4; M=2.9;
solinit=bvpinit(linspace(0,8,9),@Compressibleguess);
sol=bvp4c(@Compressible,@Compressiblebc,solinit,[],h,c,s,T,P,M);
x=linspace(0,8,100);
y=deval(sol,x);
plot(x,y(2,:))
function dydx=Compressible(x,y,h,c,s,T,P,M)
dydx=[y(2);
y(3);
1/(y(5)^0.5*(h+c*s)/(y(5)*h+c*s))*(-(y(6)*((T/s)+1)*(1-(T/s)*y(5))/(2*y(5)^0.5*(y(5)*(T/s)+1)^2))*y(3)-y(1)*y(3));
y(6);
1/(y(5)^0.5*(h+c*s)/(y(5)*h+c*s))*(-P*y(1)*y(6)-P*(y(5)^0.5*(h+c*s)/(y(5)*h+c*s))*(g-1)*M^2*y(3)^2-(y(6)*((T/s)+1)*(1-(T/s)*y(5))/(2*y(5)^0.5*(y(5)*(T/s)+1)^2))*y(6))];
function res=Compressiblebc(ya,yb,h,c,s,T,P,M)
res=[ya(1);ya(2);yb(2)-1;yb(5)-1;ya(6)];
function y=Compressibleguess(x)
y(1)=x;
y(2)=x^0.5;
y(3)=5-x;
y(5)=-x^2+2;
y(6)=-x;
When i run this i get two errors;
??? Error using ==> bvp4c The boundary condition function should return a column vector of length 6
Error in ==> Compressible_Boundary_Layer at 4 sol=bvp4c(@Compressible,@Compressiblebc,solinit,[],h,c,s,T,P,M);
Hope someone can help, thanks in advance.
Ayden
0 Comments
Answers (2)
Walter Roberson
on 31 Mar 2012
Before assigning to y(1), insert
y = zeros(6,1);
By default arrays accessed with a single index are created as row vectors rather than column vectors.
4 Comments
Walter Roberson
on 31 Mar 2012
Might I suggest that you only want your guess function to create y(1) to y(5) ?
See Also
Categories
Find more on Ordinary Differential Equations 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!