-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
feat: add substitute_component
#3502
feat: add substitute_component
#3502
Conversation
I agree that that would be a great syntax. However, we use |
oldargs = [ap.input; ap.outputs] | ||
end | ||
newargs = map(get_systems(eq.rhs)) do arg | ||
name = arg isa AbstractSystem ? nameof(arg) : getname(arg) |
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've tested this locally a bit and I have a case where eq.rhs
is a (top level) connect
equation and the arg
s are ModelingToolkit.SymbolicWithNameof
and then getname(arg)
gives the Symbol("var_name(t)")
variant instead of just :var_name
. I saw that using getname(arg.var)
works, but I'm not sure if that makes sense since the resulting system crashes on printing during n_expanded_connection_equations
😅.
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.
Oh oops, I always forget that SymbolicWithNameof
exists. Thanks for pointing it out.
b5fb23c
to
2d9d4e1
Compare
We could really use this functionality, but unless I'm mistaken the requirements limit its applicability.
Eg. "What if we replaced this continuously-stirred tank with a non-stirred tank?" might not meet these requirements, right? Or "ComplexReactorModel => NaiveReactorModel". I understand that there's probably an efficiency reason for these constraints, but in this case I would rather have inefficient-and-general than efficient-but-limited. My use case is for running experiments. "What if we replaced component A.B.C with C2(...)?" is much nicer to write than copy-paste the Is there another way of doing this? |
It's not an efficiency but correctness issue. It's really difficult to see how a component (and all subcomponents) are used across the entire model and then verify that the replacement has the same pieces. I'd be more than happy to work on it in the future, but this addresses a limited set of problems with scope for expansion in the future. The way to do this is define the model with an "interface component" - one which isn't intended for simulation but has the bare minimum interface required to connect with the rest of the system. This can then be replaced to form different model variants. |
2d9d4e1
to
e747405
Compare
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.