朱莉娅我可以用我自己的数据功能制作一个流图
我正在做我的论文,我需要用速度矩阵制作流图。 我已经解决了Navier-Stokes方程,并且有一个U-Velocity 19x67的矩阵和V速度19x67的其他矩阵。
为了获得连续函数,我已经完成了双线性插值,但是我对绘图有问题。
我不知道我是否很好地解释了自己,但是让您代码。
#BILINEAR INTERPOLATION#
X=2
Y=0.67
x_pos=findlast(x->x<X, x)
y_pos=findlast(x->x<Y, y)
x1=((x_pos-1))*Dx
x2=(x_pos)*Dx
y1=((y_pos-1)-0.5)*Dy
y2=(y_pos-0.5)*Dy
u1=u[y_pos-1,x_pos-1]
u2=u[y_pos-1,x_pos]
u3=u[y_pos,x_pos-1]
u4=u[y_pos,x_pos]
u_int(Y,X)=(1/(Dx*Dy))*((x2.-X).*(y2.-Y).*u1+(X.-x1).*(y2.-Y).*u2+(x2.-X).*(Y.-y1).*u3+(X.-x1).*(Y.-y1).*u4)
xx1=((x_pos-1)-0.5)*Dx
xx2=(x_pos-0.5)*Dx
yy1=((y_pos-1))*Dy
yy2=(y_pos)*Dy
v1=v[y_pos-1,x_pos-1]
v2=v[y_pos-1,x_pos]
v3=v[y_pos,x_pos-1]
v4=v[y_pos,x_pos]
v_int(Y,X)=(1/(Dx*Dy))*((x2-X)*(y2-Y)*v1+(X-x1)*(y2-Y)*v2+(x2-X)*(Y-y1)*v3+(X-x1)*(Y-y1)*v4)
#PLOT#
function stream(Y,X)
u_c=u_int(Y,X)
v_c=v_int(Y,X)
return u_c,v_c
end
using CairoMakie
let
fig = Figure(resolution = (600, 400))
ax = Axis(fig[1, 1], xlabel = "x", ylabel = "y", backgroundcolor = :black)
streamplot!(ax, stream, -2 .. 4, -2 .. 2, colormap = Reverse(:plasma),
gridsize = (32, 32), arrow_size = 10)
display(fig)
end;
有解决方案吗? 如果您知道其他软件包的其他方法,请告诉我。
I'm doing my dissertetion and I need to make a streamplot with the velocities matrix.
I have resolved Navier-stokes equations and I have one matrix of u-velocity 19x67 and other matrix of v-velocity 19x67.
To obtain a continuos function I have done a bilinear interpolation but I have problem with the plotting.
I don't know if I explain myself very well but y let you the code.
#BILINEAR INTERPOLATION#
X=2
Y=0.67
x_pos=findlast(x->x<X, x)
y_pos=findlast(x->x<Y, y)
x1=((x_pos-1))*Dx
x2=(x_pos)*Dx
y1=((y_pos-1)-0.5)*Dy
y2=(y_pos-0.5)*Dy
u1=u[y_pos-1,x_pos-1]
u2=u[y_pos-1,x_pos]
u3=u[y_pos,x_pos-1]
u4=u[y_pos,x_pos]
u_int(Y,X)=(1/(Dx*Dy))*((x2.-X).*(y2.-Y).*u1+(X.-x1).*(y2.-Y).*u2+(x2.-X).*(Y.-y1).*u3+(X.-x1).*(Y.-y1).*u4)
xx1=((x_pos-1)-0.5)*Dx
xx2=(x_pos-0.5)*Dx
yy1=((y_pos-1))*Dy
yy2=(y_pos)*Dy
v1=v[y_pos-1,x_pos-1]
v2=v[y_pos-1,x_pos]
v3=v[y_pos,x_pos-1]
v4=v[y_pos,x_pos]
v_int(Y,X)=(1/(Dx*Dy))*((x2-X)*(y2-Y)*v1+(X-x1)*(y2-Y)*v2+(x2-X)*(Y-y1)*v3+(X-x1)*(Y-y1)*v4)
#PLOT#
function stream(Y,X)
u_c=u_int(Y,X)
v_c=v_int(Y,X)
return u_c,v_c
end
using CairoMakie
let
fig = Figure(resolution = (600, 400))
ax = Axis(fig[1, 1], xlabel = "x", ylabel = "y", backgroundcolor = :black)
streamplot!(ax, stream, -2 .. 4, -2 .. 2, colormap = Reverse(:plasma),
gridsize = (32, 32), arrow_size = 10)
display(fig)
end;
Any solution?
If you know other method with other package, pls tell me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论