From 4f26c776afb720761aabdf2fc5f9734cb7b9bba7 Mon Sep 17 00:00:00 2001 From: arun3688 Date: Wed, 21 Feb 2024 15:27:54 +0100 Subject: [PATCH] export stepSize to in modeldescription.xml (#12017) * expected output * do not export stepSize to FMI-1.0 --- .../Compiler/Template/CodegenCppInit.tpl | 2 +- OMCompiler/Compiler/Template/CodegenFMU1.tpl | 2 +- OMCompiler/Compiler/Template/CodegenFMU2.tpl | 2 +- .../Compiler/Template/CodegenFMUCommon.tpl | 11 ++++-- ...MultiBody.Examples.Elementary.Pendulum.mos | 6 +-- .../fmu/modelExchange/2.0/exposeLocalIOs.mos | 2 +- .../modelExchange/2.0/testArrayEquations.mos | 2 +- .../fmu/modelExchange/2.0/testCSTR.mos | 2 +- .../2.0/testClockDescription.mos | 2 +- .../fmu/modelExchange/2.0/testDrumBoiler.mos | 2 +- .../2.0/testModelDescription.mos | 2 +- .../fmi/ModelExchange/2.0/Makefile | 1 + .../ModelExchange/2.0/fmi_attributes_15.mos | 2 +- .../ModelExchange/2.0/fmi_attributes_21.mos | 39 +++++++++++++++++++ .../fmi/ModelExchange/2.0/testBug2764.mos | 2 +- .../fmi/ModelExchange/2.0/testBug3049.mos | 2 +- .../fmi/ModelExchange/2.0/testDisableDep.mos | 2 +- .../ModelExchange/2.0/testDiscreteStructe.mos | 2 +- 18 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_21.mos diff --git a/OMCompiler/Compiler/Template/CodegenCppInit.tpl b/OMCompiler/Compiler/Template/CodegenCppInit.tpl index aa43299c77a..f3851195809 100644 --- a/OMCompiler/Compiler/Template/CodegenCppInit.tpl +++ b/OMCompiler/Compiler/Template/CodegenCppInit.tpl @@ -19,7 +19,7 @@ template modelInitXMLFile(SimCode simCode, String numRealVars, String numIntVars let descriptionTag = if generateFMUModelDescription then "fmiModelDescription" else "ModelDescription" let fmiDescriptionAttributes = if generateFMUModelDescription then fmiDescriptionAttributes(simCode, FMUVersion, FMUType, FMUGuid) else 'modelName="<%dotPath(modelInfo.name)%>"' let fmiTypeDefinitions = if generateFMUModelDescription then CodegenFMUCommon.fmiTypeDefinitions(simCode, FMUVersion) - let fmiDefaultExperiment = if generateFMUModelDescription then CodegenFMUCommon.DefaultExperiment(simulationSettingsOpt) + let fmiDefaultExperiment = if generateFMUModelDescription then CodegenFMUCommon.DefaultExperiment(simulationSettingsOpt, FMUVersion) << diff --git a/OMCompiler/Compiler/Template/CodegenFMU1.tpl b/OMCompiler/Compiler/Template/CodegenFMU1.tpl index 2b5bed8401c..44a6aeb19ad 100644 --- a/OMCompiler/Compiler/Template/CodegenFMU1.tpl +++ b/OMCompiler/Compiler/Template/CodegenFMU1.tpl @@ -64,7 +64,7 @@ case SIMCODE(__) then > <%fmiTypeDefinitions(simCode, "1.0")%> - <%DefaultExperiment(simulationSettingsOpt)%> + <%DefaultExperiment(simulationSettingsOpt, "1.0")%> <%fmiModelVariables(simCode, "1.0")%> <%if isFMICSType(FMUType) then Implementation()%> diff --git a/OMCompiler/Compiler/Template/CodegenFMU2.tpl b/OMCompiler/Compiler/Template/CodegenFMU2.tpl index 87575d220d0..1836b1acb9e 100644 --- a/OMCompiler/Compiler/Template/CodegenFMU2.tpl +++ b/OMCompiler/Compiler/Template/CodegenFMU2.tpl @@ -98,7 +98,7 @@ case SIMCODE(__) then >> %> - <%DefaultExperiment(simulationSettingsOpt)%> + <%DefaultExperiment(simulationSettingsOpt, "2.0")%> <%fmiModelVariables(simCode, "2.0")%> <%ModelStructure(modelStructure)%> diff --git a/OMCompiler/Compiler/Template/CodegenFMUCommon.tpl b/OMCompiler/Compiler/Template/CodegenFMUCommon.tpl index 991c7e9d1de..6366394373c 100644 --- a/OMCompiler/Compiler/Template/CodegenFMUCommon.tpl +++ b/OMCompiler/Compiler/Template/CodegenFMUCommon.tpl @@ -793,21 +793,26 @@ match type_ >> end TypeDefinitionType; -template DefaultExperiment(Option simulationSettingsOpt) +template DefaultExperiment(Option simulationSettingsOpt, String FMUVersion) "Generates code for DefaultExperiment file for FMU target." ::= match simulationSettingsOpt case SOME(v) then << - /> + /> >> end DefaultExperiment; -template DefaultExperimentAttribute(SimulationSettings simulationSettings) +template DefaultExperimentAttribute(SimulationSettings simulationSettings, String FMUVersion) "Generates code for DefaultExperiment Attribute file for FMU target." ::= match simulationSettings case SIMULATION_SETTINGS(__) then + if isFMIVersion20(FMUVersion) then + << + startTime="<%startTime%>" stopTime="<%stopTime%>" tolerance="<%tolerance%>" stepSize="<%stepSize%>" + >> + else << startTime="<%startTime%>" stopTime="<%stopTime%>" tolerance="<%tolerance%>" >> diff --git a/testsuite/omsimulator/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos b/testsuite/omsimulator/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos index fe6195b4bfc..439cf57521d 100644 --- a/testsuite/omsimulator/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos +++ b/testsuite/omsimulator/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos @@ -14,12 +14,12 @@ readFile("Pendulum_systemCall.log"); // "Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.fmu" // "" // 0 -// "info: maximum step size for 'model.root': 0.010000 +// "info: maximum step size for 'model.root': 0.002000 // info: Result file: model_res.mat (bufferSize=10) // info: Parameter model.root.fmu.world.label1 will not be stored in the result file, because the signal type is not supported // info: Parameter model.root.fmu.world.label2 will not be stored in the result file, because the signal type is not supported // info: Final Statistics for 'model.root': -// NumSteps = 523 NumRhsEvals = 533 NumLinSolvSetups = 36 -// NumNonlinSolvIters = 532 NumNonlinSolvConvFails = 0 NumErrTestFails = 1 +// NumSteps = 2511 NumRhsEvals = 2517 NumLinSolvSetups = 134 +// NumNonlinSolvIters = 2516 NumNonlinSolvConvFails = 0 NumErrTestFails = 1 // " // endResult diff --git a/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/exposeLocalIOs.mos b/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/exposeLocalIOs.mos index c1a088438c1..e4fd2d2c955 100644 --- a/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/exposeLocalIOs.mos +++ b/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/exposeLocalIOs.mos @@ -120,7 +120,7 @@ readFile("modelDescription.tmp.xml"); // // // -// +// // // // // // -// +// // // // // // -// +// // // // // // -// +// // // // // // -// +// // // // // // -// +// // // // // // -// +// // // // fmi_attributes_21_tmp.xml"); getErrorString(); + +system("sed -n \"/ fmi_attributes_21.xml"); getErrorString(); +readFile("fmi_attributes_21.xml"); getErrorString(); + + +// Result: +// true +// "" +// "fmi_attributes_21.fmu" +// "" +// 0 +// "" +// 0 +// "" +// " +// " +// "" +// endResult diff --git a/testsuite/openmodelica/fmi/ModelExchange/2.0/testBug2764.mos b/testsuite/openmodelica/fmi/ModelExchange/2.0/testBug2764.mos index 6586c888151..000ebb75d8d 100644 --- a/testsuite/openmodelica/fmi/ModelExchange/2.0/testBug2764.mos +++ b/testsuite/openmodelica/fmi/ModelExchange/2.0/testBug2764.mos @@ -129,7 +129,7 @@ readFile("modelDescription.tmp.xml"); // // // -// +// // // // // // -// +// // // // // // -// +// // // // // // -// +// // // //