User Subroutines
User Subroutines
ii
Table of Contents
Table of Contents
Chapter 1 Introduction
1.1 Introduction...........................................................................................................1-1
1.2 Hardware and software requirements....................................................................1-2
1.3 Installation.............................................................................................................1-2
iii
Cycle-Tempo Manual
User Subroutines
4.4.1 Introduction...........................................................................................4-19
4.4.2 Argument list and declarations of variables..........................................4-19
4.4.3 Explanation of the variables..................................................................4-20
4.4.4 The operation of USREAC...................................................................4-20
4.4.5 Example: COS conversion....................................................................4-21
4.5 FUNCOP user function.......................................................................................4-22
4.5.1 Application............................................................................................4-22
4.5.2 Argument list and declarations of variables..........................................4-22
4.5.3 Explanation of the variables in the argument list..................................4-22
4.6 EPILOG subroutine.............................................................................................4-26
4.6.1 Introduction...........................................................................................4-26
4.6.2 Argument list and declaration of variables...........................................4-26
4.6.3 Classification and overview of the argument list..................................4-27
4.6.4 Explanation of the variables in the argument list..................................4-29
iv
Working with User Subroutines
Chapter 1
Introduction
1.1 Introduction
The isentropic efficiency of a turbine can depend on the mass flow through the turbine.
The condenser outlet pressure can depend on the quantity of heat transferred.
The pressure drop in a pipe can depend on the mass flow through the pipe.
A valve joining two flows can be controlled so as to produce a desired outlet
composition.
For a separation apparatus, for example a cyclone that can be modeled using a valve, the
outlet compositions depend, among other things, on inlet composition and volume flow.
All these dependencies differ per system. Besides that, we would like the user to be able to
add his own relations to the program in a simple manner; this is possible with a “user
subroutine”. The program has six user subroutines. The examples referred to above can be
performed using the APSUB and PIPSUB user subroutines. The other four user subroutines are:
EPILOG for post-processing facilities, USREAC for defining chemical reactions, FUNCOP for
defining an optimization function, and CTMAIN for modifying the memory required for the
calculations.
The calculation procedure for Cycle-Tempo is a closed module in which openings have been
created at some places. User subroutines can be linked to these openings. The user
subroutines are bits of FORTRAN code in which the user himself programs the desired
1
Cycle-Tempo Manual
User Subroutines
behavior. If no user subroutines are applied, dummy user subroutines have been linked to the
openings in the module.
1.2 Hardware and software requirements
In order to use user subroutines, the user should have a FORTRAN compiler, i.e. at least:
The hardware requirements for using user subroutines are the same as for Cycle-Tempo
itself (see the “Introduction” part). Note, however, that additional disk space is required for
the above compiler.
1.3 Installation
During the installation of Cycle-Tempo, the user is free to determine in which directory the
program is selected. This manual assumes C:\Program Files\Cycle-Tempo as default
directory.
During the Cycle-Tempo installation, the object files of the Cycle-Tempo calculation
module are saved in the directory C:\Program Files\Cycle-Tempo\System. The object files
are clustered in the files WinTempo.lib and WinTempo.res. Furthermore, the source code
(extension .FOR) of the following files is available:
CTMAIN
APSUB
PIPSUB
USREAC
FUNCOP
EPILOG
In the file CTMAIN.FOR, the user can modify, if necessary, the memory space reserved for
Cycle-Tempo, in connection with array sizes. The user himself can modify the APSUB.FOR,
PIPSUB.FOR, USREAC.FOR, FUNCOP.FOR and EPILOG.FOR files so as to create user subroutines
himself.
2
Working with User Subroutines
The file COMPILE.BAT is used to compile and link user subroutines with the Cycle-Tempo
object files.
Chapter 2
You can create a user subroutine using any text editor. This may be either the editor supplied
with the compiler or any other editor.
The easiest way is to copy a supplied template (for example C:\Program Files\Cycle-Tempo\
System) directory to the desired work directory and then add your own code to it.
Subroutines created by you should be compiled and linked with the Cycle-Tempo object
files.
Although other ways are possible the user is advised to make use of the files COMPILE.BAT,
WINTEMPO.LIB and WINTEMPO.RES supplied with the program, and present in the Cycle-
Tempo subdirectory SYSTEM after installation. You can copy the APSUB.FOR, PIPSUB.FOR,
USREAC.FOR, FUNCOP.FOR and EPILOG.FOR files from the system directory (default: C:\
Program Files\Cycle-Tempo\System) to your work directory under the same or other names.
The names of the files do not matter; however, it is required that the names of the
subroutines remain the same, i.e., APSUB, PIPSUB, USREAC, FUNCOP and EPILOG, respectively.
3
Cycle-Tempo Manual
User Subroutines
You can create your own versions of the APSUB, PIPSUB, USREAC, FUNCOP and EPILOG
subroutines. The files in which these subroutines are found, as well as files that contain
subroutines opened from APSUB, PIPSUB, USREAC, FUNCOP and EPILOG, respectively, should
also be compiled.
To compile a Fortran source file, for example APSUB.FOR, use the Windows command
interpreter (open Run in the Windows Start Menu and type cmd) and go to directory where
the user subroutine resides, for example:
cd C:\My Documents\MyUserSubs
Next use the COMPILE.BAT file in the Windows command interpreter by giving the
command:
compile apsub
Then the batch file will ensure that the file APSUB.FOR is compiled using the correct compiler
switches. Note that the COMPILE.BAT file assumes that the Fortran compiler has been
installed in the C:\PROGRAM FILES\INTEL\COMPILER\FORTRAN\9.1 directory. If the compiler is
present in a different directory or you have a different version of the compiler, you should
change the data in the COMPILE.BAT file accordingly. Usually you can find this data in the
file IFORTVARS.BAT, which is in one of the subdirectories where the compiler has been
installed.
When you compiled your own Fortran source files, the batch file creates an executable file
named USERSUB.EXE. The executable USERSUB.EXE is placed in the directory where the
compile command is issued. You can refer to this executable in the input window for user
subroutines (see next chapter).
In the input window for user subroutines, you can state what apparatuses and pipes must be
controlled by user subroutines.
4
Working with User Subroutines
As an illustration, several apparatus and pipe numbers have been entered in Figure 2-1. Enter
the name of the user executable into the lower text box made during the compiling and
linking of the user subroutine itself.
If you use the user subroutine APSUB, the row with apparatus numbers (maximally 50) has to
be filled in. Commas must separate the apparatus numbers.
The order in which the apparatus numbers are listed in the input window determines the
order in which they can be opened from APSUB. This can be important if, for example, data
need to be transferred from one apparatus to another. The apparatus supplying data must be
listed in front of (the number of) the apparatus receiving data.
If you use the PIPSUB subroutine, the row with pipe numbers (maximally 100) should be
entered. Commas must separate the pipe numbers.
Just as with the apparatus numbers, the order of the pipe numbers is important if data from
the one pipe need to be passed to another.
If only user subroutines other than APSUB and PIPSUB are used, it is sufficient to enter the
name of the user executable.
5
Cycle-Tempo Manual
User Subroutines
You can perform calculations using user subroutines simply by entering the name of the user
executable in the input window for user subroutines (see also section 2.3). You can then
make the calculation in exactly the same manner as a calculation without user subroutines:
6
General Observations
Chapter 3
General Observations
3.1 Available user subroutines
The program has six user subroutines available. The overview below states the available
subroutines and their objectives.
The routines are found in the files that have the same name as the routine name, only with
the extension “.FOR”.
1
Cycle-Tempo Manual
User Subroutines
The PROGRAM CTMAIN routine is the first routine to be activated for calculations and
also the place to reserve memory for the calculations.
In the main iterations, the apparatus subroutines of the apparatuses in the process diagram
are activated again and again. If in a chemical reactor (type 27) the TRUSER parameter has
been entered, the apparatus subroutine of the chemical reactor will load the USREAC user
subroutine, in which you can define the desired chemical reaction yourself.
After each main iteration in the calculation, the actual mass flows, compositions, pressures,
temperatures and enthalpies are available for the APSUB and PIPSUB user subroutines.
2
General Observations
When an optimization calculation has been performed, the system efficiency is calculated
every time after convergence has been reached for the compositions and the mass flows. If
the efficiency differs from previous optimization iterations, the parameters to be optimized
are modified and a series of main iterations is started again. Using the FUNCOP user
subroutine, with the data available in FUNCOP, you can establish an optimization function
yourself, the function value of which should be optimized.
The sixth user subroutine, the EPILOG subroutine, is not activated during the main
iterations. This subroutine serves for ‘post-processing’ the results and is activated at the very
end of the program.
Figure 3-1 gives a graphical presentation of the places of the user subroutines in the
program.
3.3 FORTRAN
The Cycle-Tempo calculation procedure has been written in standard FORTRAN 90, meaning
that user subroutines must also be written in this language. The templates of user subroutines
supplied with the program have been designed accordingly. Although various tricks with
Argument lists and declarations are possible in FORTRAN, it is recommended not to make
changes in the Argument lists and declaration parts (which together form the subroutine
specification). Changes in these parts may disrupt the operation of the entire calculation
procedure. The code fragment on the next page states in which part of the user subroutine
code can be added ‘safely’.
Finally, it should be stated that the user should be reasonably familiar with FORTRAN in order
to successfully apply user subroutines.
3
Cycle-Tempo Manual
User Subroutines
INTEGER IPIPE(NP),ILIN(NLIN),IDX(NCOMP)
CHARACTER COMP(NCOMP)*8,APNAME*12
this part
change
END Do not
4
General Observations
In making user subroutines, you should bear in mind that, earlier in the program, files have
been opened for reading and writing data. In Cycle-Tempo, the following unit numbers are
used for these files:
Note! Unit numbers associated with standard input and output devices (unit numbers 5 and 6) are
not allowed. This means that statements like READ(5,…), WRITE(6,…) are not allowed, nor
usage of PRINT and PAUSE statements. Usage of these statements will lead to a premature
termination of the calculation process.
Furthermore, the unit numbers 1, 10 and 22 are reserved for internal use and may not be used
in user subroutines.
In a user subroutine, these unit numbers can not be used for matters other than those stated
above. However, you can make use of the fact that these files are already open.
in a user subroutine, the text “This text will appear in the message window…” will be
written in the message window after completion of the calculation. With WRITE(7,*), you
can cause text to appear in the Text output.
Design data for off-design calculations are written in unit number 12. These are files with a
“.PLD”. extension. It is not advisable to save data in these files. This could also cause
problems in pasting design data into the input of off-design calculations.
5
Cycle-Tempo Manual
User Subroutines
User Defined Loading data from the standard input file, unit number 9, can be handy if extra data
Input need to be loaded in a user subroutine. Using the General Data | User Defined Input, you can
enter extra data. These data are pasted behind the other data in the input file. Subsequently,
these data can be read with READ(9,…).
An example of this construction can be found in the “Examples” part. In example 5 (EX5,
EX5A, EX5B en EX5C) of this part, extra data that have been entered with General Data | User
Defined Input are read via the APSUB user subroutine.
If you want to open a file yourself for reading or writing, you can use a unit number not yet
in use. You can open the file using an OPEN statement. If, for example, you want to write
data to a file with the name MYFILE, you can do this as follows:
Then you can write everything to this file, using WRITE(14,…). The file is closed again
using the CLOSE(14) statement.
Comment:
Note! In a user subroutine, it is not allowed to re-open or close the files with the reserved unit
numbers stated in this section.
6
User Subroutines in Detail
Chapter 4
The memory capacity, required not only for drafting the system matrix but also for internal
bookkeeping of apparatuses, pipes, working fluids, and cycles, strongly depends on the
relative process diagram. It is not practical to work with fixed upper limits for the number of
apparatuses, pipes, etc., since this would lead to limitations in the program’s application or
to over-use of memory capacity. In standard FORTRAN it is not possible to reserve dynamic
memory. Therefore, you can modify the required memory capacity in Cycle-Tempo’s main
program.
PROGRAM CTMAIN
END
1
Cycle-Tempo Manual
User Subroutines
The exact memory capacity required by the program is printed in a number of 4-byte words,
folllowing the output on system capacity (see “CONFIGURATION OF THE
INSTALLATION” in the Text Output). If the required memory capacity is larger than the
reserved memory capacity, the program will say so in the Message window by way of an
error message and terminate the calculation.
You can specify the required memory capacity in Cycle-Tempo’s main program, the
CTMAIN.FOR. file, by changing the number stated with LCSIZE in the line:
according to your wishes. By default, the reserved memory capacity is 300000 words of 4
bytes. An example of a main program is presented on the previous page.
Comment
Note! Any other change in the program text of the main program may lead to the program not
working properly.
Although CTMAIN is not a real user subroutine, the file CTMAIN.FOR should be treated like
a user subroutine in order to activate a change in the reserved memory capacity.
2
User Subroutines in Detail
4.2.1 Introduction
After each main iteration, the APSUB subroutine calculates values to be modified for the
apparatus data (saved in DATA array, see Appendix A).
The argument list of this subroutine contains all thermodynamic and characteristic apparatus
data, calculated by Cycle-Tempo or stated for the relevant apparatus. The argument list also
contains the real gas composition of each pipe.
To activate APSUB for specific apparatuses, the apparatus numbers should be entered into
the input window for user subroutines (Calculation | User Subroutines) (see also section 2.3).
The order in which the apparatus numbers are listed in the input window determines the
order in which they can be opened from APSUB. This can be important if, for example, data
need to be transferred from one apparatus to another. The apparatus supplying data must be
listed in front of (the number of) the apparatus receiving data.
3
Cycle-Tempo Manual
User Subroutines
INTEGER IPIPE(NP),ILIN(NLIN),IDX(NCOMP)
CHARACTER COMP(NCOMP)*8,APNAME*12
Warning
The above program text is the subroutine specification. It is recommended that you do not
make changes in it. A change in the above program text may lead to the program not
working properly.
Input variables
4
User Subroutines in Detail
Input variables in the form of composition data of working fluids for the types FUEL
and GASMIX:
Although all relevant thermodynamic data of the apparatus are offered, not all changes are
transferred to the program from which you are operating (see statements made at input
description of the relative apparatus in the “Reference” part).
Modifications entered via RESULT have a higher priority than modifications entered in the
DATA data.
5
Cycle-Tempo Manual
User Subroutines
The overview below describes the meaning of the variables in the argument list, in
alphabetical order.
C Medium type
2 FUEL
1 GASMIX
-1 WATERSTM
-2 POTASIUM
-4<C<-3 DUPONT-database
-5<C<-4 REFPROP-database
-5 NH3-H2O
-8<C<-7 LIQUIDS-database
6
User Subroutines in Detail
DATA = array with the input data (maximally 50) of apparatus IAP.
If input data have been stated with “Normal Input” for apparatus IAP in the
input window for apparatus data, you can modify these data here.
Appendix A states which input data are entered at which places in the
DATA array for apparatus type ITYP.
H = double precision array with NP*3 elements divided over NP rows and 3
columns.
Contains the specific enthalpies in the pipes connected with apparatus IAP
(kJ/kg).
Each row i (where i = 1,2,...,NP) contains the following pipe data:
H (i,1): enthalpy at pipe inlet;
H (i,2): enthalpy at pipe outlet;
H (i,3): enthalpy drop in the pipe.
7
Cycle-Tempo Manual
User Subroutines
The order of the stored pipes (rows) is the same as that of the row
identification numbers in IPIPE.
IAP = the apparatus number for which the APSUB subroutine is opened.
IAP is one of the apparatus numbers stated in the input window for user
subroutines (Calculation | User Subroutines).
8
User Subroutines in Detail
ITM = number of the main iteration in which the APSUB subroutine is opened by
the program.
Usually, ITM is applied to perform certain operations either exclusively in
the zeroth and/or first main iteration, or in all iterations except the zeroth
and/or first. The zeroth iteration is the very first calculation round; the first
iteration is the second calculation round, etc.
P = double precision array with NP*3 elements divided over NP rows and 3
columns.
Contains the pressures in the pipes connected with apparatus IAP (bar).
Each row i (where i = 1,2,...,NP) contains the following pipe data:
P (i,1): pressure at pipe inlet
P (i,2): pressure at pipe outlet
P (i,3): pressure drop in the pipe
The sequence of the stored pipes (rows) is the same as that of the
identification numbers of the pipes in IPIPE.
9
Cycle-Tempo Manual
User Subroutines
T = double precision array with NP*2 elements divided over NP rows and 2
columns.
Contains the temperatures in the pipes connected with apparatus IAP (°C).
Each row i (with i = 1,2,...,NP) contains the following pipe data:
T (i,1): temperature at pipe inlet
T (i,2): temperature at pipe outlet
The sequence of the stored pipes (rows) is the same as that of the
identification numbers of the pipes in IPIPE.
X = double precision array with NP*2 elements divided over NP rows and 2
columns.
Contains the vapor fractions in the pipes connected with apparatus IAP
(-).
Each row i (with i = 1,2,...,NP) contains the following pipe data:
X (i, 1): vapor fraction at pipe inlet
X (i, 2): vapor fraction at pipe outlet
The sequence of the stored pipes (rows) is the same as that of the
identification numbers of the pipes in IPIPE.
Comment: the elements in X have the value 0 for the FUEL and GASMIX
medium types.
10
User Subroutines in Detail
4.2.5 Examples
Exampe 1
In this example, the value of the RESULT variable is calculated as a function of the mass
flow.
INTEGER IPIPE(NP),ILIN(NLIN),IDX(NCOMP)
CHARACTER COMP(NCOMP)*8,APNAME*12
IF (ITM.LT.2) RETURN
IF (IAP.EQ.k) RESULT = f1(FM)
IF (IAP.EQ.m) RESULT = f2(FM)
END
The ’k’ and ’m’ variables are the numbers of the apparatuses stated in the row with
apparatus numbers in the input window for user subroutines (Calculation | User
Subroutines). For initialization, estimates must be entered into the input for the
accompanying apparatus with respect to the isentropic efficiency and the pressure increase
of the relative apparatuses. The estimate for the U*A value should be stated in the off-design
input data of the relative apparatus.
11
Cycle-Tempo Manual
User Subroutines
Example 2
Another construction that is used quite often is transferring a variable from one apparatus to
another, without the apparatuses being directly connected with a pipe. For this, the apparatus
number (supplying the variable) must first be entered into the row with apparatus numbers in
the input window for user subroutines (Calculation | User Subroutines). Then the apparatus
number (receiving the variable) must be entered. In the following example a variable
prop(ip,a) of apparatus ‘k’ is transferred to variable number ‘j’ of apparatus ‘m’. The latter
must have been entered in the input window for apparatus data of apparatus ‘m’. In it,
prop(ip), for example, is a mass flow (FM), pressure (P), temperature (T) or an enthalpy (H)
in the connected pipe ‘ip’.
If, for example, you would transfer the temperature at the end of a pipe connected with
apparatus ‘k’, prop(ip) is identical to T(ip,2).
INTEGER IPIPE(NP),ILIN(NLIN),IDX(NCOMP)
CHARACTER COMP(NCOMP)*8,APNAME*12
SAVE PROPTY
END
Note: Usually, this manoeuvre is easier to perform with the PIPSUB user subroutine.
12
User Subroutines in Detail
4.3.1 Introduction
In this subroutine, after each main iteration, you can modify characteristic pipe data (such as
pressure drop and specific enthalpy drop) that have been entered into the input. Furthermore,
you can use this subroutine to calculate or modify thermodynamic variables such as
pressure, temperature, and specific enthalpy in a pipe.
The argument list of this subroutine contains all relevant pipe data, as well as the real gas
composition of each pipe.
To activate PIPSUB for specific pipes, enter the pipe numbers in the input window for user
subroutines (Calculation | User Subroutines) (see also section 2.3).
The order in which the pipe numbers are listed in the input window determines the order in
which they can be opened in PIPSUB. This can be important if data from one pipe need to be
transferred to another pipe. The number of the pipe supplying data should be listed in front
of the number of the pipe receiving data.
The variables to be modified in each pipe should be stated in the input as “extra condition”
of the relative pipe. The modifications to be made in PIPSUB are not performed when the
variables have also been entered with the apparatus input.
Compositions in the pipes can only be modified if the composition of the relative pipes is
explicitly stated in the input (and not as an estimate).
13
Cycle-Tempo Manual
User Subroutines
Warning
The above program text is the subroutine specification. It is recommended not to make
changes in it. A change in the above program text may lead to the program not working
properly.
Input variables
14
User Subroutines in Detail
Input variables in the form of composition data of media for the FUEL and GASMIX
medium types:
AVERG : average mole flow in the pipes
COMP : components in the system
CONC : concentrations of components in the pipes
IDX : identification numbers of the components
NCOMP : number of different components in the system
H : enthalpy
DH : enthalpy difference
P : pressure
DP : pressure drop
T : temperature
X : vapor quality
The overview below describes the meaning of the variables in the argument list, in
alphabetical order.
15
Cycle-Tempo Manual
User Subroutines
C Medium type
2 FUEL
1 GASMIX
-1 WATERSTM
-2 POTASIUM
-4<C<-3 DUPONT-database
-5<C<-4 REFPROP-database
-5 NH3-H2O
-8<C<-7 LIQUIDS-database
16
User Subroutines in Detail
IPIPE = the pipe number for which the PIPSUB subroutine is called.
IPIPE is one of the pipe numbers stated in the input window for user
subroutines (Calculation | User Subroutines).
ITM = number of the main iteration in which the APSUB subroutine is opened by
the program.
Usually, ITM is applied to perform certain operations either exclusively in
the zeroth and/or first main iteration, or in all iterations except the zeroth
and/or first. The zeroth iteration is the very first calculation round; the first
iteration is the second calculation round, etc.
17
Cycle-Tempo Manual
User Subroutines
4.3.5 Example
For pipe k, the pressure drop is a function of the mass flow: p = f1 (m).
For pipe m, the enthalpy drop is a function of the mass flow: h = f2 (m). This leads to the
following PIPSUB subroutine:
IF (ITM.LT.2) RETURN
IF (L.EQ.k) DP = f1(FM)
IF (L.EQ.m) DH = f2(FM)
END
18
User Subroutines in Detail
4.4.1 Introduction
In the chemical reactor (type 27), you can calculate a new equilibrium for a chemical
reaction based on an equilibrium temperature, using the equilibrium constants. Several
reactions can also be brought to equilibrium simultaneously, at different equilibrium
temperatures.
19
Cycle-Tempo Manual
User Subroutines
PPART = array with concentrations of ambient partial pressures in the reactor of all
components available in the Cycle-Tempo gas library [bar]
The COMMON-area GASDAT is stated here only for the purpose of having the NAME
array available. The meaning of the other variables is not important here.
NAME = character*8 array with the names of the components in the gas library
The intention is that you modify the PPART array in such a way that equilibrium is reached
for the reaction(s). In this array, you will find the partial pressures of all substances available
in Cycle-Tempo’s gas library, as they are found in the reactor (total pressure is PREACT, or
if this pressure is not stated, the outlet pressure). If a substance does not occur in the reactor,
its partial pressure is zero. In the NAME array you can look up where substances can be
found.
The programmed reaction may also be a terminating reaction.
For further information about calculating equilibrium, see the “Technical Notes” part.
20
User Subroutines in Detail
In this example, all COS of a gas mixture is converted in conformity with the following
reaction:
COS + H2O CO2 + H2S
END
In the user subroutine, the numbers of the components are first looked up using the NAME
array, and saved in ISPEC1, ISPEC2, ISPEC3 and ISPEC4, respectively. Subsequently, the
reaction coordinate X is determined. Finally, the new partial pressures are determined.
21
Cycle-Tempo Manual
User Subroutines
4.5.1 Application
In this user subroutine, you can define a function. An optimization is made according to the
function value produced by this function, if the “Use user-defined optimization function” is
selected in the input window for optimization data.
INTEGER IAPP(NAPP),ILIN(NLIN)
The overview below describes the meaning of the variables in the argument list in
alphabetical order.
DATAP = double precision array with NAPP*50 elements divided among NAPP
rows 50 columns.
Contains the input data of all apparatuses entered into the window for
apparatus input data at "Normal Input". Appendix A states at which places
22
User Subroutines in Detail
in the DATAP array which input data are found for a specific type of
apparatus.
Each row contains the data of an apparatus. The row number is the
identification number of the apparatus in IAPP. The data of the first row
number, for example, belong to apparatus number IAPP(1).
HKJK = double precision array with NLIN*3 elements divided among NLIN rows
and 3 columns.
Contains the specific enthalpies in the pipes in the process diagram (kJ/kg).
Each row i (with i = 1,2,...,NLIN) contains the following data about the
pipe:
HKJK (i, 1): enthalpy at the pipe inlet
HKJK (i, 2): enthalpy at the pipe outlet
HKJK (i, 3): enthalpy drop in a pipe.
The row number is the identification number of a pipe in ILIN.
23
Cycle-Tempo Manual
User Subroutines
PBAR = double precision array with NLIN*3 elements divided among NLIN rows
and 3 columns.
Contains the pressures in the pipes in the process diagram (bar).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
PBAR (i,1): pressure at the pipe inlet
PBAR (i,2): pressure at the pipe outlet;
PBAR (i,3): pressure drop in the pipe
The row number is the identification number of a pipe in ILIN.
TCEL = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the temperatures in the pipes in the process diagram (°C).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
TCEL (i,1): temperature at the pipe inlet
TCEL (i,2): temperature at the pipe outlet
The row number is the identification number of a pipe in ILIN.
XFAC = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the vapor fractions in the pipes in the process diagram (-).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
XFAC (i,1): vapor fraction at the pipe inlet
XFAC (i,2): vapor fraction at the pipe outlet.
The row number is the identification number of a pipe in ILIN.
24
User Subroutines in Detail
Comment: the elements in XFAC have the value 0 for the FUEL and
GASMIX types of working fluid.
25
Cycle-Tempo Manual
User Subroutines
4.6.1 Introduction
The last program statement to be performed concerns the EPILOG. subroutine. With the
argument list all available data are passed on. This produces the possibility of “post
processing" such as printing tables or plotting graphs. After this routine, no other operations
are performed so that you are completely free in using the data.
INTEGER IAPP(NAPP),ILIN(NLIN),MED(NLIN),
* ITYPE(NAPP),NLIK(NAPP,2),M(NLIN,2),
* IDX(NCOMP),IGEO(NUMGEO),IDATGM(NUMGEO,5)
CHARACTER COMP(NCOMP)*8,NAMAP(NAPP)*12
26
User Subroutines in Detail
Warning
The above program text is the subroutine specification. It is recommended that no changes
be made in it. A change in the above program text may lead to the program not working
properly.
Apparatus data
27
Cycle-Tempo Manual
User Subroutines
Pipe data
Composition data of working fluids for the medium types FUEL and GASMIX:
28
User Subroutines in Detail
Other data
The overview below describes the meaning of the variables in the argument list in
alphabetical order.
Note After completing the calculation and thus loading the EPILOG
routine, the average mole masses of all pipes are stored in
AVERG array, i.e., not only those of the pipes with medium type
FUEL and GASMIX.
29
Cycle-Tempo Manual
User Subroutines
process diagram. For example, the third row refers to the pipe whose pipe
number is identical to ILIN(3). The virtual pipe identification numbers
naturally do not refer to a pipe in the process diagram.
The column number is the identification number of a component in a
process diagram. The name of the component to which for example the
first column refers is identical to COMP(1).
DATAP = double precision array with NAPP*50 elements divided among NAPP
rows 50 columns.
Contains the input data of all apparatuses entered into the window for
apparatus input data with "Normal Input". Appendix A states which data of
a specific apparatus type are found at which places in the DATAP array.
Each row contains the data of an apparatus. The row number is the
identification number of the apparatus in IAPP. The data of the first row
number, for example, belong to the apparatus number IAPP(1).
DELTDF = double precision array with 2*k elements divided among 2 rows and "k"
columns. The number of “k” columns is identical to the number of heat
exchangers present (types 4, 5, 6, 12 and 22). Contains the inlet and outlet
temperature differences for the heat exchangers in the process diagram.
The rows contain the following data in case of co-flow (only for types 6
and 12):
DELTDF (1, *): temperature difference between the secondary inlet
and the primary inlet side (Th);
DELTDF (2, *): temperature difference between the secondary outlet
and the primary outlet side (Tl).
30
User Subroutines in Detail
EXDIFA = double precision array with NAPP*2 elements divided among NAPP rows
and 2 columns.
Contains the exergy differences between all ingoing and all outgoing
process flows of an apparatus (kJ/s).
Each row i (where i = 1,2,...,NAPP) contains the following data about the
apparatus:
EXDIFA (i, 1): exergy difference over apparatus calculated using
ingoing and outgoing exergy flows;
EXDIFA (i, 2): same, now calculated via enthalpy and entropy values
of the ingoing and outgoing process flows.
The row number is the identification number of an apparatus in IAPP.
EXDIFP = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the exergy differences between the inlet and the outlet of the
pipes in the process diagram (kW).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
EXDIFP (i, 1): exergy difference over pipe calculated using ingoing
and outgoing exergy flows;
EXDIFP (i,2): same, now calculated via enthalpy and entropy values
at the inlet and outlet of the pipe.
The row number is the identification number of a pipe in ILIN.
EXKJKG = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the total (= chemical + thermomechanical) exergy of the working
fluids in the pipes of the process diagram (kJ/kg).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
EXKJKG (i, 1): total exergy at the inlet of a pipe;
EXKJKG (i, 2): total exergy at the outlet of a pipe.
The row number is the identification number of a pipe in ILIN.
31
Cycle-Tempo Manual
User Subroutines
FACUA = double precision array with 3*k elements divided among 3 rows and "k"
columns. The number of "k" columns is identical to the number of heat
exchangers present (types 4, 5, 6, 12 and 22).
The rows contain the following data about condensers (type = 4):
FACUA (1, *): heat-exchanging surface A (m2);
The second and third rows are not used with condensers.
The rows contain the following data about feedwater pre-heaters (type =
5):
FACUA (2, *): design mass flow (kg/s);
The first and third rows are not used with feedwater pre-heaters.
The rows contain the following data about heat exchangers (type = 6:
EEQCOD = 2, or type = 12: EEQCOD = 1):
FACUA (1, *): UA value (kW/K);
FACUA (2, *): design mass flow (kg/s);
FACUA (3, *): exponent ETHA for U * A correction.
HENV = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the specific enthalpy values with respect to the environment in
the pipes in the process diagram (kJ/kg).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
HENV (i, 1): enthalpy with respect to the environment at the inlet of a
pipe;
32
User Subroutines in Detail
HENV (i, 2): enthalpy with respect to the environment at the outlet of
a pipe.
The row number is the identification number of a pipe in ILIN.
HKJK = double precision array with NLIN*3 elements divided among NLIN rows
and 3 columns.
Contains the specific enthalpies in the pipes in the process diagram (kJ/kg).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
HKJK (i, 1): enthalpy at the inlet of a pipe;
HKJK (i, 2): enthalpy at the outlet of a pipe;
HKJK (i, 3): enthalpy drop in a pipe.
The row number is the identification number of a pipe in ILIN.
33
Cycle-Tempo Manual
User Subroutines
IDATGM = integer array with NUMGEO*5 elements divided among NUMGEO rows
and 5 columns.
Contains the integer geometry data entered with the apparatuses. Table 4-3
presents the contents of this array.
Table 4-3: the contents of the "IDATGM" array for the relevant apparatus types
Type Name 1 2 3 4 5
4 condenser NPIPES NEDGE PRISEC
21 fuel cell FLOW NITER NCELL PGFC
M = integer array with NLIN*2 elements divided among NLIN rows and 2
columns.
This array is the connection matrix of the process diagram.
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
34
User Subroutines in Detail
NLIK = integer array with NAPP*2 elements divided among NAPP rows and 2
columns.
Contains the pipe identification numbers of the pipes that are connected to
the primary working fluid of an apparatus.
Each row i (where i = 1,2,...,NAPP) contains the following data:
NLIK (i, 1): pipe number of the outgoing pipe;
NLIK (i, 2): pipe number of the ingoing pipe.
The row number is the identification number of an apparatus in IAPP.
35
Cycle-Tempo Manual
User Subroutines
NTURB = the total number of turbines in the process diagram, or the number of
apparatuses for which it applies type = 3.
NUMGEO = the number of apparatuses for which geometry data have been entered
(only possible with condenser, type = 4 and fuel cell, type = 21)
PBAR = double precision array with NLIN*3 elements divided among NLIN rows
and 3 columns.
Contains the pressures in the pipes in the process diagram (bar).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
PBAR (i,1): pressure at the inlet of the pipe;
PBAR (i,2): pressure at the outlet of the pipe;
PBAR (i,3): pressure drop in the pipe.
The row number is the identification number of a pipe in ILIN.
36
User Subroutines in Detail
37
Cycle-Tempo Manual
User Subroutines
Table 4-4: the contents of the "RDATGM" array for the relevant types of apparatuses
Type Name 1 2 3 4 5 6 7 8
4 condenser DIAIN DIAOUT PITCH LAMBDW AIRFAC RFOUL
21 fuel cell RCELL VCELL DELU CDENS ACELL ESTVLT ESTCDN
TCEL = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the temperatures in the pipes in the process diagram (°C).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
TCEL (i,1): temperature at the inlet of a pipe;
TCEL (i,2): temperature at the outlet of a pipe.
The row number is the identification number of a pipe in ILIN.
XFAC = double precision array with NLIN*2 elements divided among NLIN rows
and 2 columns.
Contains the vapor fractions in the pipes in the process diagram (-).
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
XFAC (i,1): vapor fraction at the inlet of the pipe;
XFAC (i,2): vapor fraction at the outlet of the pipe.
The row number is the identification number of a pipe in ILIN.
38
User Subroutines in Detail
Comment: the elements in XFAC have the value 0 for the medium types
FUEL and GASMIX.
39
Cycle-Tempo Manual
User Subroutines
40
Available Functions
Chapter 5
Available Functions
5.1 Introduction
This chapter contains an overview of a number of functions that can be applied from a user
subroutine:
All variables stated meet the default FORTRAN convention, unless stated otherwise. This
means that variables starting with the letters I through N are variables of the INTEGER type.
The others are floating point variables. Since Cycle-Tempo fully calculates in double
precision, these are of the DOUBLE PRECISION type.
1
Cycle-Tempo Manual
User Subroutines
When working with user subroutines, you often need the serial number of an apparatus in the
IAPP array. With this serial number, you can, for example, use data from the DATAP array.
The first possibility to determine the serial number is to write a DO loop in which IAPP(I) is
compared with the relative apparatus number. If the condition is true, I is the required serial
number. This is displayed in the code fragment below.
INTEGER IAPP(NAPP)
………
20 ………
END
This directly produces the serial number of apparatus with IAPNO number. Instead of a DO
loop, the internal INAPNO function is used in the code fragment below.
INTEGER IAPP(NAPP)
………
………
END
2
Available Functions
If the apparatus involved does not exist, the INAPNO function will return the zero value.
If IAPNO exists in the process diagram, INAPNO will return the serial number of
IAPNO in IAPP. If IAPNO does not exist, INAPNO will return the value 0.
If IAPNO exists in the process diagram, ISAPNO will return the value.TRUE.;
otherwise,.FALSE.
If IAPNO exists in the process diagram, APNAME will return the name of IAPNO. If
IAPNO does not exist, APNAME will return the value ‘?’.
If IAPNO exists in the process diagram, APTYPE will give the apparatus type of
IAPNO. If IAPNO does not exist, APTYPE will return the value 0.
3
Cycle-Tempo Manual
User Subroutines
In the functions stated above, IAPNO is always the number of the apparatus in the diagram.
The meaning of the other variables is:
4
Available Functions
When working with user subroutines, you often need the serial number of a pipe in the ILIN
array. The first possibility to determine the serial number is to write a DO loop in which
ILIN(L) is compared with the relevant pipe number, as is displayed in the first code
fragment on page 2. The second method is to use the INPINO function:
This directly produces the serial number of the pipe with IPINO number. The code fragment
below contains an example of the use of INPINO.
………
END
If the relevant pipe does not exist, the INPINO function will return the value zero.
5
Cycle-Tempo Manual
User Subroutines
If IPINO exists in the process diagram, INPINO will return the serail number of IPINO
in ILIN. If IPINO does not exist, INPINO will return the value 0.
If IPINO exists in the process diagram, ISPINO will return the value .TRUE.,
otherwise .FALSE.
If apparatus IAPNO and pipe IPINO are connected with each other, ISAPPI will return
the value .TRUE., otherwise .FALSE..
If IAPNO or IPINO do not exist, ISAPPI will also return .FALSE..
In the above functions, IPINO is always the number of the pipe in the diagram and IAPNO is
always the number of the apparatus in the diagram. The meaning of the other variables is:
6
Available Functions
M = integer array with NLIN*2 elements divided among NLIN rows and 2
columns.
This array is the connection matrix of the process diagram.
Each row i (where i = 1,2,...,NLIN) contains the following data about the
pipe:
M (i,1) = element number of the apparatus in IAPP at the pipe inlet (i);
M (i,2) = element number of the apparatus in IAPP at the pipe outlet
ILIN(i);
Thus, the row number is the identification number of a pipe in ILIN.
If, for example, M(5,2) = 3, this means that the apparatus number at the
pipe outlet with pipe number ILIN(5) is identical to IAPP(3).
This section contains an overview of functions that can be called to calculate thermodynamic
properties. The meaning of the variables used in the argument lists in the column ‘way of
utilization’ is as follows:
H = enthalpy [kJ/kg]
P = pressure [bar]
S = entropy [kJ/kg K]
T = temperature [°C]
W = mass fraction [-]
X = vapor fraction [-]
XGAS = medium type (see Table 5-1)
7
Cycle-Tempo Manual
User Subroutines
See section 4.6 “EPILOG” for the meaning of COMP, CONC, AVERG, IDX, NCOMP,
NLIN and HUC. These variables are used to transfer the composition of a gas mixture
(GASMIX or FUEL) to the relevant function. The same applies to W. This is also a
composition parameter, but for certain mixtures (NH3-H2O, solutions). The L variable is the
serial number of a pipe in ILIN (see also section 4.6 “EPILOG”). L is used for error
messages and also to transfer the composition of a gas mixture (GASMIX or FUEL).
If a specific function is applied to a non-valid medium type, the program will generate an
error message and the calculation is terminated.
1)
Only REFDROP
8
Available Functions
9
Cycle-Tempo Manual
User Subroutines
a function of POTASIUM
temperature, vapor Refrigerants 1)
fraction and composition
WATERSTM
t = f(p,h,comp.) Temperature as a T = TPHW( P, H, W, XGAS, L,
GASMIX
function of pressure, COMP, CONC,
FUEL
enthalpy and AVERG, IDX,
POTASIUM
composition NCOMP, NLIN,
Refrigerants
HUC)
NH3-H2O
10
Appendix A: Apparatus Variables
Appendix A
Apparatus Variables
Contents of the DATA(P) array for all apparatus types (elements 1 through 6)
Type Name 1 2 3 4 5 6
no.
1 boiler PIN POUT DELP TIN TOUT DELT
2 reheater PIN POUT DELP TIN TOUT DELT
3 turbine PIN PINCND TIN TOUT DELT
4 condenser PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
5 flash. heat. PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
6 heatexchng. PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
7 deaerator PIN POUT DELP TIN TOUT DELT
8 pump PIN POUT DELP TIN TOUT DELT
9 node DELP
10 sink/source PIN POUT DELP TIN TOUT DELT
11 node+e DELP
12 evaporator PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
13 combustor PIN POUT DELP TIN TOUT
14 valve DELP
15 drum PIN POUT
20 reformer PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
21 fuel cell PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
22 moist. sep. PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
23 gasifier PIN1 POUT1 DELP1 TIN1 TOUT1 DELT1
25 scrubber PING POUT DELPG TING
26 separator PIN POUT5 DELP5 TIN TOUT5 DELT5
27 ch. reactor PIN POUT DELP TIN TOUT
28 saturator PING POUTG DELPG TING TOUTG DELTG
29 compressor PIN POUT DELP TIN TOUT DELT
A-1
Cycle-Tempo Manual
User Subroutines
Contents of the DATA(P) array for all apparatus types (elements 7 through 12) (continued)
Type Name 7 8 9 10 11 12
no.
1 boiler DELE (DELM) ETHAB
2 reheater DELE (DELM) ETHAB
3 turbine ETHAI ETHAM TUCODE DIAIN DIAOUT POUTDS
4 condenser DELE RPSM PIN2 POUT2 DELP2 TIN2
5 flash. heat. DELE PIN2 POUT2 DELP2 TIN2
6 heat exchng. DELE RPSM PIN2 POUT2 DELP2 TIN2
7 deaerator DELE
8 pump ETHAI ETHAM ETHAE
9 node RMASS(1) RMASS(2) RMASS(3)
10 sink/source DELE DELM HIN HOUT DELH XIN
11 node+e DELE
12 evaporator RPSM PIN2 POUT2 DELP2 TIN2
13 combustor DELE ESTPOU DPREAC
14 valve RMASS(1) RMASS(2) RMASS(3)
15 drum DELE CRATIO
20 reformer DELE RPSM PIN2 POUT2 DELP2 TIN2
21 fuel cell DELE PINCA POUTCA DELPCA TINCA
22 moist. sep. DELE RPSM PIN2 POUT2 DELP2 TIN2
23 gasifier DELE PIN2 POUT2 DPREAC TIN2
25 scrubber DELE MAXIT PINW DELPW TINW
26 separator DELE POUT6 DELP6
27 ch. reactor DELE MAXIT RMASS(1) RMASS(2) RMASS(3)
28 saturator DELE DELMW PINW POUTW DELPW TINW
29 compressor ETHAI ETHAM PRATI ETHAE
A-2
Appendix A: Apparatus Variables
Contents of the DATA(P) array for all apparatus types (elements 13 through 18) (continued)
Type Name 13 14 15 16 17 18
no.
1 boiler EXFUEL ESTMAS LHV
2 reheater EXFUEL ESTMAS LHV
3 turbine DESMAS POUTRT ETHAID GDCODE
4 condenser TOUT2 DELT2 DELTH DELTL/SATCOD
5 flash. heat. TOUT2 DELT2 DELTH DELTL/SATCOD
6 heatexchng. TOUT2 DELT2 DELTH DELTL
7 deaerator
8 pump (ETHAIC) (ETHATT)
9 node RMASS(4) RMASS(5) RMASS(6)
10 sink/source XOUT PIPE (IMEQ) ESTMAS LHV SUBTYP
11 node+e
12 evaporator TOUT2 DELT2 DELTH DELTL PRISEC
13 combustor DTREAC (IMEQ1) (IMEQ2) PREACT TREACT
14 valve RMASS(4) PIPE (IMEQ) RVOL(1) RVOL(2) RVOL(3)
15 drum
20 reformer TOUT2 DELT2 PREACT TREACT
21 fuelcell TOUTPS DELTCA (IMEQ) (IEEQ) PREACT TREACT
22 moist. sep. TOUT2 DELT2 (IMEQ) DELTL ESTTGS
23 gasifier TOUT2 DTREAC (IMEQ) SFRATI PREACT TREACT
25 scrubber RELHUM ESTTEM
26 separator TOUT6 DELT6 (IMEQ) TEMDIF
27 ch. reactor RMASS(4) RMASS(5) ESTMAS PREACT
28 saturator TOUTW PIPE (IMEQ) DELTL RELHUM ESTTEM
29 compressor (COCODE) (ETHAIC) (ETHATT)) ETHAID (VOLFLD)
A-3
Cycle-Tempo Manual
User Subroutines
Contents of the DATA(P) array for all apparatus types (elements 19 through 25) (continued)
Type Name 19 20 21 22 23 24 25
no.
1 boiler
2 reheater
3 turbine (POWER)
4 condenser DTSUBC
5 flash. heat.
6 heatexchng.
7 deaerator
8 pump (POWER)
9 node
10 sink/source DTSUBC DTSUPH WFOT ESTTIN ESTTOU DELV DELVN
11 node+e
12 evaporator
13 combustor ESTOFR LAMBDA PASH DPASH TASH DTASH
14 valve RVOL(4) RVOLN(1) RVOLN(2) RVOLN(3) RVOLN(4)
15 drum
20 reformer SFRATI SFMOL
21 fuelcell UFL UOX IPUFL IPUOX DELEP DCAC POWER
22 moist. sep. CGRATI DELTH ESTPGS
23 gasifier ESTOFR OFRATI PASH DPASH TASH DTASH AFRATI
25 scrubber ESTMLF ESTPGS DSPLIT
26 separator
27 ch. reactor ESTPGS TWGS TCH4R TRUSER
28 saturator ESTMLF DELTH WFOTEB DELTW MLFH2O
29 compressor PRATID PCTRPM (POWER)
The elements 26 through 50 are used only for the fuel cell (type 21), and are currently not
being used for any other apparatus type.
Contents of the DATA(P) array for apparatus type 21 (elements 26 through 50)
element Element element
26 PFCELL 35 (RMK) 43
27 TFCELL 36 (OFRAT) 44 (UC)
28 ICCUFL 37 (UFL) 45 ESTMFL
29 (URATIO) 38 (UOX) 46 ESTMOX
30 TH2OOS 39 PINAN 47 ESTUFL
31 40 POUTAN 48 ESTUOX
32 41 DELPAN 49 DELTAN
33 (RMA1) 42 TINAN 50 XSHIFT
34 (RMA2)
A-4