Velocity field in two vertical density layers(left=3200,right=3300).

这篇具有很好参考价值的文章主要介绍了Velocity field in two vertical density layers(left=3200,right=3300).。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

%set parameter
Nx = 31; %ordinary
Ny = 21; 
L1 = 1000; 
L2 = 1500;
g_y = 10;
constant_viscosity = 10.^21;%unit:(Pa*s)
density_left = 3200;
density_right = 3300;
deltax = L1 / (Nx-1);
deltay = L2 / (Ny-1);
x_middle = L1/2;
Kcont = 2*constant_viscosity./(deltax+deltay);
%grids has Ny+1 rows and Nx+1 columns
[x,y] = meshgrid(0:deltax:L1,0:deltay:L2);
%unknown_number is (Ny+1)*(Nx+1)*3
unknown_number = (Nx+1)*(Ny+1)*3;
coe = sparse(unknown_number,unknown_number);
R = zeros(unknown_number, 1);
in_node = zeros(Ny+1,Nx+1);
in_vx = zeros(Ny+1,Nx+1);
in_vy = zeros(Ny+1,Nx+1);
in_p = zeros(Ny+1,Nx+1);
%boundary condition : free slip = -1 ; no slip = 1//why
bc_left=-1;
bc_right=-1;
bc_top=-1;
bc_bottom=-1;
density = zeros(Ny,Nx);
%two vertical layers
for j = 1:Nx
    for i = 1:Ny
        if (j-1)*deltax < x_middle
            density(i,j) = density_left;
        else
            density(i,j) = density_right;
        end
    end
end
%index
for i = 1:Ny+1
    for j = 1:Nx+1
        in_node(i,j) = (j-1)*(Ny+1)+i;
        in_vx(i,j) = 3*in_node(i,j)-2;
        in_vy(i,j) = 3*in_node(i,j)-1;
        in_p(i,j) = 3*in_node(i,j);
    end
end

for i = 1:Ny+1
    for j = 1:Nx+1
        %condition of Vx
        if(i==1 || i==Ny1 || j==1 || j==Nx || j==Nx1)
            %boundary condition
            coe(in_vx(i,j),in_vx(i,j)) = 1;% vx(i,j) = 0
            %right hand side
            R(in_vx(i,j),1) = 0;
            %top free slip
            if(i==1 && j>1 && j<Nx) % vx(i,j)-vx(i+1,j) = 0
                coe(in_vx(i,j),in_vx(i+1,j))=bctop; 
            end
            %bottom free slip
            if(i==Ny+1 && j>1 && j<Nx)% vx(i,j)-vx(i-1,j) = 0
                coe(in_vx(i,j),in_vx(i-1,j))=bcbottom; 
            end
        %x-Stokes equation    
        else
            coe(in_vx(i,j),in_vx(i,j)) = -2*constant_viscosity.*(1/(deltax.^2)+1/(deltay.^2));%vx3
            coe(in_vx(i,j),in_vx(i,j-1)) = constant_viscosity./(deltax.^2);%vx1
            coe(in_vx(i,j),in_vx(i,j+1)) = constant_viscosity./(deltax.^2);%vx5
            coe(in_vx(i,j),in_vx(i-1,j)) = constant_viscosity./(deltay.^2);%vx2
            coe(in_vx(i,j),in_vx(i+1,j)) = constant_viscosity./(deltay.^2);%vx4
            coe(in_vx(i,j),in_p(i,j+1)) = -Kcont./deltax;%P2'
            coe(in_vx(i,j),in_p(i,j)) = Kcont./deltax;%P1'
            %right hand side    
            R(in_vx(i,j),1)=0;    
        end
        %condition of Vy
        if(j==1 || j==Nx+1 || i==1 || i==Ny || i==Ny+1)
            %boundary condition
            coe(in_vy(i,j),in_vy(i,j)) = 1;% vy(i,j) = 0
            %right hand side
            R(in_vy(i,j),1) = 0;
            %left free slip
            if(j==1 && i>1 && i<Ny) % vy(i,j)-vy(i,j+1) = 0
                coe(in_vy(i,j),in_vy(i,j+1))=bcleft; 
            end
            %right free slip
            if(j==Nx+1 && i>1 && i<Ny)% vx(i,j)-vx(i,j-1) = 0
                coe(in_vy(i,j),in_vx(i,j-1))=bcright; 
            end
        %y-Stokes equation    
        else
            coe(in_vy(i,j),in_vy(i,j)) = -2*constant_viscosity.*(1/(deltax.^2)+1/(deltay.^2));%vy3
            coe(in_vy(i,j),in_vy(i,j-1)) = constant_viscosity./(deltax.^2);%vy1
            coe(in_vy(i,j),in_vy(i,j+1)) = constant_viscosity./(deltax.^2);%vy5
            coe(in_vy(i,j),in_vy(i-1,j)) = constant_viscosity./(deltay.^2);%vy2
            coe(in_vy(i,j),in_vy(i+1,j)) = constant_viscosity./(deltay.^2);%vy4
            coe(in_vy(i,j),in_p(i+1,j)) = -Kcont./deltay;%P2'
            coe(in_vy(i,j),in_p(i,j)) = Kcont./deltay;%P1'
            %right hand side    
            R(in_vy(i,j),1) = -g_y.*( density(i,j-1)+density(i,j) )./2;     
        end
        %condition of P
        if(i==1 || j==1 || i==Ny+1 || j==Nx+1 || (i==2 && j==2))        
            % Boundary Condition
            coe(in_p(i,j),in_p(i,j))=1; %p(i,j) = 0 
            % right hand side
            R(in_p(i,j),1)=0; 
            if(i==2 && j==2)
                coe(in_p(i,j),in_p(i,j))=1*Kcont;% p(2,2) = 0,p=p'*Kcont
                R(in_p(i,j),1)=0; 
            end
        %continuity equation    
        else
            coe(in_p(i,j),in_vx(i,j-1)) = -Kcont./deltax;%vx1
            coe(in_p(i,j),in_vx(i,j))   =  Kcont./deltax;%vx2
            coe(in_p(i,j),in_vy(i-1,j)) = -Kcont./deltay;%vy1
            coe(in_p(i,j),in_vy(i,j))   =  Kcont./deltay;%vy2
            % Right hand side
            R(in_p(i,j),1)=0;
        end
    end
