-
Notifications
You must be signed in to change notification settings - Fork 41
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
Restricted class for parameter record with initial equation #2311
Comments
Cross-reference: https://stackoverflow.com/q/54717649/8520615 |
Language group:
record Data
Real z=1;
Real x;
equation
/* Or perhaps new keyword ("algebraic equation", "record equation")
to indicate that not dependent on time*/
x=cos(z*x);
end Data;
parameter Data data(z=...); Could set either z or x.
model Data
parameter Real z=1;
parameter Real x(start=0,fixed=false);
initial equation
x=cos(z*x);
end Data;
Data d(z=4);
Will need more, but should not proceed with work-arounds like "initial equation" in records. |
Thinking more I believe that to get this to work as expected we will need several changes. The basic issue is that even if we could create a parameter-record with equations we normally propagate parameter-records in various ways, and we need to handle that as well - and with structural type system that becomes messy. I don't see that the examples justify this. I also realized that there is a straightforward workaround (hinted at 10 years ago).
This is standard Modelica, and to me this solves the issue in a good way (especially if the classes have better names), and allows freely modifying m2.data afterwards. Possibly not only I even see a benefit: we can have multiple initializer-models that compute the parameter-record based on different approximations. Thus I would propose that we close this without any changes. |
|
The cause for not initializing is that M.init.data.x does not become an interaton variable in the initial system for some reason. So it seems to be a tool issue. |
Seems that we can close it for now. |
Based on modelica/ModelicaStandardLibrary#1860
And related to #183
The issue is that we need the ability to create a class containing parameters and implicit equations for them, e.g.:
This is currently not possible, since
parameter
can only be combined withtype
,record
,connector
, and none of those specialized class may contain (initial) equations. In particularrecord
is unsuitable since you cannot pass aroundData
as a record-value.However, it is not clear that
parameter
as part ofparameter Data
is needed, and without itmodel Data
would be perfectly ok. Will clarify.There is also the general discussion whether class should be used. It is sort discouraged in practice, but allowed - and this could be one use and another would be documentation-only classes. There is (currently) at least one case where
class
itself is used: classes derived from ExternalObject (the specification also has this in the example).An existing proposal #1345 is to specify that
model
is the normal modeling class (and not the same asclass
), and since documentation-only isn't a modeling class it wouldn't be odd that it still usesclass
.The text was updated successfully, but these errors were encountered: