/[ascend]/trunk/models/distance_calc.a4c
ViewVC logotype

Annotation of /trunk/models/distance_calc.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2649 - (hide annotations) (download) (as text)
Wed Dec 12 12:39:25 2012 UTC (11 years, 6 months ago) by jpye
File MIME type: text/x-ascend
File size: 1805 byte(s)
Fixing GPL header, removing postal address (rpmlint incorrect-fsf-address)
1 johnpye 1165 (* ASCEND modelling environment
2     Copyright (C) 1997 Carnegie Mellon University
3     Copyright (C) 2006 Carnegie Mellon University
4    
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2, or (at your option)
8     any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License
16 jpye 2649 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 johnpye 1165 *)
18 aw0a 1 REQUIRE "atoms.a4l";
19     (*
20 johnpye 1165 This model is the second example in "Solved simple models with ASCEND."
21 aw0a 1
22 johnpye 1165 @TODO add a citation and/or brief problem description
23    
24     by Arthur Westerberg, 1997.
25     *)
26    
27 aw0a 1 MODEL travel_distance;
28 johnpye 1165 kmax IS_A integer_constant;
29     v[1..2*kmax+1] IS_A speed;
30     delta_time IS_A time;
31     d IS_A distance;
32 aw0a 1
33 johnpye 1165 d = SUM[
34     v[2*k-1] + 4*v[2*k] + v[2*k+1]
35     SUCH_THAT k IN [1..kmax]
36     ] * delta_time/6;
37 aw0a 1
38     END travel_distance;
39    
40 johnpye 1165 MODEL distance_calc REFINES travel_distance;
41 aw0a 1 kmax :== 5;
42    
43     METHODS
44    
45     METHOD specify;
46 johnpye 576 FIX v[1..2*kmax+1];
47     FIX delta_time;
48 aw0a 1 END specify;
49    
50     METHOD values;
51     v[1] := 100 {ft/min};
52     v[2] := 120 {ft/min};
53     v[3] := 130 {ft/min};
54     v[4] := 135 {ft/min};
55     v[5] := 140 {ft/min};
56     v[6] := 160 {ft/min};
57     v[7] := 180 {ft/min};
58     v[8] := 210 {ft/min};
59     v[9] := 240 {ft/min};
60     v[10] := 220 {ft/min};
61     v[11] := 200 {ft/min};
62     delta_time := 10 {s};
63     END values;
64    
65 johnpye 1165 METHOD on_load;
66     RUN reset;
67     RUN values;
68     END on_load;
69 aw0a 1
70 johnpye 1165 METHOD self_test;
71     ASSERT abs(d - 42.84 {m}) < 1 {cm};
72     END self_test;
73    
74     END distance_calc;
75    
76    

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22