CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Patankar CFD FORTRAN 90 Code FVM

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By siddiquesil
  • 1 Post By vesp
  • 1 Post By siddiquesil

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   February 6, 2019, 12:52
Default Patankar CFD FORTRAN 90 Code FVM
  #1
New Member
 
Numan Siddique
Join Date: Jan 2019
Location: India
Posts: 24
Rep Power: 7
siddiquesil is on a distinguished road
!===============================================
This is a general purpose transient 2-d CFD code (FORTRAN 90)based
on FVM.
!************************************************* ************
Note to the users:
Please go through this brief instruction before attempting anything with this code
!************************************************* ************
1. Most of the variables used in the code are listed in the file "list_of_var". However, some new variables are also used, typically for the USER portion. Those variables are explained just before opening the input file in subroutine GRID

2. The coordinate system used is right-handed. The systems are as:
mode=1 : cartesian; mode=2: cylindrical(axisym); mode=3: polar

3. The user is reqd. to use only six subroutines almost. They are:

a) Subroutine GRID: For specification of input data and initialization of arrays. It calls subroutine UGRID if one selects uniform gridding;
and calls subroutine MESH if one selects non-uniform gridding. The
selection is made by giving a value to a variable called NGRID introduced
in subroutine GRID. Do not forget to specify following in subroutine grid:
# mode: to specify coordinate system. For a system involving radial
direction, also specify r(1).

# lsolve: to select which variables you want to solve; eg. lsolve(4)=.true.
will make eqn corresponding to nf=4(ie., energy eqn) to be solved.
Note that nf=1,2,3,4,np,6 correspond to solving for u,v,pc,T,p,conc. in the code.

!# ngrid: to specify choice of grid. For non-uniform grid, subroutine MESH is
called. It takes input from a file "grid.dat", where proportional lengths of
non-uniform grids are specified. However, for class-problems; generally
uniform grid will suffice, for which specify NGRID =1
# no. of grids in coordinate dirns, domain size, time step(dt) etc.
# eru,erv,ert: For convergence criteria
# property values as reqd.
# initialise all arrays, logical variables

b) Subroutine START: For giving initial condns for variables (say u,v,T)
for the problem

c) Subroutine DENSE : For specifying density of the working medium.

d) Subroutine BOUND: For giving boundary condns. for the problem

e) Subroutine GAMSOR: For giving diffusion coeff and source term for
all nfs (i.e., all eqns). As per symbols used in Patankar's book;
the symbol 'ap' used in the code corresponds to 'Sp' and the symbol
'con' used in the code corresponds to 'Sc'. 'gam(:,: )' corresponds to
the diffusion coefficient 'gamma' as per general 'phi' formulation

f) Subroutine Printout: This subroutine will give the plot files which contain isotherms and velocity vectors plot compatible with matlab or tecplot (as you choose). There is a logical switch called ltecplot declared in the programme. If you declare ltecplot as true, then you will get matlab files only. You can run the ".m" files generated in MATLAB to see the outputs.However, you are encouraged to develop output format according to your own choice and needs.

4. For steady state soln; use a typically large value of time step(dt)
as per instruction of the instructor

5. The code deals with a sample problem of natural convection in a rectangular cavity.The cavity is heated from two vertical sides by employing a uniform heat
flux (symbolised as FLUX in the code). The top and bottom are insulated. Due to heating,
there is a natural convection driven flow inside the liquid that develops with time. We are interested in studying the evolution of temperature field and velocity field inside the cavity.

6.Once you get the code, first compile it as it is. For compilation of the code in UNIX Systems, either compile in IBM m/c using the compilation command: xlf90 code.f OR complile in a COMPAQ machine using the compilation command f90 -fast code.90

Note: for compiling and running in IBM, you have to rename the file from code.f90 to code.f
Once it is compiled, execute the file a.out by typing a.out in the command prompt of your terminal. You will soon see that in your screen certain figures are appearing. We are basically printing the values of u,v,T and their relative errors in every iteration to monitor convergence.
Once it converges within a timestep, it goes to the next timestep. In this programme, I have kept timestep, i.e., dt=10s. The time domain I have kept as 510s, and in subroutine printout
I have stated that the MATLAB output should be written every 50 timestep. Accordingly, after 500s, this programme will open a file out500.m You can run the file in MATLAB to see various plots. Note that the streamfunction is symbolised as pc in the output. Do not confuse it with the pressure correction that we are solving to get the fluid flow.The figure 1 will give you temperature contours, figure 2 will give you velocity vectors and figure 3 will give you streamfunctions.Once you start solving problems on your own, initially you will be solving steady state problems only. For that, use dt=1.0e30 (a typically large no.) and tlast=1.0e30. Change the name
!of the .m file you want to have by altering the filename in subroutine printout. Note that
your tlast (i.e. end of time domain) should be same as dt for a steady state problem
optimux likes this.

Last edited by siddiquesil; February 6, 2019 at 14:16.
siddiquesil is offline   Reply With Quote

 

Tags
code, fortran 90, fvm, patankar


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFD Salary CFD Main CFD Forum 17 January 3, 2017 17:09
A simple CFD code for teaching basic CFD? Christoph Lund Main CFD Forum 13 September 14, 2005 04:36
CFD code structure (F90) ma Main CFD Forum 4 January 10, 2005 20:47
OOP for CFD code Jongtae Kim Main CFD Forum 26 October 20, 2000 06:11
cfd job Dr. Don I anyanwu Main CFD Forum 20 May 17, 1999 15:13


All times are GMT -4. The time now is 12:08.