end

%compute the solution u1:include vx,vy and p
u1 = coe \ R

vx_matrix = zeros(Ny+1,Nx+1);
vy_matrix = zeros(Ny+1,Nx+1);
p_matrix = zeros(Ny+1,Nx+1);
%decompose the solution of global matrix.
for j = 1:Nx+1
    for i = 1:Ny+1
        vx_matrix(i,j) = u1(in_vx(i,j),1);
        vy_matrix(i,j) = u1(in_vy(i,j),1);
        p_matrix(i,j) = u1(in_p(i,j),1);
    end
end
% Velocity field in two vertical density layers(left=3200,right=3300)
figure(1)
scale = 1
quiver(x,y,vx_matrix(1:Ny,1:Nx),vy_matrix(1:Ny,1:Nx),scale,color = 'r')
xlabel('Horizontal(Km)')
ylabel('Vertical(Km)')
title('Velocity field in two vertical density layers(left=3200,right=3300)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')

% Velocity_x field in two vertical density layers(left=3200,right=3300)
figure(2)
pcolor(x,y,vx_matrix(1:Ny,1:Nx))
xlabel('Horizontal(Km)')
ylabel('Vertical(Km)')
title('Velocity_x field in two vertical density layers(left=3200,right=3300)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')
shading interp;
% Velocity_y field in two vertical density layers(left=3200,right=3300)
figure(3)
pcolor(x,y,vy_matrix(1:Ny,1:Nx))
xlabel('Horizontal(Km)')
ylabel('Vertical(Km)')
title('Velocity_y field in two vertical density layers(left=3200,right=3300)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')
shading interp;
% Pressure field in two vertical density layers(left=3200,right=3300)
figure(4)
pcolor(x(2:Ny,2:Nx),y(2:Ny,2:Nx),p_matrix(2:Ny,2:Nx))
xlabel('Horizontal(Km)')
ylabel('Vertical(Km)')
title('Pressure field in two vertical density layers(left=3200,right=3300)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')
colorbar;
shading interp;
% Distribution of two vertical density layers(left=3200,right=3300)
figure(5)
pcolor(x,y,density)
xlabel('Horizontal(Km)')
ylabel('Vertical(Km)')
title('Distribution of two vertical density layers(left=3200,right=3300)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')
colorbar;
shading interp;

 Velocity field in two vertical density layers(left=3200,right=3300).,matlab,velocity field,numerical,mantle

Velocity field in two vertical density layers(left=3200,right=3300).,matlab,velocity field,numerical,mantle

 文章来源地址https://www.toymoban.com/news/detail-631789.html

Velocity field in two vertical density layers(left=3200,right=3300).,matlab,velocity field,numerical,mantle

 Velocity field in two vertical density layers(left=3200,right=3300).,matlab,velocity field,numerical,mantle

Velocity field in two vertical density layers(left=3200,right=3300).,matlab,velocity field,numerical,mantle 

 

 

