Parent Directory | Revision Log

Revision **1294** -
(**show annotations**)
(**download**)
(**as text**)

*Mon Feb 26 22:44:04 2007 UTC*
(14 years, 3 months ago)
by *johnpye*

File MIME type: text/x-ascend

File size: 3140 byte(s)

File MIME type: text/x-ascend

File size: 3140 byte(s)

Added build() inside Simulation::check() function. Updated syntax/comments in vessel, vesselPlain models (need to revisit the tutorial now).

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, write to the Free Software |

16 | Foundation, Inc., 59 Temple Place - Suite 330, |

17 | Boston, MA 02111-1307, USA. |

18 | *) |

19 | REQUIRE "atoms.a4l"; (* => atoms.a4l, measures.a4l, system.a4l, basemodel.a4l *) |

20 | (* |

21 | by Arthur W Westerberg, Benjamin A Allan and John Pye |

22 | |

23 | This file contains two model declarations. The first is a 'full-blown' |

24 | vessel model build by extending the declaration from vesselPlain.a4c. This |

25 | new model contains a number of initialisation routines that ensure that |

26 | the model can easily be put into a solvable state. The model also contains |

27 | a 'values' method that defines the base case for which we are solving. |

28 | |

29 | The second model in this file is an optimisation problem. Here, we are |

30 | REFINING the earlier 'vessel' model with the addition of an objective |

31 | function (see the 'OPTIMIZE' statement). We can then load the model and |

32 | optimise it. |

33 | *) |

34 | |

35 | MODEL vessel; |

36 | |

37 | (* variables *) |

38 | side_area, end_area IS_A area; |

39 | vessel_vol, wall_vol IS_A volume; |

40 | wall_thickness, H, D IS_A distance; |

41 | H_to_D_ratio IS_A factor; |

42 | metal_density IS_A mass_density; |

43 | metal_mass IS_A mass; |

44 | |

45 | (* equations *) |

46 | FlatEnds: end_area = 1{PI} * D^2 / 4; |

47 | Sides: side_area = 1{PI} * D * H; |

48 | Cylinder: vessel_vol = end_area * H; |

49 | Metal_volume: (side_area + 2 * end_area) * wall_thickness = wall_vol; |

50 | HD_definition: D * H_to_D_ratio = H; |

51 | VesselMass: metal_mass = metal_density * wall_vol; |

52 | |

53 | METHODS |

54 | |

55 | METHOD default; |

56 | H_to_D_ratio := 2; |

57 | END default; |

58 | |

59 | METHOD specify; |

60 | FIX vessel_vol; |

61 | FIX H_to_D_ratio; |

62 | FIX wall_thickness; |

63 | FIX metal_density; |

64 | END specify; |

65 | |

66 | METHOD values; |

67 | vessel_vol := 250 {ft^3}; |

68 | wall_thickness := 5 {mm}; |

69 | metal_density := 13000 {kg/m^3}; |

70 | END values; |

71 | |

72 | METHOD on_load; |

73 | RUN default_self; |

74 | RUN reset; |

75 | RUN values; |

76 | END on_load; |

77 | |

78 | END vessel; |

79 | |

80 | MODEL vessel_optimize REFINES vessel; |

81 | |

82 | cost IS_A monetary_unit; |

83 | a IS_A cost_per_volume; |

84 | |

85 | obj1def: cost = a * wall_thickness * (side_area + 2*(4/1{PI})*end_area); |

86 | |

87 | obj1: MINIMIZE cost; |

88 | |

89 | METHODS |

90 | |

91 | METHOD specify; |

92 | FIX vessel_vol; |

93 | FIX wall_thickness; |

94 | FIX metal_density; |

95 | FIX a; |

96 | END specify; |

97 | |

98 | METHOD values; |

99 | vessel_vol := 250 {ft^3}; |

100 | wall_thickness := 5 {mm}; |

101 | metal_density := 13000 {kg/m^3}; |

102 | |

103 | (* a is the cost per cubic foot of metal. rather arbitrary. *) |

104 | a := 10 {USD/m^3}; |

105 | END values; |

106 | |

107 | METHOD on_load; |

108 | RUN default_self; |

109 | RUN reset; |

110 | RUN values; |

111 | END on_load; |

112 | |

113 | END vessel_optimize; |

john.pye@anu.edu.au | ViewVC Help |

Powered by ViewVC 1.1.22 |