Skip to content
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

substitute should take fully qualified substitutions #3023

Open
BenChung opened this issue Sep 6, 2024 · 1 comment
Open

substitute should take fully qualified substitutions #3023

BenChung opened this issue Sep 6, 2024 · 1 comment

Comments

@BenChung
Copy link
Contributor

BenChung commented Sep 6, 2024

The overload for Symbolics.substitute takes a dict mapping symbols to be replaced to the values to replace them with. However, the symbols must be written in the local scope of whatever model you're substituting into:

@parameters y, w
function ExampleMod(;name) 
    @variables begin 
        x(t)=0
        u(t)
    end
    eqs = [ 
        D(x) ~ u
        u ~ y*sin(t)
    ]
    return ODESystem(eqs, t; name=name)
end
@named mdl = ExampleMod()
equations(substitute(mdl, Dict(mdl.y => w))) # still has y in it
equations(substitute(mdl, Dict(y => w))) # replaces y with w

It should be possible to substitute into a system using fully qualified names.

@ChrisRackauckas
Copy link
Member

You can, that's the semantics of a completed system. This is the reason for system completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants