CENG 301 Material and Energy Balances

Chapter 2: The Chemical Engineering FORTRAN Programs

On this page:

Other Sections in Chapter 2:


2.1: Discussion


A number of FORTRAN programs have been developed to assist students in Ceng 301 and other courses. The programs were first written before MATLAB was available for our use. The programs would look simpler in MATLAB, but they run faster in FORTRAN so the incentive to convert them is not there. The main group of eight programs perform the following functions:

Function

Used For

convu

Converts Units for any Numeric Data and most units.

fwt

Determines the Molecular Weight and Atomic Makeup of a Compound

atm

Sets up an Atomic Matrix for use in Finding the number of
Independent Element Balances among a Set of Compounds

el1, el2,
and el3

Element Balance programs

steam

Determines thermodynamic properties of steam.

humid

Determines properties of humid air


As an aid in learning to use the programs there is a single interactive program called cengfort that allows you to call one or more of the programs and/or to get online information or demonstrations. We will start with a deomstration of cengfort and then show examples of the individual programs.
We will close the chapter with a short discussion of two FORTRAN programs that have been used in Ceng 301 at various times, but have not been included in cengfort.


2.2: The General Program: cengfort

The cengfort program is menu driven so you choose among several options to execute or get information about each of the programs. The main menu also gives a very brief description of each program as an aid in getting acquainted with the names. The programs run on various PC platforms as well as on Owlnet. We have tried to make them perform the same way on all platforms, but there are minor differences associated with file systems and the way you initiate the programs. On Owlnet, as long as you have registered for ceng301, you simply type the name of the program you want to execute:

wsname% cengfort	
***************************************************
 Chemical Engineering FORTRAN Programs
Choose your Response from the Following Menu:

Option                                                  Respond
STOP                                                      stop 
Get Information about Programs.                           info 
See a Demo of one of the programs.                        demo 
Construct Atomic Matrix for Compounds.                    atm  
Convert Units                                             convu
List the Unit Names                                       convh
Find Compound Name & Formula Weight.                      fwt  
Give Molar Flows in Element Balance.                      el1  
Give Molar & Mass Flows in Element Balance.               el2  
Store Flows in a File read for Element Balance.           el3  
Get Steam Properties.                                     steam
Get Humid Air Properties.                                 humid
***************************************************

Now you may choose any of the 12 options listed in this menu. For example, if you want information about the program that will "Find Compound Name & Formula Weight", you can reply: info to then see

Get Information about Programs.                          
***************************************************
 Which Program do you want information about?
Choose your Response from the Following Menu:

 

Option                                                  Respond
Construct Atomic Matrix for Compounds.                    atm  
Convert Units                                             convu
List the Unit Names                                       convh
Find Compound Name & Formula Weight.                      fwt  
Give Molar Flows in Element Balance.                      el1  
Give Molar & Mass Flows in Element Balance.               el2  
Store Flows in a File read for Element Balance.           el3  
Get Steam Properties.                                     steam
Get Humid Air Properties.                                 humid
***************************************************

Here is where you give the name of the program you want information about:

fwt

The program will then list a file stored for that program:

Information about the Formula Weight Program: fwt     
This program may be used to find the molecular or formula weights       
for compounds with known molecular formulas.  The program also trys     
to find the names of the compounds and will report alll names that      
it finds in the data file: namfor.t.  Finally, it will put the          
mol weights into a form that is suitable for copying to MATLAB.         
This last feature is less useful in the Rice Chemical engineering       
MATLAB programs than it was before 1994, since the recent versions      
of the programs: setnm and setname automatically set molecular weights  
into a vector called mw.                                                

When you are ready to continue cengfort, hit the RETURN key


Hitting the return key at this point will bring up the main menu again and you can then choose to execute the program you asked about or you can get more inforamtion or see a demonstration of the program. Note that the replys to execute the programs or get inforation about them are identical to the names of the programs you would use at a Unix prompt.

The source programs on Owlnet for all the main programs discussed in this chapter are in the directory:

		~ceng301/prgf

The subprograms used by those main programs are in the directory:

		~ceng301/subf.

All these programs may be listed and used to create other FORTRAN applications. Compiled versions of the subroutines used by these the main programs are in the directory:

		~ceng301/subr4

