-
-
Notifications
You must be signed in to change notification settings - Fork 235
RFC: no-parsing @components
#4029
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
base: master
Are you sure you want to change the base?
Conversation
|
I may have some understanding of the current test failure. It seems that, with @mtkmodel SimpleLag begin
@structural_parameters begin
K # Gain
end
end
@mtkmodel DoubleLag begin
@parameters begin
K1, [description="Proportional gain 1"]
end
@components begin
lag1 = SimpleLag(K = K1)
end
endWhen passing the parameter On this branch, |
Fixes the problem described in SciML#4029 (comment)
|
I figured it out ( |
|
This is... interesting. Given that |
|
We could spawn it off to a separate subpackage. I don't think anyone really plans to maintain it from the core SciML group but it could stay alive in that way, just we shouldn't use it in the docs. |
This PR rewrites the
@componentsparsing logic. Instead of parsing the RHS of each equation in the@componentsblock, it evaluates it normally as plain julia code. Because the new code is a lot simpler, it was relatively easy to improve the flexibility of the model construction interface (see below) along the lines of #3791There's still a lot of work to do, so I'd like to get some feedback before pushing forward (... or giving up). Is that a reasonable direction to take?
The good
__syntax:@mtkcompile my_model = MyModel(sub_component__N=10)__syntax:@mtkcompile my_model = MyModel(sub_component__subsub_component=MyAlternativeComponent()). I believe this fixes Replacing subsystems #2038.resistors = [FixedResistor(), VariableResistor()].ifblocks now work inside of@componentsThe bad
Modelmetadata for components@test A.structure[:components] == [[:cc, :C]]now yields[[:cc, :unimplemented]]. (ButSystemmetadata is fine). How bad is that? Where is that information used? Maybe Dyad?Potential workaround: bring back
#master's parsing code just for metadata parsing. Maybe if I strip that code of everything except the metadata part, it would be reasonably small, and we can give up on more complex cases (that aren't supported ATM anyway)?The ugly
To support
plant__component__subcomponent => AlternativeComponent(), I usedScopedValuesto thread those parameters. I believe that it's broadly fine, but there might be edge cases I haven't thought about.TODO
If this PR looks appealing, then the remaining items would be
Let me know what you think! If this is too disruptive, I can tackle another direction. Most of these features can be implemented without getting rid of the RHS parsing code, but it's a lot more work.