|=====================================|
		|                                     |
		|      USERS GUIDE TO 'TANKSPILL'     |
		|                                     |
		|       A process control game        |
		|                                     |
		|    Version 2.0 (for WINDOWS 3.0)    |
		|                                     |
		|=====================================|

			    S. Skogestad
		   Department of Chemical Engineering 
	         Norwegian Institute of Technology (NTH)
			   N-7034 Trondheim 

		  Progammed by A. Blandhol & E. Wolff




	Part 1:    Introduction
		   The Model of the system
		   Parameter Values
		   The Transfer function
		   Comments on the controller

	Part 2:    Hardware requirements
		   Operating the game
		   Penalty points
		   Graphic representation
		   How to quit and restart
		   Keyboard use
		   Slow version of program
		   Previous versions



Part 1:

   Introduction
   ------------

      The game simulates a tank with a gas and liquid feed, and the
   objective is to keep the pressure and liquid level in the tank at
   given values. Physically, a tank with feed of water and high
   pressure air is an example of such a system. However, the
   parameter values chosen in this game are intended to represent a
   gas-oil separator where a high-pressure well stream is separated
   into liquid and gas. Condensation or vaporization is neglected.

   The objective of the game is to introduce the student to the
   dynamics of an interacting process. It is suggested that the game
   is used several times during a process control course:

   1) Introduction to dynamics: Impulse or step responses in training
   mode (change all four flows).

   2) Introduction to feedback control: Manual control in game mode.
   Who is the best? Should be able to get more than 450 sec.

   3) Introduction to automatic control: P-control in training mode.
   Start with level control (with constant position for gas outlet)
   and then add on pressure control. See how long the regulator will
   last in game mode with these settings.

   4) Controller tuning: Training mode. Leave valve for gas outlet in
   manual (this works since pressure is self-controlled in open
   loop). Use P-control and adjust gain in level control to obtain
   oscillations. Use this for ZN-tuning of level loop. With this loop
   CLOSED (PI or PID) use P-control for the pressure and adjust the
   gain to obtain oscillations. Use this for ZN-tuning of the
   pressure loop.

   5) PID-control in game mode. Who is the best? Should be able to
   get more than 650 sec.

      As noted above the process is very interactive. The RGA has a
   steady-state value of 1, then goes down to 0.25 at a frequency of
   0.01 Hz, and returns back to 1 at about 1 Hz. This implies that
   interactions increase the effective gains of the loops and that
   interactions are most severe at intermediate frequencies. The
   system is triangular (and therefore has a RGA-value of 1) at
   steady-state because liquid flow has no effect on pressure at
   steady state, and the system is triangular at high frequency 
   because the gas stream has a direct effect on pressure, but only
   a indirect effect on level.


   The Model of the system
   ------------------------

       Stream 3             /-----\         Stream 4
       Gas In, q3    ------>| P   |----X--> Gas Out, q4
			    |     |  z2(%)
       Stream 1             |#####|         Stream 2
       Liquid In, q1 ------>|##VL#|----X--> Liquid Out, q2
			    \-----/  z4(%)

      The system has four independent variables (flows). The manipulated
   variables (inputs) are z2 and z4, the valve opening on the streams
   leaving the tank. Disturbances are q1 and q3, the flows of the streams
   entering the tank.

      Units are: Pressure in Pa, Level in m3, Time in sec., Gas flows are in
   kmol/s, Liquid flows in m3/s, valve openings (z) normalized 0-1 (although
   they are shown in percent on the flowsheet).

      The system is described by the following differential equations:


		 dVL
		----- = q1 - q2                 [m3/s]
		 dt

		  dP
      (V - VL) * ---- = RT*(q3-q4) + P*(q1-q2)  [m3 * Pa/s]
		  dt


   Valve equations:
				     1/2
	q2 = Cv2 * f(z2) * (P  - P  )           [m3/s]
			     L    L0


			     2    2  1/2
	q4 = Cv4 * f(z4) * (P  - P  )           [kmol/s]
				  G0

	Linear valves f(zi) = zi, where zi = [0,1]

	Valve constant Cv2 = 7.972e-3, Cv4 = 1.420e-3.

      There is a 5 sec. dead-time in the valve-dynamics which is modelled
   using a 5th order lag. In terms of Laplace transforms:

	dz2 = (1/(1+s)^5) dz2%/100.
                      
	dz4 = (1/(1+s)^5) dz4%/100.

   where z2 and z4 are the actual valve openings, and z2%(D) and z4%(B) are
