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
New block for raising an input to an Integer exponent #4095
base: master
Are you sure you want to change the base?
New block for raising an input to an Integer exponent #4095
Conversation
Why not add this as a feature to the existing model: ie two exponent parameters (realExponont and integerExponent) and a boolean flag to switch between real and integer behavior? |
I think it would be too confusing to use a component with two parameters for the same thing, and too cumbersome to have to specify to things when all you want is to select which exponent to use. Also, the name |
Another thought is to wrap the
...but potentially this is also confusing and the behavior can't be guaranteed to behave as desired. However, in my tests, it always behaved as desired (ie integer(2.0)==2)... I don't feel strongly any which way (probably fine as is). Still, I will comment that this new feature feels more like an "advanced" feature/functionality of an existing component rather than a feature that truly warrants a new component. |
I think that a
|
Ok, if it helps with unit related future improvements, I think that starts to make more sense to me. Though for the examples you gave, I can't help but wonder where "rational numbers" fit into this picture. E.g. there are scenarios like r=(A/pi)^(1/2) which doesn't fit neatly into the examples given (though of course it could be rearranged back into real^integer case). However, as you mentioned, we don't need to discuss here. Thanks! |
Off-topic: While rational numbers in Modelica would be nice, I don't see it happen. More realistically, we could hope for a new built-in
If we get such a function, we could then think about how to expose it in the form of blocks. Edit: Here's a new issue requesting that |
It is good that the MSL now has the
Exponentiation
block. In the future, when the MSL uses Modelica 3.6, however, there will be a difference between raising an expression to aReal
or to anInteger
exponent, see:This PR introduces an
IntegerExponentiation
block similar toExponentiation
, but with anInteger
exponent.The fact that there is no separation in semantics in the Modelica version used by the MSL today doesn't mean one cannot have two different blocks already today. Offering both blocks makes it possible to make a future-proof selection of which block to use, and users may also be able to take advantage of the
IntegerExponent
even before the MSL changes to Modelica 3.6, as it is often possible for users to enable more modern language features in tools while still using an MSL pointing to a language version from the past.