2

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 enter image description here

to then look like this

enter image description here

Johnny
  • 320
  • 3
  • 12
  • 1
    Matplotlib has a ‘drag and drop feature’ where you can drag, drop and delete axes with your mouse. The best thing is it knows exactly what you need and will easily convert it into these triangles you want. It’s a simply exercise just playing about with the axes using your mouse. You should check there. I’d be happy to make this comment an answer for you to accept if you’d like? – Hamish Gibson Mar 13 '22 at 23:29

0 Answers0