-
Notifications
You must be signed in to change notification settings - Fork 164
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
Add discrete intermediate variable to Mean block to clarify that the block output is a continuous-time variable #3269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the reason for these changes.
Having "discrete" on an output is pretty useless in Modelica; as it doesn't propagate to the input (when connecting the block to another block).
Not using the base-class "SISO" causes code duplication (especially since there is no DiscreteSISO) - and there are some more complicated consequences of that in Dymola.
Well, I started with Mean, which is a discrete block by design, when using the inheritance from DiscreteBlock. Additionally, SystemModeler complained about output y not being made discrete, which is the reason why I did not extend from DiscreteSISO (in Interfaces), but from DiscreteBlock. Then, I noticed that RectifiedMean, RootMeanSquare, Harmonic all use the Mean block as component by passing the sampling frequency. For that reason I changed the icon from SISO to Discrete for these three blocks, too. |
The reason y cannot be discrete in DiscreteSISO is that the "discrete" definition in Modelica isn't propagated and thus Mean may have a discrete output but not RectifiedMean (as currently implemented; Clocked signals are better in that way). And you cannot detect it when connecting to the output so, I don't see why making the output "discrete" is important. I understand that there has been some issues related to that in SystemModeler - but that is how Modelica is defined. On the other hand not using inheritance will cause problems in Dymola (even though it should work the same way in Modelica). However, the base Interfaces.DiscreteBlock is also problematic, and complicates the code for little gain (you have to switch between classes to understand the new class, including realizing that the extra protected outputs aren't used etc). In general my view is that if we duplicate code instead of using Interfaces-classes there is some problem with the design of the Interface-classes; and we should first fix that. |
OK, I see. Let's consider the two issues here. Mean and the 3 other blocks.
|
An easy way to fix this in a clean way is:
The output is then clearly a continuous-time variable. |
Probably with |
Yes |
d1da137
to
0851d59
Compare
Now SystemModeler no longer complains. Looks better and cleaner now indeed. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. That seems like a much simpler solution.
Just a tiny change: Change the initial equation to "y_last=0" instead of "y=0".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I still don't see why it is necessary, but at least it doesn't break anything.
Two reasons for the change:
|
Note, that Mean.y is marked as discrete output.Not sure if these blocks rather belong to Modelica.Blocks.Discrete.