-
Notifications
You must be signed in to change notification settings - Fork 298
/
SimpleCoolingCycle.mo
86 lines (75 loc) · 2.43 KB
/
SimpleCoolingCycle.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// name: SimpleCoolingCycle
// status: correct
// cflags: -d=newInst -f
type MolarMass = Real(final quantity = "MolarMass");
package PartialMedium
record ThermodynamicState
Real p;
Real T;
end ThermodynamicState;
replaceable partial function specificHeatCapacityCp
input ThermodynamicState state;
output Real cp;
end specificHeatCapacityCp;
end PartialMedium;
package DryAirNasa
extends PartialMedium;
constant T.DataRecord data;
redeclare function extends specificHeatCapacityCp
algorithm
cp := T.Functions.cp_T(data, state.T);
end specificHeatCapacityCp;
end DryAirNasa;
package T
record DataRecord
MolarMass MM;
end DataRecord;
package Functions
function cp_T
input DataRecord data;
input Real T;
output Real cp = 0;
end cp_T;
end Functions;
end T;
model CounterFlowNTU
replaceable package MediumA = PartialMedium;
MediumA.ThermodynamicState state;
protected
Real cpA_in = MediumA.specificHeatCapacityCp(state);
end CounterFlowNTU;
model SimpleCoolingCycle
replaceable package Medium_air = DryAirNasa;
CounterFlowNTU heatExchange_CounterFlowNTU(redeclare package MediumA = Medium_air);
end SimpleCoolingCycle;
// Result:
// package 'SimpleCoolingCycle'
// function 'SimpleCoolingCycle.heatExchange_CounterFlowNTU.MediumA.specificHeatCapacityCp'
// input 'heatExchange_CounterFlowNTU.MediumA.ThermodynamicState' 'state';
// output Real 'cp';
// algorithm
// 'cp' := 'T.Functions.cp_T'('T.DataRecord'('heatExchange_CounterFlowNTU.MediumA.data'.'MM'), 'state'.'T');
// end 'SimpleCoolingCycle.heatExchange_CounterFlowNTU.MediumA.specificHeatCapacityCp';
//
// function 'T.Functions.cp_T'
// input 'T.DataRecord' 'data';
// input Real 'T';
// output Real 'cp' = 0.0;
// end 'T.Functions.cp_T';
//
// record 'heatExchange_CounterFlowNTU.MediumA.ThermodynamicState'
// Real 'p';
// Real 'T';
// end 'heatExchange_CounterFlowNTU.MediumA.ThermodynamicState';
//
// record 'T.DataRecord'
// Real 'MM'(quantity = "MolarMass");
// end 'T.DataRecord';
//
// model 'SimpleCoolingCycle'
// 'heatExchange_CounterFlowNTU.MediumA.ThermodynamicState' 'heatExchange_CounterFlowNTU.state';
// protected
// Real 'heatExchange_CounterFlowNTU.cpA_in' = 'SimpleCoolingCycle.heatExchange_CounterFlowNTU.MediumA.specificHeatCapacityCp'('heatExchange_CounterFlowNTU.state');
// end 'SimpleCoolingCycle';
// end 'SimpleCoolingCycle';
// endResult