/[ascend]/branches/ksenija2/models/ksenija/bball_event3.a4c
ViewVC logotype

Contents of /branches/ksenija2/models/ksenija/bball_event3.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2867 - (show annotations) (download) (as text)
Mon Mar 23 02:31:01 2015 UTC (7 years, 3 months ago) by jpye
File MIME type: text/x-ascend
File size: 1306 byte(s)
minor changes to debug output.
comments relating to disused var flags.

1 REQUIRE "ivpsystem.a4l";
2 REQUIRE "atoms.a4l";
3
4 (* The Modelica version of the bouncing ball model. *)
5
6 (* Suggested integrator settings for this model, from test_idaevent.c:
7 integrator_set_minstep(integ,0.00001);
8 integrator_set_maxstep(integ,0.01);
9 integrator_set_stepzero(integ,0.0001);
10 integrator_set_maxsubsteps(integ,200);
11 SET_LINEAR_SAMPLELIST(0., 60., 100);
12 *)
13
14 MODEL bball_event3;
15
16 y, r IS_A distance;
17 v IS_A speed;
18 g IS_A acceleration;
19 switch, flying IS_A boolean_var;
20 t IS_A time;
21 INDEPENDENT t;
22 DERIVATIVE OF y, v;
23 PREVIOUS v, y;
24
25 gravity: der(v) = -1*g;
26 diff_eq: v = der(y);
27 stop: der(v) = 0;
28
29 bnd: v = -pre(v)*0.9;
30
31 CONDITIONAL
32 boundary: y > r;
33 speed: v >= 0;
34 END CONDITIONAL;
35
36 switch == NOT SATISFIED(boundary);
37 flying == SATISFIED(boundary) OR SATISFIED(speed);
38
39 ev1: EVENT(switch)
40 CASE TRUE: USE bnd;
41 END EVENT;
42
43 WHEN(flying)
44 CASE TRUE: USE gravity;
45 CASE FALSE: USE stop;
46 END WHEN;
47
48 METHODS
49 METHOD obs_init;
50 y.obs_id := 1;
51 flying.obs_id := 2;
52 END obs_init;
53 METHOD values;
54 FIX r, g;
55 g := 9.8 {m/s^2};
56 r := 10 {m};
57
58 y := 40 {m};
59 v := 0 {m/s};
60 der(v,t) := 0 {m/s^2};
61 t := 0 {s};
62 switch := FALSE;
63 flying := TRUE;
64 END values;
65 METHOD on_load;
66 RUN values;
67 RUN obs_init;
68 END on_load;
69 END bball_event3;

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