the desired valve openings (in %) set manually or by the controller.


   Parameter Values
   ----------------

      The simulation starts up at a stationary point (steady state) where:

	Liquid Feed           : q1 = 4.0  m3/s   = q3
	Gas Feed              : q2 = 2.56 kmol/s = q4
	Tank Pressure         :  P = 70.0 bar
	Tank Level            :  V = 20.0 m3
	Temperature           :  T = 400  K
	Initial Valve openings:  z = 0.5
	Downstream pressure   :  P   = P   = 60.0 bar 
				  L0    G0

   The Transfer function
   ---------------------

      Linearizing the model at this steady state yields:

       	{dVL} = G(s) {dB}
	{dp }        {dD}

   where B and D are the valve openings in percent. Here


		    1               { -11.50*(17.47*s+1)   11.12           }
     Gc(s) = -------------------- * {                                      }
	     (5814*s+1)(4.32*s+1)   { -175.7e00e+5 * s    -3712*(1439*s+1) }


			   5
     G(s) = Gc(s) * 1/(1+s)


   Controller: The ideal PID-controller is used :

	 C(PID) = Kc * (1 + 1/ti*s + td*s)


   Comment on the controller
   ------------------------

      When using a PI- or a PID-controller, the velocity form is used for
   computing the inputs (see Stephanopoulus, 1984, p.636), that is,
   proportional action is based on c(i)-c(i-1) = -Kc * (eps(i) - eps(i-1)),
   where eps is the deviation from setpoint, c is the controlled input, i
   is the present timestep, and i-1 is the previous timestep. The velocity
   form does not need initialization and is protected against integral
   windup. However, this form does not work with a pure P-controller
   because there is no way to reset the bias term and one gets offset even
   with a large gain. Therefore, with a pure P-controller the algorithm
   used is c(i) = -Kc * eps(i).



