Thin-walled tank/Parameterized models: Difference between revisions
Restored page from Google Cache, uploaded by John Pye |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{thinwalled}} | |||
{{incomplete}} | |||
==Introduction== | ==Introduction== | ||
| Line 18: | Line 8: | ||
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. | 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== | ==A parametric interface for a tank model== | ||
| Line 25: | Line 13: | ||
<source lang="a4c">MODEL tank_end( | <source lang="a4c">MODEL tank_end( | ||
D WILL_BE distance; | D WILL_BE distance; | ||
A WILL_BE area; | A WILL_BE area; | ||
); | ); | ||
| Line 35: | Line 22: | ||
<source lang="a4c">MODEL tank_side; | <source lang="a4c">MODEL tank_side; | ||
D WILL_BE distance; | D WILL_BE distance; | ||
H WILL_BE distance; | H WILL_BE distance; | ||
A WILL_BE area; | A WILL_BE area; | ||
| Line 49: | Line 35: | ||
<source lang="a4c">MODEL partitioned_thin_walled_tank; | <source lang="a4c">MODEL partitioned_thin_walled_tank; | ||
(* variables *) | (* variables *) | ||
wall_thickness IS_A distance; | wall_thickness IS_A distance; | ||
wall_area IS_A area; | wall_area IS_A area; | ||
| Line 61: | Line 46: | ||
(* parts *) | (* parts *) | ||
top IS_A tank_end(D, topend_area); | top IS_A tank_end(D, topend_area); | ||
bottom IS_A tank_end(D, bottomend_area); | bottom IS_A tank_end(D, bottomend_area); | ||
side IS_A tank_side(D, H, side_area); | side IS_A tank_side(D, H, side_area); | ||
(* equations *) | (* equations *) | ||
| Line 76: | Line 59: | ||
METHODS | METHODS | ||
METHOD specify; | METHOD specify; | ||
RUN top.specify; (* fixes diameter *) | RUN top.specify; (* fixes diameter *) | ||
RUN bottom.specify; (* fixes diameter *) | RUN bottom.specify; (* fixes diameter *) | ||
RUN side.specify; (* fixes diameter and height *) | RUN side.specify; (* fixes diameter and height *) | ||
FIX metal_thickness; | FIX metal_thickness; | ||
FIX metal_density; | FIX metal_density; | ||
END specify; | END specify; | ||
METHOD values; | METHOD values; | ||
D := 20.0 {cm}; | D := 20.0 {cm}; | ||
H := D/10.0; | H := D/10.0; | ||
wall_thickness := 0.15 {cm}; | wall_thickness := 0.15 {cm}; | ||
metal_density := 7.85 {g/cm^3}; | metal_density := 7.85 {g/cm^3}; | ||
END values; | END values; | ||
END partitioned_thin_walled_tank;</source> | END partitioned_thin_walled_tank;</source> | ||
[[Category:Incomplete]] | |||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
Latest revision as of 11:48, 13 November 2011
Thin-walled tank tutorial
←Return to start
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;