Thin-walled tank/Parameterized models
''''Thin-walled tank tutorial
←Return to start
- Introduction
- Adding methods to a model
- Arrays
- Building complex models
- Parameterised models
See also
Introduction
As noted earlier in Building complex models, ASCEND modeling supports a part/whole paradigm. Models contain parts that themselves are instances of other models, ad infinitum. For example, we typically build a process using parts that are reactors, separators, pumps, tanks, and the pipes that connect them. We just built a tank out of sides and ends. One can see and connect to any variable inside a part (e.g., tank.D reaches inside a tank to "see" the tank diameter). By making any two variables in a model be the same variable (ARE_THE_SAME), we can connect up very complex structures. But, and it is a very big "but," constructing models using only these concepts proves to be very difficult unless we just wrote and fully understand the part models.
Modelers must be able to use part definitions that others have written. To do so they should only need to know what the model does and how to interface to it. They should not need to know in gory detail how it does what it does - though, when it does not work as expected, this lack of knowledge could be their undoing.
We can provide the requisite interface to allow easier model reuse in at least two ways: (1) by providing a document or header that tells us exactly how to wire into the model and/or (2) by elevating the variables we need to wire to a special status within the model, e.g., as parameters for the model. ASCEND uses parameterized models.
A parametric interface for a tank model
MODEL tank_end( D WILL_BE distance; A WILL_BE area; ); (* equation *) A=3.1416*D^2/4; END tank_end;
MODEL tank_side; D WILL_BE distance; H WILL_BE distance; A WILL_BE area; ) WHERE ( ); (* equation *) A=3.1416*D*H; END tank_side;
MODEL partitioned_thin_walled_tank; (* variables *) wall_thickness IS_A distance; wall_area IS_A area; wall_vol IS_A volume; metal_density IS_A mass_density; metal_mass IS_A mass; D, H IS_A distance; topend_area, bottomend_area, side_area IS_A area; (* parts *) top IS_A tank_end(D, topend_area); bottom IS_A tank_end(D, bottomend_area); side IS_A tank_side(D, H, side_area); (* equations *) wall_area = topend_area + bottomend_area + side_area; wall_vol = wall_thickness*wall_area; metal_mass = metal_density*wall_vol; METHODS METHOD specify; RUN top.specify; (* fixes diameter *) RUN bottom.specify; (* fixes diameter *) RUN side.specify; (* fixes diameter and height *) FIX metal_thickness; FIX metal_density; END specify; METHOD values; D := 20.0 {cm}; H := D/10.0; wall_thickness := 0.15 {cm}; metal_density := 7.85 {g/cm^3}; END values; END partitioned_thin_walled_tank;