All executables are in the directory:

		~ceng301/prog4

The FORTRAN executables include all eight programs discussed in this chapter. Thus all the programs may be directly accessed by typing their names. This is simpler than using cengfort, but it has the disadvantage that you must remember the correct program name. When you begin to become acquainted with the programs cengfort can be helpful in reminding you of the names and giving you information about how to use them. Similar information is included in these notes, but it is not nearly as helpful if you do not have the notes with you when you are trying to use our software.


2.3: Unit Conversion

The Programs: convu and convh

There are many unit conversion programs that you may find useful as students and in your work. One of these is the Unix command: units that will allow you to convert many units from a variety of sources. If you try it, you may find it somewhat difficult to determine how to use it and even more important when it will work. Use the man units command to read about it and to get the very long list of conversion factors that it does know about. This list is included in the file mentioned near the end of the manual page for units. One of the problems with this general unit conversion program is that many of the units that you will use frequently in your engineering courses are not included. For example it does not know about the pressure unit Pa. The two FORTRAN programs: convu and convh were specifically written to allow you to convert nearly all units that you will encounter in your engineering courses.

The unit equivalences shown in Table 2.3-1 may be used to convert units for most numeric data that you are likely to see in engineering. The data in Table 2.3-1 together with other unit conversions (both numeric and character) are stored in a file read by a FORTRAN program so that the unit conversion process may be done automatically. This program is called convu. Chemical engineering students have found the convu program to be a very useful aid in working problems for this and other courses.

The file convu.f used to create the program convu is stored in ~ceng301/prgf. It is very short since it simply calls the subroutine in convus.f. That subroutine plus several others do the bulk of the work involved in unit conversions. A file used to list the unit abbreviations is called convh.f.


Table 2.3-1: Unit Conversion Table

	MASS		SI UNIT: ONE kg
	=  2.20462 lbm	=  1000.00 g	=  35.2739 oz
	= 0.110231E-02 ton	= 0.100000E-02 met ton	= 0.984210E-03 lng ton
	=  15432.3 grain

	LENGTH		SI UNIT: ONE m
	=  3.28084 ft	=  39.3702 in	= 0.621371E-03 mi
	=  1.09361 yd	= 0.100000E+11 angst	= 0.539594E-03 naut mi
	= 0.546807 fath

	TIME		SI UNIT: ONE s
	= 0.166667E-01 min	= 0.277778E-03 hr	= 0.115740E-04 day
	= 0.165343E-05 wk	= 0.316879E-07 yr

	PREFIX		SI UNIT: ONE 1
	= 0.100000E-05 M	= 0.100000E-02 k	=  100.000 c
	=  1000.00 m	= 0.100000E+07 mu	= 0.100000E+10 n
	= 0.100000E-08 G	=  10.0000 d	= 0.100000E-11 T
	= 0.100000 da

	VOLUME		SI UNIT: ONE m3
	=  1.00000 m3	=  1000.00 liter	= 0.100000E+07 cm3
	=  35.3147 ft3	=  264.170 gal	=  61023.7 in3
	=  220.830 imp gal

	FORCE		SI UNIT: ONE N
	=  1.00000 kg m/s2	=  100000. dyne	=  100000. g cm/s2
	= 0.224810 lbf	=  7.23304 #mft/s2

	PRESSURE		SI UNIT: ONE Pa
	=  1.00000 N/m2	= 0.986923E-05 atm	= 0.100000E-04 bar
	=  10.0000 dyn/cm2	= 0.750063E-02 mm Hg	= 0.101979E-03 m H2O
	= 0.145038E-03 psi	= 0.750062E-02 torr	= 0.295297E-03 in Hg

	ENERGY		SI UNIT: ONE J
	=  1.00000 N m	= 0.100000E+08 erg	= 0.277800E-06 kW hr
	= 0.239010 cal	= 0.737600 ft lbf	= 0.948600E-03 Btu
	= 0.239010E-03 kcal	= 0.239010E-03 kg cal

	POWER		SI UNIT: ONE W
	=  1.00000 J/s	= 0.239010 cal/s	= 0.737600 ft #f/s
	= 0.94860E-03 Btu/s	= 0.134100E-02 hp

	TEMPERATURE	SI UNIT: ONE K
	=  1.80000 R

	MOLS		SI UNIT: ONE mol
	= 0.1000E-02 kg mol	= 0.220462E-02 lb mol	= 0.100000E-05 ton mol

     VISCOSITY	SI UNIT: ONE  Pas
     = 1.00000 Pa s     = 1.00000 kg/m/s   = 10 poise    = 10 g/cm/s
     = 1000 cp     = 0.671969 lbm/fts   = 2.0886E-2 #fs/ft2   = 2.4191E3 #m/fthr

     THERMAL COND.	SI UNIT: ONE tc
     = 1.00000 W/m/K   = 1.00000 kgm/s3K   = 100000 gcm/s3K   = 4.0183 #mf/s3F
     = 0.12489 #f/sF   = 2.3901E-3 cl/scmK   = 0.5778 Btu/hrF

     Momentm Diff	SI UNIT: ONE dif
     = 1.00000 m2/s    = 10000 cm2/s   =  3.875E4 ft2/hr   = 1000000 cstokes

     Heat Transfer	SI UNIT: ONE htc
     = 1.00000 W/m2/K    = 1.00000 kg/s3/K    = 1000 g/s3/K   = 1.2248 #m/s3F
     = 3.8068E-2 #f/ftsF   = 2.3901E-5 cl/c2sK    = 10E-4 W/cm2/K  
     = 0.17611 Btu/ft2hrF

     Mass Transfer	SI UNIT: ONE k
     = 1.00000 kg/m2/s   = 0.1 g/cm2/s   = 0.20482 #m/ft2/s = 6.3659E-3 #f s/ft3
     = 737.3 #m/ft2hr


