# How would I write a 2d steady, inviscid, and incompressible flow simulation?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 13, 2017, 12:24 How would I write a 2d steady, inviscid, and incompressible flow simulation? #1 New Member   Join Date: Jan 2017 Posts: 3 Rep Power: 8 I'm trying to write a 2D steady, inviscid, and incompressible flow simulation in matlab incorporating some potential flow elements. Essentially, I'll have a few sources and a sink and I want to calculate the velocity for each cell in my mesh. For starters, I'm just doing a simple 3x3 grid with one source and one sink. Which equations are of particular usefulness in completing this program? Where I've started is with continuity -- mass flow into any cell is equal to mass flow out of that cell. This leaves me a few equations short of having a solvable problem (9 equations with 12 unknowns where each cell just has an equation for mass flow in and mass flow out to surrounding cells). How would I go about solving such a system? My end goal is to have a 64x64 grid with multiple sources and a couple of barriers leading to a single sink. Potential flow equations won't work for this since the geometry may be variable. Again, I want to implement this in Matlab (or possibly C++) so I won't be using any CFD software. This is because I want to learn the process for developing/implementing the equations and not the applied method for solving them in a software package. Any help is appreciated.

 January 13, 2017, 14:28 #2 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,290 Rep Power: 67 I am not sure of what you want to do ...however, the set of equations and BC you have to work with is div v = 0 curl v =0 n.v =vn This problem can be solved in a very simple way by introducing the either the real or the immaginary part of the potential function: v =grad phi -> dif grad phi = 0 being curl v =0 satisfied v =curl k psi -> Lap psi =0 being div v = 0 that allows to compute the complete flow field (the pressure being computed by Bernouilli). Differently, in a boundary element formulation you solve only for the flow over the geometry along which you introduce vortices, sources and sink (singular solution)

 January 13, 2017, 14:46 #3 New Member   Join Date: Jan 2017 Posts: 3 Rep Power: 8 What I basically want to do is solve for velocity in an arbitrarily shaped geometry defined by a grid (for my first test case, a 3x3 grid, but expanding that to a 64x64 grid with arbitrarily shaped boundaries defined within) with a "source" (either an inlet or a potential flow source) and a "sink" (either an outlet or a potential flow sink). For example: If I define a rectangular "obstacle" within my grid, I need to solve the flow around that rectangular obstacle and determine the velocity at each node in my grid. Would the potential function work if I have an arbitrarily-defined obstacle in the middle of my grid? My test 3x3 grid case is going to be done on paper, then I'm going to model a program to do other problems.

 January 13, 2017, 15:05 #4 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,290 Rep Power: 67 yes, you can use the stream-function for multi-connected geometry

 January 13, 2017, 15:57 #5 New Member   Join Date: Jan 2017 Posts: 3 Rep Power: 8 Could you please direct me towards some reading material that would cover designing boundaries/obstacles in potential flow? The best I can think of with the material I've been able to find is just marking which cells in my grid contain an obstacle and placing a source for each of the faces to make the normal component of velocity at the face zero.

January 13, 2017, 16:04
#6
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,290
Rep Power: 67
Quote:
 Originally Posted by 7he404guy Could you please direct me towards some reading material that would cover designing boundaries/obstacles in potential flow? The best I can think of with the material I've been able to find is just marking which cells in my grid contain an obstacle and placing a source for each of the faces to make the normal component of velocity at the face zero.

Immagine a rectangular obstacle in a channel. If it is located at the centre, due to the symmetry of the solution for an inviscid flow, you can set the constant value of the psi over the obstacle that is equal to the value Psi_wall_up/2 (given the arbitrary value Psi_wall_down=0). Then solve the Laplace equation for the flow nodes.

 Tags equations, incompressible flow, inviscid flow, steady flow