Working on my undergraduate degree in Mechanical Engineering, my favorite class was heat transfer. For a class project, I built a simple simulation that showed convection for a randomly generated temperature field. Unfortunately, I didn’t have enough programming skills to build a quality program. I want to revisit that class project with my improved science and computer skills. Along the way I will teach the science and programming behind building the model. The first step will be to research the fundamental equations for this system.

# Problem Definition

In this project, we will model a compressible fluid. Natural convection forces will affect the fluid. The simulation will model the transient behavior of a starting temperature or input heat. The simulation will be 2-Dimensional to display the results easier. Lastly, the model will use constant Cartesian cell structure to simplify the problem.

# Governing Equations

The Navier-Stokes momentum equations for 2D Cartesian flow will be used to determine the fluid velocities

Conservation of mass will be used to determine fluid densities

A conservation of energy equation was developed by including conduction, convection and external heat to the first law of thermodynamics

The ideal gas law will be used to determine pressure

# Finite Difference Approximation

A finite difference approximation will be used to solve the fluid state at future time intervals. A small time step and cell size will be desired to maximize accuracy. Central difference approximations will be used to reduce any directional biases.

When using a finite difference, we can encounter a problem. The grid below uses the same area for pressure and velocity.

Since we are using a central difference approximation, the velocities of center square is based on the pressure difference between it’s neighbors. We can see how the equation does not compare the squares current pressure between it’s neighbor squares.

If there is not a pressure differential between the 2 opposite neighbor cells then we do not get flow. As a result, a checkerboard pattern will emerge. The image below shows a possible solution.

This solution solves the governing equations but creates a system that is unrealistic. In a real system, we would see flow from the 4-pressure elements into the 2-pressure elements.

A better solution uses different, overlapping areas for the pressures and velocities. In the improved solution, the pressures exist in each area of the grid and the velocities represent the flows between the pressure cells. This solution is represented below.

# Solved Equations

With our improved solution, we can finally solve the governing equations using a finite difference approximation.

Navier-Stokes equations for velocity

Conservation of mass for density

Conservation of energy for temperature

Ideal gas law for pressure

These equations can directly be used in our simulation. Beyond these equations, we will have to consider the boundary conditions. The boundaries can be modeled in many different ways so we will review them later. With all that in mind, we can begin the design and development of our simulation.

NáximarNice work. it´s realy not as dificult as i taught it was. Did you got to program this equations? i would like to see the results.