-
Notifications
You must be signed in to change notification settings - Fork 297
/
TestFalseIterationNLS.mos
254 lines (247 loc) · 7.52 KB
/
TestFalseIterationNLS.mos
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// name: TestFalseIterationNLS
// status: correct
// cflags: -d=-newInst
//
// Ticket 4046
//
loadModel(Modelica, {"3.2.3"}); getErrorString();
loadString("
model TestFalseIterationNLS
Modelica.SIunits.Pressure p;
Modelica.SIunits.Temperature T;
//Pure Component Properties
Modelica.SIunits.PartialPressure p_s \"Saturation partial pressure of condensing component\";
Modelica.SIunits.SpecificEnthalpy delta_hv \"Specific enthalpy of vaporation of condensing component\";
Modelica.SIunits.SpecificEnthalpy delta_hd \"Specific enthalpy of desublimation of condensing component\";
parameter Integer nc=5;
Modelica.SIunits.SpecificEnthalpy h_i[nc];
equation
p_s = 4e6*time;
T = 273.15 + time * 10;
(p_s, delta_hv, delta_hd, h_i) = pureComponentProperties_pTnc(p, T, nc);
end TestFalseIterationNLS;
function pureComponentProperties_pTnc
input Modelica.SIunits.AbsolutePressure p \"Pressure\";
input Modelica.SIunits.Temperature T \"Temperature\";
input Integer nc \"Number of components\";
output Modelica.SIunits.PartialPressure ppS \"Saturation partial pressure of condensing component\";
output Modelica.SIunits.SpecificEnthalpy delta_hv \"Specific enthalpy of vaporation of condensing component\";
output Modelica.SIunits.SpecificEnthalpy delta_hd \"Specific enthalpy of desublimation of condensing component\";
output Modelica.SIunits.SpecificEnthalpy h_idealGas[nc] \"Specific enthalpy of theoretical pure component ideal gas state\";
external \"C\" TILMedia_Gas_pureComponentProperties_pT(p, T, ppS, delta_hv, delta_hd, h_idealGas) annotation(Include=\"
void TILMedia_Gas_pureComponentProperties_pT(double p, double T, double *ppS, double *delta_hv, double *delta_hd, double *h_idealGas){
*ppS = 0.1*p;
*delta_hv = -1;
*delta_hd = -1;
}
\");
end pureComponentProperties_pTnc;
"); getErrorString();
setCommandLineOptions("-d=dumpSimCode"); getErrorString();
simulate(TestFalseIterationNLS); getErrorString();
val(p, 0.0); getErrorString();
val(delta_hv, 0.0); getErrorString();
val(delta_hd, 0.0); getErrorString();
val(h_i[1], 0.0); getErrorString();
val(h_i[2], 0.0); getErrorString();
val(h_i[3], 0.0); getErrorString();
val(h_i[4], 0.0); getErrorString();
val(h_i[5], 0.0); getErrorString();
val(p, 1.0); getErrorString();
val(delta_hv, 1.0); getErrorString();
val(delta_hd, 1.0); getErrorString();
val(h_i[1], 1.0); getErrorString();
val(h_i[2], 1.0); getErrorString();
val(h_i[3], 1.0); getErrorString();
val(h_i[4], 1.0); getErrorString();
val(h_i[5], 1.0); getErrorString();
// Result:
// true
// ""
// true
// ""
// true
// ""
//
//
// *********************
// * SimCode Equations *
// *********************
//
//
// allEquations:
// ========================================
//
// 6: T=273.15 + 10.0 * time [Real]
// 7: p_s=4e6 * time [Real]
// 10: (NONLINEAR) index:1 jacobian: false
// crefs: p
// 8: ($TMP_pureComponentProperties__pTnc8.p_s, delta_hv, delta_hd, h_i) := pureComponentProperties_pTnc(p, T, 5);
//
// 9: $TMP_pureComponentProperties__pTnc8.p_s - p_s (RESIDUAL)
//
// ========================================
//
//
//
// odeEquations (0 systems):
// ========================================
// ========================================
//
//
//
// algebraicEquations (1 systems):
// ========================================
// 6: T=273.15 + 10.0 * time [Real]
// 7: p_s=4e6 * time [Real]
// 10: (NONLINEAR) index:1 jacobian: false
// crefs: p
// 8: ($TMP_pureComponentProperties__pTnc8.p_s, delta_hv, delta_hd, h_i) := pureComponentProperties_pTnc(p, T, 5);
//
// 9: $TMP_pureComponentProperties__pTnc8.p_s - p_s (RESIDUAL)
//
// ========================================
//
//
// clockPartitions (0 systems):
//
// ========================================
//
//
//
// initialEquations: (3)
// ========================================
// 1: alias of 7
// 2: alias of 6
// 5: (NONLINEAR) index:0 jacobian: false
// crefs: p
// 3: ($TMP_pureComponentProperties__pTnc3.p_s, delta_hv, delta_hd, h_i) := pureComponentProperties_pTnc(p, T, 5);
//
// 4: $TMP_pureComponentProperties__pTnc3.p_s - p_s (RESIDUAL)
//
// ========================================
//
//
//
// initialEquations_lambda0: (0)
// ========================================
//
// removedInitialEquations:
// ========================================
//
// startValueEquations:
// ========================================
//
// nominalValueEquations:
// ========================================
//
// minValueEquations:
// ========================================
//
// maxValueEquations:
// ========================================
//
// parameterEquations:
// ========================================
// 11: nc=5 [Integer]
//
// removedEquations:
// ========================================
//
// algorithmAndEquationAsserts:
// ========================================
// 12: assert(T >= 0.0, "Variable violating min constraint: 0.0 <= T, has value: " + String(T, "g"));
//
// 13: assert(p_s >= 0.0, "Variable violating min constraint: 0.0 <= p_s, has value: " + String(p_s, "g"));
//
//
// equationsForZeroCrossings:
// ========================================
//
// generic calls:
// ========================================
//
// jacobianEquations:
// ========================================
//
// jacobianMatrices:
// ========================================
// Jacobian idx: 0
//
// Jacobian idx: 1
//
// Jacobian idx: 2
//
// Jacobian idx: 3
//
// Jacobian idx: 4
//
// Jacobian idx: 5
//
//
// modelInfo:
// ========================================
// algVars (12)
// ----------------------
// index:0: $TMP_pureComponentProperties__pTnc3.p_s (no alias) protected hideResult initial: no arrCref index:(1) []
// index:1: $TMP_pureComponentProperties__pTnc8.p_s (no alias) protected hideResult initial: no arrCref index:(2) []
// index:2: T (no alias) initial: 288.15 no arrCref index:(3) []
// index:3: delta_hd (no alias) initial: no arrCref index:(4) []
// index:4: delta_hv (no alias) initial: no arrCref index:(5) []
// index:5: h_i[1] (no alias) initial: arrCref:h_i index:(6) [5]
// index:6: h_i[2] (no alias) initial: no arrCref index:(7) [5]
// index:7: h_i[3] (no alias) initial: no arrCref index:(8) [5]
// index:8: h_i[4] (no alias) initial: no arrCref index:(9) [5]
// index:9: h_i[5] (no alias) initial: no arrCref index:(10) [5]
// index:10: p (no alias) initial: no arrCref index:(11) []
// index:11: p_s (no alias) initial: 0.0 no arrCref index:(12) []
// intParamVars
// ----------------------
// index:0: nc (no alias) initial: 5 no arrCref index:(13) []
// functions:
// -----------
//
// External Function: pureComponentProperties_pTnc
// outVars: ppS (Real, ) , delta_hv (Real, ) , delta_hd (Real, ) , h_idealGas (Real, ) ,
// record SimulationResult
// resultFile = "TestFalseIterationNLS_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'TestFalseIterationNLS', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "[<interactive>:20:3-20:42:writable] Warning: Unused input variable nc in function .pureComponentProperties_pTnc.
// "
// 0.0
// ""
// -1.0
// ""
// -1.0
// ""
// 6.95244340847174e-310
// ""
// 0.0
// ""
// 0.0
// ""
// 0.0
// ""
// 0.0
// ""
// 4e7
// ""
// -1.0
// ""
// -1.0
// ""
// 6.95244341398394e-310
// ""
// 0.0
// ""
// 0.0
// ""
// 0.0
// ""
// 0.0
// ""
// endResult