Sei sulla pagina 1di 9

gPROMS model developer course

1 Equation Chapter 1 Section 1000Modelling and simulation of a buffer tank


1.1 Objectives
By the end of of this exercise, you will know How to build a model from scratch How to write equations using the gPROMS language How run a simulation How to obtain diagnostic information

1.1 Model description


We want to model the dynamic operation of a buffer tank.

Figure 11: Buffer tank

The tank has a single inlet and a single outlet. The outlet flowrate is driven by gravity. The tank geometry and inlet flowrate will be provided as model inputs. The outlet flowrate is determined by the model based on the level of the liquid in the tank.

1.2 Assumptions
The The The The operation of the tank is isothermal. tank is well-stirred. tank contains a single component in liquid phase. cross-section area is constant along the height of the tank.

gPROMS model developer course

1.1 Parameters
Symbo l
A

Description Horizontal crosssection area of the tank Outlet flowrate coefficient Liquid density

Units m2

gPROMS identifier area

Parameter type REAL

kg/ (s.m) kg/m3

outlet_flowrate_coeffic ient density

REAL REAL

Table 11: Model parameters

1.2 Variables
Symbo l
Fin

Description Inlet mass flowrate Outlet mass flowrate Amount of liquid mass contained in the tank Liquid level in the tank

Units kg/s kg/s kg

gPROMS identifier inlet_mass_flowrate outlet_mass_flowrate mass_holdup

Variable type mass_flowra te mass_flowra te Mass

Fout

height

Length

Table 12: Model variables

1.3 Equations
Mass balance: \* MERGEFORMAT0
M = Fin Fout t

Liquid level in the tank: \* MERGEFORMAT0


M = Ah

Outlet mass flowrate:

gPROMS model developer course \* MERGEFORMAT0


Fout = h

1.4 Parameter values


The cross-section area of the tank is 1 m2. The liquid density is 1000 kg/m3. The outlet flowrate coefficient

is 10 kg/(s.m).

1.5 Degrees of freedom


The inlet mass flowrate into the tank is constant at 20 kg/s throughout the simulation.

1.6 Initial conditions


At the start of the operation, the liquid level in the tank is 2.1 m.

1.7 Things to do
1. Create a new project. Go to the menu File > New. A new project called gPROMS_Project_1 appears in the project tree area.

2. Save your newly created project under a different name. Make sure the name is highlighted in the project tree and go to the menu File > Save as... Choose an appropriate location and name for the file, e.g. Buffer tank.gPJ. 3. Create the three variable types required for this model. Name length mass mass_flowra te Lower bound 0 0 0 Default value 1 1 1 Upper bound 100 1e5 100 Units m kg kg/s

Table 13 Variable types

To create a new variable type, go to the menu Entity > New entity... The New Entity dialog box will appear. Provide the name for the new entity (e.g. length) and the type of entity (i.e. VARIABLE TYPE). Click OK to create the variable type length. You will see a table with all variable types created in this project so far. Using the information in Table 13, provide a suitable lower and upper bound for this variable, as well as a default value and units. Repeat this for the other variable types using the information given above.

