Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added testcase for fmi discrete model structure
Belonging to [master]: - OpenModelica/OMCompiler#2253 - OpenModelica/OpenModelica-testsuite#869
- Loading branch information
1 parent
2919af7
commit 32e74c0
Showing
3 changed files
with
215 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
openmodelica/fmi/ModelExchange/2.0/testDiscreteStructe.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |