Skip to main content Skip to navigation

How to Run the Code

 

The Program

After completing a project using this program in 2005/2006 here are some things that I wish I’d known before I started. I apologise if you are a CSE student and some of this seems obvious because you are better with Fortran and Unix before you start than I was when I finished but I’m a Mechanical Engineer so if you’re not CSE this should be helpful. If you are CSE most of it should be helpful anyway as it tells you which parts of the program are important etc.

Overview

The program that you use to do the simulations can be split into three stages. The initial stage sets up the initial conditions, the middle stage is where all the simulations occur and the final stage saves the results. The middle stage is therefore the main stage in which all the hard work is done and the initial stage is what will be altered in the course of your project to make each simulation different.  The middle stage is contained within a DO loop in the program. This enables this stage to be repeated many times. Within each run through of the middle stage there are three time steps and within each time step the program calculates u, v, w, and p. The subroutines that it is important to understand in this project are the subroutines CMPJET and INITIA. CMPJET determines such things as the position at which the velocity is measured, how much blowing or suction to apply in the opposite direction and where to apply the blowing and suction if a checkerboard pattern is desired. This is the subroutine that you will change in the project for every one of the main simulations that you attempt. Initia sets up the initial flow field. It is within this subroutine that all the theory behind the project is contained. The Reynolds number, Reτ, the formula for the pressure gradient and whether or not the simulation is starting from a turbulent flow or a laminar flow are all defined in this subroutine along with all the variables such as the dimensions of the grid. This subroutine also defines grid points outside the grid, giving the flow periodic boundary conditions so that when values outside the grid need to be known, the program has values to use. The program uses the x direction to mean parallel to the direction of the flow, y is the distance away from the bottom wall toward the top wall and the z direction is parallel to the flat plates but perpendicular to the flow direction. The u, v and w velocities are defined as the velocities in the x, y and z directions respectively. 

The important parameters

The following parameters should be checked to see if they are correct before attempting simulations: RESTRT – If set to 1 this continues the simulation from a starting point where the flow is already turbulent (provided you have the correct restrt file in your directory). If set to zero the simulation will start from laminar flow and a great deal more simulations will have to be done waiting for the flow to become turbulent (don’t set this to zero for anything other than preliminary experiments, use the restrt file). NSTEP – This determines how many time steps the simulation runs for, several thousand are necessary in order to get good results. I suggest 2000 but then continuing to do another 2000 afterwards and so on until good results have been achieved. MJET – This determines the distance away from the wall that the velocity is measured. Different values of mjet correspond to different values of y+ which is a measurement of distance from the wall in wall units.  AMPJET – This determines the velocity at which blowing and suction is applied (e.g. if it is set to 0.5, blowing and suction will be applied at 0.5 times the velocity that is measured, 1 would apply them at the same velocity that is measured). It will of course be applied in the opposite direction from the velocity that is measured but no negative sign is necessary. IBCJET – Found in the para.f file, if set to zero the simulations will not run properly. Set this to 1. I did a whole lot of simulations with this set to zero! If I remember correctly having this set to zero basically switches off the cmpjet routine so all those changes you are happily making have no effect whatsoever.  These parameters can all be checked by searching for the word in the program.  Also check the size of the grid that you are using. This is contained in the file “para.f”. Make sure that the grid size is acceptable and also make sure that it is the same as the grid size in the restrt file or it won’t work! 

What you need to make the program run

First of all you need putty on your home PC to connect to the solar computer. Also, four files: 
  • code10nov2003.f (or similar name)
  • fourier.f
  • para.f
  • restrt41h6b.dat

 To edit the program type: pico code10nov2003.fTo run the program type: f77 –O4 –r8 code10nov2003.f fourier.f –o mjet_1.out. Then: mjet_1.out > mjet_1 & Obviously change the “code10nov2003” to your program name and mjet_1 to the name of the output file that you want. The last line means that you run the program on the solar computer without needing your PC to be turned on.  

Other tips:

  • Try to analyse and understand the results as you get them, don’t just do loads and expect to analyse them later. This program is one of those annoying things where everything looks like it is working fine as you are doing it but when you closely analyse it later everything is wrong and you have to do it ALL again! I lost count of the number of times I repeated the same experiments because of this. You’ll save a lot of time by getting it right first time or at least noticing it’s wrong quickly.
  • Learn how to use fortran and unix as quickly as possible. You don’t need to be able to write long fortran programs but make sure you know the basic commands and what everything means.
  • Look through the INITIA subroutine of the program. Although understanding every line is unnecessary, looking through it will help to understand what is going on and may help you to write a theory section in your report.
  • Look through subroutine CMPJET. Read it quite carefully as knowing what it means will help you to understand what you are changing and will help cut out mistakes.
  • Understanding is the key, it all sounds easy when you are told to just change MJET from 1 to 9 and get the results but if anything that I have mentioned is set wrong, all your results will be worthless and I may have forgotten to mention one or two things! However, knowing all that I’ve written here before I started would have saved me a lot of weeks as I pretty much did a set of simulations with each of them set wrong at least once!
  • Understand the N-S equations.
  • Don’t be afraid to ask when you don’t know what something means or you are stuck. It will probably happen a lot. It did to me.
  • Finally everything takes longer than you think, especially if a set of simulations goes wrong and you have to redo them so leave plenty of spare time. I ended up working a lot through the easter holiday and I planned it all to finish nicely in time to write the draft report before Week 18.
This is by no means all you need to know to do your project but hopefully it’ll help a bit and save you some time. Once again, if you don’t know something, ask. The theory behind the program is quite tough at times and the program itself can be quite confusing so you won’t be expected to just work everything out by yourself. Good luck!