Chapter 2:


   Hardware Requirements
   ---------------------

     TANKSPILL Ver 2.0 operates under WINDOWS 3.0, and a IBM compatible PC
   with a 286 or 386 processor is needed for acceptable speed. A color
   monitor is needed to identify streams etc. It is possible to operate
   the program with a keyboard only, but the use of a mouse recommended.


   Operating the game
   ------------------

   TANKSPILL is started by entering 'win tank' at the DOS prompt. This will
   start WINDOWS and TANKSPILL simultaneously. This way of starting TANKSPILL
   avoids the need for learning more about WINDOWS.

      If you have not used a mouse before then note that moving the mouse
   will move the position of the mouse cursor (usually an arrow) and a
   selection is generally made by pressing the LEFT mouse button.

      A screen appears and you must select the modes of operation and enter
   your name. Modes :

	Manual or Automatic
	Game or Training  

      Use the mouse to move around and make your selections. The game will
   start up when you press the left mouse button while the mouse cursor is
   on the 'Ok' button in the Startup dialogbox.

	     q3       /-----\        q4
	       ------>|     |----X-->
		      |     |  % = z4          Figure : Tank Flowsheet
		      |     |
	     q1       |#####|        q2
	       ------>|#####|----X-->
		      \-----/  % = z2


      In MANUAL MODE the program starts with constant valve openings,
   set to 50% open. In AUTOMATIC MODE the controller parameters must
   first be set before the program starts. The valve-openings are then
   shown in red (rather than in black) to indicate automatic mode.

	In GAME MODE the objective is to maximize the game time, that is,
   to adjust D and B to keep level and pressure close to their desired
   values of VL = 20 m3 and p = 70 bar in spite of disturbances on the
   flows entering the tank. The method for penalty points is outlined
   below. The Checksum which appears at the end of the game is computed
   as a function of the game time and may be used to check if the claimed
   time is correct. A different checksum applies to manual and automatic
   operation.

      In TRAINING MODE the valves on the input streams are visible and
   their openings may be changed to simulate disturbances (step, pulse
   etc.).


   Operation with mouse
   ---------------------

   a)  Change valve opening manually (provided the valve is shown in black):
   Position mouse at valve and click mouse button:

      Left  button :  	- 1% 
      Right button :	+ 1% 
      As over while SHIFT-key is held down: +/- 5% 

   b)  Change valve mode from manual to auto (as indicated by color changing
   from black to red): Position mouse at valve and press the left mouse-
   button while the CTRL-key is held down.

   c)  Change in setpoint and other controller parameters (may be done
   at any time and in any mode): Position mouse at controller circle (on
   the dotted lines) and press left mouse-button. A standard dialog box
   will appear.


   Penalty Points
   --------------

      Since the program may be used as a game to measure capabilities in
   process control, points are calculated based on the ability to keep the
   pressure and level close to setpoint. The current pointrate is

	Point rate = (k*e*e)         + (k*e*e)
                            pressure          level

   where e is the relative deviation from set point which is 70 bar for
   pressure and 20 m3 for level. k is 150 for pressure and is 25 for level.
   Outside the allowed max- and min-margins of 60 to 80 bar for pressure
   and 10 to 40 m3 for level, the pointrate increases with a factor 10 for
   pressure and a factor 4 for level. This is also signaled to the user
   by a 'beep' when these margins are passed. The game is over when the
   original 1000 points are 'used up'. The user may continue training for
   any amount of time after this.


   Graphic representation
   ----------------------

      The level in the "allowed" range from 10 to 40 m3 is indicated in
   blue on the tank itself. The pressure may be inferred from the intensity
   of the red in the space above. It will be all red when the pressure is
   above 80 bar.

      Deviations from setpoint and also the magnitude of disturbances are
   shown graphically in the upper right part of the screen. The vertical
   scale of the graph may be changed by pressing the '+' or '-' buttons
   next to the graph.


   How to quit and restart
   -----------------------

      Quit: Position the mouse cursor to the upper left corner and press
   the left button twice (or use ALT+F4).

      Restart: Position the left cursor to the upper left corner and press
   the left button once. Select the entry "Restart Game". You may now
   select to keep the new values of the controller parameters if these have
   been changed.


   Keyboard use (no mouse)
   -----------------------

      Most functions mentioned may be performed also from the keyboard.

      To move about between boxes on the menu screens use the TAB-key,
   and use the arrow-keys to make your selection. Use the Enter-key when
   a screen is finished (or Esc-key to cancel your entries).

   a)  To change valve openings (or flows for input streams) the following
   letters are used to change their values:

	D(istillate): changes valve opening z4 by 1%.
	B(ottoms)   : changes valve opening z2 by 1%.
	L(iquid)    : changes stream flow   q1 by 1%.
	V(apour)    : changes stream flow   q3 by 1%.

   Lowercase valve-labels decrease the valve-opening (flow) by 1% while
   uppercase increases by 1%. For example, pressing b decreases the valve
   opening for liquid leaving the tank by 1%. There is no way of making
   5% changes.

   b)  Holding the CTRL-key down while pressing the label switches
   between Manual and Automatic control.

   c) Pressing 'c' (lowercase c) allows changing the level control
   parameters and 'C' the pressure control parameters.

   d) The graph scale is adjusted by pressing 'p' or 'm' (for Plus and
   Minus).

   e) The game is terminated by pressing simultaneously Alt and F4 or
   CTRL-C (The last must be confirmed, the first not).

   f) Restarting the game (in any mode) is done by pressing CTRL-R,
   whereupon a confirmation must be entered (Yes, No or ESC).


   Slow version of program
   -----------------------

      The program is set to run approximately such that 1 second game
   time corresponds to 1 second real time. For some slower computers this
   may be too fast. The version SLOWTANK which runs approximately twice as
   slow may be used instead in such cases.


  Previous versions of TANKSPILL
  ------------------------------

  Version 1.0 operates under WINDOWS 2.1, and there are a few other minor
  changes compared to the present version.