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

Change to NoInit in ClockedWithDiscretizedContinuousController #4465

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

henrikt-ma
Copy link
Contributor

Fixes #4458.

As discussed in today's MAP-Lib monthly meeting.

There appears to be no need to update the reference result.

@beutlich beutlich added example Issue only addresses example(s) L: Clocked Issue addresses Modelica.Clocked labels Sep 10, 2024
Copy link
Contributor

@casella casella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With @HansOlsson's suggestion this looks good to me, also for MSL 4.1.0

@casella casella added this to the MSL4.2.0 milestone Sep 17, 2024
@casella
Copy link
Contributor

casella commented Sep 17, 2024

@Esther-Devakirubai, please back-port this to maint/4.1.x as soon as it is merged in. Thanks!

initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=0,
initType=Modelica.Blocks.Types.Init.NoInit,
x(fixed=true),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't x(fixed = true) a violation of this rule from https://specification.modelica.org/master/synchronous-language-elements.html#initialization-of-clocked-partitions?

Attribute fixed cannot be applied to variables in clocked partitions. The attribute fixed is true for variables to which previous is applied, otherwise false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. So, how are initial conditions specified for such clocked partitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid question, but more work on the specification side is needed to answer it. Until then, I would just find it best to avoid breaking one of the few simple rules we have.

By the way, System Modeler also warns about underdetermined initialization where PI.x was automatically selected to be initialized from start, so it is not only in Dymola that this example will not run as cleanly as we'd ideally want it to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should also mention that System Modeler is lacking a check for

Attribute fixed cannot be applied to variables in clocked partitions.

so I can't tell how close the rest of the MSL is to complying with the rule.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some more thinking I think the specification got a bit messed up when trying to clarify.

Basically I don't see how we can get this to work as desired for MSL with the current specification:

However, going back to 3.5 the rule for initial equations and fixed only applied to "clocked discrete-time partitions", which are now called "discrete-time sub-partitions". That should be restored, and we can see that example in https://specification.modelica.org/master/synchronous-language-elements.html#solver-methods has fixed=true.

Obviously we will later clarify initialization for "discrete-time sub-partitions".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "having fully defined initial conditions" is a strong requirement for tool-independent behaviour. If this is not possible with the current specification, I agree at relaxing/changing it. @HansOlsson would the proposed changes to the code OK with your proposed change to the MLS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the proposed change to the specification there is no need to update this model at all, as the restrictions apply equally to initial equations and fixed=true.

Copy link
Contributor

@HansOlsson HansOlsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As indicated I believe there's a slight error in the specification that should be corrected instead. Thus this one will not be needed.

@Esther-Devakirubai
Copy link
Contributor

@casella @HansOlsson Will Backport this as per Casella's comment #4465 (comment)
Is that okay?

@HansOlsson
Copy link
Contributor

@casella @HansOlsson Will Backport this as per Casella's comment #4465 (comment) Is that okay?

No, we first need to clear up if it is needed or not (and if needed exactly how). My current interpretation is that it isn't needed and the specification should be updated instead.

@HansOlsson
Copy link
Contributor

Should not be needed after modelica/ModelicaSpecification#3577 is merged.

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 this pull request may close these issues.

ClockedWithDiscretizedContinuousController has clocked variable in initial equation
5 participants