Solution of Possion2D equation with direct method.

这篇具有很好参考价值的文章主要介绍了Solution of Possion2D equation with direct method.。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

%set parameter
N1 = 41; 
N2 = 51;
L1 = 1000; 
L2 = 1500; 
deltax = L1 / (N1 - 1);
deltay = L2 / (N2 - 1);
%grids has N2 rows and N1 columns
[x,y] = meshgrid(0:L1/(N1-1):L1,0:L2/(N2-1):L2);
coe = zeros(N1*N2, N1*N2);
%coefficients of boundary
%up and down
for i = 1:N1
    j = 1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
    j = N2
    k = (i-1)*N2 + j;
    coe(k, k) = 1;    
end
%left and right
for j = 1:N2
    i = 1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
    i = N1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
end
%coefficients of interval points
for i = 2:N1-1
    for j = 2:N2-1
        k = (i-1)*N2 + j; % k表示网格点 (i,j) 对应的未知量索引
        coe(k, k) = -2./(deltax.^2)-2./(deltay.^2); % 中心点系数
        coe(k, k-1) = 1./(deltax.^2); % 左边点系数
        coe(k, k+1) = 1./(deltax.^2); % 右边点系数
        coe(k, k-N2) = 1./(deltay.^2); % 上边点系数
        coe(k, k+N2) = 1./(deltay.^2); % 下边点系数
    end
end
%set right hand side martix
%right value equal to 1 except boundary points
b = ones(N1*N2, 1);
%up and down
for i1 = 1:N1
    j1 = 1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
    j1 = N2
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
end
%left and right
for j1 = 1:N2
    i1 = 1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
    i1 = N1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
end
%direct method:right martix is divided by coe martix on the left
u = coe \ b
%transform vector to grids 
%grids has N2 rows and N1 columns
U = reshape(u, N2, N1);
%visualize solution of possion2D equation
mesh(x,y, U);
xlabel('Horizontal(Km)');
ylabel('Vertical(Km)');
zlabel('Gravitational potential');
title('Direct solution of Possion2D equation')

Solution of Possion2D equation with direct method.,Possion2D equ,direct method,numerical sol 

 

The above is the latest. 

%set parameter
N1 = 41; 
N2 = 31;
L1 = 1500; 
L2 = 1000; 
rp = 1.0;%relaxation parameter
deltax = L1 / (N1 - 1);
deltay = L2 / (N2 - 1);
[x,y] = meshgrid(0:L2/(N2-1):L2,0:L1/(N1-1):L1);%meshgrid:x and y are interchangeable
coe = zeros(N1*N2, N1*N2);
%coefficients of boundary
%up and down
for i = 1:N1
    j = 1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
    j = N2
    k = (i-1)*N2 + j;
    coe(k, k) = 1;    
end
%left and right
for j = 1:N2
    i = 1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
    i = N1
    k = (i-1)*N2 + j;
    coe(k, k) = 1;
end
%coefficients of interval points
for i = 2:N1-1
    for j = 2:N2-1
        k = (i-1)*N2 + j; % k表示网格点 (i,j) 对应的未知量索引
        coe(k, k) = -2./(deltax.^2)-2./(deltay.^2); % 中心点系数
        coe(k, k-1) = 1./(deltax.^2); % 左边点系数
        coe(k, k+1) = 1./(deltax.^2); % 右边点系数
        coe(k, k-N2) = 1./(deltay.^2); % 上边点系数
        coe(k, k+N2) = 1./(deltay.^2); % 下边点系数
    end
end
%set right hand side martix
%right value equal to 1 except boundary points
b = ones(N1*N2, 1);
%up and down
for i1 = 1:N1
    j1 = 1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
    j1 = N2
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
end
%left and right
for j1 = 1:N2
    i1 = 1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
    i1 = N1
    k = (i1-1)*N2 + j1;
    b(k, 1) = 0;
end
%direct method:right martix is divided by coe martix on the left
u = coe \ b
%transform vector to grids 
U = zeros(N1, N2);
U = reshape(u, N2, N1);
%this line is necessary:because of tops and bottoms' program are not consistent 
[X,Y] = meshgrid(0:L1/(N1-1):L1,0:L2/(N2-1):L2)
%visualize solution of possion2D equation
mesh(X,Y, U);
xlabel('y');
ylabel('x');
zlabel('Gravitational potential');
title('Direct solution of Possion2D equation')

Solution of Possion2D equation with direct method.,Possion2D equ,direct method,numerical sol文章来源地址https://www.toymoban.com/news/detail-620571.html

