Unbound Shear Layer boundary condition problem
3 次查看(过去 30 天)
显示 更早的评论
Hi, I'm very new to Matlab so bare with me, I'm trying to solve the unbounded shear layer problem for the internal section, between z=1 and -1. I cannot however enter the boundary conditon at z=1 to depend on a constant. Any help would be great.
Thanks.
4 个评论
采纳的回答
Torsten
2019-4-10
编辑:Torsten
2019-4-10
function main
xlow = -1; xhigh = 1;
A = 1;
solinit = bvpinit(linspace(xlow,xhigh,4000),[1,1],1);
sol = bvp4c(@bvp4ode, @(ya,yb,parameters)bvp4bc(ya,yb,parameters,A), solinit);
a = sol.parameters;
xint = linspace(xlow,xhigh,2000);
Sxint = deval(sol,xint);
% Analytical solution
C1 = A/(2*sin(a));
C2 = A/(2*cos(a));
fun = @(x) C1*sin(a*x) + C2*cos(a*x);
% Plot numerical vs. analytical solution
plot(xint,Sxint(1,:),xint,fun(xint))
end
function dydx = bvp4ode(x,y,parameters)
dydx=[y(2); -parameters^2*y(1)];
end
function res = bvp4bc(ya,yb,parameters,A)
res=[ya(1); yb(1)-A; ya(2)-1];
end
5 个评论
Torsten
2019-4-15
As before, please state the problem in a mathematical fashion (equations and boundary conditions).
更多回答(1 个)
Alexander Kimbley
2019-4-16
4 个评论
Torsten
2019-4-16
编辑:Torsten
2019-4-16
function main
xlow = -1; xhigh = 1;
a = 1;
B = 0.5;
c0 = 0.5;
R0 = 0.5;
y10 = 1.0;
y20 = 0.0;
solinit = bvpinit(linspace(xlow,xhigh,4000),[y10,y20],[c0,R0]);
sol = bvp4c(@(x,y,p)bvp4ode(x,y,p,a,B), @(ya,yb,p)bvp4bc(ya,yb,p,a,B), solinit);
c = sol.parameters(1)
R = sol.parameters(2)
xint = linspace(xlow,xhigh,2000);
Sxint = deval(sol,xint);
plot(xint,Sxint(1,:))
end
function dydx = bvp4ode(x,y,p,a,B)
c = p(1);
R = p(2);
dydx = [y(2); 2*B^2*(y(1)-(x-c^2)*y(2))/((x-c^2)^2*((x-c^2)^2-B^2))+a*y(1)];
end
function res = bvp4bc(ya,yb,p,a,B)
c = p(1);
R = p(2);
res = [ya(1)-1; yb(1)-R; ya(2)-((1+c^2)-a*(1+c^2)^2)/(B^2-(1+c^2)^2); yb(2)-R*((1-c^2)-a*(1-c^2)^2)/((1-c^2)^2-B^2)];
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!