You may execute the unit conversion program and its companion with either cengfort or more directly by answering the % prompt in an xterm wndow with convu or convh as in:

wsname% convu


You can see the abbreviations used for the units if you execute the convh program. The current version (1995) gives:

wsname% convh
Here are the SI Abbreviations and what they measure.
 Index  Measures    SI Unit Abbreviation
   1   Mass                 kg       
   2   Length               m        
   3   time                 s        
   4   Units                1        
   5   Volume               m3       
   6   Force                N        
   7   Pressure             Pa       
   8   Energy               J        
   9   Energy/time          W        
  10   Abs. Temp.           K        
  11   mole                 mol      
  12   Viscosity            Pas      
  13   Thermal Cond.        tc       
  14   Momenturm Diff       dif      
  15   Heat Transfer        htc      
  16   Mass Transfer        k        
If you want to see the names of other units that go
with one of these give the index or 0 to STOP.
6
Other abbreviations for Force         
  besides the SI Unit=N    
  kg m/s2
  dyne   
  g cm/s2
  lbf    
  #mft/s2

If you want to look at some more abbreviations,
   Reply: y


If you reply anything other than y to the last prompt (including just hit the return key,) you will then exit convh. If you want this information during an execution of convu, it will be convenient to get it in a Scrolling Shell window separate from the window used with convu, so you can scroll back to previously listed abbreviations.
Execution of convu gives:

wsname% convu

Give the NUMERICAL value to be converted.

 

You may then give any numerical value you want. It may be an integer, a real number including a decimal point or a real in scientific notation. The following are acceptable:

5 or -5.245 or 5E-5 or 5.24E10 or 5e-5 or 5.24e10
 

The following are not acceptable:

5,000 or 5 e-5 or 5e -5
 

The reply:

1

will lead to another prompt:

Give the NUMERATOR of the OLD units.

Your answer must be no longer than 70 characters. It may include any of the unit names in the table listed. If more than one name is included, each must be separated by an asterisk from its neighbor(s). Your reply should not be entirely blank. If the number has no units in its numerator give 1 as a reply. For example:

m3

The next prompt asks you to:

Give the DENOMINATOR of the OLD units.

A blank reply or any set of names of units separated by *'s is acceptable. Again the total length must be no more than 70 characters long. A Blank reply would then produce:

Give the NUMERATOR of the NEW units.

This prompt may be answered in the same way as the one for the old units. The reply:

gal

will then give the final prompt:

Give the DENOMINATOR of the NEW units.

A blank reply will then give the result:

To change from your old units to the new ones multiply by:    264.170
  1.000000    m3   =  264.1699    gal   