到了这里,关于Solution of Possion2D equation with direct method.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • 【论文阅读】Directional Connectivity-based Segmentation of Medical Images(可以跑通代码)

    论文:Directional Connectivity-based Segmentation of Medical Images 代码:https://github.com/zyun-y/dconnnet 出发点 :生物标志分割中的解剖学一致性对许多医学图像分析任务至关重要。 之前工作的问题 :以往的连通性工作忽略了潜在空间中丰富的信道方向的信息。 证明 :有效地将方向子空间

    2024年02月04日
    浏览(30)
  • 成功解决 nginx: [emerg] invalid number of arguments in “root“ directive in 问题

    目录 问题原因 解决方法 看这里 如下图,启动nginx时报错  , 很明显是E盘下的Program Files文件夹中间 存在空格 ,导致识别错误。  问题原因不唯一,可从下中检查下自己的问题 句尾忘记加 分号 路径中文件名使用了 中文 路径中有 空格 斜杠错误,要用  /  而不是 模板 路

    2024年02月12日
    浏览(32)
  • 已解决The above exception was the direct cause of the following exception:

    已解决RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd ImportError: numpy.core.multiarray failed to import The above exception was the direct cause of the following exception: SystemError: returned a result with an error set 粉丝群里面的一个小伙伴遇到问题跑来私信我,想用ddddocr模块做验证码识

    2024年01月19日
    浏览(39)
  • 启动nginx报错:invalid number of arguments in “root“ directive in,是文件路径书写问题

    无法启动nginx,错误日志提示如下: 原因: 这个一个比较常见的问题,配置文件里面应该有路径有问题 注意在:这里如果路径名称有空格要用引号引起来,否则会被当成2个路径解析。 如上,提示nginx.conf文件的208行, 改成这样就没事了:

    2024年02月09日
    浏览(34)
  • 【论文笔记】3DOPFormer: 3D Occupancy Perception from Multi-Camera Images with Directional and Distance Enh

    【论文笔记】3DOPFormer: 3D Occupancy Perception from Multi-Camera Images with Directional and Distance Enhancement 原文链接:https://ieeexplore.ieee.org/abstract/document/10363646 本文的3DOPFormer使用空间交叉注意力机制和反卷积恢复3D占用,然后基于激光雷达射线方向特征提出优化3D占用感知模型的新方法。使

    2024年01月25日
    浏览(29)
  • OrienterNet: visual localization in 2D public maps with neural matching 论文阅读

    题目 :OrienterNet: visual localization in 2D public maps with neural matching 作者 :Paul-Edouard Sarlin, Daniel DeTone 项目地址 :github.com/facebookresearch/OrienterNet 来源 :CVPR 时间 :2023 人类可以使用简单的 2D 地图在 3D 环境中定位自己。不同的是,视觉定位算法主要依赖于复杂的 3D 点云,随着时

    2024年02月11日
    浏览(32)
  • docker-compose重新启动Mysql报错changing ownership of ‘/var/lib/mysql/mysql.sock‘: No such file or direct

    最近在使用 docker-compose 编排整合一个项目(springboot+mysql)的时候,首次启动后重新再启动的时候,mysql 容器启动失败,通过 docker logs 命令查看 mysql 容器的启动日志如下: docker-compose.yml 文件完整内容如下: my.cnf 文件完整内容如下: 从报错信息上来看,应该是 mysql 启动的时

    2024年02月15日
    浏览(26)
  • [论文笔记] CLRerNet: Improving Confidence of Lane Detection with LaneIoU

    Honda, Hiroto, and Yusuke Uchida. “CLRerNet: Improving Confidence of Lane Detection with LaneIoU.” arXiv preprint arXiv:2305.08366 (2023). 2023.05 出的一篇车道线检测的文章, 效果在CULane, CurveLanes SOTA 这篇论文在CLRNet基础上, 使用提出的LaneIoU代替CLRNet论文中LineIoU, 在两个数据集上取得了SOTA效果 论文其他部

    2024年02月15日
    浏览(31)
  • Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of

    问题原因 idea 中的 kotlin 插件版本比 pom 中的低,导致无法启动 解决方式 把项目 pom 中的版本降低 或 升级下idea插件的版本 实际解决 pom 中的一般我们没有办法轻易改动,这里选择升级idea 中的插件,共两种方式 第一种(推荐) : 通过左上角菜单进入 settings 或者 直接快捷键

    2024年02月07日
    浏览(38)
  • 问题:module was compiled with an incompatible version of kotlin

    不同模块使用不一致的kotlin版本编译,导致最后merge的时候版本冲突出错了 临时解决 build-rebuild project 永久解决 项目不使用kotlin,关闭插件kotlin enable-disable

    2024年02月12日
    浏览(32)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包