Ticket #1805: Test2.mo

File Test2.mo, 1.3 KB (added by anonymous, 12 years ago)
Line 
1within ;
2partial package MyPartialMedium
3 replaceable partial function MyFunction
4 output Modelica.SIunits.SpecificHeatCapacityAtConstantPressure CP "Cp";
5 end MyFunction;
6end MyPartialMedium;
7
8
9package MyMedium1
10 extends MyPartialMedium;
11 redeclare function extends MyFunction
12 algorithm
13 CP:=1;
14 end MyFunction;
15end MyMedium1;
16
17
18package MyMedium2
19 extends MyPartialMedium;
20 redeclare function extends MyFunction
21 algorithm
22 CP:=2;
23 end MyFunction;
24end MyMedium2;
25
26
27model MyComponent
28 replaceable package componentMedium = MyPartialMedium;
29 Real result;
30equation
31 result = componentMedium.MyFunction();
32end MyComponent;
33
34
35model MyModel1
36 replaceable package model1Medium = MyMedium1 constrainedby MyPartialMedium;
37 MyComponent comp(redeclare package componentMedium = model1Medium);
38 Real result;
39equation
40 result = comp.result;
41end MyModel1;
42
43
44model MyModel2
45 replaceable package model2Medium = MyMedium2 constrainedby MyPartialMedium;
46 MyComponent comp(redeclare package componentMedium = model2Medium);
47 Real result;
48equation
49 result = comp.result;
50end MyModel2;
51
52
53model MyModel3
54 MyModel1 model1(redeclare package model1Medium = MyMedium2);
55 Real result;
56equation
57 result = model1.result;
58end MyModel3;
59