找到流线并在图表上绘制它

时间:2017-09-14 06:48:56

标签: matlab

我正在尝试绘制以下流程的简化: flow equation

我们正在用sparatrix线绘制我们的停滞点但不过某种程度上简化了它... 我们不能使用流功能。知道什么是错的吗?

不知何故情节没有正确绘图......这是我的matlab代码:

%% constant parameters
a=1;
U=100;
T=3*pi*a*U;

%% plot the stagnation points
syms z 
k=100./z^2 - 1i*3./(2*z) - 100==0;    %diff(w)==0
stagpoint=solve(k,z);                 %get the points
plot(stagpoint,'MarkerFaceColor','g');

%% plot the the sparatrix line
[x,y]=meshgrid([-7:0.1:7],[-2:0.1:2]);
z=x+1i*y;
w1=-100*(z+1./z)-1i*log(z).*3*pi*100./(2*pi);
psi=imag(w1);
limit=sqrt(x.^2+y.^2);
x((limit<0.99))=NaN;
y((limit<0.99))=NaN;

contour(x,y,psi,'k');
xlabel('Re');
ylabel('Im');
title('streamline for question4(a)');


axis([-5 5 -5 5])
daspect([1 1 1]);
hold on

%% plot streamline

RK4_4A(z);

%% plot the surface of the cylinder
angle=[0:0.1:360];
x=cosd(angle);          %x component of the cylinder
y=sind(angle);          %y component of the cylinder
plot(x,y);
hold on
fill(x,y,'r');

这是我们用于第4阶Runge-Kutta方法的函数:

function RK4_4A(zn)

h=0.001;
x=5;
y=[-5:0.5:5];
zn=x+1i*y;

for j=1:length(y)
    z(1)=zn(j);
     t=0:h:2;
for i=1:length(t)-1

    k1 = ffunc(z(i));
    k2 = ffunc(z(i)+h/2*k1);
    k3 = ffunc(z(i)+h/2*k2);
    k4 = ffunc(z(i)+h*k3);

    z(i+1) = z(i) + h*(1/6*k1+1/3*k2...
        +1/3*k3+1/6*k4);
end

 plot(real(z),imag(z),'b');

    hold on

end

function s=ffunc(z)
s = 100./z^2 - 1i*3./(2*z) - 100;
s=conj(s);

end

end

0 个答案:

没有答案