1 |
(* ASCEND modelling environment |
2 |
Copyright (C) 1998, 2007 Carnegie Mellon University |
3 |
|
4 |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2, or (at your option) |
7 |
any later version. |
8 |
|
9 |
This program is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
13 |
|
14 |
You should have received a copy of the GNU General Public License |
15 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 |
*) |
17 |
REQUIRE "atoms.a4l"; |
18 |
REQUIRE "plot.a4l"; |
19 |
(* |
20 |
by Arthur W. Westerberg |
21 |
If using the Tcl/Tk GUI, see the accompanying vesselPlot.a4s file. |
22 |
*) |
23 |
|
24 |
(* a PARAMETERISED version of the vessel model developed earlier... *) |
25 |
MODEL vessel( |
26 |
vessel_vol WILL_BE volume; |
27 |
wall_thickness WILL_BE distance; |
28 |
metal_density WILL_BE mass_density; |
29 |
H_to_D_ratio WILL_BE factor; |
30 |
metal_mass WILL_BE mass; |
31 |
); |
32 |
|
33 |
NOTES 'purpose' SELF { |
34 |
This model relates the mass of metal in the walls to the diameter |
35 |
and height of a thin-walled storage vessel. The vessel is cylindrical |
36 |
with two flat ends. Extensive documentation exists for this model to |
37 |
teach a new user of ascend how to write, debug, and run ASCEND |
38 |
models. |
39 |
} |
40 |
END NOTES; |
41 |
|
42 |
(* variables *) |
43 |
side_area, end_area IS_A area; |
44 |
wall_vol IS_A volume; |
45 |
H, D IS_A distance; |
46 |
|
47 |
(* equations *) |
48 |
FlatEnds: end_area = 1{PI} * D^2 / 4; |
49 |
Sides: side_area = 1{PI} * D * H; |
50 |
Cylinder: vessel_vol = end_area * H; |
51 |
Metal_volume: (side_area + 2 * end_area) * wall_thickness = wall_vol; |
52 |
HD_definition: D * H_to_D_ratio = H; |
53 |
VesselMass: metal_mass = metal_density * wall_vol; |
54 |
|
55 |
METHODS |
56 |
METHOD default_self; |
57 |
D := 1 {m}; |
58 |
H := 1 {m}; |
59 |
END default_self; |
60 |
|
61 |
METHOD specify; |
62 |
FIX vessel_vol; |
63 |
FIX H_to_D_ratio; |
64 |
FIX wall_thickness; |
65 |
FIX metal_density; |
66 |
END specify; |
67 |
|
68 |
METHOD values; |
69 |
H_to_D_ratio := 2; |
70 |
vessel_vol := 250 {ft^3}; |
71 |
wall_thickness := 5 {mm}; |
72 |
metal_density := 5000 {kg/m^3}; |
73 |
END values; |
74 |
END vessel; |
75 |
|
76 |
(* |
77 |
This model tabulates a set of parametric 'vessel' objects and loads the |
78 |
results into a data structure ('plt_curve') that ASCEND understands and |
79 |
can plot graphically. |
80 |
*) |
81 |
MODEL vesselPlot; |
82 |
vessel_volume IS_A volume; |
83 |
wall_thickness IS_A distance; |
84 |
metal_density IS_A mass_density; |
85 |
|
86 |
n_entries IS_A integer_constant; |
87 |
n_entries :== 20; |
88 |
|
89 |
H_to_D_ratio[1..n_entries] IS_A factor; |
90 |
metal_mass[1..n_entries] IS_A mass; |
91 |
|
92 |
FOR i IN [1..n_entries] CREATE |
93 |
v[i] IS_A vessel(vessel_volume, wall_thickness, |
94 |
metal_density, H_to_D_ratio[i], metal_mass[i]); |
95 |
END FOR; |
96 |
|
97 |
CurveSet IS_A set OF symbol_constant; |
98 |
CurveSet :== ['5 mm']; |
99 |
|
100 |
Curves['5 mm'] IS_A plt_curve([1..n_entries], metal_mass, |
101 |
H_to_D_ratio); |
102 |
|
103 |
massVSratio IS_A plt_plot_symbol(CurveSet, Curves); |
104 |
|
105 |
METHODS |
106 |
|
107 |
METHOD default_self; |
108 |
(* set the title for the plot and the labels for the ordinate and abscissa |
109 |
*) |
110 |
massVSratio.title := |
111 |
'Metal mass of the walls vs H to D ratio for a thin-walled cylindrical vessel'; |
112 |
massVSratio.XLabel := 'H to D ratio'; |
113 |
massVSratio.YLabel := 'metal mass IN kg/m^3'; |
114 |
END default_self; |
115 |
|
116 |
METHOD specify; |
117 |
RUN v[1..n_entries].specify; |
118 |
END specify; |
119 |
|
120 |
METHOD values; |
121 |
vessel_volume := 250 {ft^3}; |
122 |
wall_thickness := 5 {mm}; |
123 |
metal_density := 5000 {kg/m^3}; |
124 |
FOR i IN [1..n_entries] DO |
125 |
H_to_D_ratio[i] := i/10.0; |
126 |
END FOR; |
127 |
END values; |
128 |
|
129 |
METHOD on_load; |
130 |
RUN default_self; |
131 |
RUN reset; |
132 |
RUN values; |
133 |
END on_load; |
134 |
|
135 |
END vesselPlot; |