gPROMS model developer course 4. Create a Buffer_tank model To create a new model, right-click on the Models folder in the project tree and select New entity.... In the New Entity dialog box, provide the name for the new entity (e.g. Buffer_tank) and make sure the right type of entity is selected (MODEL). Leave the Use template? box checked and click OK to create a new model. A new model Buffer_tank will appear. Click on the gPROMS language tab of this new model to see the template for the gPROMS language. The template shows you a list of sections (e.g. PARAMETER, DISTRIBUTION_DOMAIN, UNIT, etc.) and the general syntax to be used when writing a gPROMS model. 5. Define parameters for the Buffer_tank model Select the gPROMS language tab of the Buffer_tank model. Complete the PARAMETER section using the information given in Table 11. Start by removing the comment identifier (#) in front of the PARAMETER keyword, and in the following lines type:

PARAMETER area AS REAL density AS REAL outlet_flowrate_coefficient AS REAL

Remove the DISTRIBUTION_DOMAIN, UNIT and PORT sections from the template (we dont need them for this model). 6. Define variables for the Buffer_tank model In the VARIABLE section, uncomment the VARIABLE keyword by removing the # before it. Use the information provided in Table 12 and the variable types you defined earlier to define the variables needed for this model:

gPROMS model developer course

VARIABLE inlet_mass_flowrate outlet_mass_flowrate mass_holdup height

AS AS AS AS

mass_flowrate mass_flowrate mass length

Remove the SELECTOR, SET, BOUNDARY and TOPOLOGY sections from the template. 7. Write the equations for the Buffer_tank model. Activate the EQUATION keyword by removing the comment identifier (#) in front of it, and write the three equations according to section Equations. Use control+space to get gPROMS to suggest a list of available options as you are writing the equations. Place comments with the equations to increase readability. Finally, clean up the model by removing the ASSIGN, PRESET, INITIALSELECTOR and INITIAL sections from the template. You have now created a generic model for a buffer tank. Next, you will set up a simulation using this model. The input information specific to this simulation is provided in a process entity. (Note how generic vs. specific information can be separated in different entities in gPROMS.) 8. Create a new process called Sim_buffer_tank To create a new process entity, right-click on the Processes folder in the project tree and select New entity.... In the New Entity dialog box, provide the name for the new entity (e.g. Sim_buffer_tank) and make sure the right type of entity is selected (PROCESS). Leave the Use template? box checked and click OK to create a new process. A new process will appear. Click on the gPROMS language tab of this new process to see the template for the gPROMS language. 9. Tell the simulation which model to use The UNIT section defines which model (or models) will be used in the simulation. In this case we want to perform a simulation with a single instance of the Buffer_tank model. We will refer to this instance with the identifier T101. Remove the PARAMETER section from the process template (we dont need it) and complete the UNIT section by typing the following in the process:

gPROMS model developer course UNIT T101 AS Buffer_tank

10.Set parameter values Provide values for each of the model parameters according to section Parameter values by completing the SET section of the process (you can remove the MONITOR section). Use the WITHIN construct to refer to parameters inside unit T101. SET WITHIN T101 DO area outlet_flowrate_coefficient density END # WITHIN T101

:= 1 ; # m2 := 10 ; # kg/(s.SQRT(m)) := 1000 ; # kg/m3

Remove the EQUATION section from the process template (we are not using it). 11.Assign degrees of freedom Assign a value to the inlet flowrate according to section Degrees of freedom. ASSIGN T101.inlet_mass_flowrate := 20 ; # kg/s

gPROMS model developer course Remove the PRESET and INITIALSELECTOR sections from the template. 12.Provide initial conditions Define the initial state of the model by providing the initial liquid level in the tank according to section Initial conditions. In the INITIAL section, write: INITIAL T101.height = 2.1 ; # m

Remove the SOLUTIONPARAMETERS section from the process template for now. 13.Define the duration of the simulation. The SCHEDULE section defines what to do during a simulation. In this case we want to simulate for 1800 seconds. Write the following to implement this: SCHEDULE CONTINUE FOR 1800

This will make the simulation continue for 1800 time units. You have now completely defined the problem setup and are ready to execute a simulation. 14.Execute the simulation Select the process you just created (Sim_buffer_tank) in the project tree. In the toolbar, click the simulate button ( ). The Simulate dialog box will appear. Accept the default settings and run the simulation by clicking OK.

gPROMS model developer course The execution output appears and gRMS is started. Also, note that a new case is being created this is the blue folder in the project tree). By default, the name of the case is a concatenation of the process name (i.e. Sim_buffer_tank) plus a date and time stamp. 15.Plot the results using gRMS In gRMS (gPROMS Results Management System), create a new twodimensional plot by clicking on the 2D button ( ). An empty plot window will appear. Next, add a line to the plot by clicking the Add line button ( ). In the Add line dialog, expand the variable tree by clicking on the plus signs ( ) and double-click on the variable height. In the line properties dialog, click OK to add the line to the plot area. Close the Add line dialog by clicking Cancel. Explore the formatting options available in gRMS through the Format and Line menus. Now that you have performed a simulation, it is time to explore some of the diagnostics tools available. 16.Modify a copy of the Sim_buffer_tank process and compare the two To do so, copy-paste the Sim_buffer_tank process. Open the copy named Sim_buffer_tank_1 and change the inlet flowrate to 25 kg/s, then run a simulation with the new process. When the simulation has completed, select both Sim_buffer_tank and Sim_buffer_tank_1 in the project tree (keep the control key pressed to select multiple entities) and compare the two entities by going to the menu Tools > Compare. You will see a window with a side-by-side comparison of the two entities, highlighting the differences. 17.Retain the license after execution of the Sim_buffer_tank_1 process to view additional diagnostic information. To do so, run another simulation with the Sim_buffer_tank_1 process, but this time un-tick the option Release license after execution in the Simulate activity dialog. This will enable a range of diagnostic tools. After the simulation has completed, a. Right-click in the Execution Output window and select Create problem report.... Select OK to accept the default options for a problem report. Inspect the equation scaling information in the problem report. b. Right-click in the Execution Output window and select Query equation.... Select equation number 1 (this is the mass balance as you can see from the problem report), then OK. gPROMS will report the equation in symbolic form as well as the values of the variables

gPROMS model developer course it contains, as well as the blocks in which the variables were determined. 18.Explore the structure of the case file created after each simulation. Plot the liquid level in the tank from the variable trajectories in the case. 19.Create a new project based on the case file. To do so, right-click on the case name in the project tree and Click Create gPROMS project. (This enables you to use a previous simulation as a starting point for future work.)

Potrebbero piacerti anche