1 | package ImportInitialValues "Test cases for importing initial values in OpenModelica"
|
---|
2 |
|
---|
3 | partial model BaseModel
|
---|
4 | Real v1;
|
---|
5 | Real v2;
|
---|
6 | Real v3;
|
---|
7 | Real x;
|
---|
8 | parameter Real p1;
|
---|
9 | parameter Real p2 = 2*p1;
|
---|
10 | final Real p3 = 3*p1;
|
---|
11 | equation
|
---|
12 | end BaseModel;
|
---|
13 |
|
---|
14 | model ResultGenerator
|
---|
15 | extends BaseModel(p1 = 7, p2 = 10);
|
---|
16 | equation
|
---|
17 | v1 = 2.8;
|
---|
18 | v2 = 3.9;
|
---|
19 | v3 = 10;
|
---|
20 | der(x) = 0;
|
---|
21 | initial equation
|
---|
22 | x = 4;
|
---|
23 | annotation(
|
---|
24 | experiment(StopTime = 1),
|
---|
25 | __OpenModelica_simulationFlags(r = "initial.mat"));
|
---|
26 | end ResultGenerator;
|
---|
27 |
|
---|
28 | model ImportModel
|
---|
29 | extends BaseModel(
|
---|
30 | v1(start = 14),
|
---|
31 | v2(start = 14),
|
---|
32 | p1 = 1, p2 = 1);
|
---|
33 | equation
|
---|
34 | (v1 - 3)*(v1 + 10)*(v1 - 15) = 0;
|
---|
35 | (v2 - x)*(v2 + 10)*(v2 - 15) = 0;
|
---|
36 | v3 = time;
|
---|
37 | der(x) = -x;
|
---|
38 | initial equation
|
---|
39 | x = 6;
|
---|
40 | end ImportModel;
|
---|
41 |
|
---|
42 | model ImportModelAnnotationInitialEqs
|
---|
43 | extends BaseModel(
|
---|
44 | v1(start = 12),
|
---|
45 | v2(start = 12),
|
---|
46 | p1 = 1, p2 = 1);
|
---|
47 | equation
|
---|
48 | (v1 - 3)*(v1 + 10)*(v1 - 15) = 0;
|
---|
49 | (v2 - x)*(v2 + 10)*(v2 - 15) = 0;
|
---|
50 | v3 = time;
|
---|
51 | der(x) = -x;
|
---|
52 | initial equation
|
---|
53 | x = 6;
|
---|
54 | annotation(__OpenModelica_simulationFlags(iif = "initial.mat"));
|
---|
55 | end ImportModelAnnotationInitialEqs;
|
---|
56 |
|
---|
57 | model ImportModelAnnotationNoInitialEqs
|
---|
58 | extends BaseModel(
|
---|
59 | v1(start = 12),
|
---|
60 | v2(start = 12),
|
---|
61 | p1 = 1, p2 = 1);
|
---|
62 | equation
|
---|
63 | (v1 - 3)*(v1 + 10)*(v1 - 15) = 0;
|
---|
64 | (v2 - x)*(v2 + 10)*(v2 - 15) = 0;
|
---|
65 | v3 = time;
|
---|
66 | der(x) = -x;
|
---|
67 | initial equation
|
---|
68 | x = 6;
|
---|
69 | annotation(__OpenModelica_simulationFlags(iim = "none", iif = "initial.mat"));
|
---|
70 | end ImportModelAnnotationNoInitialEqs;
|
---|
71 | end ImportInitialValues;
|
---|