Skip to content

Commit

Permalink
added testcase for fmi discrete model structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Mar 6, 2018
1 parent 2919af7 commit 32e74c0
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 2 deletions.
Expand Up @@ -142,10 +142,10 @@ readFile("modelDescription.tmp.xml");
// </ModelVariables>
// <ModelStructure>
// <Outputs>
// <Unknown index=\"4\" dependencies=\"\" dependenciesKind=\"\" />
// <Unknown index=\"4\" dependencies=\"1\" dependenciesKind=\"dependent\" />
// </Outputs>
// <DiscreteStates>
// <Unknown index=\"3\" dependencies=\"\" dependenciesKind=\"\" />
// <Unknown index=\"3\" dependencies=\"1 2\" dependenciesKind=\"dependent dependent\" />
// </DiscreteStates>
// </ModelStructure>
// </fmiModelDescription>
Expand Down
1 change: 1 addition & 0 deletions openmodelica/fmi/ModelExchange/2.0/Makefile
Expand Up @@ -14,6 +14,7 @@ testBug3049.mos \
testBug3763.mos \
testBug3846.mos \
testBug3902.mos \
testDiscreteStructe.mos \
testInitialEquationsFMI.mos \
TestSourceCodeFMU.mos \
ZeroStates.mos \
Expand Down
212 changes: 212 additions & 0 deletions openmodelica/fmi/ModelExchange/2.0/testDiscreteStructe.mos
@@ -0,0 +1,212 @@
// name: testDiscreteStruct
// keywords: FMI 2.0 export
// status: correct
// teardown_command: rm -rf binaries sources modelDescription.xml modelDescription.tmp.xml testDID* output.log
//

loadModel(Modelica);
setCommandLineOptions("--std=3.3");
loadString("
model testDID
parameter Real p = 1;
parameter Real y1_start = 1;
parameter Real y2_start = 0;
input Real u(start = -2);
output Real y1(start = y1_start, fixed = true);
output Real y2(start = y2_start, fixed = true);
Real ud;
equation
ud = sample(u, Clock(Clock(/*inferred*/), solverMethod = \"ImplicitEuler\"));
der(y1) = p * ud;
der(y2) = previous(y1) + 0.5 * p * ud * interval(ud);
end testDID;
");
getErrorString();

translateModelFMU(testDID, version="2.0");
getErrorString();

// unzip to console, quiet, extra quiet
system("unzip -cqq testDID.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml");
readFile("modelDescription.tmp.xml");

// Result:
// true
// true
// true
// ""
// "testDID.fmu"
// ""
// 0
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
// <fmiModelDescription
// fmiVersion=\"2.0\"
// modelName=\"testDID\"
// description=\"\"
// variableNamingConvention=\"structured\"
// numberOfEventIndicators=\"0\">
// <ModelExchange
// modelIdentifier=\"testDID\">
// </ModelExchange>
// <TypeDefinitions>
// <Clocks>
// <Clock><Inferred/></Clock>
// </Clocks>
// </TypeDefinitions>
// <LogCategories>
// <Category name=\"logEvents\" />
// <Category name=\"logSingularLinearSystems\" />
// <Category name=\"logNonlinearSystems\" />
// <Category name=\"logDynamicStateSelection\" />
// <Category name=\"logStatusWarning\" />
// <Category name=\"logStatusDiscard\" />
// <Category name=\"logStatusError\" />
// <Category name=\"logStatusFatal\" />
// <Category name=\"logStatusPending\" />
// <Category name=\"logAll\" />
// <Category name=\"logFmi2Call\" />
// </LogCategories>
// <DefaultExperiment startTime=\"0.0\" stopTime=\"1.0\" tolerance=\"1e-06\"/>
// <ModelVariables>
// <!-- Index of variable = \"1\" -->
// <ScalarVariable
// name=\"previous(y1)\"
// valueReference=\"0\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"2\" -->
// <ScalarVariable
// name=\"previous(y2)\"
// valueReference=\"1\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"3\" -->
// <ScalarVariable
// name=\"der(y1)\"
// valueReference=\"2\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// initial=\"calculated\">
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"4\" -->
// <ScalarVariable
// name=\"der(y2)\"
// valueReference=\"3\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// initial=\"calculated\">
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"5\" -->
// <ScalarVariable
// name=\"_D_outputStateAlias_y1\"
// valueReference=\"4\"
// variability=\"discrete\"
// causality=\"output\"
// clockIndex=\"1\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"6\" -->
// <ScalarVariable
// name=\"_D_outputStateAlias_y2\"
// valueReference=\"5\"
// variability=\"discrete\"
// causality=\"output\"
// clockIndex=\"1\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"7\" -->
// <ScalarVariable
// name=\"u\"
// valueReference=\"6\"
// variability=\"continuous\"
// causality=\"input\"
// >
// <Real start=\"-2.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"8\" -->
// <ScalarVariable
// name=\"ud\"
// valueReference=\"7\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// initial=\"calculated\">
// <Real/>
// </ScalarVariable>
// <!-- Index of variable = \"9\" -->
// <ScalarVariable
// name=\"y1\"
// valueReference=\"8\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// previous=\"1\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"10\" -->
// <ScalarVariable
// name=\"y2\"
// valueReference=\"9\"
// variability=\"discrete\"
// causality=\"local\"
// clockIndex=\"1\"
// previous=\"2\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"11\" -->
// <ScalarVariable
// name=\"p\"
// valueReference=\"10\"
// variability=\"fixed\"
// causality=\"parameter\"
// initial=\"exact\">
// <Real start=\"1.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"12\" -->
// <ScalarVariable
// name=\"y1_start\"
// valueReference=\"11\"
// variability=\"fixed\"
// causality=\"parameter\"
// initial=\"exact\">
// <Real start=\"1.0\"/>
// </ScalarVariable>
// <!-- Index of variable = \"13\" -->
// <ScalarVariable
// name=\"y2_start\"
// valueReference=\"12\"
// variability=\"fixed\"
// causality=\"parameter\"
// initial=\"exact\">
// <Real start=\"0.0\"/>
// </ScalarVariable>
// </ModelVariables>
// <ModelStructure>
// <Outputs>
// <Unknown index=\"5\" dependencies=\"1 7\" dependenciesKind=\"dependent dependent\" />
// <Unknown index=\"6\" dependencies=\"1 2 7\" dependenciesKind=\"dependent dependent dependent\" />
// </Outputs>
// <DiscreteStates>
// <Unknown index=\"9\" dependencies=\"1 7\" dependenciesKind=\"dependent dependent\" />
// <Unknown index=\"10\" dependencies=\"1 2 7\" dependenciesKind=\"dependent dependent dependent\" />
// </DiscreteStates>
// </ModelStructure>
// </fmiModelDescription>
// "
// endResult

0 comments on commit 32e74c0

Please sign in to comment.