SWITCH
From ASCEND
This article is incomplete or needs expanding. Please help out by adding your comments.
The SWITCH statement is used to perform logical branching within METHODs. This, for example, allows a model to be initialised in different ways, depending on the value of certain variables in the model. Using SWITCH is one way of doing limited conditional modelling without a conditional solver like CMSlv.
From the user's manual:
- Essentially roughly equivalent to the C switch statement, except that ASCEND allows wildcard matches, allows any number of controlling variables to be given in a list, and assumes BREAK at the end of each CASE.
An example from models/ben/benHGthermo.a4l:
METHOD specify; RUN td_homogeneous_mixture::specify; SWITCH (options.mixture_thermo_correlation) CASE 'UNIFAC': FREE partial[ds.components].V; FREE partial[ds.components].H; FREE partial[ds.components].G; CASE 'Wilson': FREE partial[ds.components].V; FREE partial[ds.components].H; FREE partial[ds.components].G; END SWITCH; END specify;

