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

Evaluate number of phases parameter #3119

Merged
merged 5 commits into from
Feb 2, 2020

Conversation

henrikt-ma
Copy link
Contributor

@henrikt-ma henrikt-ma commented Sep 13, 2019

This PR is limited to Modelica.Electrical and Modelica.Magnetic. It does for these sub-libraries what #3113 does for Modelica.Mechanics, namely change some components declared parameter to be constant instead in order to make clear to both users and tools that they can and are expected to be evaluated during translation.

There is ongoing discussion in #3113 whether the right way to do this would be with Evaluate=true instead of constant, and the two PRs should be settled the same way.

Note connection to #1966, which is fixed by the first commit.

Fix #1966.

@beutlich beutlich added L: Electrical.Machines Issue addresses Modelica.Electrical.Machines L: Electrical.PowerConverters Issue addresses Modelica.Electrical.PowerConverters L: Electrical.Polyphase Issue addresses Modelica.Electrical.Polyhase L: Electrical.QuasiStatic Issue addresses Modelica.Electrical.QuasiStatic L: Magnetic.FundamentalWave Issue addresses Modelica.Magnetic.FundamentalWave L: Magnetic.QuasiStatic Issue addresses Modelica.Magnetic.QuasiStatic labels Sep 14, 2019
Copy link
Contributor

@christiankral christiankral left a comment

Choose a reason for hiding this comment

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

I am afraid I do not understand this PR. Why should m be constant in thePolyphase package, which is intended to model an arbitrary number of phases. The case m = 3 is very common in power engineering, but Polyphase is definitely not limited to three phases.

@beutlich
Copy link
Member

beutlich commented Sep 15, 2019

I am afraid I do not understand this PR.

You need to read #3113 to get the actual purpose of constants ad evaluated parameters.

@hendrikt-ma I recommend to wait with further similar change proposals as long as #3113 is not merged. And given the current reviews it does not look that promising.

@henrikt-ma
Copy link
Contributor Author

@hendrikt-ma I recommend to wait with further similar change proposals as long as #3113 is not merged. And given the current reviews it does not look that promising.

No problem. I don't have any more PRs like this in the pipe. I've done what I can to improve the situation, and now it's time to enjoy the show.

@henrikt-ma
Copy link
Contributor Author

I am afraid I do not understand this PR. Why should m be constant in thePolyphase package, which is intended to model an arbitrary number of phases. The case m = 3 is very common in power engineering, but Polyphase is definitely not limited to three phases.

