diff --git a/OMCompiler/Compiler/SimCode/SimCodeUtil.mo b/OMCompiler/Compiler/SimCode/SimCodeUtil.mo index c2c019d59d6..6aec0036267 100644 --- a/OMCompiler/Compiler/SimCode/SimCodeUtil.mo +++ b/OMCompiler/Compiler/SimCode/SimCodeUtil.mo @@ -13658,12 +13658,13 @@ algorithm if debug then BackendDump.dumpVariables(currentSystem.orderedVars,"orderedVariables"); BackendDump.dumpEquationArray(currentSystem.orderedEqs,"orderedEquation"); + BackendDump.dumpVariables(shared.globalKnownVars,"globalknownVars"); end if; // traverse the simulation DAE globalknownVars and update the initialization DAE with new equations and vars for var in BackendVariable.varList(inSimDAE.shared.globalKnownVars) loop - // check for param Vars, as we are only interested in causality = calculatedParameters - if BackendVariable.isParam(var) then + // check for param Vars, as we are only interested in causality = parameters + if BackendVariable.isParam(var) and not BackendVariable.containsCref(var.varName, currentSystem.orderedVars) then lhs := BackendVariable.varExp(var); rhs := BackendVariable.varBindExpStartValueNoFail(var) "bindings are optional"; eqn := BackendDAE.EQUATION(lhs, rhs, DAE.emptyElementSource, BackendDAE.EQ_ATTR_DEFAULT_BINDING); @@ -13672,7 +13673,7 @@ algorithm //var := BackendVariable.setVarFixed(var,false); //var := BackendVariable.setVarKind(var, BackendDAE.VARIABLE()); currentSystem := BackendVariable.addVarDAE(var, currentSystem); - else + elseif not BackendVariable.containsCref(var.varName, currentSystem.orderedVars) then shared := BackendVariable.addGlobalKnownVarDAE(var, shared); end if; end for; diff --git a/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/testDrumBoiler.mos b/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/testDrumBoiler.mos index 32a33422196..023dfe3db2d 100644 --- a/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/testDrumBoiler.mos +++ b/testsuite/openmodelica/cppruntime/fmu/modelExchange/2.0/testDrumBoiler.mos @@ -129,7 +129,7 @@ val(evaporator_qm_S, 100); // // // -// +// // // // @@ -179,7 +179,7 @@ val(evaporator_qm_S, 100); // // // -// +// // // // -// +// // // // -// +// // // // -// +// // // // -// +// // // // -// +// // // // // // -// -// -// -// -// -// -// -// -// -// -// +// +// +// +// +// +// +// +// +// +// +// // -// -// -// -// -// -// -// +// +// +// +// +// +// +// // -// +// // // // // -// -// -// -// -// -// -// -// -// -// -// +// +// +// +// +// +// +// +// +// +// +// // // // @@ -2352,7 +2352,7 @@ val(evaporator_qm_S, 100); // "" // record SimulationResult // resultFile = "DrumBoilerModel_me_FMU_res.mat", -// simulationOptions = "startTime = 0.0, stopTime = 100.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'DrumBoilerModel_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-override=q_F=10,Y_Valve=1'", +// simulationOptions = "startTime = 0.0, stopTime = 100.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'DrumBoilerModel_me_FMU', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-override=q_F=10,Y_Valve=1'", // messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. // LOG_SUCCESS | info | The simulation finished successfully. // " @@ -2360,10 +2360,10 @@ val(evaporator_qm_S, 100); // "" // 10.0 // 1.0 -// 1.066186961478094 -// 1.132373922956188 -// -16.62186178224934 -// 101.4102128671589 -// 66.98717518863343 -// -1.132373922956188 +// 1.06618690902324 +// 1.132373818046481 +// -16.62186201223443 +// 101.4102114768519 +// 66.98717539330144 +// -1.132373818046481 // endResult diff --git a/testsuite/openmodelica/fmi/ModelExchange/2.0/Makefile b/testsuite/openmodelica/fmi/ModelExchange/2.0/Makefile index ce41888f262..7fb0c1039e4 100644 --- a/testsuite/openmodelica/fmi/ModelExchange/2.0/Makefile +++ b/testsuite/openmodelica/fmi/ModelExchange/2.0/Makefile @@ -19,6 +19,7 @@ fmi_attributes_12.mos \ fmi_attributes_13.mos \ fmi_attributes_14.mos \ fmi_attributes_15.mos \ +fmi_attributes_16.mos \ FMIExercise.mos \ FMUResourceTest.mos \ HelloFMIWorld.mos \ diff --git a/testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_16.mos b/testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_16.mos new file mode 100644 index 00000000000..c557de90145 --- /dev/null +++ b/testsuite/openmodelica/fmi/ModelExchange/2.0/fmi_attributes_16.mos @@ -0,0 +1,76 @@ +// name: fmi_attributes_16.mos +// status: correct +// teardown_command: rm -rf fmi_attributes_16.fmu fmi_attributes_16.log fmi_attributes_16.xml fmi_attributes_16_tmp.xml fmi_attributes_16.fmutmp/ + +loadString(" +model fmi_attributes_16 + Real x(fixed=true, start=x_start); + parameter Real x_start(fixed=false); +initial equation + der(x) + x_start = 1; +equation + der(x) = 0.0; +end fmi_attributes_16; +"); getErrorString(); + +translateModelFMU(fmi_attributes_16); getErrorString(); + +// unzip to console, quiet, extra quiet +system("unzip -cqq fmi_attributes_16.fmu modelDescription.xml > fmi_attributes_16_tmp.xml"); getErrorString(); +system("sed -n \"//,/<\\/ModelVariables>/p\" fmi_attributes_16_tmp.xml > fmi_attributes_16.xml"); getErrorString(); +readFile("fmi_attributes_16.xml"); getErrorString(); + +system("sed -n \"//,/<\\/ModelStructure>/p\" fmi_attributes_16_tmp.xml > fmi_attributes_16.xml"); getErrorString(); +readFile("fmi_attributes_16.xml"); getErrorString(); + +// Result: +// true +// "" +// "fmi_attributes_16.fmu" +// "" +// 0 +// "" +// 0 +// "" +// " +// +// +// +// +// +// +// +// +// +// +// +// +// +// " +// "" +// 0 +// "" +// " +// +// +// +// +// +// +// +// +// +// " +// "" +// endResult