Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClockedWithDiscretizedContinuousController has clocked variable in initial equation #4458

Open
henrikt-ma opened this issue Sep 3, 2024 · 2 comments · May be fixed by #4465
Open

ClockedWithDiscretizedContinuousController has clocked variable in initial equation #4458

henrikt-ma opened this issue Sep 3, 2024 · 2 comments · May be fixed by #4465
Assignees
Labels
example Issue only addresses example(s) L: Clocked Issue addresses Modelica.Clocked
Milestone

Comments

@henrikt-ma
Copy link
Contributor

The ClockedWithDiscretizedContinuousController contains a clocked instance of Modelica.Blocks.Continuous.PI:

However, this block contains an initial equation:

initial equation
  if initType == Init.SteadyState then
    der(x) = 0;
  elseif initType == Init.InitialState then
    x = x_start;
  elseif initType == Init.InitialOutput then
    y = y_start;
  end if;

This means that the clocked variable y violates one of the two very basic rules about synchronous variable initialization in https://specification.modelica.org/master/synchronous-language-elements.html#initialization-of-clocked-partitions:

Variables in clocked partitions cannot be used in initial equation or initial algorithm sections.

I know that the specification is considered more or less flawed when it comes to achieving the goal of being able to "sample any continuous-time model",

The goal is that every continuous-time Modelica model can be utilized in a sampled data control system. This is achieved by solving the continuous-time equations with a defined integration method between clock ticks. With this feature, it is for example possible to invert the nonlinear dynamic model of a plant, see Thümmel et al. (2005), and use it in a feedforward path of an advanced control system that is associated with a clock.

but while waiting for the specification to achieve this goal, the ClockedWithDiscretizedContinuousController should use a control block without initial equations.

@henrikt-ma henrikt-ma added the L: Clocked Issue addresses Modelica.Clocked label Sep 3, 2024
@henrikt-ma henrikt-ma changed the title ClockedWithDiscretizedContinuousController uses clocked PI block with initial equation ClockedWithDiscretizedContinuousController has clocked variable in initial equation Sep 3, 2024
@casella
Copy link
Contributor

casella commented Sep 10, 2024

See MCP 0038 regarding how to solve this issue in general

henrikt-ma added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this issue Sep 10, 2024
@beutlich beutlich added the example Issue only addresses example(s) label Sep 10, 2024
@casella casella added this to the MSL4.1.0 milestone Sep 17, 2024
@casella
Copy link
Contributor

casella commented Sep 17, 2024

#4465 fixes the issue on master for MSL 4.2.0. @Esther-Devakirubai we should back-port it to maint/4.1.x so we also get this in 4.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example Issue only addresses example(s) L: Clocked Issue addresses Modelica.Clocked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants