Section L2.1: Philosophy of Structured Modelling

Models can in principle be written in any computer language. A large number of special purpose languages have been developed to represent the steady state behaviour of process flowsheets. Rather fewer specialised languages are available for modelling at the level with which most of this course in concerned, and the majority of process models are in practice described using general purpose computer languages.

One of the most widely used general languages historically is Fortran (section L3.1), and many large models, particularly of special purpose process units such as reactors will be found in this language. We have given a number of examples of algorithms in Fortran.

A very large number of models in the last few years have been written to run in spreadsheet systems. The spreadsheet is extremely convenient, as it can be found on every PC and most palmtops. However, spreadsheets have several very serious disadvantages:

As a result of the above, manually generated spreadsheets cannot be regarded as a safe modelling tool! The most important property which a model must have is that it should be UNDERSTANDABLE. This is much more important than that it should be correct!

The Elements of a Modelling Procedure

The most important function of a modelling procedure is that it should encourage the production of readable models. All models contain the following elements which must be represented in any modelling language or system: Additionally it is highly convenient to be able to represent: The definition of the model does not itself have to say anything about how the model is to be solved, although it may be convenient to include instructions about the nature of the solution, i.e. is it a steady state, unsteady state or optimisation problem which is to be solved. In addition it will usually be necessary to provide various `housekeeping' information about what length of time or degree of precision is required, and so forth. This is not strictly speaking part of the model itself.

The model itself should be easy to read and self explanatory. In addition, a modelling system may usefully provide additional and/or summarised information information about the model.

A WWW Form-based Modelling `Language'

Our system contains the three main elements above. The model is written by typing into boxes on a web browser for. In general each model element should be written on a separate line, but they can also be written on one line separated by semicolons or commas if this makes the model more readable.

A very similar format is used to model both steady state systems, represented by algebraic equations, and dynamic systems represented by differential-algebraic equations. The discussion below pertains specifically to algebraic equations.

Refer to the example here.


The user specifies the variables in the model by listing them in the variables area.

The ability to give user specified names to variables is a key feature of any modelling language, and the choice of `meaningful' names is an important factor in making a model comprehensible.

For example, a very simple model is to be used to calculate the mass density in kg/m³ of an ideal gas at a given Kelvin temperature and pressure in atmospheres. We are also given the molecular weight of the gas. We decide that we need variables to represent the specific molar volume and mass and molar densities. Although the pressure is given, and is not an unknown or variable (it is a parameter, see below) the Gas Law requires pressure in pascals which the model will require to calculate, so we require a variable for this pressure, giving 4 variables in all. The model instructions are then:

 romolar, romass,
Note the use of both standard symbols for standard quantities, e.g. P for pressure, and mnemonic names for other quantities.


Parameter is a term used by modellers to mean a `variable constant', that is a quantity which is known, but which the modeller may wish to change. Here the specified temperature, pressure and gas molecular weight are parameters. They are introduced into the model in the Parameter box. However parameters must be given values, which is done as in the example below.
 MW = 16 
 T = 273 
 Patm = 1.0 
 R = 8.314  
Note the appearance of R, the gas constant in this section. strictly, R is a true constant, having a fixed value, but most modelling languages do not distinguish these from parameters.

The modelling languages requires initial values for parameters, but these can be changed once the model has been generated. Do not however change the values of constants like R!


Equations are written in normal `computer algebra' notation in the Equation area.

The simplest version of the model generator requires that all equations be written as formulas, and that every unknown (variable) appears once and only once on the LHS of a formula. This approach is discussed in the general introduction to algebraic equations (section 3.1). The equations have to be ordered as described in section 3.2, so that no variable appears on the RHS of the an equals sign until after it has appeared on the LHS and so been given a value.

It will not always be possible to do this; in these cases a trial-and-error or iterative solution will be required, as described later.

The equations section for this model is as follows:

 vmolar = R*T/P    
 romolar = 1/ vmolar  
 romass = romolar*MW/1000 
 P = Patm * 101300


The only additional information required for this model is to tell the solver that no iteration is required and so no variable need be guessed or `torn'.

This is indicated by typing the word none in the Tear variable box. Ignore the Bounds boxes meantime as these are only required for iterative solutions.

Note that all names used in the model must be a combination of letters and number only , and must start with a letter. Note that upper and lower case letters are not the same.

Solving the model

Click the Solve button. A new window will pop up with the solution, i.e. a list of the variables and their values.

If you want to put these values into a report, you can copy and paste them from this window.

Complete Model

To get a copy of the complete model click the Show Model Data button>. You can copy and paste the model listing from the popup window into a report. Note that for reasons to do with web browser security you cannot save these popup windows from the browser, only copy and paste from the boxes inside them.

Iterative Solution of Algebraic Models

Before trying to understand this type of model you should have worked through Section 3.2: Simple Ordered Sets of Equations .

Consider first a trivial model described by the single equation:

x + log x = 0
Although simple this equation has no analytical solution. It must therefore be solved iteratively by trial-and-error using one of the methods described in Section 3.3. For a single equation the bisection method is usually the simplest, and can be used with the single eqaution solver here.

The user has to estimate and specify bounds on the solution, here set to 0.0001 (why not zero?) and 10. Click the Solve button and you will see the path followed to the solution in the lower box and also plotted as points on the right.

Most real problems involve many equations, most of which, unlike the ideal gas example above, cannot be solved without iteration. But as described in Section 3.2 many problems can be manipulated so that iteration on only one of the variables is required. (However, there are still problems which would require trial-and-error solution on more than one variable; other methods have to be used for these.)

If you return to the ordered equation solver and clich the Example Model 2 button you will get a model consisting of the equations:

y = 3 + x
y - x + z = 0
Here x and y are unknown variables and z is a parameter having the value 0.1.

As described in Section 3.2 all but one of the equations must be written as formulas, each with a different variable on the LHS. The final consists of an expression whose value is to be reduced to zero by the solution procedure, This must be written in the form:

Func = expression
The variable which does not appear on the LHS of an equals sign is the tear variable whose value has to be determined by the solver. As with the single equation solver, you must estimate and specify bounds on its value. This information is provided by entries in the Tear variable and bounds section of the model.

Click the Solve button and the popup window will display values of all the variables and also the function (the expression to be reduced to zero) as the solution proceeds. Scroll down to be bottom to see the final, and so most accurate, solution values.

Modelling Dynamic Systems with Differential Algebraic Equations

The use of a similar tool to model DAE systems is described in section L2.3

Return to Modelling Lab

Course Organiser
Last Modified 2/9/00