If you want to convert another measure, reply: y

You may continue by typing y after the last prompt. Here are a few more examples that followed in the same session:

Changing Gas Constants

y
Give the NUMERICAL value to be converted.
0.7302
Give the NUMERATOR   of the OLD units.
ft3*atm
Give the DENOMINATOR of the OLD units.
lb mol*R
Give the NUMERATOR   of the NEW units.
m3*Pa
Give the DENOMINATOR of the NEW units.
mol*K
To change from your old units to the new ones multiply by:    11.3859
 0.7302000    ft3*atm/(lb mol*R) =  8.313989    m3*Pa/(mol*K)   
If you want to convert another measure, reply: y
y

An Old Homework Assignment

 

Give the NUMERICAL value to be converted.
221.559
Give the NUMERATOR   of the OLD units.
J
Give the DENOMINATOR of the OLD units.
g
Give the NUMERATOR   of the NEW units.
m*m
Give the DENOMINATOR of the NEW units.
s*s
To change from your old units to the new ones multiply by:   1000.000
  221.5590    J/(g) =  221559.0    m*m/(s*s)   
If you want to convert another measure, reply: y
y

 

Inconsistent old and new Units?

 

Give the NUMERICAL value to be converted.
4
Give the NUMERATOR   of the OLD units.
ft3
Give the DENOMINATOR of the OLD units.
s
Give the NUMERATOR   of the NEW units.
m
Give the DENOMINATOR of the NEW units.
mol
YOUR UNITS ARE INCONSISTENT.
 The old base SI units are:kg **  0;m  **  3;s  ** -1;K  **  0;mol**  0;
 The new base SI units are:kg **  0;m  **  1;s  **  0;K  **  0;mol** -1;
If you want to convert another measure, reply: y



2.4 Molecular Weight Determination

The Program: fwt

The FORTRAN program fwt and associated subroutines may be used to determine the molecular weight and atomic makeup of any given compound when you know the formula for it. For many compounds you will also be told the name for the compound. The compound names are stored in the file:

   	~ceng301/data/namfor.t

and currently contains the names for most organic compounds that are involved in problems in this course together with a large number of inorganic compounds. As time permits, we will add more inorganic and organic names. An example session with the program is shown next:

wsname% fwt        <-- Starting the session
Find Compound Name & Formula Weight.                     
For each Formula you Give, fwt will report:
1) the number of atoms of each element in it,
2) its molecular weight and
3) its name if it is in the chemical engineering
compound list: namfor.t

Give the formula or stop to STOP
H2SO4               <-- One compound
 Element Number:  1 16  8
Number of Atoms:  2  1  4
Molecular Weight=   98.07340     Name: Sulfuric Acid                           

Give the formula or stop to STOP
CO2                 <-- A second compound
 Element Number:  6  8
Number of Atoms:  1  2
Molecular Weight=   44.00980     Name: Carbon Dioxide                          

Give the formula or stop to STOP
stop
  Formula         Molecular Weight     Name
H2SO4                  98.0734      Sulfuric Acid                      
CO2                    44.0098      Carbon Dioxide                     
If you want the mol wts. printed for copying to MATLAB, reply: y
y
mw=[   98.0734   44.0098]

 


2.5: The Atomic Matrix

The Program: atm



The atomic matrix discussed in Section 4.1.1 of Reklaitis may be produced for any set of compounds with the program atm. A sample session with this program looked like:

wsname% atm          <-- Starting the session
  GIVE THE FORMULA FOR COMPOUND   1   OR STOP TO STOP.
H2SO4                <-- One formula
  GIVE THE FORMULA FOR COMPOUND   2   OR STOP TO STOP.
H2O                  <-- Another
  GIVE THE FORMULA FOR COMPOUND   3   OR STOP TO STOP.
C6H6                 <-- One more
  GIVE THE FORMULA FOR COMPOUND   4   OR STOP TO STOP.
stop                 <-- Quitting
COMPOUND   1   2   3
   H       2   2   6
   S       1   0   0
   O       4   1   0
   C       0   0   6



Chapter 2: 2.1-1.5, 2.6, 2.7


[ Go to CENG301 Homepage | CENG301 Notes Table of Contents]

Last modified August 22, 1997.