1 |
REQUIRE "ivpsystem.a4l"; |
2 |
REQUIRE "atoms.a4l"; |
3 |
|
4 |
(* |
5 |
Test case for boundary-monitoring in IDA. |
6 |
|
7 |
This is a second order linear system with a ramp input. The idea is that |
8 |
IDA will re-start when the ramp first starts, then again then the ramp |
9 |
end is reached. This will ensure that discontinuities in derivatives across |
10 |
the jump are managed as well as possible. |
11 |
*) |
12 |
MODEL boundaries; |
13 |
nodes IS_A set OF integer_constant; |
14 |
nodes :== [1..2]; |
15 |
|
16 |
t IS_A time; |
17 |
x[nodes], dx_dt[nodes] IS_A solver_var; (* system states *) |
18 |
u[1] IS_A solver_var; (* input signals *) |
19 |
|
20 |
(* second-order transfer function G(s) = 1 / (1 + s + 0.5 s^2) *) |
21 |
0.5 * dx_dt[1] = u[1] -x[1] - x[2]; |
22 |
dx_dt[2] = x[1]; |
23 |
|
24 |
(* ramp input |
25 |
u = u1 t < t1 |
26 |
u = u2 t > t2 |
27 |
linear t1 < t < t2 |
28 |
*) |
29 |
t1 IS_A solver_var; |
30 |
t2 IS_A solver_var; |
31 |
uisbefore, uisafter IS_A boolean_var; |
32 |
u1,u2 IS_A solver_var; |
33 |
CONDITIONAL |
34 |
ubeforecond: t <= t1; (* mysteriously, I can't make t1 and t2 constants! *) |
35 |
uaftercond: t >= t2; (* and these conditions really don't behave themselves... *) |
36 |
END CONDITIONAL; |
37 |
satbefore: uisbefore == SATISFIED(ubeforecond,1e-8{s}); |
38 |
satend: uisafter == SATISFIED(ubeforecond,1e-8{s}); |
39 |
(* variant equations *) |
40 |
ubefore: u[1] = u1; |
41 |
uduring: u[1] = u1 + (t - t1)*(u2 - u1)/(t2 - t1); |
42 |
uafter: u[1] = u2; |
43 |
(* disjunctive statements *) |
44 |
WHEN (uisbefore,uisafter) |
45 |
CASE TRUE,FALSE: |
46 |
USE ubefore; |
47 |
CASE FALSE,TRUE: |
48 |
USE uafter; |
49 |
CASE FALSE,FALSE: |
50 |
USE uduring; |
51 |
END WHEN; |
52 |
|
53 |
METHODS |
54 |
METHOD ode_init; |
55 |
FOR i IN nodes DO |
56 |
x[i].ode_type := 1; dx_dt[i].ode_type := 2; |
57 |
x[i].ode_id := i; dx_dt[i].ode_id := i; |
58 |
END FOR; |
59 |
END ode_init; |
60 |
METHOD specify; |
61 |
FIX t1,t2; |
62 |
FIX u1,u2; |
63 |
END specify; |
64 |
METHOD values; |
65 |
x[1] := 0; |
66 |
x[2] := 0; |
67 |
t1 := 1 {s}; u1 := 5; |
68 |
t2 := 2 {s}; u2 := 10; |
69 |
END values; |
70 |
METHOD on_load; |
71 |
RUN default_self; |
72 |
RUN reset; |
73 |
RUN values; |
74 |
RUN ode_init; |
75 |
END on_load; |
76 |
END boundaries; |