Open dhblum opened 6 years ago
This error can be resolved if:
allowFlowReversal = false
andenergyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState
Setting energyDynamics=SteadyState
removes part of the use of a MixingVolume
. I am using them all over the place without problems so I'm not sure why you are getting problems. The folks at Modelon should be able to fix this in no time. I can also have a look at it after newyear.
What equation is actually causing the problem? In any case, if it's a parameter, try adding annotation(Evaluate=true)
.
@dhblum, @Mathadon, could you eventually find a solution for this? I'm running into same trouble:
java.lang.UnsupportedOperationException: Cannot convert expression to MX: fill(0.0, 0)
at org.jmodelica.optimica.compiler.FExp.toMX(Unknown Source)
at org.jmodelica.optimica.compiler.FExp.toMXVector(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionCall.toMXVector(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionCall.toMXVector(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionCall.toMX(Unknown Source)
at org.jmodelica.optimica.compiler.FDotMulExp.toMX(Unknown Source)
at org.jmodelica.optimica.compiler.FDotAddExp.toMX(Unknown Source)
and couldn't solve it even when setting allowFlowReversal=false
and energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState
. I'm using the BuildingMpc.Media.DryAir
package, and found out that the issue boils down to this equation in the flattened model:
Modelica.SIunits.Energy vol.dynBal.U(start = vol.dynBal.fluidVolume * vol.dynBal.rho_start * BuildingMpc.Media.DryAir.specificInternalEnergy(BuildingMpc.Media.DryAir.setState_pTX(vol.dynBal.p_start, vol.dynBal.T_start, fill(0.0, 0))) + (vol.dynBal.T_start - 273.15) * vol.dynBal.CSen,nominal = 100000.0) "Internal energy of fluid";
where the expression fill()
is being used to provide an input value to X
in function BuildingMpc.Media.DryAir.setState_pTX(p,T,X)
. It is very surprising to me that the fill()
expression is being used there since the BuildingMpc.Media.DryAir
package is hardcoded with reference_X={1}
, which should eventually be used to initialize X_start
in the Fluid.Sources.MixingVolume model.
I've tried with the old JModelica 2.2 and also with JModelica 2.14 in Windows with both giving the same result.
UPDATE: I realized that the reason why this solution was not solving the problem was that I only had one port connected to the mixing volume of my very simple test exaple. This which was forcing to use the dynamic balance of the mixing volume even when energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState
. When two ports are connected, the solution of @dhblum indeed relieves the error. Notice though that as @Mathadon points out this is only a partial solution since part of the mixing volume is not being used. Additionally, I encounter further errors not only with the use of fill()
, but also with other elementary Modelica operators like:
java.lang.UnsupportedOperationException: Cannot convert expression to MX: size(per.V_flow, 1)
at org.jmodelica.optimica.compiler.FExp.toMX(Unknown Source)
at org.jmodelica.optimica.compiler.FExp.toMXVector(Unknown Source)
at org.jmodelica.optimica.compiler.FAssignStmt.updateExpressionsAccordingToStatement(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionDecl.generateFinalExpressionVector(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionDecl.toMXFunction_compute(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionDecl.toMXFunction(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionCall.toMXVector(Unknown Source)
at org.jmodelica.optimica.compiler.FFunctionCall.toMX(Unknown Source)
at org.jmodelica.optimica.compiler.FEquation.toMXForRhs(Unknown Source)
@JavierArroyoBastida Your experience is similar to mine. I have not yet found a solution for using the mixing volume directly with dynamic energy balance.
thanks @dhblum for answering! I've not found a solution either, but something that has helped in the process is setting the following compiler options:
compiler_options['inline_functions']='all' # Controlles what function calls are inlined. 'none' - nofunction calls are inlined. 'trivial' - inline function calls that will not increase the number of variables in the system. 'all' - inline all function calls that are possible
compiler_options['homotopy_type']='simplified' # Decides how homotopy expressions are interpreted during compilation. Can be set to either 'simplified' or'actual' which will compile the model using only the simplified or actual expressions of the homotopy() operator.
This issue is to create a Fluid.Sources.MixingVolume model that works.
JModelica optimization with IBPSA.Fluid.Sources.MixingVolume results in