我正在为一些研究进行一些计算流体动力学 (CFD) 模拟,并且我遇到了一篇论文,我想以此为基础。
原则上,我试图模拟三角形容器内的流动和粘度等。现在,一些空腔流和纳维-斯托克斯方程相当长。因此,一些方程已公开编写并以 python 格式提供 这里。这些方程的代码广泛使用 numpy.meshgrid() 和 numpy.linspace() 来在链接中生成一些矩形图。这些方程没有任何问题,而且在数学上也是合理的。
但是,我想通过在三角形容器内模拟它们来复制这些结果。因此,这些图看起来就像 本文。请注意,这不是仅绘制了三角形分段的矩形图,而是此模拟中的“网格”本身是三角形的。
我的问题是 numpy 是否具有允许这些三角形网格的特定功能?我对这个问题的研究证据促使我搜索有关非矩形数组的文档,但是我能找到的最接近的是 numpy.tril() 和 numpy.triu(),它仍然给我矩形数组,数组的下三角和上三角分别为零。我想知道是否有任何 numpy 方法允许创建这些三角形容器来模拟流体。
我最后的希望是创建某种字典,其中键作为行号,值作为存储列的列表。这样我就可以创建一个三角形字典。但这不会与前面提到的为 numpy 编写的数学方程相结合。
TLDR
我如何使用现有的 numpy 库来创建三角形网格,以便我可以得到如下所示的图

然后看起来像这样

I am doing some computational fluid dynamics (CFD) simulations for some research, and I have come across a paper that I would like to build upon.
In principle, I am trying to simulate flows and viscosities etc inside a triangular shaped container. Now, some of the cavity-flow and Navier-Stokes equations are quite long. Therefore, some these equations have kindly been publicly written and available in python format here. The code for these equations uses numpy.meshgrid()
and numpy.linspace()
extensively to produce some rectangular plots in the link. There is nothing wrong with the equations and they are mathematically sound.
However, I would like to replicate these results by simulating them instead inside a triangular container. The plots for these would therefore look like the plots provided on page 28 of this paper. Note here that this is not the rectangular plots with only a triangular subsection plotted, rather the "grid" in this simulation is triangular itself.
My question is whether numpy has a specific feature that would allow for these triangular grids? My evidence of research into this question has led me to scour the documentation regarding non-rectangular arrays, however the closest that I could find was numpy.tril() and numpy.triu(), which still give me rectangular arrays with zeros in the lower and upper triangles of the array respectively. I was wondering if there was any numpy method that allows for the creation of these triangular containers to simulate fluids in.
My last hope would be to create some kind of dictionary, with keys as row numbers, and values as lists which store the column. That way I could create a triangular dictionary. But this would not integrate with the mathematical equations that have written for numpy mentioned previously.
TLDR
How can I use the existing numpy libraries to create triangular grids so that I can have plots that look like this

to then look like this

发布评论