full EDIT:
I will give some more information about the whole problem. The project is in early stage and my question is actually only about a narrow portion of the thing.
the final goal:
I am currently trying to simulate the flow of hot air around a rigid obstacle in Python. I have a steady inflow of air, the flow in the bulk is transient and turbulent. The aim of the whole exercise is to understand how
-the air flow behaves
-the obstacle heats up
-the air cools down and the air-pressure drops
done so far:
Not much, the thing is in early stage. I have a 2d rectangular domain and a circular obstacle. The mesh is getting finer at the boundary between bulk and obstacle, since that is where the interesting stuff is happening. Currently I only consider the airflow, no convection or heat transfer. I use the FEniCS software collection to solve the Navier-Stokes equation. Fenics comes with an example for an N-S solver using the Chorin projection method, I adapted this example to my setting. I model the rigid body as an area with no-slip boundary condition (i.e. I set the velocity of the air flow to zero). The solver still solves the N-S equation in that area, in particular the pressure inside the obstacle changes over time. Probably it is a better idea to avoid this and restrict the N-S solver to the bulk. But at the moment I don't think this affects the speed very much.
problem:
The thing runs quite slow. I do not mind if the final simulations takes a few days, but currently it is only 2d fluid flow around an obstacle and the mesh is not as fine as I want it to be in the end. I hoped this to be faster, as it will become a lot more complicated when the heat comes into play.
my question:
It boils down to one question:
What is a fast algorithm or method to solve the Navier-Stokes equation in Python?
I am perfectly fine with writing a solver from scratch, but this raises the same question. This morning it occured to me that the projection method is maybe not the worst idea, because it decouples the pressure and velocity upgrade, I could try to assign this to different CPU kernels.
Python would actually be a fine choice if you were writing it all from scratch. But you'll need a LOT of background to do it from scratch.
A coupled solution is a difficult problem.
It's been pointed out to me that you're using a package - FEniCS (thank you, Sven). My original answer needs some amendment. I'll start with a few questions about the physics, then turn to the package.
Incompressible Navier Stokes applies to a gas like air if the Mach number for air at that temperature is less than 0.1. Is that the case for your problem? It's probably true, but I thought I'd ask.
Navier Stokes does NOT apply to your solid obstacle. If you model the whole thing with one mesh, how are you describing the solid? Is it a high viscosity fluid? This could make the system of equations ill-conditioned and hard to solve. It would also affect the stable time step size if you're using explicit integration.
Is it a steady flow or a transient? (steady is easier) Is the flow laminar or turbulent? (laminar is easier)
It's conduction heat transfer in your solid obstacle and conduction/convection in your fluid. The fluid will have momentum and thermal boundary layers along the solid obstacle of the surface that your mesh will have to resolve. That's where the important heat transfer between the solid and fluid is happening. These will require a fine mesh local to the solid surface to resolve the transition from the boundary condition to the far field velocity and temperature. Have you taken that into account in your mesh?
It appears to me that FEniCS is using finite elements, but I don't see anything in the docs that tells me how you're supposed to couple the momentum and energy equations together.
You'll have to tell a great deal more to get decent advice here. Is there a numerical methods in physics Stackoverflow? You'll need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With