ibpsa / modelica-ibpsa

Modelica library for building and district energy systems developed within IBPSA Project 1
https://ibpsa.github.io/project1
144 stars 84 forks source link

Simplify filter and avoid translation warning for actuators #1498

Closed mwetter closed 3 years ago

mwetter commented 3 years ago

The filter that is used for actuators triggers many warnings with OCT. These are of the form

*** Compiling IBPSA.Fluid.Actuators.Dampers.Examples.VAVBoxExponential
Warning at line 1879, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.c0 does not have a binding expression
Warning at line 1879, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.c0 does not have a binding expression
Warning at line 1880, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.c1 does not have a binding expression
Warning at line 1880, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.c1 does not have a binding expression
Warning at line 1884, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.a does not have a binding expression
Warning at line 1884, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.a does not have a binding expression
Warning at line 1885, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.b does not have a binding expression
Warning at line 1885, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.b does not have a binding expression
Warning at line 1886, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.ku does not have a binding expression
Warning at line 1886, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.ku does not have a binding expression
Warning at line 1887, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.k1 does not have a binding expression
Warning at line 1887, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.k1 does not have a binding expression
Warning at line 1889, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component dam:
  The parameter dam.filter.k2 does not have a binding expression
Warning at line 1889, column 5, in file '/opt/oct/ThirdParty/MSL/Modelica/Blocks/Continuous.mo',
In component vav:
  The parameter vav.filter.k2 does not have a binding expression

Also, MSL has an implementation of Modelica.Blocks.Continuous.CriticalDamping that could be used instead of the more complex filter Modelica.Blocks.Continuous.Filter, which is currently configured with

...
final analogFilter=Modelica.Blocks.Types.AnalogFilter.CriticalDamping
...

This issue is to update the models to use the simpler implementation of the filter and remove the warnings.

This revision also removes the parameter

  parameter Integer order(min=1) = 2 "Order of filter"
    annotation(Dialog(tab="Dynamics", group="Filtered opening",enable=use_inputFilter));

and sets the order to two as I don't think anyone ever uses another value. If another value should be used for a special application, then this can be done outside of the actuator model.

mwetter commented 3 years ago

Based on the coordination call,

  parameter Integer order(min=1) = 2 "Order of filter"
    annotation(Dialog(tab="Dynamics", group="Filtered opening",enable=use_inputFilter));

should be set to a constant as for special applications, some users set it to 1 to avoid fast states.

mwetter commented 3 years ago

Using the model Modelica.Blocks.Continuous.CriticalDamping leads in some models to larger system of nonlinear equations with Dymola 2022. The tests were done in the Buildings library, branch IBPSASync_issue1498_actuatorFilter.

On a small (edited) model based on Buildings.Examples.Tutorial.CDL.System1, it was found that this is likely due to the symbolic manipulations (maybe the tearing?). The model is shown below: image

The model CriticalDamping implements

  der(x[1]) = (u - x[1])*w;
  for i in 2:n loop
    der(x[i]) = (x[i - 1] - x[i])*w;
  end for;
  y = x[n];

The translation leads to

Sizes after manipulation of the nonlinear systems: {7}
Number of numerical Jacobians: 0

Initialization problem
Sizes of nonlinear systems of equations: {1, 17, 1, 1}
Sizes after manipulation of the nonlinear systems: {0, 6, 0, 0}
Number of numerical Jacobians: 0

If the above filter is changed to

y = 1.001*x[n];  // setting y = 1*x[n]; won't make any change to the translation statistics, the translator seems to eliminate 1

then the translation statistics is

Sizes after manipulation of the nonlinear systems: {5}
Number of numerical Jacobians: 0

Initialization problem
Sizes of nonlinear systems of equations: {1, 17, 1, 1, 1}
Sizes after manipulation of the nonlinear systems: {0, 5, 0, 0, 0}
Number of numerical Jacobians: 0

This statistics is equal to this model if the existing filter implementation is used. Therefore, it seems like to keep the statistics, a coordinate transformation is needed to "trick" the symbolic processing into keeping the old translation statistics.

Mathadon commented 3 years ago

@mwetter I could not replicate this behaviour in Dymola 2020. Or I did something wrong.

In any case, these changed statistics are for the initialisation problem only. I wouldn't worry too much about those?