The key change here, is that the phase index is now a constant (fixing #1966). The constants were given a Dialog annotation so that tools should still let the user select the value similar to when they were parameters, but I didn't foresee that Dymola would hide the constants despite the presence of Dialog.

Then, with the phase index being a constant, it follows naturally that also the number of phases is also a constant.

In the end, I guess the lack of respect for Dialog in some tools and the unfinished status of modelica/ModelicaSpecification#2211 will force me to degrade these changes to use Evaluate=true instead…

@AHaumer
Copy link
Contributor

AHaumer commented Dec 1, 2019

I dislike the idea to use a constant with annotation(Dialog) instead of a parameter.

AHaumer
AHaumer previously requested changes Dec 8, 2019
Copy link
Contributor

@AHaumer AHaumer left a comment

Choose a reason for hiding this comment

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

I dislike the idea to use a constant with annotation(Dialog) instead of a parameter.

@henrikt-ma
Copy link
Contributor Author

I dislike the idea to use a constant with annotation(Dialog) instead of a parameter.

Should that be interpreted as preferring the use of Evaluate=true, or do you expect tools to do some other magic to end up with the expected equation systems?

Out of curiosity, is it because of the lack of Dymola support for constants with Dialog that you prefer a parameter, or do you see other reasons?

@AHaumer
Copy link
Contributor

AHaumer commented Dec 22, 2019

@henrikt-ma
In my understanding the number of phases is a parameter, not a constant. Evaluate=true is fine.

@henrikt-ma
Copy link
Contributor Author

OK, so it's the confusion about the name constant, not the Modelica variability constant again… I really wish there was a name for constant that didn't come with so many expectations that don't have anything to do with variability. Anyway, the conclusion remains: not enough interest in using constant, and I'll have to litter the code with Evaluate=true instead. I'll get to actually doing it some day… :)

@claassistantio
Copy link

claassistantio commented Jan 14, 2020

CLA assistant check
All committers have signed the CLA.

@dietmarw
Copy link
Member

@henrikt-ma Is it fine for you to close this one?

@henrikt-ma
Copy link
Contributor Author

Please don't close, as I'm planning to do this with the Evaluate=true fallback instead.

henrikt-ma added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 21, 2020
…ameter to constant"

This reverts commit 0c367ba.

The use of constants was not accepted by AHaumer, so I'll have to resort to the use of Evaluate=true instead.  See discussion in PR:
modelica#3119
henrikt-ma added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 21, 2020
…ing"

This reverts commit 12e0458.

The use of constants was not accepted by AHaumer, so I'll have to resort to the use of Evaluate=true instead.  See discussion in PR:
modelica#3119
henrikt-ma added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 21, 2020
…r to constant"

This reverts commit 800c702.

The use of constants was not accepted by AHaumer, so I'll have to resort to the use of Evaluate=true instead.  See discussion in PR:
modelica#3119
@henrikt-ma
Copy link
Contributor Author

@AHaumer, per your request, I have now reverted the changes from parameter to constant, and replaced them with the use of Evaluate=true.

Although hidden inside an annotation, this still gives the user a chance to see that the intention is that these parameters should be evaluated during translation.

As long as new components are created by means of copying an existing component and modifying the copy, there's a chance that the Evaluate=true will also be present on similar parameters in the future. Otherwise, we will likely end up in an inconsistent state where the presence of Evaluate=true on a parameter that should be evaluated during translation is more or less random. However, compared to the other drawbacks of using Evaluate=true, I consider this a minor issue. (Note that it would be much more unlikely to get into similar randomness when using constant, as the Modelica tool will enforce the rules of variability.)

beutlich added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 24, 2020
beutlich added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 24, 2020
@beutlich beutlich added the L: ModelicaTest Issue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined label Jan 24, 2020
Copy link
Member

@beutlich beutlich left a comment

Choose a reason for hiding this comment

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

LGTM.

@christiankral
Copy link
Contributor

christiankral commented Jan 26, 2020

Just a side comment: This PR actually also reveals that we have two different implementation of the min = 3 attribute for the parameter m:

  1. parameter Integer m(min=3) = 3 "Number of phases" annotation(Evaluate=true);
  2. parameter Integer m(final min=1) = 3 "Number of phases" annotation(Evaluate=true);

@AHaumer I guess we should replace case 1. by 2. one day, shouldn't we?

@christiankral
Copy link
Contributor

I am OK with this PR but I would like to have @AHaumer's explicit review before merging.

beutlich added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 29, 2020
beutlich added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 29, 2020
beutlich added a commit to henrikt-ma/ModelicaStandardLibrary that referenced this pull request Jan 29, 2020
@beutlich
Copy link
Member

I rebased and resolved the merge conflict.

@AHaumer Can you please add your review as @christiankral requested. Thank you.

@AHaumer
Copy link
Contributor

AHaumer commented Feb 1, 2020

Just a side comment: This PR actually also reveals that we have two different implementation of the min = 3 attribute for the parameter m:

1. `parameter Integer m(min=3) = 3 "Number of phases" annotation(Evaluate=true);`

2. `parameter Integer m(final min=1) = 3 "Number of phases" annotation(Evaluate=true);`

@AHaumer I guess we should replace case 1. by 2. one day, shouldn't we?

Depends where these 2 lines are found.
For Electrical.Machines min=3 is neccesary at the moment.
For PolyPhase min=1 is possible.

henrikt-ma and others added 5 commits February 1, 2020 19:38
This is a constant-free replacement for 800c702 'Change variability of "Phase index" and friends from parameter to constant'.

Let's hope that one doesn't forget to set Evaluate=true when adding new components in the future... (With the use of constant, the Modelica tool would let you know when you accidentally try to introduce a component with a parameter instead of a constant.)

Fixes modelica#1966
This is a constant-free replacement for 0c367ba 'Change variability of "Number of phases" and friends from parameter to constant'.

Let's hope that one doesn't forget to set Evaluate=true when adding new components in the future...  (With the use of constant, the Modelica tool would let you know when you accidentally try to introduce a component with a parameter instead of a constant.)
@beutlich
Copy link
Member

beutlich commented Feb 1, 2020

I resolved the pseudo-merge conflicts again.

@beutlich beutlich requested review from AHaumer and christiankral and removed request for christiankral and AHaumer February 2, 2020 12:18
@beutlich beutlich removed the request for review from AHaumer February 2, 2020 19:29
@beutlich beutlich merged commit cbe6433 into modelica:master Feb 2, 2020
@beutlich beutlich assigned beutlich and unassigned christiankral Feb 2, 2020
@beutlich beutlich changed the title Feature/phase constants Evaluate number of phases parameter Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: Electrical.Machines Issue addresses Modelica.Electrical.Machines L: Electrical.Polyphase Issue addresses Modelica.Electrical.Polyhase L: Electrical.PowerConverters Issue addresses Modelica.Electrical.PowerConverters L: Electrical.QuasiStatic Issue addresses Modelica.Electrical.QuasiStatic L: Magnetic.FundamentalWave Issue addresses Modelica.Magnetic.FundamentalWave L: Magnetic.QuasiStatic Issue addresses Modelica.Magnetic.QuasiStatic L: ModelicaTest Issue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluate parameter phase index in Modelica.Electrical.MultiPhase.Basic.PlugToPin_n
6 participants