到了这里,关于Velocity field in two vertical density layers(left=3200,right=3300).的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • SQL Server 查找字符串LIKE vs SUBSTRING vs LEFT/RIGHT vs CHARINDEX

    开发人员经常需要在数据库表中查询以某种文本模式开始和/或结束的记录。例如,查找名字以“DAV”开头的所有员工。 根据我的经验,SQL 开发人员通常依赖 4 个常用函数来实现这一点。 就在那时,这位好奇的顾问决定将它们正面交锋:LIKE vs SUBSTRING vs LEFT / RIGHT vs CH

    2024年02月05日
    浏览(31)
  • MySQL多表查询内连接外连接详解,join、left join、right join、full join的使用

    目录 1、多表查询概览 1.1、分类 1.2、外连接的分类 1.3、常用的SQL语法标准 2、内外联接案例 2.1、初始化表 2.2、内连接 2.3、外连接案例 2.4、全连接案例 2.5、union和union all 2.6、实现MySQL全连接 2.7、内外连接面试基础 2.8、SQL99多表查询新特性 1.1、分类 可以根据3个角度进行分类

    2024年02月05日
    浏览(45)
  • Mysql表关联简单介绍(inner join、left join、right join、full join不支持、笛卡尔积)

    A 是1、2、3 B是2、3、4 A、B的交集是A∩B = 2、3 A、B的并集是 AUB = 1、2、3、4 A、B的差集是 A-B = 1 B、A的差集是 B-A = 4 造数据 select A. ,B. from xin_stu_t_bak A inner join xin_teach_t_bak B on A.relation_id = B.id order by A.id; select distinct A. ,B. from xin_stu_t_bak A inner join xin_teach_t_bak B on A.relation_id = B.id

    2024年01月17日
    浏览(36)
  • 【问题解决】【linux的双显示器无法识别的问题】【HDMI-1-1 disconnected (normal left inverted right x axis y axis)】

    @[TOC](【问题解决】【linux的双显示器无法识别的问题】【HDMI-1-1 disconnected (normal left inverted right x axis y axis)】) 如果你是刚开机就解决这个问题,很简单,参考添加链接描述, 切记关闭BIOS的安全启动security boot ,如果是灰色的,那么参考:win10/华硕主板/ security boot disable/ secu

    2024年02月09日
    浏览(21)
  • 微信小程序——van-field中的left-icon属性自定义

    ✅作者简介:2022年 博客新星 第八 。热爱国学的Java后端开发者,修心和技术同步精进。 🍎个人主页:Java Fans的博客 🍊个人信条:不迁怒,不贰过。小知识,大智慧。 💞当前专栏:微信小程序学习分享 ✨特色专栏:国学周更-心性养成之路 🥭本文内容:微信小程序——

    2024年02月11日
    浏览(29)
  • 完美解决微信小程序van-field left-icon自定义图片

    实现效果:   data中定义:

    2024年02月12日
    浏览(21)
  • 【Unity2D】Order in Layer 与Layer的区别

    Order in Layer 是Unity 图形渲染的顺序,通过设置Order in Layer ,可以设置同层(Layer)的物体出现顺序,可以默认使一种物体出现在另一种物体前方 设置一物体默认在其他物体之上不被遮挡  Layer是Unity中物体的层级,不同物体可以位于不同层上 通过这个可以设置不同层的物体之间的

    2024年02月14日
    浏览(22)
  • pnpm 源不对 Will retry in 10 seconds. 2 retries left.

    由于使用npm config set registry 切换淘宝源时,把地址打错了。 后面使用pnpm install 时出现  此时无论我怎么使用npm config set registry 或者pnpm config set registry 切回正确的源均没有效果。 在其他用npm的项目运行一下npm i  再运行pnpm i 即可解决。

    2024年01月24日
    浏览(23)
  • Unity UI与粒子 层级问题Camera depth Sorting Layer Order in Layer RenderQueue

    Unity游戏开发中,模型、界面、特效等,需要规划好 layer 的概念,涉及到摄像机(Camera)、画布(Canvas)、Shader等相关内容。 在 Unity 中,渲染顺序是由多个因素共同决定的,大致分为三层优先级: Camera depth、Sorting Layer/Order in Layer 和 RenderQueue 。 一般游戏项目,会创建至少两

    2024年02月08日
    浏览(23)
  • ERROR: Can‘t find a suitable configuration file in this directory or anyparent. Are you in the right

      解决: 方法一: 检查当前目录: 确保你在配置文件所在的正确目录中。你可以使用命令 \\\"pwd\\\" 来检查当前目录。 检查父目录: 如果配置文件不在当前目录中,可以使用命令 \\\"cd ..\\\" 一级一级地向上移动,直到找到包含配置文件的目录。 搜索配置文件: 如果你仍然找不到配

    2024年02月12日
    浏览(26)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包