朱莉娅我可以用我自己的数据功能制作一个流图

发布于 2025-02-03 21:44:52 字数 1222 浏览 0 评论 0原文

我正在做我的论文,我需要用速度矩阵制作流图。 我已经解决了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文