source: branches/dev-5819/Compiler/FmiXMLCodeGen/test/modelica/FmiXMLTests.mo @ 13651

Last change on this file since 13651 was 13651, checked in by randersson, 2 months ago

#5819 Merged trunk into branch

File size: 103.0 KB
Line 
1/*
2    Copyright (C) 2014 Modelon AB
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, version 3 of the License.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program.  If not, see <http://www.gnu.org/licenses/>.
15*/
16
17package FmiXMLTests
18
19model DisplayUnit1
20    type A = Real(unit="N", displayUnit="kN");
21    A a = time;
22    Real b(unit="J", displayUnit="kW.h") = 2 * time;
23
24    annotation(__JModelica(UnitTesting(tests={
25        FmiXMLCodeGenTestCase(
26            name="DisplayUnit1",
27            description="Check that offset & gain are not generated incorrectly for units",
28            fmi_version="1.0",
29            template="$unitDefinitions$",
30            generatedCode="
31<UnitDefinitions>
32    <BaseUnit unit=\"N\">
33        <DisplayUnitDefinition displayUnit=\"kN\" gain=\"0.001\" />
34    </BaseUnit>
35    <BaseUnit unit=\"J\">
36        <DisplayUnitDefinition displayUnit=\"kW.h\" gain=\"2.7777777777777776E-7\" />
37    </BaseUnit>
38</UnitDefinitions>
39")})));
40end DisplayUnit1;
41
42model DisplayUnit2
43    type A = Real(unit="N", displayUnit="kN");
44    A a = time;
45    Real b(unit="J") = 2 * time;
46
47    annotation(__JModelica(UnitTesting(tests={
48        FmiXMLCodeGenTestCase(
49            name="DisplayUnit2",
50            description="Check that base units without display units are generated",
51            fmi_version="1.0",
52            template="$unitDefinitions$",
53            generatedCode="
54<UnitDefinitions>
55    <BaseUnit unit=\"N\">
56        <DisplayUnitDefinition displayUnit=\"kN\" gain=\"0.001\" />
57    </BaseUnit>
58    <BaseUnit unit=\"J\">
59    </BaseUnit>
60</UnitDefinitions>
61")})));
62end DisplayUnit2;
63
64model DisplayUnit3
65    type A = Real(unit="N", displayUnit="kN");
66    A a = time;
67    Real b(unit="J", displayUnit="kW.h") = 2 * time;
68
69    annotation(__JModelica(UnitTesting(tests={
70        FmiXMLCodeGenTestCase(
71            name="DisplayUnit3",
72            description="Check that offset & gain are not generated incorrectly for units",
73            fmi_version="2.0",
74            template="$unitDefinitions$",
75            generatedCode="
76<UnitDefinitions>
77    <Unit name=\"N\">
78        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" />
79        <DisplayUnit name=\"kN\" factor=\"0.001\" />
80    </Unit>
81    <Unit name=\"J\">
82        <BaseUnit m=\"2\" s=\"-2\" kg=\"1\" />
83        <DisplayUnit name=\"kW.h\" factor=\"2.7777777777777776E-7\" />
84    </Unit>
85</UnitDefinitions>
86")})));
87end DisplayUnit3;
88
89model DisplayUnit4
90    type A = Real(unit="N", displayUnit="kN");
91    A a = time;
92    Real b(unit="J") = 2 * time;
93
94    annotation(__JModelica(UnitTesting(tests={
95        FmiXMLCodeGenTestCase(
96            name="DisplayUnit4",
97            description="Check that base units without display units are generated",
98            fmi_version="2.0",
99            template="$unitDefinitions$",
100            generatedCode="
101<UnitDefinitions>
102    <Unit name=\"N\">
103        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" />
104        <DisplayUnit name=\"kN\" factor=\"0.001\" />
105    </Unit>
106    <Unit name=\"J\">
107        <BaseUnit m=\"2\" s=\"-2\" kg=\"1\" />
108    </Unit>
109</UnitDefinitions>
110")})));
111end DisplayUnit4;
112
113model DisplayUnit5
114    type A = Real(unit="N", displayUnit="kN");
115    type B = Real(unit="N", displayUnit="mN");
116    A a = time;
117    B b = time;
118    Real c(unit="J", displayUnit="kW.h") = 2 * time;
119    Real d(unit="J", displayUnit="W.h") = 2 * time;
120
121    annotation(__JModelica(UnitTesting(tests={
122        FmiXMLCodeGenTestCase(
123            name="DisplayUnit5",
124            description="Two display unit with same base unit.",
125            fmi_version="1.0",
126            template="$unitDefinitions$",
127            generatedCode="
128<UnitDefinitions>
129    <BaseUnit unit=\"N\">
130        <DisplayUnitDefinition displayUnit=\"mN\" gain=\"1000.0\" />
131        <DisplayUnitDefinition displayUnit=\"kN\" gain=\"0.001\" />
132    </BaseUnit>
133    <BaseUnit unit=\"J\">
134        <DisplayUnitDefinition displayUnit=\"kW.h\" gain=\"2.7777777777777776E-7\" />
135        <DisplayUnitDefinition displayUnit=\"W.h\" gain=\"2.777777777777778E-4\" />
136    </BaseUnit>
137</UnitDefinitions>
138")})));
139end DisplayUnit5;
140
141model DisplayUnit6
142    type A = Real(unit="N", displayUnit="kN");
143    type B = Real(unit="N", displayUnit="mN");
144    A a = time;
145    B b = time;
146    Real c(unit="J", displayUnit="kW.h") = 2 * time;
147    Real d(unit="J", displayUnit="W.h") = 2 * time;
148
149    annotation(__JModelica(UnitTesting(tests={
150        FmiXMLCodeGenTestCase(
151            name="DisplayUnit6",
152            description="Two display unit with same base unit.",
153            fmi_version="2.0",
154            template="$unitDefinitions$",
155            generatedCode="
156<UnitDefinitions>
157    <Unit name=\"N\">
158        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" />
159        <DisplayUnit name=\"mN\" factor=\"1000.0\" />
160        <DisplayUnit name=\"kN\" factor=\"0.001\" />
161    </Unit>
162    <Unit name=\"J\">
163        <BaseUnit m=\"2\" s=\"-2\" kg=\"1\" />
164        <DisplayUnit name=\"kW.h\" factor=\"2.7777777777777776E-7\" />
165        <DisplayUnit name=\"W.h\" factor=\"2.777777777777778E-4\" />
166    </Unit>
167</UnitDefinitions>
168")})));
169end DisplayUnit6;
170
171model DisplayUnit7
172    type A = Real(unit="kN", displayUnit="mN");
173    type B = Real(unit="N", displayUnit="mN");
174    A a = time;
175    B b = time;
176    Real c(unit="kW.h", displayUnit="J") = 2 * time;
177    Real d(unit="W.h", displayUnit="J") = 2 * time;
178
179    annotation(__JModelica(UnitTesting(tests={
180        FmiXMLCodeGenTestCase(
181            name="DisplayUnit7",
182            description="Two display unit with same base unit.",
183            fmi_version="1.0",
184            template="$unitDefinitions$",
185            generatedCode="
186<UnitDefinitions>
187    <BaseUnit unit=\"N\">
188        <DisplayUnitDefinition displayUnit=\"mN\" gain=\"1000.0\" />
189    </BaseUnit>
190    <BaseUnit unit=\"kW.h\">
191        <DisplayUnitDefinition displayUnit=\"J\" gain=\"3600000.0\" />
192    </BaseUnit>
193    <BaseUnit unit=\"W.h\">
194        <DisplayUnitDefinition displayUnit=\"J\" gain=\"3600.0\" />
195    </BaseUnit>
196    <BaseUnit unit=\"kN\">
197        <DisplayUnitDefinition displayUnit=\"mN\" gain=\"1000000.0\" />
198    </BaseUnit>
199</UnitDefinitions>
200")})));
201end DisplayUnit7;
202
203model DisplayUnit8
204    type A = Real(unit="kN", displayUnit="mN");
205    type B = Real(unit="N", displayUnit="mN");
206    A a = time;
207    B b = time;
208    Real c(unit="kW.h", displayUnit="J") = 2 * time;
209    Real d(unit="W.h", displayUnit="J") = 2 * time;
210
211    annotation(__JModelica(UnitTesting(tests={
212        FmiXMLCodeGenTestCase(
213            name="DisplayUnit8",
214            description="Two display unit with same base unit.",
215            fmi_version="2.0",
216            template="$unitDefinitions$",
217            generatedCode="
218<UnitDefinitions>
219    <Unit name=\"N\">
220        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" />
221        <DisplayUnit name=\"mN\" factor=\"1000.0\" />
222    </Unit>
223    <Unit name=\"kW.h\">
224        <BaseUnit m=\"2\" s=\"-2\" kg=\"1\" factor=\"3600000.0\" />
225        <DisplayUnit name=\"J\" factor=\"3600000.0\" />
226    </Unit>
227    <Unit name=\"W.h\">
228        <BaseUnit m=\"2\" s=\"-2\" kg=\"1\" factor=\"3600.0\" />
229        <DisplayUnit name=\"J\" factor=\"3600.0\" />
230    </Unit>
231    <Unit name=\"kN\">
232        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" factor=\"1000.0\" />
233        <DisplayUnit name=\"mN\" factor=\"1000000.0\" />
234    </Unit>
235</UnitDefinitions>
236")})));
237end DisplayUnit8;
238
239model DisplayUnit9
240    type A = Real(unit="N", displayUnit="x");
241    A a = time;
242    Real b(unit="Y", displayUnit="y") = 2 * time;
243
244    annotation(__JModelica(UnitTesting(tests={
245        FmiXMLCodeGenTestCase(
246            name="DisplayUnit9",
247            description="Test with unknown base units and display units",
248            fmi_version="1.0",
249            template="$unitDefinitions$",
250            generatedCode="
251<UnitDefinitions>
252    <BaseUnit unit=\"N\">
253        <DisplayUnitDefinition displayUnit=\"x\" />
254    </BaseUnit>
255    <BaseUnit unit=\"Y\">
256        <DisplayUnitDefinition displayUnit=\"y\" />
257    </BaseUnit>
258</UnitDefinitions>
259")})));
260end DisplayUnit9;
261
262model DisplayUnit10
263    type A = Real(unit="N", displayUnit="x");
264    A a = time;
265    Real b(unit="Y", displayUnit="y") = 2 * time;
266
267    annotation(__JModelica(UnitTesting(tests={
268        FmiXMLCodeGenTestCase(
269            name="DisplayUnit10",
270            description="Test with unknown base units and display units",
271            fmi_version="2.0",
272            template="$unitDefinitions$",
273            generatedCode="
274<UnitDefinitions>
275    <Unit name=\"N\">
276        <BaseUnit m=\"1\" s=\"-2\" kg=\"1\" />
277        <DisplayUnit name=\"x\" />
278    </Unit>
279    <Unit name=\"Y\">
280        <DisplayUnit name=\"y\" />
281    </Unit>
282</UnitDefinitions>
283")})));
284end DisplayUnit10;
285
286model DisplayUnit11
287    Real a(displayUnit="W") = 2 * time;
288
289    annotation(__JModelica(UnitTesting(tests={
290        FmiXMLCodeGenTestCase(
291            name="DisplayUnit11",
292            description="Test that no displayUnit without unit is generated for XML variable",
293            fmi_version="1.0",
294            template="$modelVariables$",
295            generatedCode="
296<ModelVariables>
297    <!-- Variable with index #1 -->
298    <ScalarVariable name=\"a\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
299        <Real relativeQuantity=\"false\" />
300    </ScalarVariable>
301</ModelVariables>
302")})));
303end DisplayUnit11;
304
305model DisplayUnit12
306    Real a(displayUnit="W") = 2 * time;
307
308    annotation(__JModelica(UnitTesting(tests={
309        FmiXMLCodeGenTestCase(
310            name="DisplayUnit12",
311            description="Test that no displayUnit without unit is generated for XML variable",
312            fmi_version="2.0",
313            template="$modelVariables$",
314            generatedCode="
315<ModelVariables>
316    <!-- Variable with index #1 -->
317    <ScalarVariable name=\"a\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
318        <Real relativeQuantity=\"false\" />
319    </ScalarVariable>
320</ModelVariables>
321")})));
322end DisplayUnit12;
323
324model Fmi1StartAttribute
325    constant Real independent1(start=1);
326    constant Real dependent1(fixed=false) = independent1*independent1;
327   
328    constant Real independent2(start=1);
329    constant Real dependent2(fixed=true) = independent2*independent2;
330   
331    constant Real independent3(start=1);
332    constant Real dependent3 = independent3*independent3;
333   
334    parameter Real independent4(start=1);
335    parameter Real dependent4(fixed=false);
336   
337    parameter Real independent5(start=1);
338    parameter Real dependent5(fixed=true) = independent5*independent5;
339   
340    parameter Real independent6(start=1);
341    parameter Real dependent6 = independent6*independent6;
342   
343    Real x1(start=0);
344    Real x2"start=0";
345    Real x3(fixed=false, start=0);
346    Real x4(fixed=true, start=0);
347    Real x5"fixed=true";
348 
349  initial equation
350    dependent4 = independent4*independent4;
351    //x3*x3 = 4;
352
353  equation
354    der(x1) = x1;
355    der(x2) = x2;
356    der(x3) = x3;
357    der(x4) = x4;
358    der(x5) = x5;
359   
360   
361    annotation(__JModelica(UnitTesting(tests={
362        FmiXMLCodeGenTestCase(
363            name="Fmi1StartAttribute",
364            description="Check parameters without binding expressions",
365            eliminate_alias_variables=false,
366            fmi_version="1.0",
367            template="
368$modelVariables$",
369            generatedCode="
370<ModelVariables>
371    <!-- Variable with index #1 -->
372    <ScalarVariable name=\"dependent1\" valueReference=\"1\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
373        <Real relativeQuantity=\"false\" start=\"1.0\" />
374    </ScalarVariable>
375    <!-- Variable with index #2 -->
376    <ScalarVariable name=\"dependent2\" valueReference=\"3\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
377        <Real relativeQuantity=\"false\" start=\"1.0\" />
378    </ScalarVariable>
379    <!-- Variable with index #3 -->
380    <ScalarVariable name=\"dependent3\" valueReference=\"5\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
381        <Real relativeQuantity=\"false\" start=\"1.0\" />
382    </ScalarVariable>
383    <!-- Variable with index #4 -->
384    <ScalarVariable name=\"dependent4\" valueReference=\"11\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
385        <Real relativeQuantity=\"false\" />
386    </ScalarVariable>
387    <!-- Variable with index #5 -->
388    <ScalarVariable name=\"dependent5\" valueReference=\"9\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
389        <Real relativeQuantity=\"false\" />
390    </ScalarVariable>
391    <!-- Variable with index #6 -->
392    <ScalarVariable name=\"dependent6\" valueReference=\"10\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
393        <Real relativeQuantity=\"false\" />
394    </ScalarVariable>
395    <!-- Variable with index #7 -->
396    <ScalarVariable name=\"independent1\" valueReference=\"0\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
397        <Real relativeQuantity=\"false\" start=\"1.0\" />
398    </ScalarVariable>
399    <!-- Variable with index #8 -->
400    <ScalarVariable name=\"independent2\" valueReference=\"2\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
401        <Real relativeQuantity=\"false\" start=\"1.0\" />
402    </ScalarVariable>
403    <!-- Variable with index #9 -->
404    <ScalarVariable name=\"independent3\" valueReference=\"4\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
405        <Real relativeQuantity=\"false\" start=\"1.0\" />
406    </ScalarVariable>
407    <!-- Variable with index #10 -->
408    <ScalarVariable name=\"independent4\" valueReference=\"6\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
409        <Real relativeQuantity=\"false\" start=\"1.0\" />
410    </ScalarVariable>
411    <!-- Variable with index #11 -->
412    <ScalarVariable name=\"independent5\" valueReference=\"7\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
413        <Real relativeQuantity=\"false\" start=\"1.0\" />
414    </ScalarVariable>
415    <!-- Variable with index #12 -->
416    <ScalarVariable name=\"independent6\" valueReference=\"8\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
417        <Real relativeQuantity=\"false\" start=\"1.0\" />
418    </ScalarVariable>
419    <!-- Variable with index #13 -->
420    <ScalarVariable name=\"x1\" valueReference=\"17\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
421        <Real relativeQuantity=\"false\" start=\"0.0\" fixed=\"false\" />
422    </ScalarVariable>
423    <!-- Variable with index #14 -->
424    <ScalarVariable name=\"der(x1)\" valueReference=\"12\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
425        <Real relativeQuantity=\"false\" />
426    </ScalarVariable>
427    <!-- Variable with index #15 -->
428    <ScalarVariable name=\"x2\" valueReference=\"18\" description=\"start=0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
429        <Real relativeQuantity=\"false\" />
430    </ScalarVariable>
431    <!-- Variable with index #16 -->
432    <ScalarVariable name=\"der(x2)\" valueReference=\"13\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
433        <Real relativeQuantity=\"false\" />
434    </ScalarVariable>
435    <!-- Variable with index #17 -->
436    <ScalarVariable name=\"x3\" valueReference=\"19\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
437        <Real relativeQuantity=\"false\" start=\"0.0\" fixed=\"false\" />
438    </ScalarVariable>
439    <!-- Variable with index #18 -->
440    <ScalarVariable name=\"der(x3)\" valueReference=\"14\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
441        <Real relativeQuantity=\"false\" />
442    </ScalarVariable>
443    <!-- Variable with index #19 -->
444    <ScalarVariable name=\"x4\" valueReference=\"20\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
445        <Real relativeQuantity=\"false\" start=\"0.0\" />
446    </ScalarVariable>
447    <!-- Variable with index #20 -->
448    <ScalarVariable name=\"der(x4)\" valueReference=\"15\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
449        <Real relativeQuantity=\"false\" />
450    </ScalarVariable>
451    <!-- Variable with index #21 -->
452    <ScalarVariable name=\"x5\" valueReference=\"21\" description=\"fixed=true\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
453        <Real relativeQuantity=\"false\" />
454    </ScalarVariable>
455    <!-- Variable with index #22 -->
456    <ScalarVariable name=\"der(x5)\" valueReference=\"16\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
457        <Real relativeQuantity=\"false\" />
458    </ScalarVariable>
459</ModelVariables>
460")})));
461end Fmi1StartAttribute;
462
463model Fmi2StartAttribute
464    constant Real independent1(start=1);
465    constant Real dependent1(fixed=false) = independent1*independent1;
466   
467    constant Real independent2(start=1);
468    constant Real dependent2(fixed=true) = independent2*independent2;
469   
470    constant Real independent3(start=1);
471    constant Real dependent3 = independent3*independent3;
472   
473    parameter Real independent4(start=1);
474    parameter Real dependent4(fixed=false);
475   
476    parameter Real independent5(start=1);
477    parameter Real dependent5(fixed=true) = independent5*independent5;
478   
479    parameter Real independent6(start=1);
480    parameter Real dependent6 = independent6*independent6;
481   
482    Real x1(start=0);
483    Real x2"start=0";
484    Real x3(fixed=false, start=0);
485    Real x4(fixed=true, start=0);
486    Real x5"fixed=true";
487 
488  initial equation
489    dependent4 = independent4*independent4;
490    //x3*x3 = 4;
491
492  equation
493    der(x1) = x1;
494    der(x2) = x2;
495    der(x3) = x3;
496    der(x4) = x4;
497    der(x5) = x5;
498   
499   
500    annotation(__JModelica(UnitTesting(tests={
501        FmiXMLCodeGenTestCase(
502            name="Fmi2StartAttribute",
503            description="Check parameters without binding expressions",
504            fmi_version="2.0",
505            eliminate_alias_variables=false,
506            template="
507$modelVariables$",
508            generatedCode="
509<ModelVariables>
510    <!-- Variable with index #1 -->
511    <ScalarVariable name=\"dependent1\" valueReference=\"1\" causality=\"local\" variability=\"constant\" initial=\"exact\">
512        <Real relativeQuantity=\"false\" start=\"1.0\" />
513    </ScalarVariable>
514    <!-- Variable with index #2 -->
515    <ScalarVariable name=\"dependent2\" valueReference=\"3\" causality=\"local\" variability=\"constant\" initial=\"exact\">
516        <Real relativeQuantity=\"false\" start=\"1.0\" />
517    </ScalarVariable>
518    <!-- Variable with index #3 -->
519    <ScalarVariable name=\"dependent3\" valueReference=\"5\" causality=\"local\" variability=\"constant\" initial=\"exact\">
520        <Real relativeQuantity=\"false\" start=\"1.0\" />
521    </ScalarVariable>
522    <!-- Variable with index #4 -->
523    <ScalarVariable name=\"dependent4\" valueReference=\"11\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
524        <Real relativeQuantity=\"false\" />
525    </ScalarVariable>
526    <!-- Variable with index #5 -->
527    <ScalarVariable name=\"dependent5\" valueReference=\"9\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
528        <Real relativeQuantity=\"false\" />
529    </ScalarVariable>
530    <!-- Variable with index #6 -->
531    <ScalarVariable name=\"dependent6\" valueReference=\"10\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
532        <Real relativeQuantity=\"false\" />
533    </ScalarVariable>
534    <!-- Variable with index #7 -->
535    <ScalarVariable name=\"independent1\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
536        <Real relativeQuantity=\"false\" start=\"1.0\" />
537    </ScalarVariable>
538    <!-- Variable with index #8 -->
539    <ScalarVariable name=\"independent2\" valueReference=\"2\" causality=\"local\" variability=\"constant\" initial=\"exact\">
540        <Real relativeQuantity=\"false\" start=\"1.0\" />
541    </ScalarVariable>
542    <!-- Variable with index #9 -->
543    <ScalarVariable name=\"independent3\" valueReference=\"4\" causality=\"local\" variability=\"constant\" initial=\"exact\">
544        <Real relativeQuantity=\"false\" start=\"1.0\" />
545    </ScalarVariable>
546    <!-- Variable with index #10 -->
547    <ScalarVariable name=\"independent4\" valueReference=\"6\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
548        <Real relativeQuantity=\"false\" start=\"1.0\" />
549    </ScalarVariable>
550    <!-- Variable with index #11 -->
551    <ScalarVariable name=\"independent5\" valueReference=\"7\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
552        <Real relativeQuantity=\"false\" start=\"1.0\" />
553    </ScalarVariable>
554    <!-- Variable with index #12 -->
555    <ScalarVariable name=\"independent6\" valueReference=\"8\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
556        <Real relativeQuantity=\"false\" start=\"1.0\" />
557    </ScalarVariable>
558    <!-- Variable with index #13 -->
559    <ScalarVariable name=\"x1\" valueReference=\"17\" causality=\"local\" variability=\"continuous\" initial=\"approx\">
560        <Real relativeQuantity=\"false\" start=\"0.0\" />
561    </ScalarVariable>
562    <!-- Variable with index #14 -->
563    <ScalarVariable name=\"der(x1)\" valueReference=\"12\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
564        <Real relativeQuantity=\"false\" derivative=\"13\" />
565    </ScalarVariable>
566    <!-- Variable with index #15 -->
567    <ScalarVariable name=\"x2\" valueReference=\"18\" description=\"start=0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
568        <Real relativeQuantity=\"false\" />
569    </ScalarVariable>
570    <!-- Variable with index #16 -->
571    <ScalarVariable name=\"der(x2)\" valueReference=\"13\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
572        <Real relativeQuantity=\"false\" derivative=\"15\" />
573    </ScalarVariable>
574    <!-- Variable with index #17 -->
575    <ScalarVariable name=\"x3\" valueReference=\"19\" causality=\"local\" variability=\"continuous\" initial=\"approx\">
576        <Real relativeQuantity=\"false\" start=\"0.0\" />
577    </ScalarVariable>
578    <!-- Variable with index #18 -->
579    <ScalarVariable name=\"der(x3)\" valueReference=\"14\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
580        <Real relativeQuantity=\"false\" derivative=\"17\" />
581    </ScalarVariable>
582    <!-- Variable with index #19 -->
583    <ScalarVariable name=\"x4\" valueReference=\"20\" causality=\"local\" variability=\"continuous\" initial=\"exact\">
584        <Real relativeQuantity=\"false\" start=\"0.0\" />
585    </ScalarVariable>
586    <!-- Variable with index #20 -->
587    <ScalarVariable name=\"der(x4)\" valueReference=\"15\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
588        <Real relativeQuantity=\"false\" derivative=\"19\" />
589    </ScalarVariable>
590    <!-- Variable with index #21 -->
591    <ScalarVariable name=\"x5\" valueReference=\"21\" description=\"fixed=true\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
592        <Real relativeQuantity=\"false\" />
593    </ScalarVariable>
594    <!-- Variable with index #22 -->
595    <ScalarVariable name=\"der(x5)\" valueReference=\"16\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
596        <Real relativeQuantity=\"false\" derivative=\"21\" />
597    </ScalarVariable>
598</ModelVariables>
599")})));
600end Fmi2StartAttribute;
601
602model Fmi1Enumerations
603  type E = enumeration (A,B,C);
604 
605  E one(start = E.A);
606  E two(start = E.B);
607  E three(start = E.C);
608 
609  equation
610    one = E.A;
611    two = E.B;
612    three = E.C;
613   
614    annotation(__JModelica(UnitTesting(tests={
615        FmiXMLCodeGenTestCase(
616            name="Fmi1Enumerations",
617            description="Check parameters without binding expressions",
618            fmi_version="1.0",
619            template="
620$typeDefinitions$
621$modelVariables$",
622            generatedCode="
623<TypeDefinitions>
624    <Type name=\"FmiXMLTests.Fmi1Enumerations.E\">
625        <EnumerationType min=\"1\" max=\"3\">
626            <Item name=\"A\" />
627            <Item name=\"B\" />
628            <Item name=\"C\" />
629        </EnumerationType>
630    </Type>
631</TypeDefinitions>
632<ModelVariables>
633    <!-- Variable with index #1 -->
634    <ScalarVariable name=\"one\" valueReference=\"268435456\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
635        <Enumeration declaredType=\"FmiXMLTests.Fmi1Enumerations.E\" start=\"1\" />
636    </ScalarVariable>
637    <!-- Variable with index #2 -->
638    <ScalarVariable name=\"three\" valueReference=\"268435458\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
639        <Enumeration declaredType=\"FmiXMLTests.Fmi1Enumerations.E\" start=\"3\" />
640    </ScalarVariable>
641    <!-- Variable with index #3 -->
642    <ScalarVariable name=\"two\" valueReference=\"268435457\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
643        <Enumeration declaredType=\"FmiXMLTests.Fmi1Enumerations.E\" start=\"2\" />
644    </ScalarVariable>
645</ModelVariables>
646")})));
647end Fmi1Enumerations;
648
649model Fmi2Enumerations
650  type E = enumeration (A,B,C);
651 
652  E one(start = E.A);
653  E two(start = E.B);
654  E three(start = E.C);
655 
656  equation
657    one = E.A;
658    two = E.B;
659    three = E.C;
660   
661    annotation(__JModelica(UnitTesting(tests={
662        FmiXMLCodeGenTestCase(
663            name="Fmi2Enumerations",
664            description="Check parameters without binding expressions",
665            fmi_version="2.0",
666            template="
667$typeDefinitions$
668$modelVariables$",
669            generatedCode="
670<TypeDefinitions>
671    <SimpleType name=\"FmiXMLTests.Fmi2Enumerations.E\">
672        <Enumeration>
673            <Item name=\"A\" value=\"1\" />
674            <Item name=\"B\" value=\"2\" />
675            <Item name=\"C\" value=\"3\" />
676        </Enumeration>
677    </SimpleType>
678</TypeDefinitions>
679<ModelVariables>
680    <!-- Variable with index #1 -->
681    <ScalarVariable name=\"one\" valueReference=\"268435456\" causality=\"local\" variability=\"constant\" initial=\"exact\">
682        <Enumeration declaredType=\"FmiXMLTests.Fmi2Enumerations.E\" start=\"1\" />
683    </ScalarVariable>
684    <!-- Variable with index #2 -->
685    <ScalarVariable name=\"three\" valueReference=\"268435458\" causality=\"local\" variability=\"constant\" initial=\"exact\">
686        <Enumeration declaredType=\"FmiXMLTests.Fmi2Enumerations.E\" start=\"3\" />
687    </ScalarVariable>
688    <!-- Variable with index #3 -->
689    <ScalarVariable name=\"two\" valueReference=\"268435457\" causality=\"local\" variability=\"constant\" initial=\"exact\">
690        <Enumeration declaredType=\"FmiXMLTests.Fmi2Enumerations.E\" start=\"2\" />
691    </ScalarVariable>
692</ModelVariables>
693")})));
694end Fmi2Enumerations;
695
696model Fmi1Aliases1
697
698    parameter Real original(start = 1.0);
699    parameter Real alias = original;
700    parameter Real negatedAlias = - original;
701   
702    annotation(__JModelica(UnitTesting(tests={
703        FmiXMLCodeGenTestCase(
704            name="Fmi1Aliases1",
705            description="FMI 1.0 alias test for parameters",
706            fmi_version="1.0",
707            template="
708$modelVariables$",
709            generatedCode="
710<ModelVariables>
711    <!-- Variable with index #1 -->
712    <ScalarVariable name=\"alias\" valueReference=\"1\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
713        <Real relativeQuantity=\"false\" />
714    </ScalarVariable>
715    <!-- Variable with index #2 -->
716    <ScalarVariable name=\"negatedAlias\" valueReference=\"2\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
717        <Real relativeQuantity=\"false\" />
718    </ScalarVariable>
719    <!-- Variable with index #3 -->
720    <ScalarVariable name=\"original\" valueReference=\"0\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
721        <Real relativeQuantity=\"false\" start=\"1.0\" />
722    </ScalarVariable>
723</ModelVariables>
724")})));
725end Fmi1Aliases1;
726
727model Fmi1Aliases2
728
729    Real original(start = 1.0);
730    Real alias;
731    Real negatedAlias;
732   
733    equation
734        alias = original;
735        negatedAlias = -original;
736        der(original) = original;
737   
738    annotation(__JModelica(UnitTesting(tests={
739        FmiXMLCodeGenTestCase(
740            name="Fmi1Aliases2",
741            description="FMI 1.0 alias test for reals",
742            fmi_version="1.0",
743            template="
744$modelVariables$",
745            generatedCode="
746<ModelVariables>
747    <!-- Variable with index #1 -->
748    <ScalarVariable name=\"alias\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"alias\">
749        <Real relativeQuantity=\"false\" />
750    </ScalarVariable>
751    <!-- Variable with index #2 -->
752    <ScalarVariable name=\"negatedAlias\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"negatedAlias\">
753        <Real relativeQuantity=\"false\" />
754    </ScalarVariable>
755    <!-- Variable with index #3 -->
756    <ScalarVariable name=\"original\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
757        <Real relativeQuantity=\"false\" start=\"1.0\" fixed=\"false\" />
758    </ScalarVariable>
759    <!-- Variable with index #4 -->
760    <ScalarVariable name=\"der(original)\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
761        <Real relativeQuantity=\"false\" />
762    </ScalarVariable>
763</ModelVariables>
764")})));
765end Fmi1Aliases2;
766
767model Fmi2Aliases1
768
769    parameter Real original(start = 1.0);
770    parameter Real alias = original;
771    parameter Real negatedAlias = - original;
772   
773    annotation(__JModelica(UnitTesting(tests={
774        FmiXMLCodeGenTestCase(
775            name="Fmi2Aliases1",
776            description="FMI 2.0 alias test for parameters",
777            fmi_version="2.0",
778            template="
779$modelVariables$
780$modelStructure$",
781            generatedCode="
782<ModelVariables>
783    <!-- Variable with index #1 -->
784    <ScalarVariable name=\"alias\" valueReference=\"1\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
785        <Real relativeQuantity=\"false\" />
786    </ScalarVariable>
787    <!-- Variable with index #2 -->
788    <ScalarVariable name=\"negatedAlias\" valueReference=\"2\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
789        <Real relativeQuantity=\"false\" />
790    </ScalarVariable>
791    <!-- Variable with index #3 -->
792    <ScalarVariable name=\"original\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
793        <Real relativeQuantity=\"false\" start=\"1.0\" />
794    </ScalarVariable>
795</ModelVariables>
796<ModelStructure>
797    <InitialUnknowns>
798        <Unknown index=\"1\" dependencies=\"3\" />
799        <Unknown index=\"2\" dependencies=\"3\" />
800    </InitialUnknowns>
801</ModelStructure>
802")})));
803end Fmi2Aliases1;
804
805model Fmi2Aliases2
806
807    Real original(start = 1.0);
808    Real alias;
809    Real negatedAlias;
810   
811    equation
812        alias = original;
813        negatedAlias = -original;
814        der(original) = original;
815   
816    annotation(__JModelica(UnitTesting(tests={
817        FmiXMLCodeGenTestCase(
818            name="Fmi2Aliases2",
819            description="FMI 2.0 alias test for reals",
820            fmi_version="2.0",
821            template="
822$modelVariables$
823$modelStructure$",
824            generatedCode="
825<ModelVariables>
826    <!-- Variable with index #1 -->
827    <ScalarVariable name=\"alias\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
828        <Real relativeQuantity=\"false\" />
829    </ScalarVariable>
830    <!-- Variable with index #2 -->
831    <ScalarVariable name=\"negatedAlias\" valueReference=\"134217729\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
832        <Real relativeQuantity=\"false\" />
833    </ScalarVariable>
834    <!-- Variable with index #3 -->
835    <ScalarVariable name=\"original\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"approx\">
836        <Real relativeQuantity=\"false\" start=\"1.0\" />
837    </ScalarVariable>
838    <!-- Variable with index #4 -->
839    <ScalarVariable name=\"der(original)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
840        <Real relativeQuantity=\"false\" derivative=\"3\" />
841    </ScalarVariable>
842</ModelVariables>
843<ModelStructure>
844    <Derivatives>
845        <Unknown index=\"4\" dependencies=\"3\" />
846    </Derivatives>
847    <InitialUnknowns>
848        <Unknown index=\"3\" dependencies=\"\" />
849        <Unknown index=\"4\" dependencies=\"\" />
850    </InitialUnknowns>
851</ModelStructure>
852")})));
853end Fmi2Aliases2;
854
855model FixedParameters2
856
857    parameter Real fixed1(fixed=false);
858    parameter Real independent = 4;
859 
860  initial equation
861    fixed1 = independent;
862   
863    annotation(__JModelica(UnitTesting(tests={
864        FmiXMLCodeGenTestCase(
865            name="FixedParameters2",
866            description="Check parameters with binding expressions",
867            fmi_version="2.0",
868            template="
869$modelVariables$
870$modelStructure$",
871            generatedCode="
872<ModelVariables>
873    <!-- Variable with index #1 -->
874    <ScalarVariable name=\"fixed1\" valueReference=\"1\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
875        <Real relativeQuantity=\"false\" />
876    </ScalarVariable>
877    <!-- Variable with index #2 -->
878    <ScalarVariable name=\"independent\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
879        <Real relativeQuantity=\"false\" start=\"4.0\" />
880    </ScalarVariable>
881</ModelVariables>
882<ModelStructure>
883    <InitialUnknowns>
884        <Unknown index=\"1\" dependencies=\"2\" />
885    </InitialUnknowns>
886</ModelStructure>
887")})));
888end FixedParameters2;
889
890model FixedParameters3
891
892    parameter Real independent1 = 1.0;
893    parameter Real fixed1(fixed=true) = independent1*independent1;
894   
895    parameter Real independent2 = 1.0;
896    parameter Real fixed2 = independent2*independent2 "fixed=true is default";
897   
898    annotation(__JModelica(UnitTesting(tests={
899        FmiXMLCodeGenTestCase(
900            name="FixedParameters3",
901            description="Check parameters with and without the fixed attribute",
902            fmi_version="2.0",
903            template="
904$modelVariables$
905$modelStructure$",
906            generatedCode="
907<ModelVariables>
908    <!-- Variable with index #1 -->
909    <ScalarVariable name=\"fixed1\" valueReference=\"2\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
910        <Real relativeQuantity=\"false\" />
911    </ScalarVariable>
912    <!-- Variable with index #2 -->
913    <ScalarVariable name=\"fixed2\" valueReference=\"3\" description=\"fixed=true is default\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
914        <Real relativeQuantity=\"false\" />
915    </ScalarVariable>
916    <!-- Variable with index #3 -->
917    <ScalarVariable name=\"independent1\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
918        <Real relativeQuantity=\"false\" start=\"1.0\" />
919    </ScalarVariable>
920    <!-- Variable with index #4 -->
921    <ScalarVariable name=\"independent2\" valueReference=\"1\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
922        <Real relativeQuantity=\"false\" start=\"1.0\" />
923    </ScalarVariable>
924</ModelVariables>
925<ModelStructure>
926    <InitialUnknowns>
927        <Unknown index=\"1\" dependencies=\"3\" />
928        <Unknown index=\"2\" dependencies=\"4\" />
929    </InitialUnknowns>
930</ModelStructure>
931")})));
932end FixedParameters3;
933
934model ParameterDependencies1
935  function f1
936    input Real x;
937    output Real y;
938  algorithm
939    y := x*x;
940    annotation(Inline=false);
941  end f1;
942
943    Real x1, x2, x3, x4;
944    parameter Real independentParameter1 = 1.0;
945    parameter Real independentParameter2 = 1.0;
946    parameter Real dependentParameter(fixed=true) = independentParameter1 * independentParameter1;
947 
948  initial equation
949    //Block 1
950    x1 = f1(x1);
951    //Block 2
952    x2 = f1(x1 * x2) + independentParameter2;
953    //Block 3
954    x3 = f1(x2 * x3) + dependentParameter;
955    //Block 4
956    x4 = f1(x3 * x4); 
957  equation
958    der(x1) = x1;
959    der(x2) = x2;
960    der(x3) = x3;
961    der(x4) = x4;
962   
963    annotation(__JModelica(UnitTesting(tests={
964        FmiXMLCodeGenTestCase(
965            name="ParameterDependencies1",
966            description="Check that the initial unknowns are correct",
967            fmi_version="2.0",
968            template="
969$modelVariables$
970$modelStructure$",
971            generatedCode="
972<ModelVariables>
973    <!-- Variable with index #1 -->
974    <ScalarVariable name=\"dependentParameter\" valueReference=\"2\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
975        <Real relativeQuantity=\"false\" />
976    </ScalarVariable>
977    <!-- Variable with index #2 -->
978    <ScalarVariable name=\"independentParameter1\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
979        <Real relativeQuantity=\"false\" start=\"1.0\" />
980    </ScalarVariable>
981    <!-- Variable with index #3 -->
982    <ScalarVariable name=\"independentParameter2\" valueReference=\"1\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
983        <Real relativeQuantity=\"false\" start=\"1.0\" />
984    </ScalarVariable>
985    <!-- Variable with index #4 -->
986    <ScalarVariable name=\"x1\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
987        <Real relativeQuantity=\"false\" />
988    </ScalarVariable>
989    <!-- Variable with index #5 -->
990    <ScalarVariable name=\"der(x1)\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
991        <Real relativeQuantity=\"false\" derivative=\"4\" />
992    </ScalarVariable>
993    <!-- Variable with index #6 -->
994    <ScalarVariable name=\"x2\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
995        <Real relativeQuantity=\"false\" />
996    </ScalarVariable>
997    <!-- Variable with index #7 -->
998    <ScalarVariable name=\"der(x2)\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
999        <Real relativeQuantity=\"false\" derivative=\"6\" />
1000    </ScalarVariable>
1001    <!-- Variable with index #8 -->
1002    <ScalarVariable name=\"x3\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1003        <Real relativeQuantity=\"false\" />
1004    </ScalarVariable>
1005    <!-- Variable with index #9 -->
1006    <ScalarVariable name=\"der(x3)\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1007        <Real relativeQuantity=\"false\" derivative=\"8\" />
1008    </ScalarVariable>
1009    <!-- Variable with index #10 -->
1010    <ScalarVariable name=\"x4\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1011        <Real relativeQuantity=\"false\" />
1012    </ScalarVariable>
1013    <!-- Variable with index #11 -->
1014    <ScalarVariable name=\"der(x4)\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1015        <Real relativeQuantity=\"false\" derivative=\"10\" />
1016    </ScalarVariable>
1017</ModelVariables>
1018<ModelStructure>
1019    <Derivatives>
1020        <Unknown index=\"5\" dependencies=\"4\" />
1021        <Unknown index=\"7\" dependencies=\"6\" />
1022        <Unknown index=\"9\" dependencies=\"8\" />
1023        <Unknown index=\"11\" dependencies=\"10\" />
1024    </Derivatives>
1025    <InitialUnknowns>
1026        <Unknown index=\"1\" dependencies=\"2\" />
1027        <Unknown index=\"4\" dependencies=\"\" />
1028        <Unknown index=\"5\" dependencies=\"\" />
1029        <Unknown index=\"6\" dependencies=\"3\" />
1030        <Unknown index=\"7\" dependencies=\"3\" />
1031        <Unknown index=\"8\" dependencies=\"2 3\" />
1032        <Unknown index=\"9\" dependencies=\"2 3\" />
1033        <Unknown index=\"10\" dependencies=\"2 3\" />
1034        <Unknown index=\"11\" dependencies=\"2 3\" />
1035    </InitialUnknowns>
1036</ModelStructure>
1037")})));
1038end ParameterDependencies1;
1039
1040model ParameterDependencies2
1041    Real x1, x2, x3;
1042    parameter Real independentParameter1 = 1.0;
1043    parameter Real independentParameter2 = 1.0;
1044    parameter Real dependentParameter1(fixed=false);
1045    parameter Real dependentParameter2(fixed=false);
1046    parameter Real dependentParameter3(fixed=false);
1047    parameter Real dependentParameter4(fixed=false);
1048   
1049    parameter Real dependentParameter5(fixed=true) = independentParameter2 * independentParameter2 "parameter equation";
1050  initial equation
1051    //Block 1
1052    dependentParameter1 = dependentParameter2 + independentParameter1;
1053    dependentParameter1 * dependentParameter2 = 1;
1054    //Block 2
1055    dependentParameter3 = dependentParameter4 + dependentParameter1 + dependentParameter5;
1056    dependentParameter3 * dependentParameter4 = 1;
1057  equation
1058    der(x1) = x1 + dependentParameter1;
1059    der(x2) = x2 + dependentParameter3;
1060    der(x3) = x3 + dependentParameter5;
1061   
1062    annotation(__JModelica(UnitTesting(tests={
1063        FmiXMLCodeGenTestCase(
1064            name="ParameterDependencies2",
1065            description="Check that the initial unknowns are correct",
1066            fmi_version="2.0",
1067            template="
1068$modelVariables$
1069$modelStructure$",
1070            generatedCode="
1071<ModelVariables>
1072    <!-- Variable with index #1 -->
1073    <ScalarVariable name=\"dependentParameter1\" valueReference=\"3\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1074        <Real relativeQuantity=\"false\" />
1075    </ScalarVariable>
1076    <!-- Variable with index #2 -->
1077    <ScalarVariable name=\"dependentParameter2\" valueReference=\"4\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1078        <Real relativeQuantity=\"false\" />
1079    </ScalarVariable>
1080    <!-- Variable with index #3 -->
1081    <ScalarVariable name=\"dependentParameter3\" valueReference=\"5\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1082        <Real relativeQuantity=\"false\" />
1083    </ScalarVariable>
1084    <!-- Variable with index #4 -->
1085    <ScalarVariable name=\"dependentParameter4\" valueReference=\"6\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1086        <Real relativeQuantity=\"false\" />
1087    </ScalarVariable>
1088    <!-- Variable with index #5 -->
1089    <ScalarVariable name=\"dependentParameter5\" valueReference=\"2\" description=\"parameter equation\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1090        <Real relativeQuantity=\"false\" />
1091    </ScalarVariable>
1092    <!-- Variable with index #6 -->
1093    <ScalarVariable name=\"independentParameter1\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1094        <Real relativeQuantity=\"false\" start=\"1.0\" />
1095    </ScalarVariable>
1096    <!-- Variable with index #7 -->
1097    <ScalarVariable name=\"independentParameter2\" valueReference=\"1\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1098        <Real relativeQuantity=\"false\" start=\"1.0\" />
1099    </ScalarVariable>
1100    <!-- Variable with index #8 -->
1101    <ScalarVariable name=\"x1\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1102        <Real relativeQuantity=\"false\" />
1103    </ScalarVariable>
1104    <!-- Variable with index #9 -->
1105    <ScalarVariable name=\"der(x1)\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1106        <Real relativeQuantity=\"false\" derivative=\"8\" />
1107    </ScalarVariable>
1108    <!-- Variable with index #10 -->
1109    <ScalarVariable name=\"x2\" valueReference=\"11\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1110        <Real relativeQuantity=\"false\" />
1111    </ScalarVariable>
1112    <!-- Variable with index #11 -->
1113    <ScalarVariable name=\"der(x2)\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1114        <Real relativeQuantity=\"false\" derivative=\"10\" />
1115    </ScalarVariable>
1116    <!-- Variable with index #12 -->
1117    <ScalarVariable name=\"x3\" valueReference=\"12\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1118        <Real relativeQuantity=\"false\" />
1119    </ScalarVariable>
1120    <!-- Variable with index #13 -->
1121    <ScalarVariable name=\"der(x3)\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1122        <Real relativeQuantity=\"false\" derivative=\"12\" />
1123    </ScalarVariable>
1124</ModelVariables>
1125<ModelStructure>
1126    <Derivatives>
1127        <Unknown index=\"9\" dependencies=\"8\" />
1128        <Unknown index=\"11\" dependencies=\"10\" />
1129        <Unknown index=\"13\" dependencies=\"12\" />
1130    </Derivatives>
1131    <InitialUnknowns>
1132        <Unknown index=\"1\" dependencies=\"6\" />
1133        <Unknown index=\"2\" dependencies=\"6\" />
1134        <Unknown index=\"3\" dependencies=\"6 7\" />
1135        <Unknown index=\"4\" dependencies=\"6 7\" />
1136        <Unknown index=\"5\" dependencies=\"7\" />
1137        <Unknown index=\"8\" dependencies=\"\" />
1138        <Unknown index=\"9\" dependencies=\"6\" />
1139        <Unknown index=\"10\" dependencies=\"\" />
1140        <Unknown index=\"11\" dependencies=\"6 7\" />
1141        <Unknown index=\"12\" dependencies=\"\" />
1142        <Unknown index=\"13\" dependencies=\"7\" />
1143    </InitialUnknowns>
1144</ModelStructure>
1145")})));
1146end ParameterDependencies2;
1147
1148model InitialUnknown1
1149  function f1
1150    input Real x;
1151    output Real y;
1152  algorithm
1153    y := x*x;
1154    annotation(Inline=false);
1155  end f1;
1156 
1157  function f2
1158    input Real x;
1159    output Real y;
1160  algorithm
1161    y := x*x;
1162    annotation(Inline=false);
1163  end f2;
1164 
1165  function f3
1166    input Real x1;
1167    input Real x2;
1168    input Real x3;
1169    input Real x4;
1170    input Real x5;
1171    output Real y;
1172  algorithm
1173    y := x1*x2*x3*x4*x5;
1174    annotation(Inline=false);
1175  end f3;
1176 
1177  function g1
1178    input Real x1;
1179    input Real x2;
1180    output Real y;
1181  algorithm
1182    y := x1*x1 + x2*x2;
1183    annotation(Inline=false);
1184  end g1;
1185
1186    Real x1;
1187    Real x2;
1188    Real x3;
1189    output Real y;
1190    input Real u1,u2,u3;
1191    parameter Real p(start=1.0);
1192    Real t1,t2;
1193  initial equation
1194    y = 3.3;
1195    der(x2) = 0;
1196    x1 = 1.1;
1197  equation
1198   
1199    t1 + t2 = 1;
1200    t1      = p * p;
1201   
1202    der(x1) = f1(x2);
1203    der(x2) = f2(x1) + 3*p*p*x2 + 2*u1 + 3*u3;
1204    der(x3) = f3(x1,x3,u1,u2,u3);
1205    y = g1(x2, x3);
1206
1207    annotation(__JModelica(UnitTesting(tests={
1208        FmiXMLCodeGenTestCase(
1209            name="InitialUnknown1",
1210            description="Check that the initial unknowns are correct",
1211            fmi_version="2.0",
1212            template="
1213$modelVariables$
1214$modelStructure$",
1215            generatedCode="
1216<ModelVariables>
1217    <!-- Variable with index #1 -->
1218    <ScalarVariable name=\"p\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1219        <Real relativeQuantity=\"false\" start=\"1.0\" />
1220    </ScalarVariable>
1221    <!-- Variable with index #2 -->
1222    <ScalarVariable name=\"t1\" valueReference=\"1\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1223        <Real relativeQuantity=\"false\" />
1224    </ScalarVariable>
1225    <!-- Variable with index #3 -->
1226    <ScalarVariable name=\"t2\" valueReference=\"2\" causality=\"calculatedParameter\" variability=\"fixed\" initial=\"calculated\">
1227        <Real relativeQuantity=\"false\" />
1228    </ScalarVariable>
1229    <!-- Variable with index #4 -->
1230    <ScalarVariable name=\"u1\" valueReference=\"9\" causality=\"input\" variability=\"continuous\">
1231        <Real relativeQuantity=\"false\" start=\"0.0\" />
1232    </ScalarVariable>
1233    <!-- Variable with index #5 -->
1234    <ScalarVariable name=\"u2\" valueReference=\"10\" causality=\"input\" variability=\"continuous\">
1235        <Real relativeQuantity=\"false\" start=\"0.0\" />
1236    </ScalarVariable>
1237    <!-- Variable with index #6 -->
1238    <ScalarVariable name=\"u3\" valueReference=\"11\" causality=\"input\" variability=\"continuous\">
1239        <Real relativeQuantity=\"false\" start=\"0.0\" />
1240    </ScalarVariable>
1241    <!-- Variable with index #7 -->
1242    <ScalarVariable name=\"x1\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1243        <Real relativeQuantity=\"false\" />
1244    </ScalarVariable>
1245    <!-- Variable with index #8 -->
1246    <ScalarVariable name=\"der(x1)\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1247        <Real relativeQuantity=\"false\" derivative=\"7\" />
1248    </ScalarVariable>
1249    <!-- Variable with index #9 -->
1250    <ScalarVariable name=\"x2\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1251        <Real relativeQuantity=\"false\" />
1252    </ScalarVariable>
1253    <!-- Variable with index #10 -->
1254    <ScalarVariable name=\"der(x2)\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1255        <Real relativeQuantity=\"false\" derivative=\"9\" />
1256    </ScalarVariable>
1257    <!-- Variable with index #11 -->
1258    <ScalarVariable name=\"x3\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1259        <Real relativeQuantity=\"false\" />
1260    </ScalarVariable>
1261    <!-- Variable with index #12 -->
1262    <ScalarVariable name=\"der(x3)\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1263        <Real relativeQuantity=\"false\" derivative=\"11\" />
1264    </ScalarVariable>
1265    <!-- Variable with index #13 -->
1266    <ScalarVariable name=\"y\" valueReference=\"12\" causality=\"output\" variability=\"continuous\" initial=\"calculated\">
1267        <Real relativeQuantity=\"false\" />
1268    </ScalarVariable>
1269</ModelVariables>
1270<ModelStructure>
1271    <Outputs>
1272        <Unknown index=\"13\" dependencies=\"9 11\" />
1273    </Outputs>
1274    <Derivatives>
1275        <Unknown index=\"10\" dependencies=\"4 6 7 9\" />
1276        <Unknown index=\"8\" dependencies=\"9\" />
1277        <Unknown index=\"12\" dependencies=\"4 5 6 7 11\" />
1278    </Derivatives>
1279    <InitialUnknowns>
1280        <Unknown index=\"2\" dependencies=\"1\" />
1281        <Unknown index=\"3\" dependencies=\"1\" />
1282        <Unknown index=\"7\" dependencies=\"\" />
1283        <Unknown index=\"8\" dependencies=\"1 4 6\" />
1284        <Unknown index=\"9\" dependencies=\"1 4 6\" />
1285        <Unknown index=\"10\" dependencies=\"\" />
1286        <Unknown index=\"11\" dependencies=\"1 4 6\" />
1287        <Unknown index=\"12\" dependencies=\"1 4 5 6\" />
1288        <Unknown index=\"13\" dependencies=\"\" />
1289    </InitialUnknowns>
1290</ModelStructure>
1291")})));
1292end InitialUnknown1;
1293
1294model SortingStates
1295    Real y,b,x,a;
1296  equation
1297    der(y) = time;
1298    der(x) = time;
1299    der(a) = time;
1300    der(b) = time;
1301
1302    annotation(__JModelica(UnitTesting(tests={
1303        FmiXMLCodeGenTestCase(
1304            name="SortingStatesXML",
1305            description="Check sorting of derivatives in model structure after value reference",
1306            fmi_version="2.0",
1307            template="
1308$modelVariables$
1309$modelStructure$",
1310            generatedCode="
1311<ModelVariables>
1312    <!-- Variable with index #1 -->
1313    <ScalarVariable name=\"a\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1314        <Real relativeQuantity=\"false\" />
1315    </ScalarVariable>
1316    <!-- Variable with index #2 -->
1317    <ScalarVariable name=\"der(a)\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1318        <Real relativeQuantity=\"false\" derivative=\"1\" />
1319    </ScalarVariable>
1320    <!-- Variable with index #3 -->
1321    <ScalarVariable name=\"b\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1322        <Real relativeQuantity=\"false\" />
1323    </ScalarVariable>
1324    <!-- Variable with index #4 -->
1325    <ScalarVariable name=\"der(b)\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1326        <Real relativeQuantity=\"false\" derivative=\"3\" />
1327    </ScalarVariable>
1328    <!-- Variable with index #5 -->
1329    <ScalarVariable name=\"x\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1330        <Real relativeQuantity=\"false\" />
1331    </ScalarVariable>
1332    <!-- Variable with index #6 -->
1333    <ScalarVariable name=\"der(x)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1334        <Real relativeQuantity=\"false\" derivative=\"5\" />
1335    </ScalarVariable>
1336    <!-- Variable with index #7 -->
1337    <ScalarVariable name=\"y\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1338        <Real relativeQuantity=\"false\" />
1339    </ScalarVariable>
1340    <!-- Variable with index #8 -->
1341    <ScalarVariable name=\"der(y)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1342        <Real relativeQuantity=\"false\" derivative=\"7\" />
1343    </ScalarVariable>
1344</ModelVariables>
1345<ModelStructure>
1346    <Derivatives>
1347        <Unknown index=\"8\" dependencies=\"\" />
1348        <Unknown index=\"6\" dependencies=\"\" />
1349        <Unknown index=\"2\" dependencies=\"\" />
1350        <Unknown index=\"4\" dependencies=\"\" />
1351    </Derivatives>
1352    <InitialUnknowns>
1353        <Unknown index=\"1\" dependencies=\"\" />
1354        <Unknown index=\"2\" dependencies=\"\" />
1355        <Unknown index=\"3\" dependencies=\"\" />
1356        <Unknown index=\"4\" dependencies=\"\" />
1357        <Unknown index=\"5\" dependencies=\"\" />
1358        <Unknown index=\"6\" dependencies=\"\" />
1359        <Unknown index=\"7\" dependencies=\"\" />
1360        <Unknown index=\"8\" dependencies=\"\" />
1361    </InitialUnknowns>
1362</ModelStructure>
1363")})));
1364end SortingStates;
1365
1366model DynamicStateUnknowns
1367    Real x;
1368    Real y;
1369    Real vx;
1370    Real vy;
1371    Real lambda;
1372  equation
1373    der(x) = vx;
1374    der(y) = vy;
1375    der(vx) = lambda*x;
1376    der(vy) = lambda*y - 2;
1377    x^2 + y^2 = 1;
1378
1379    annotation(__JModelica(UnitTesting(tests={
1380        FmiXMLCodeGenTestCase(
1381            name="DynamicStateUnknowns",
1382            description="Check so that dynamic states are included correctly in the dependency information for unkowns",
1383            fmi_version="2.0",
1384            template="
1385$modelVariables$
1386$modelStructure$",
1387            generatedCode="
1388<ModelVariables>
1389    <!-- Variable with index #1 -->
1390    <ScalarVariable name=\"_der_x\" valueReference=\"11\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1391        <Real relativeQuantity=\"false\" />
1392    </ScalarVariable>
1393    <!-- Variable with index #2 -->
1394    <ScalarVariable name=\"der(_der_x)\" valueReference=\"17\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1395        <Real relativeQuantity=\"false\" />
1396    </ScalarVariable>
1397    <!-- Variable with index #3 -->
1398    <ScalarVariable name=\"_der_y\" valueReference=\"12\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1399        <Real relativeQuantity=\"false\" />
1400    </ScalarVariable>
1401    <!-- Variable with index #4 -->
1402    <ScalarVariable name=\"der(_der_y)\" valueReference=\"18\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1403        <Real relativeQuantity=\"false\" />
1404    </ScalarVariable>
1405    <!-- Variable with index #5 -->
1406    <ScalarVariable name=\"_ds.1.a1\" valueReference=\"13\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1407        <Real relativeQuantity=\"false\" />
1408    </ScalarVariable>
1409    <!-- Variable with index #6 -->
1410    <ScalarVariable name=\"_ds.1.s1\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1411        <Real relativeQuantity=\"false\" />
1412    </ScalarVariable>
1413    <!-- Variable with index #7 -->
1414    <ScalarVariable name=\"der(_ds.1.s1)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1415        <Real relativeQuantity=\"false\" derivative=\"6\" />
1416    </ScalarVariable>
1417    <!-- Variable with index #8 -->
1418    <ScalarVariable name=\"_ds.2.a1\" valueReference=\"14\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1419        <Real relativeQuantity=\"false\" />
1420    </ScalarVariable>
1421    <!-- Variable with index #9 -->
1422    <ScalarVariable name=\"_ds.2.s1\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1423        <Real relativeQuantity=\"false\" />
1424    </ScalarVariable>
1425    <!-- Variable with index #10 -->
1426    <ScalarVariable name=\"der(_ds.2.s1)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1427        <Real relativeQuantity=\"false\" derivative=\"9\" />
1428    </ScalarVariable>
1429    <!-- Variable with index #11 -->
1430    <ScalarVariable name=\"lambda\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1431        <Real relativeQuantity=\"false\" />
1432    </ScalarVariable>
1433    <!-- Variable with index #12 -->
1434    <ScalarVariable name=\"vx\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1435        <Real relativeQuantity=\"false\" />
1436    </ScalarVariable>
1437    <!-- Variable with index #13 -->
1438    <ScalarVariable name=\"der(vx)\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1439        <Real relativeQuantity=\"false\" derivative=\"12\" />
1440    </ScalarVariable>
1441    <!-- Variable with index #14 -->
1442    <ScalarVariable name=\"vy\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1443        <Real relativeQuantity=\"false\" />
1444    </ScalarVariable>
1445    <!-- Variable with index #15 -->
1446    <ScalarVariable name=\"der(vy)\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1447        <Real relativeQuantity=\"false\" derivative=\"14\" />
1448    </ScalarVariable>
1449    <!-- Variable with index #16 -->
1450    <ScalarVariable name=\"x\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1451        <Real relativeQuantity=\"false\" />
1452    </ScalarVariable>
1453    <!-- Variable with index #17 -->
1454    <ScalarVariable name=\"der(x)\" valueReference=\"15\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1455        <Real relativeQuantity=\"false\" />
1456    </ScalarVariable>
1457    <!-- Variable with index #18 -->
1458    <ScalarVariable name=\"y\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1459        <Real relativeQuantity=\"false\" />
1460    </ScalarVariable>
1461    <!-- Variable with index #19 -->
1462    <ScalarVariable name=\"der(y)\" valueReference=\"16\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1463        <Real relativeQuantity=\"false\" />
1464    </ScalarVariable>
1465</ModelVariables>
1466
1467<ModelStructure>
1468    <Derivatives>
1469        <Unknown index=\"7\" dependencies=\"6 9\" />
1470        <Unknown index=\"10\" dependencies=\"6 9\" />
1471    </Derivatives>
1472    <InitialUnknowns>
1473        <Unknown index=\"6\" dependencies=\"\" />
1474        <Unknown index=\"7\" dependencies=\"\" />
1475        <Unknown index=\"9\" dependencies=\"\" />
1476        <Unknown index=\"10\" dependencies=\"\" />
1477    </InitialUnknowns>
1478</ModelStructure>
1479")})));
1480end DynamicStateUnknowns;
1481
1482model SecondOrderDerivatives
1483    Real x(stateSelect=StateSelect.always);
1484    Real y;
1485    Real vx(stateSelect=StateSelect.always);
1486    Real vy;
1487    Real lambda;
1488  equation
1489    der(x) = vx;
1490    der(y) = vy;
1491    der(vx) = lambda*x;
1492    der(vy) = lambda*y - 2;
1493    x^2 + y^2 = 1;
1494
1495    annotation(__JModelica(UnitTesting(tests={
1496        FmiXMLCodeGenTestCase(
1497            name="SecondOrderDerivatives",
1498            description="Check so that second order derivatives point at the correct lower order variables",
1499            fmi_version="2.0",
1500            template="
1501$modelVariables$",
1502            generatedCode="
1503<ModelVariables>
1504    <!-- Variable with index #1 -->
1505    <ScalarVariable name=\"lambda\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1506        <Real relativeQuantity=\"false\" />
1507    </ScalarVariable>
1508    <!-- Variable with index #2 -->
1509    <ScalarVariable name=\"vx\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1510        <Real relativeQuantity=\"false\" />
1511    </ScalarVariable>
1512    <!-- Variable with index #3 -->
1513    <ScalarVariable name=\"der(vx)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1514        <Real relativeQuantity=\"false\" derivative=\"2\" />
1515    </ScalarVariable>
1516    <!-- Variable with index #4 -->
1517    <ScalarVariable name=\"vy\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1518        <Real relativeQuantity=\"false\" />
1519    </ScalarVariable>
1520    <!-- Variable with index #5 -->
1521    <ScalarVariable name=\"der(vy)\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1522        <Real relativeQuantity=\"false\" derivative=\"4\" />
1523    </ScalarVariable>
1524    <!-- Variable with index #6 -->
1525    <ScalarVariable name=\"x\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1526        <Real relativeQuantity=\"false\" />
1527    </ScalarVariable>
1528    <!-- Variable with index #7 -->
1529    <ScalarVariable name=\"der(x,2)\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1530        <Real relativeQuantity=\"false\" derivative=\"8\" />
1531    </ScalarVariable>
1532    <!-- Variable with index #8 -->
1533    <ScalarVariable name=\"der(x)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1534        <Real relativeQuantity=\"false\" derivative=\"6\" />
1535    </ScalarVariable>
1536    <!-- Variable with index #9 -->
1537    <ScalarVariable name=\"y\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1538        <Real relativeQuantity=\"false\" />
1539    </ScalarVariable>
1540    <!-- Variable with index #10 -->
1541    <ScalarVariable name=\"der(y)\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1542        <Real relativeQuantity=\"false\" derivative=\"9\" />
1543    </ScalarVariable>
1544    <!-- Variable with index #11 -->
1545    <ScalarVariable name=\"der(y,2)\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1546        <Real relativeQuantity=\"false\" derivative=\"10\" />
1547    </ScalarVariable>
1548</ModelVariables>
1549")})));
1550end SecondOrderDerivatives;
1551
1552model HigherOrderOrphanTempDerivatives
1553        function F
1554            input Real i;
1555            output Real o1[2];
1556        algorithm
1557            o1[1] := i;
1558            o1[2] := -i;
1559            annotation(Inline=false,derivative=F_der);
1560        end F;
1561   
1562        function F_der
1563            input Real i;
1564            input Real i_der;
1565            output Real o1_der[2];
1566        algorithm
1567            o1_der := F(i_der);
1568            annotation(Inline=true);
1569        end F_der;
1570   
1571        Real x[2];
1572        Real vx[2];
1573        Real a[2];
1574        constant Real p[2] = {1.2, 0};
1575    equation
1576        der(x) = vx;
1577        der(vx) = a.*x;
1578        x = p + F(sin(time));
1579
1580    annotation(__JModelica(UnitTesting(tests={
1581        FmiXMLCodeGenTestCase(
1582            name="HigherOrderOrphanTempDerivatives",
1583            description="Check so that we skip generating derivative for temporaries of higher order which are orphan",
1584            expose_temp_vars_in_fmu=true,
1585            fmi_version="2.0",
1586            template="
1587$modelVariables$",
1588            generatedCode="
1589<ModelVariables>
1590    <!-- Variable with index #1 -->
1591    <ScalarVariable name=\"a[1]\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1592        <Real relativeQuantity=\"false\" />
1593    </ScalarVariable>
1594    <!-- Variable with index #2 -->
1595    <ScalarVariable name=\"a[2]\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1596        <Real relativeQuantity=\"false\" />
1597    </ScalarVariable>
1598    <!-- Variable with index #3 -->
1599    <ScalarVariable name=\"p[1]\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1600        <Real relativeQuantity=\"false\" start=\"1.2\" />
1601    </ScalarVariable>
1602    <!-- Variable with index #4 -->
1603    <ScalarVariable name=\"p[2]\" valueReference=\"1\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1604        <Real relativeQuantity=\"false\" start=\"0.0\" />
1605    </ScalarVariable>
1606    <!-- Variable with index #5 -->
1607    <ScalarVariable name=\"temp_1[1]\" valueReference=\"12\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1608        <Real relativeQuantity=\"false\" />
1609    </ScalarVariable>
1610    <!-- Variable with index #6 -->
1611    <ScalarVariable name=\"temp_4\" valueReference=\"13\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1612        <Real relativeQuantity=\"false\" />
1613    </ScalarVariable>
1614    <!-- Variable with index #7 -->
1615    <ScalarVariable name=\"temp_5\" valueReference=\"14\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1616        <Real relativeQuantity=\"false\" />
1617    </ScalarVariable>
1618    <!-- Variable with index #8 -->
1619    <ScalarVariable name=\"vx[1]\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1620        <Real relativeQuantity=\"false\" />
1621    </ScalarVariable>
1622    <!-- Variable with index #9 -->
1623    <ScalarVariable name=\"der(vx[1])\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1624        <Real relativeQuantity=\"false\" derivative=\"8\" />
1625    </ScalarVariable>
1626    <!-- Variable with index #10 -->
1627    <ScalarVariable name=\"vx[2]\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1628        <Real relativeQuantity=\"false\" />
1629    </ScalarVariable>
1630    <!-- Variable with index #11 -->
1631    <ScalarVariable name=\"der(vx[2])\" valueReference=\"11\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1632        <Real relativeQuantity=\"false\" derivative=\"10\" />
1633    </ScalarVariable>
1634    <!-- Variable with index #12 -->
1635    <ScalarVariable name=\"x[1]\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1636        <Real relativeQuantity=\"false\" />
1637    </ScalarVariable>
1638    <!-- Variable with index #13 -->
1639    <ScalarVariable name=\"der(x[1])\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1640        <Real relativeQuantity=\"false\" derivative=\"12\" />
1641    </ScalarVariable>
1642    <!-- Variable with index #14 -->
1643    <ScalarVariable name=\"der(x[1],2)\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1644        <Real relativeQuantity=\"false\" derivative=\"13\" />
1645    </ScalarVariable>
1646    <!-- Variable with index #15 -->
1647    <ScalarVariable name=\"x[2]\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1648        <Real relativeQuantity=\"false\" />
1649    </ScalarVariable>
1650    <!-- Variable with index #16 -->
1651    <ScalarVariable name=\"der(x[2])\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1652        <Real relativeQuantity=\"false\" derivative=\"15\" />
1653    </ScalarVariable>
1654    <!-- Variable with index #17 -->
1655    <ScalarVariable name=\"der(x[2],2)\" valueReference=\"11\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1656        <Real relativeQuantity=\"false\" derivative=\"16\" />
1657    </ScalarVariable>
1658</ModelVariables>
1659"),
1660        FClassMethodTestCase(
1661            name="HigherOrderOrphanTempDerivatives_alias",
1662            methodName="aliasDiagnostics",
1663            description="Ensure that the temporary is in the set of alias variables",
1664            expose_temp_vars_in_fmu=true,
1665            fmi_version="2.0",
1666            methodResult="
1667Alias sets:
1668{_der_vx[2], _der_der_x[2], temp_9}
1669{_der_vx[1], _der_der_x[1], _der_der_temp_1[1], temp_8}
16705 variables can be eliminated
1671")})));
1672end HigherOrderOrphanTempDerivatives;
1673
1674model StructuralStartValueBase
1675    parameter Integer n = 3;
1676    Real[n] x = 1:n;
1677    parameter Real a = 3 annotation(Evaluate=true);
1678    final parameter Real b = 3;
1679end StructuralStartValue;
1680
1681model StructuralStartValue1
1682    extends StructuralStartValueBase;
1683    annotation(__JModelica(UnitTesting(tests={
1684        FmiXMLCodeGenTestCase(
1685            name="StructuralStartValue1",
1686            description="Check that structural parameters does not generate a start value.",
1687            fmi_version="1.0",
1688            template="
1689$modelVariables$
1690",
1691            generatedCode="
1692<ModelVariables>
1693    <!-- Variable with index #1 -->
1694    <ScalarVariable name=\"a\" valueReference=\"2\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
1695        <Real relativeQuantity=\"false\" start=\"3.0\" />
1696    </ScalarVariable>
1697    <!-- Variable with index #2 -->
1698    <ScalarVariable name=\"b\" valueReference=\"2\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
1699        <Real relativeQuantity=\"false\" start=\"3.0\" />
1700    </ScalarVariable>
1701    <!-- Variable with index #3 -->
1702    <ScalarVariable name=\"n\" valueReference=\"268435459\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
1703        <Integer start=\"3\" />
1704    </ScalarVariable>
1705    <!-- Variable with index #4 -->
1706    <ScalarVariable name=\"x[1]\" valueReference=\"0\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
1707        <Real relativeQuantity=\"false\" start=\"1.0\" />
1708    </ScalarVariable>
1709    <!-- Variable with index #5 -->
1710    <ScalarVariable name=\"x[2]\" valueReference=\"1\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
1711        <Real relativeQuantity=\"false\" start=\"2.0\" />
1712    </ScalarVariable>
1713    <!-- Variable with index #6 -->
1714    <ScalarVariable name=\"x[3]\" valueReference=\"2\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
1715        <Real relativeQuantity=\"false\" start=\"3.0\" />
1716    </ScalarVariable>
1717</ModelVariables>
1718")})));
1719end StructuralStartValue1;
1720
1721model StructuralStartValue2
1722    extends StructuralStartValueBase;
1723    annotation(__JModelica(UnitTesting(tests={
1724        FmiXMLCodeGenTestCase(
1725            name="StructuralStartValue2",
1726            description="Check that structural parameters does not generate a start value.",
1727            fmi_version="2.0",
1728            template="
1729$modelVariables$
1730",
1731            generatedCode="
1732<ModelVariables>
1733    <!-- Variable with index #1 -->
1734    <ScalarVariable name=\"a\" valueReference=\"2\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1735        <Real relativeQuantity=\"false\" start=\"3.0\" />
1736    </ScalarVariable>
1737    <!-- Variable with index #2 -->
1738    <ScalarVariable name=\"b\" valueReference=\"2\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1739        <Real relativeQuantity=\"false\" start=\"3.0\" />
1740    </ScalarVariable>
1741    <!-- Variable with index #3 -->
1742    <ScalarVariable name=\"n\" valueReference=\"268435459\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1743        <Integer start=\"3\" />
1744    </ScalarVariable>
1745    <!-- Variable with index #4 -->
1746    <ScalarVariable name=\"x[1]\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1747        <Real relativeQuantity=\"false\" start=\"1.0\" />
1748    </ScalarVariable>
1749    <!-- Variable with index #5 -->
1750    <ScalarVariable name=\"x[2]\" valueReference=\"1\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1751        <Real relativeQuantity=\"false\" start=\"2.0\" />
1752    </ScalarVariable>
1753    <!-- Variable with index #6 -->
1754    <ScalarVariable name=\"x[3]\" valueReference=\"2\" causality=\"local\" variability=\"constant\" initial=\"exact\">
1755        <Real relativeQuantity=\"false\" start=\"3.0\" />
1756    </ScalarVariable>
1757</ModelVariables>
1758")})));
1759end StructuralStartValue2;
1760
1761model NoInitialTypeForInputs
1762    input Real myInput;
1763
1764    annotation(__JModelica(UnitTesting(tests={
1765        FmiXMLCodeGenTestCase(
1766            name="NoInitialTypeForInputs",
1767            description="Check that input variables does not generate an initial type.",
1768            fmi_version="2.0",
1769            template="
1770$modelVariables$
1771",
1772            generatedCode="
1773<ModelVariables>
1774    <!-- Variable with index #1 -->
1775    <ScalarVariable name=\"myInput\" valueReference=\"0\" causality=\"input\" variability=\"continuous\">
1776        <Real relativeQuantity=\"false\" start=\"0.0\" />
1777    </ScalarVariable>
1778</ModelVariables>
1779")})));
1780end NoInitialTypeForInputs;
1781
1782model TempVars1
1783    function f
1784        input Real i;
1785        output Real o[2];
1786    algorithm
1787        o := {i,-i};
1788    annotation(Inline=false);
1789    end f;
1790
1791    Real x;
1792equation
1793    x = f(time) * {3,4};
1794
1795    annotation(__JModelica(UnitTesting(tests={
1796        FmiXMLCodeGenTestCase(
1797            name="TempVars1",
1798            description="Ensures that temporary variables isn't exposed in the xml by default",
1799            template="
1800$modelVariables$
1801",
1802            generatedCode="
1803<ModelVariables>
1804    <!-- Variable with index #1 -->
1805    <ScalarVariable name=\"x\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
1806        <Real relativeQuantity=\"false\" />
1807    </ScalarVariable>
1808</ModelVariables>
1809
1810")})));
1811end TempVars1;
1812
1813model TempVars2
1814    function f
1815        input Real i;
1816        output Real o[2];
1817    algorithm
1818        o := {i,-i};
1819    annotation(Inline=false);
1820    end f;
1821
1822    Real x;
1823equation
1824    x = f(time) * {3,4};
1825
1826    annotation(__JModelica(UnitTesting(tests={
1827        FmiXMLCodeGenTestCase(
1828            name="TempVars2",
1829            description="Ensures that temporary variables are exposed in the xml when expose_temp_vars_in_fmu is set to true",
1830            expose_temp_vars_in_fmu=true,
1831            template="
1832$modelVariables$
1833",
1834            generatedCode="
1835<ModelVariables>
1836    <!-- Variable with index #1 -->
1837    <ScalarVariable name=\"temp_1[1]\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
1838        <Real relativeQuantity=\"false\" />
1839    </ScalarVariable>
1840    <!-- Variable with index #2 -->
1841    <ScalarVariable name=\"temp_1[2]\" valueReference=\"2\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
1842        <Real relativeQuantity=\"false\" />
1843    </ScalarVariable>
1844    <!-- Variable with index #3 -->
1845    <ScalarVariable name=\"x\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
1846        <Real relativeQuantity=\"false\" />
1847    </ScalarVariable>
1848</ModelVariables>
1849
1850")})));
1851end TempVars2;
1852
1853model TempVarState1
1854        function f
1855        input Real x[2];
1856        input Real A[2,2];
1857        output Real y[2];
1858    algorithm
1859        y := A*x;
1860    annotation(derivative=f_der,LateInline=true);
1861    end f;
1862
1863    function f_der
1864        input Real x[2];
1865        input Real A[2,2];
1866        input Real der_x[2];
1867        input Real der_A[2,2];
1868        output Real der_y[2];
1869    algorithm
1870        der_y := A*der_x;
1871    annotation(LateInline=true);
1872    end f_der;
1873
1874    parameter Real A[2,2] = {{1,2},{3,4}};
1875    Real x1[2](each stateSelect=StateSelect.never),x2[2](each stateSelect=StateSelect.never);
1876equation
1877    der(x1) + der(x2) = {2,3};
1878    x1 + f(x2,A) = {0,0};
1879
1880    annotation(__JModelica(UnitTesting(tests={
1881        FmiXMLCodeGenTestCase(
1882            name="TempVarState1",
1883            description="Ensures that temporary variables are exposed in the xml when they are differentiated (or derivative)",
1884            fmi_version="2.0",
1885            template="
1886$modelVariables$
1887$modelStructure$
1888",
1889            generatedCode="
1890<ModelVariables>
1891    <!-- Variable with index #1 -->
1892    <ScalarVariable name=\"A[1,1]\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1893        <Real relativeQuantity=\"false\" start=\"1.0\" />
1894    </ScalarVariable>
1895    <!-- Variable with index #2 -->
1896    <ScalarVariable name=\"A[1,2]\" valueReference=\"1\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1897        <Real relativeQuantity=\"false\" start=\"2.0\" />
1898    </ScalarVariable>
1899    <!-- Variable with index #3 -->
1900    <ScalarVariable name=\"A[2,1]\" valueReference=\"2\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1901        <Real relativeQuantity=\"false\" start=\"3.0\" />
1902    </ScalarVariable>
1903    <!-- Variable with index #4 -->
1904    <ScalarVariable name=\"A[2,2]\" valueReference=\"3\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
1905        <Real relativeQuantity=\"false\" start=\"4.0\" />
1906    </ScalarVariable>
1907    <!-- Variable with index #5 -->
1908    <ScalarVariable name=\"temp_6\" valueReference=\"6\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1909        <Real relativeQuantity=\"false\" />
1910    </ScalarVariable>
1911    <!-- Variable with index #6 -->
1912    <ScalarVariable name=\"der(temp_6)\" valueReference=\"4\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1913        <Real relativeQuantity=\"false\" derivative=\"5\" />
1914    </ScalarVariable>
1915    <!-- Variable with index #7 -->
1916    <ScalarVariable name=\"temp_7\" valueReference=\"7\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1917        <Real relativeQuantity=\"false\" />
1918    </ScalarVariable>
1919    <!-- Variable with index #8 -->
1920    <ScalarVariable name=\"der(temp_7)\" valueReference=\"5\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1921        <Real relativeQuantity=\"false\" derivative=\"7\" />
1922    </ScalarVariable>
1923    <!-- Variable with index #9 -->
1924    <ScalarVariable name=\"x1[1]\" valueReference=\"8\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1925        <Real relativeQuantity=\"false\" />
1926    </ScalarVariable>
1927    <!-- Variable with index #10 -->
1928    <ScalarVariable name=\"der(x1[1])\" valueReference=\"12\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1929        <Real relativeQuantity=\"false\" derivative=\"9\" />
1930    </ScalarVariable>
1931    <!-- Variable with index #11 -->
1932    <ScalarVariable name=\"x1[2]\" valueReference=\"9\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1933        <Real relativeQuantity=\"false\" />
1934    </ScalarVariable>
1935    <!-- Variable with index #12 -->
1936    <ScalarVariable name=\"der(x1[2])\" valueReference=\"14\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1937        <Real relativeQuantity=\"false\" derivative=\"11\" />
1938    </ScalarVariable>
1939    <!-- Variable with index #13 -->
1940    <ScalarVariable name=\"x2[1]\" valueReference=\"10\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1941        <Real relativeQuantity=\"false\" />
1942    </ScalarVariable>
1943    <!-- Variable with index #14 -->
1944    <ScalarVariable name=\"der(x2[1])\" valueReference=\"13\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1945        <Real relativeQuantity=\"false\" derivative=\"13\" />
1946    </ScalarVariable>
1947    <!-- Variable with index #15 -->
1948    <ScalarVariable name=\"x2[2]\" valueReference=\"11\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1949        <Real relativeQuantity=\"false\" />
1950    </ScalarVariable>
1951    <!-- Variable with index #16 -->
1952    <ScalarVariable name=\"der(x2[2])\" valueReference=\"15\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
1953        <Real relativeQuantity=\"false\" derivative=\"15\" />
1954    </ScalarVariable>
1955</ModelVariables>
1956
1957<ModelStructure>
1958    <Derivatives>
1959        <Unknown index=\"6\" dependencies=\"\" />
1960        <Unknown index=\"8\" dependencies=\"\" />
1961    </Derivatives>
1962    <InitialUnknowns>
1963        <Unknown index=\"5\" dependencies=\"\" />
1964        <Unknown index=\"6\" dependencies=\"1 2 3 4\" />
1965        <Unknown index=\"7\" dependencies=\"\" />
1966        <Unknown index=\"8\" dependencies=\"1 2 3 4\" />
1967    </InitialUnknowns>
1968</ModelStructure>
1969")})));
1970end TempVarState1;
1971
1972model ConstantAliasBase
1973    constant Real a = 1;
1974    constant Real b = a;
1975    constant Integer[n] c = 1:n;
1976    parameter Integer n = x1 + integer(x2);
1977    parameter Integer x1 = 1;
1978    parameter Real x2 = 1;
1979    constant String s1 = "string";
1980    constant String s2 = s1;
1981    parameter String s3 = "string" annotation(Evaluate=true);
1982   
1983    type E = enumeration(A,B,C);
1984   
1985    constant E e1 = e2;
1986    constant E e2 = E.B;
1987    constant E e3 = E.B;
1988    constant E e4 = E.C;
1989end ConstantAliasBase;
1990
1991model ConstantAlias1
1992    extends ConstantAliasBase;
1993    annotation(__JModelica(UnitTesting(tests={
1994        FmiXMLCodeGenTestCase(
1995            name="ConstantAlias1",
1996            description="Check xml with constant alias sets",
1997            fmi_version="1.0",
1998            template="
1999$modelVariables$
2000",
2001            generatedCode="
2002<ModelVariables>
2003    <!-- Variable with index #1 -->
2004    <ScalarVariable name=\"a\" valueReference=\"0\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2005        <Real relativeQuantity=\"false\" start=\"1.0\" />
2006    </ScalarVariable>
2007    <!-- Variable with index #2 -->
2008    <ScalarVariable name=\"b\" valueReference=\"0\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2009        <Real relativeQuantity=\"false\" start=\"1.0\" />
2010    </ScalarVariable>
2011    <!-- Variable with index #3 -->
2012    <ScalarVariable name=\"c[1]\" valueReference=\"268435457\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2013        <Integer start=\"1\" />
2014    </ScalarVariable>
2015    <!-- Variable with index #4 -->
2016    <ScalarVariable name=\"c[2]\" valueReference=\"268435458\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2017        <Integer start=\"2\" />
2018    </ScalarVariable>
2019    <!-- Variable with index #5 -->
2020    <ScalarVariable name=\"e1\" valueReference=\"268435459\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2021        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias1.E\" start=\"2\" />
2022    </ScalarVariable>
2023    <!-- Variable with index #6 -->
2024    <ScalarVariable name=\"e2\" valueReference=\"268435459\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2025        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias1.E\" start=\"2\" />
2026    </ScalarVariable>
2027    <!-- Variable with index #7 -->
2028    <ScalarVariable name=\"e3\" valueReference=\"268435459\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2029        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias1.E\" start=\"2\" />
2030    </ScalarVariable>
2031    <!-- Variable with index #8 -->
2032    <ScalarVariable name=\"e4\" valueReference=\"268435460\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2033        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias1.E\" start=\"3\" />
2034    </ScalarVariable>
2035    <!-- Variable with index #9 -->
2036    <ScalarVariable name=\"n\" valueReference=\"268435458\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2037        <Integer start=\"2\" />
2038    </ScalarVariable>
2039    <!-- Variable with index #10 -->
2040    <ScalarVariable name=\"s1\" valueReference=\"805306368\" variability=\"constant\" causality=\"internal\" alias=\"noAlias\">
2041        <String start=\"string\" />
2042    </ScalarVariable>
2043    <!-- Variable with index #11 -->
2044    <ScalarVariable name=\"s2\" valueReference=\"805306368\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2045        <String start=\"string\" />
2046    </ScalarVariable>
2047    <!-- Variable with index #12 -->
2048    <ScalarVariable name=\"s3\" valueReference=\"805306368\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2049        <String start=\"string\" />
2050    </ScalarVariable>
2051    <!-- Variable with index #13 -->
2052    <ScalarVariable name=\"x1\" valueReference=\"268435457\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2053        <Integer start=\"1\" />
2054    </ScalarVariable>
2055    <!-- Variable with index #14 -->
2056    <ScalarVariable name=\"x2\" valueReference=\"0\" variability=\"constant\" causality=\"internal\" alias=\"alias\">
2057        <Real relativeQuantity=\"false\" start=\"1.0\" />
2058    </ScalarVariable>
2059</ModelVariables>
2060")})));
2061end ConstantAlias1;
2062
2063model ConstantAlias2
2064    extends ConstantAliasBase;
2065    annotation(__JModelica(UnitTesting(tests={
2066        FmiXMLCodeGenTestCase(
2067            name="ConstantAlias2",
2068            description="Check xml with constant alias sets",
2069            fmi_version="2.0",
2070            template="
2071$modelVariables$
2072",
2073            generatedCode="
2074<ModelVariables>
2075    <!-- Variable with index #1 -->
2076    <ScalarVariable name=\"a\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2077        <Real relativeQuantity=\"false\" start=\"1.0\" />
2078    </ScalarVariable>
2079    <!-- Variable with index #2 -->
2080    <ScalarVariable name=\"b\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2081        <Real relativeQuantity=\"false\" start=\"1.0\" />
2082    </ScalarVariable>
2083    <!-- Variable with index #3 -->
2084    <ScalarVariable name=\"c[1]\" valueReference=\"268435457\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2085        <Integer start=\"1\" />
2086    </ScalarVariable>
2087    <!-- Variable with index #4 -->
2088    <ScalarVariable name=\"c[2]\" valueReference=\"268435458\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2089        <Integer start=\"2\" />
2090    </ScalarVariable>
2091    <!-- Variable with index #5 -->
2092    <ScalarVariable name=\"e1\" valueReference=\"268435459\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2093        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias2.E\" start=\"2\" />
2094    </ScalarVariable>
2095    <!-- Variable with index #6 -->
2096    <ScalarVariable name=\"e2\" valueReference=\"268435459\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2097        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias2.E\" start=\"2\" />
2098    </ScalarVariable>
2099    <!-- Variable with index #7 -->
2100    <ScalarVariable name=\"e3\" valueReference=\"268435459\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2101        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias2.E\" start=\"2\" />
2102    </ScalarVariable>
2103    <!-- Variable with index #8 -->
2104    <ScalarVariable name=\"e4\" valueReference=\"268435460\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2105        <Enumeration declaredType=\"FmiXMLTests.ConstantAlias2.E\" start=\"3\" />
2106    </ScalarVariable>
2107    <!-- Variable with index #9 -->
2108    <ScalarVariable name=\"n\" valueReference=\"268435458\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2109        <Integer start=\"2\" />
2110    </ScalarVariable>
2111    <!-- Variable with index #10 -->
2112    <ScalarVariable name=\"s1\" valueReference=\"805306368\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2113        <String start=\"string\" />
2114    </ScalarVariable>
2115    <!-- Variable with index #11 -->
2116    <ScalarVariable name=\"s2\" valueReference=\"805306368\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2117        <String start=\"string\" />
2118    </ScalarVariable>
2119    <!-- Variable with index #12 -->
2120    <ScalarVariable name=\"s3\" valueReference=\"805306368\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2121        <String start=\"string\" />
2122    </ScalarVariable>
2123    <!-- Variable with index #13 -->
2124    <ScalarVariable name=\"x1\" valueReference=\"268435457\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2125        <Integer start=\"1\" />
2126    </ScalarVariable>
2127    <!-- Variable with index #14 -->
2128    <ScalarVariable name=\"x2\" valueReference=\"0\" causality=\"local\" variability=\"constant\" initial=\"exact\">
2129        <Real relativeQuantity=\"false\" start=\"1.0\" />
2130    </ScalarVariable>
2131</ModelVariables>
2132")})));
2133end ConstantAlias2;
2134
2135model StringStartValueIllegalChars1
2136  parameter String a = "Carbon steel (%C <= 0.30)";
2137 
2138  annotation(__JModelica(UnitTesting(tests={
2139        FmiXMLCodeGenTestCase(
2140            name="StringStartValueIllegalChars1",
2141            description="Test that no illegal XML characters are generated",
2142            fmi_version="1.0",
2143            template="$modelVariables$",
2144            generatedCode="
2145<ModelVariables>
2146    <!-- Variable with index #1 -->
2147    <ScalarVariable name=\"a\" valueReference=\"805306368\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
2148        <String start=\"Carbon steel (%C &lt;= 0.30)\" />
2149    </ScalarVariable>
2150</ModelVariables>
2151")})));
2152end StringStartValueIllegalChars1;
2153
2154model StringStartValueIllegalChars2
2155  parameter String a = "Carbon steel (%C <= 0.30)";
2156 
2157  annotation(__JModelica(UnitTesting(tests={
2158        FmiXMLCodeGenTestCase(
2159            name="StringStartValueIllegalChars2",
2160            description="Test that no illegal XML characters are generated",
2161            fmi_version="2.0",
2162            template="$modelVariables$",
2163            generatedCode="
2164<ModelVariables>
2165    <!-- Variable with index #1 -->
2166    <ScalarVariable name=\"a\" valueReference=\"805306368\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
2167        <String start=\"Carbon steel (%C &lt;= 0.30)\" />
2168    </ScalarVariable>
2169</ModelVariables>
2170")})));
2171end StringStartValueIllegalChars2;
2172
2173model Quantity1
2174    Real x(quantity="Time") = time;
2175  annotation(__JModelica(UnitTesting(tests={
2176        FmiXMLCodeGenTestCase(
2177            name="Quantity1",
2178            description="Quantity attribute",
2179            fmi_version="2.0",
2180            template="$modelVariables$",
2181            generatedCode="
2182<ModelVariables>
2183    <!-- Variable with index #1 -->
2184    <ScalarVariable name=\"x\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2185        <Real quantity=\"Time\" relativeQuantity=\"false\" />
2186    </ScalarVariable>
2187</ModelVariables>
2188")})));
2189end Quantity1;
2190
2191
2192model VendorAnnotations1
2193    Real x = time;
2194
2195annotation(__JModelica(UnitTesting(tests={
2196    FmiXMLCodeGenTestCase(
2197        name="VendorAnnotations1",
2198        description="VendorAnnotations for FMI 1.0",
2199        fmi_version="1.0",
2200        template="$vendorAnnotations$",
2201        regexp="/Tool name=\"[^\"]+\"/Tool name=\"\"/",
2202        generatedCode="
2203<VendorAnnotations>
2204        <Tool name=\"\">
2205                <Annotation name=\"CompilerVersion\" value=\"compiler_version_file_not_read\" />
2206        </Tool>
2207</VendorAnnotations>
2208")})));
2209end VendorAnnotations1;
2210
2211
2212model VendorAnnotations2
2213    Real x = time;
2214
2215annotation(__JModelica(UnitTesting(tests={
2216    FmiXMLCodeGenTestCase(
2217        name="VendorAnnotations2",
2218        description="VendorAnnotations for FMI 2.0",
2219        fmi_version="2.0",
2220        template="$vendorAnnotations$",
2221        regexp="/Tool name=\"[^\"]+\"/Tool name=\"\"/",
2222        generatedCode="
2223<VendorAnnotations>
2224        <Tool name=\"\">
2225                <Annotations>
2226                        <Annotation name=\"CompilerVersion\" value=\"compiler_version_file_not_read\" />
2227                </Annotations>
2228        </Tool>
2229</VendorAnnotations>
2230")})));
2231end VendorAnnotations2;
2232
2233model DummyDerivative1
2234
2235    model M
2236        Real x1;
2237        Real x2;
2238    equation
2239        der(x1) + der(x2) = 2;
2240        x1 + x2*time = 0;
2241    end M;
2242
2243    M m;
2244
2245
2246    annotation(__JModelica(UnitTesting(tests={
2247        FmiXMLCodeGenTestCase(
2248            name="DummyDerivative1",
2249            description="XML name of dummy derivative",
2250            fmi_version="1.0",
2251            template="
2252$modelVariables$
2253",
2254            generatedCode="
2255<ModelVariables>
2256    <!-- Variable with index #1 -->
2257    <ScalarVariable name=\"m.x1\" valueReference=\"2\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2258        <Real relativeQuantity=\"false\" />
2259    </ScalarVariable>
2260    <!-- Variable with index #2 -->
2261    <ScalarVariable name=\"der(m.x1)\" valueReference=\"3\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2262        <Real relativeQuantity=\"false\" />
2263    </ScalarVariable>
2264    <!-- Variable with index #3 -->
2265    <ScalarVariable name=\"m.x2\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2266        <Real relativeQuantity=\"false\" />
2267    </ScalarVariable>
2268    <!-- Variable with index #4 -->
2269    <ScalarVariable name=\"der(m.x2)\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2270        <Real relativeQuantity=\"false\" />
2271    </ScalarVariable>
2272</ModelVariables>
2273")})));
2274end DummyDerivative1;
2275
2276model DummyDerivative2
2277
2278    model M
2279        Real x1;
2280        Real x2;
2281    equation
2282        der(x1) + der(x2) = 2;
2283        x1 + x2*time = 0;
2284    end M;
2285
2286    M m;
2287
2288
2289    annotation(__JModelica(UnitTesting(tests={
2290        FmiXMLCodeGenTestCase(
2291            name="DummyDerivative2",
2292            description="XML name of dummy derivative",
2293            fmi_version="2.0",
2294            template="
2295$modelVariables$
2296$modelStructure$
2297",
2298            generatedCode="
2299<ModelVariables>
2300    <!-- Variable with index #1 -->
2301    <ScalarVariable name=\"m.x1\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2302        <Real relativeQuantity=\"false\" />
2303    </ScalarVariable>
2304    <!-- Variable with index #2 -->
2305    <ScalarVariable name=\"der(m.x1)\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2306        <Real relativeQuantity=\"false\" derivative=\"1\" />
2307    </ScalarVariable>
2308    <!-- Variable with index #3 -->
2309    <ScalarVariable name=\"m.x2\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2310        <Real relativeQuantity=\"false\" />
2311    </ScalarVariable>
2312    <!-- Variable with index #4 -->
2313    <ScalarVariable name=\"der(m.x2)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2314        <Real relativeQuantity=\"false\" derivative=\"3\" />
2315    </ScalarVariable>
2316</ModelVariables>
2317
2318<ModelStructure>
2319    <Derivatives>
2320        <Unknown index=\"4\" dependencies=\"3\" />
2321    </Derivatives>
2322    <InitialUnknowns>
2323        <Unknown index=\"3\" dependencies=\"\" />
2324        <Unknown index=\"4\" dependencies=\"\" />
2325    </InitialUnknowns>
2326</ModelStructure>
2327")})));
2328end DummyDerivative2;
2329
2330model Start1
2331    Real x(fixed=true);
2332    Real y(start=0, fixed=true);
2333equation
2334    der(x) = 1;
2335    der(y) = 1;
2336
2337    annotation(__JModelica(UnitTesting(tests={
2338        FmiXMLCodeGenTestCase(
2339            name="Start1",
2340            description="Start value with fixed",
2341            fmi_version="1.0",
2342            template="
2343$modelVariables$
2344",
2345            generatedCode="
2346<ModelVariables>
2347    <!-- Variable with index #1 -->
2348    <ScalarVariable name=\"x\" valueReference=\"2\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2349        <Real relativeQuantity=\"false\" start=\"0.0\" />
2350    </ScalarVariable>
2351    <!-- Variable with index #2 -->
2352    <ScalarVariable name=\"der(x)\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2353        <Real relativeQuantity=\"false\" />
2354    </ScalarVariable>
2355    <!-- Variable with index #3 -->
2356    <ScalarVariable name=\"y\" valueReference=\"3\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2357        <Real relativeQuantity=\"false\" start=\"0.0\" />
2358    </ScalarVariable>
2359    <!-- Variable with index #4 -->
2360    <ScalarVariable name=\"der(y)\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2361        <Real relativeQuantity=\"false\" />
2362    </ScalarVariable>
2363</ModelVariables>
2364")})));
2365end Start1;
2366
2367model Start2
2368    Real x(fixed=true);
2369    Real y(start=0, fixed=true);
2370equation
2371    der(x) = 1;
2372    der(y) = 1;
2373
2374    annotation(__JModelica(UnitTesting(tests={
2375        FmiXMLCodeGenTestCase(
2376            name="Start2",
2377            description="Start value with fixed",
2378            fmi_version="2.0",
2379            template="
2380$modelVariables$
2381",
2382            generatedCode="
2383<ModelVariables>
2384    <!-- Variable with index #1 -->
2385    <ScalarVariable name=\"x\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"exact\">
2386        <Real relativeQuantity=\"false\" start=\"0.0\" />
2387    </ScalarVariable>
2388    <!-- Variable with index #2 -->
2389    <ScalarVariable name=\"der(x)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2390        <Real relativeQuantity=\"false\" derivative=\"1\" />
2391    </ScalarVariable>
2392    <!-- Variable with index #3 -->
2393    <ScalarVariable name=\"y\" valueReference=\"3\" causality=\"local\" variability=\"continuous\" initial=\"exact\">
2394        <Real relativeQuantity=\"false\" start=\"0.0\" />
2395    </ScalarVariable>
2396    <!-- Variable with index #4 -->
2397    <ScalarVariable name=\"der(y)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2398        <Real relativeQuantity=\"false\" derivative=\"3\" />
2399    </ScalarVariable>
2400</ModelVariables>
2401")})));
2402end Start2;
2403
2404model Start3
2405    Real x(start=0, fixed=true);
2406    Real y(start=0, fixed=true);
2407equation
2408    der(x) = time;
2409    y = x;
2410
2411    annotation(__JModelica(UnitTesting(tests={
2412        FmiXMLCodeGenTestCase(
2413            name="Start3",
2414            description="Start value with fixed, aliases",
2415            fmi_version="1.0",
2416            template="
2417$modelVariables$
2418",
2419            generatedCode="
2420<ModelVariables>
2421    <!-- Variable with index #1 -->
2422    <ScalarVariable name=\"x\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"alias\">
2423        <Real relativeQuantity=\"false\" />
2424    </ScalarVariable>
2425    <!-- Variable with index #2 -->
2426    <ScalarVariable name=\"y\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2427        <Real relativeQuantity=\"false\" start=\"0.0\" />
2428    </ScalarVariable>
2429    <!-- Variable with index #3 -->
2430    <ScalarVariable name=\"der(y)\" valueReference=\"0\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2431        <Real relativeQuantity=\"false\" />
2432    </ScalarVariable>
2433</ModelVariables>
2434")})));
2435end Start3;
2436
2437model Start4
2438    Real x(start=0, fixed=true);
2439    Real y(start=0, fixed=true);
2440equation
2441    der(x) = time;
2442    y = x;
2443
2444    annotation(__JModelica(UnitTesting(tests={
2445        FmiXMLCodeGenTestCase(
2446            name="Start4",
2447            description="Start value with fixed, aliases",
2448            fmi_version="2.0",
2449            template="
2450$modelVariables$
2451",
2452            generatedCode="
2453<ModelVariables>
2454    <!-- Variable with index #1 -->
2455    <ScalarVariable name=\"x\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2456        <Real relativeQuantity=\"false\" />
2457    </ScalarVariable>
2458    <!-- Variable with index #2 -->
2459    <ScalarVariable name=\"y\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"exact\">
2460        <Real relativeQuantity=\"false\" start=\"0.0\" />
2461    </ScalarVariable>
2462    <!-- Variable with index #3 -->
2463    <ScalarVariable name=\"der(y)\" valueReference=\"0\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2464        <Real relativeQuantity=\"false\" derivative=\"2\" />
2465    </ScalarVariable>
2466</ModelVariables>
2467")})));
2468end Start4;
2469
2470model Start5
2471    parameter Real p = 1;
2472    Real x(start=p, fixed=true);
2473equation
2474    der(x) = time;
2475
2476    annotation(__JModelica(UnitTesting(tests={
2477        FmiXMLCodeGenTestCase(
2478            name="Start5",
2479            description="Start value with fixed, parameter start",
2480            fmi_version="1.0",
2481            template="
2482$modelVariables$
2483",
2484            generatedCode="
2485<ModelVariables>
2486    <!-- Variable with index #1 -->
2487    <ScalarVariable name=\"p\" valueReference=\"0\" variability=\"parameter\" causality=\"internal\" alias=\"noAlias\">
2488        <Real relativeQuantity=\"false\" start=\"1.0\" />
2489    </ScalarVariable>
2490    <!-- Variable with index #2 -->
2491    <ScalarVariable name=\"x\" valueReference=\"2\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2492        <Real relativeQuantity=\"false\" />
2493    </ScalarVariable>
2494    <!-- Variable with index #3 -->
2495    <ScalarVariable name=\"der(x)\" valueReference=\"1\" variability=\"continuous\" causality=\"internal\" alias=\"noAlias\">
2496        <Real relativeQuantity=\"false\" />
2497    </ScalarVariable>
2498</ModelVariables>
2499")})));
2500end Start5;
2501
2502model ParametricAttributes1
2503    parameter Real p = 1;
2504    input Real x1(min=p, max=p, nominal=p);
2505    Real x2(min=p, max=p, nominal=p);
2506    output Real x3(min=p, max=p, nominal=p);
2507equation
2508    der(x2) = x1;
2509    x3 = x2;
2510
2511    annotation(__JModelica(UnitTesting(tests={
2512        FmiXMLCodeGenTestCase(
2513            name="ParametricAttributes1",
2514            description="",
2515            fmi_version="2.0",
2516            template="
2517$modelVariables$
2518",
2519            generatedCode="
2520<ModelVariables>
2521    <!-- Variable with index #1 -->
2522    <ScalarVariable name=\"p\" valueReference=\"0\" causality=\"parameter\" variability=\"fixed\" initial=\"exact\">
2523        <Real relativeQuantity=\"false\" start=\"1.0\" />
2524    </ScalarVariable>
2525    <!-- Variable with index #2 -->
2526    <ScalarVariable name=\"x1\" valueReference=\"3\" causality=\"input\" variability=\"continuous\">
2527        <Real relativeQuantity=\"false\" min=\"1.0\" max=\"1.0\" nominal=\"1.0\" start=\"0.0\" />
2528    </ScalarVariable>
2529    <!-- Variable with index #3 -->
2530    <ScalarVariable name=\"x2\" valueReference=\"2\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2531        <Real relativeQuantity=\"false\" min=\"1.0\" max=\"1.0\" nominal=\"1.0\" />
2532    </ScalarVariable>
2533    <!-- Variable with index #4 -->
2534    <ScalarVariable name=\"der(x2)\" valueReference=\"1\" causality=\"local\" variability=\"continuous\" initial=\"calculated\">
2535        <Real relativeQuantity=\"false\" derivative=\"3\" />
2536    </ScalarVariable>
2537    <!-- Variable with index #5 -->
2538    <ScalarVariable name=\"x3\" valueReference=\"4\" causality=\"output\" variability=\"continuous\" initial=\"calculated\">
2539        <Real relativeQuantity=\"false\" />
2540    </ScalarVariable>
2541</ModelVariables>
2542")})));
2543end ParametricAttributes1;
2544
2545end FmiXMLTests;
Note: See TracBrowser for help on using the repository browser.