首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >MATLAB计算矢量场中的线积分?

MATLAB计算矢量场中的线积分?
EN

Stack Overflow用户
提问于 2018-10-19 05:30:54
回答 1查看 0关注 0票数 0

下面是在原点基于自由流速度和涡流强度创建矢量场的代码。

然后我尝试通过求线积分的面积来计算循环,

例

做法:

1)从它的速度场中分离出矢量。例如:line1_2是来自矩阵u的水平向量,line2是来自矩阵u的垂直向量

2)使用trapz,在线上获取区域并以分辨率作为因子。途径

3)总结所有区域,对于任何闭合形状,它应该等于C的分子,在这种情况下为1000.如果使得它= 1000,我们可以使用area1 / 2/3/4的符号。

我的方法没有给出正确的值来总结它应该是什么,任何想法都会非常感激。

基本上需要对速度场中的闭合形状或区域积分进行线积分。(斯托克定理)

谢谢

代码语言:javascript
复制
U_i = 10;      % free stream velocity
C = 1000/(2*3.14);% vortex strength
meshfactor = 100;
[x,y] = meshgrid(-U_i:U_i/meshfactor:U_i);

% streamline= -U_i*y + G/(4*3.14)*log(y.^2 + x .^2)
% potential = -U_i*x - G/(2*pi)*atan(y/x)

% u and v components % note: substituted gamma/2i into the variable (line 2)

u = U_i - C*y./(2*(x.^2 + y.^2)); %%define the velocity component in the x
v = C*x./(2*(x.^2 + y.^2)); %%define the velocity component in the y

u(isnan(u)) = 0;
v(isnan(v)) = 0;

%prompt user for input of point coordinates in vector form, ie "[3,3]"
prompt1= 'pt1';
pt1 = input(prompt1);

prompt2= 'pt2';
pt2 = input(prompt2);

prompt3= 'pt3';
pt3 = input(prompt3);

prompt4= 'pt4';
pt4 = input(prompt4);

%% define line 1-2 in the horizontal, goes from left to right
line_1 = pt1(1):U_i/meshfactor:1;pt2(1);
yvec=u(pt1(2),pt1(1):pt2(1));
area_1 = U_i/meshfactor*trapz(yvec);

%% define line 2-3 in the vertical, goes from left to right
line_2 = pt2(2):U_i/meshfactor:1;pt3(2);
yvec2=v(pt2(2):pt3(2),pt2(1));
area_2 = U_i/meshfactor*trapz(yvec2);

%% define line 3-4 in the horizontal, goes from right to left
line_3 = pt4(1):U_i/meshfactor:1;pt3(1);
yvec3=u(pt4(2),pt4(1):pt3(1));
area_3 = U_i/meshfactor*trapz(yvec3);

%% define line 4-1 in the vertical, goes from left to right
line_4 = pt1(2):U_i/meshfactor:1;pt4(2);
yvec4=v(pt1(2):pt4(2),pt1(1));
area_4 = U_i/meshfactor*trapz(yvec4);

circulation = area_1 + area_2 + area_3 + area_4

 figure
 hold on
    title((sprintf(' Unifrom flow with vortex at origin \n Vortex Strength = %0.0f, Free Stream Velocity = %0.0f',C,U_i)));
    quiver(x,y,u,v);
 hold off
EN

回答 1

Stack Overflow用户

发布于 2018-10-19 15:22:40

tigertiger,

您能提供一组点输入样本,行积分的值以及代码计算的值吗?这可能有助于调试。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100002942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档