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

parameter splitting tries to convert to Union #2815

Open
baggepinnen opened this issue Jun 24, 2024 · 0 comments
Open

parameter splitting tries to convert to Union #2815

baggepinnen opened this issue Jun 24, 2024 · 0 comments

Comments

@baggepinnen
Copy link
Contributor

The following example, which used to work in MTKv8, now fails with no method matching Union{Float64, Particles{Float64, 2000}}(::Int64)

If I try with split=false, I get a solution.

using ModelingToolkit
using ModelingToolkitStandardLibrary: Blocks
using ControlSystemsMTK
using ModelingToolkit, MonteCarloMeasurements, Plots, OrdinaryDiffEq

T = typeof(1 ± 1)
@parameters t k::T d
@variables x(t)::T v(t)::T
D = Differential(t)
eqs = [D(x) ~ v, D(v) ~ -k*x - d*v - 9.82]
@named sys = ODESystem(eqs, t)
prob = ODEProblem(complete(sys), [x => 0.0 ± 0.1, v => 0.0, k => 10 ± 1, d => 1], (0.0, 10.0))
# sol = solve(prob, Tsit5()) # Works
# plot(sol, ri=false, N=1000) # works

W = makeweight(0.1, 1, 0.9)
T = typeof(-1..1)
@parameters Δ::T=(-1..1) # The uncertain element is between -1 and 1
@variables y(t)=0
@named Wsys = ODESystem(W)
connections = [
    Wsys.input.u ~ sys.x
    y ~ sys.x + Wsys.output.u*Δ
]
@named uncertain_sys = ODESystem(connections, t, systems=[sys, Wsys])
initial_condition = [sys.x => zero(T), sys.v => 0, sys.k => 10, sys.d =>1]
prob = ODEProblem(structural_simplify(uncertain_sys, split=true), initial_condition, (0.0, 10.0))
sol = solve(prob, Tsit5())

plot(sol, ri=false, N=500, idxs=[sys.x, sys.v, y], layout=2, sp=[1 2 1], l=[3 3 1]) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant