MODEL

From ASCEND
Jump to: navigation, search

This text has been copied from the PDF documentation and subsequently modified.

An ASCEND model has a declarative part and an optional procedural part headed by the METHODS word. Models are essentially containers for variables and relations.

MODEL foo;
    (* statements about foo go here*)
METHODS
    (* METHODs for foo go here*)

END foo;

The first part of the MODEL contains variable declarations and equations ('relations'). The second part contains METHODS, which are used to manipulate and initialise the model, and also to perform any other reporting and procedural roles that the user can think of.

A model can be built up as a refinement simpler 'base' models, using the REFINES statement:

MODEL bar REFINES foo;
    (*additional statements about foo *)
METHODS
    (* additional METHODs for bar *)

END bar;

Models can also be 'parameterised', so that they work a bit like 'functions' in C, Python and other languages. In other words, they only work if you pass them some parameters when you instantiate them. A flowsheet model can then be built up using a set of parameterised (and reusable, general purpose) sub-models. An example is

MODEL column(

	ntrays WILL_BE integer_constant;
	components IS_A set of symbol_constant;

);
	stage[1..ntrays] IS_A simple_tray;
END column;

MODEL flowsheet;
	tower4size IS_A integer_constant;
	tower4size :== 22;

	ct IS_A column(tower4size,[c5,c6]);
	(* additional flowsheet statements *)
END flowsheet;

In this example, the column model takes the first argument, ntrays, by reference, using the WILL_BE keyword. That is, ct.ntrays is an alias for the flowsheet instance tower4size. tower4size must be compiled and assigned a value before we will attempt to compile the column model instance ct. The second argument is taken by value, [c5,c6], and assigned to components, a column part that was declared with IS_A in the parameter list. There is only one name for this set, ct.components. Note that in the flowsheet model there is no part that is a set of symbol_constant.

The use of parameters in ASCEND modeling requires some thought. Beginners may wish to create new models without parameters until they are comfortable using the existing parameterized library definitions. Parameters are intended to support model reuse and efficient compilation which are not issues in the very earliest phase of developing novel models.

See also Object-oriented modelling for more examples of how to build up complex models.

See METHODS for how to use METHOD statements to initialise your model so that it is ready to solve.