You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using IfLifting additional pass, I am not able to interpolate the solution beyond the first event.
Expected behavior
I should be able to interpolate the solution at all the the same time instants as I was able to when IfLifting was not being performed.
Minimal Reproducible Example 👇
using ModelingToolkit
using ModelingToolkit: t_nounits as t
using OrdinaryDiffEqDefault
using RuntimeGeneratedFunctions
RuntimeGeneratedFunctions.init(@__MODULE__)
D =Differential(t)
@componentfunctionIntegrator(; name, x0=0, k=1)
params =@parametersbegin
(x0::Float64= x0), [description ="Initial value of the integrator state"]
(k::Float64= k), [description ="Gain"]
end
vars =@variablesbeginu(t), [input =true]
y(t), [output =true]
x(t), [description ="State of Integrator"]
end
initialization_eqs = [
x ~ x0
]
eqs = Equation[
D(x) ~ k * u
y ~ x
]
returnODESystem(eqs, t, vars, params; systems=[], name, initialization_eqs)
end@componentfunctionCosine(; name, start_time=0, offset=0, amplitude=nothing, frequency=nothing, phase=nothing)
params =@parametersbegin
(start_time::Float64= start_time)
(offset::Float64= offset)
(amplitude::Float64= amplitude)
(frequency::Float64= frequency)
(phase::Float64= phase)
end
vars =@variablesbeginy(t), [output =true]
end
eqs = Equation[
y~ifelse(start_time < t, offset + amplitude *cos(2*pi* frequency * (t - start_time) + phase), offset)
]
returnODESystem(eqs, t, vars, params; systems=[], name)
end@componentfunctionCosineTest(; name)
systems =@namedbegin
integrator =Integrator()
signal =Cosine(amplitude=1, frequency=2, start_time=0.5, offset=0.5, phase=3.14)
end
eqs = Equation[
signal.y~integrator.u
]
returnODESystem(eqs, t, [], []; systems, name)
end@named model_full =CosineTest()
model =structural_simplify(model_full; additional_passes=[ModelingToolkit.IfLifting]) # Error with IfLifting# model = structural_simplify(model_full; additional_passes=[]) # Error with IfLifting
u0 = []
prob =ODEProblem(model, u0, (0, 5))
sol =solve(prob, DefaultODEAlgorithm())
# If list the time values, they go up to 5.0, as expected
sol[:t]
# If we interpolate at 0.1 seconds...no problemsol(0.5, idxs=model.signal.y)
# If we interpolate at 0.51 seconds...it fails saying# "Solution interpolation cannot extrapolate past the final timepoint."sol(0.51, idxs=model.signal.y)
# Note the start time for our Cosine wave is 0.5 seconds!
Error & Stacktrace ⚠️
ERROR: Solution interpolation cannot extrapolate past the final timepoint. Either solve on a longer timespan or use the local extrapolation from the integrator interface.
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] interpolation
@ ~/.julia/packages/SciMLBase/3fgw8/src/interpolation.jl:230 [inlined]
[3] (::SciMLBase.ConstantInterpolation{…})(tvals::Float64, idxs::Nothing, deriv::Type, p::Nothing, continuity::Symbol)
@ SciMLBase ~/.julia/packages/SciMLBase/3fgw8/src/interpolation.jl:91
[4] (::ODESolution{…})(t::Float64, ::Type{…}, idxs::Num, continuity::Symbol)
@ SciMLBase ~/.julia/packages/SciMLBase/3fgw8/src/solutions/ode_solutions.jl:290
[5] #_#543
@ ~/.julia/packages/SciMLBase/3fgw8/src/solutions/ode_solutions.jl:221 [inlined]
[6] AbstractODESolution
@ ~/.julia/packages/SciMLBase/3fgw8/src/solutions/ode_solutions.jl:216 [inlined]
[7] top-level scope
@ ~/tmp/IfLifting/BlockComponents/src/mwe.jl:69
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
Output of using Pkg; Pkg.status()
Project BlockComponents v0.12.4
Status `~/tmp/IfLifting/BlockComponents/Project.toml`
[3626b584] JuliaSimCore v0.3.0
⌅ [961ee093] ModelingToolkit v9.61.0
[50262376] OrdinaryDiffEqDefault v1.2.0
[aea7be01] PrecompileTools v1.2.1
[7e49a35a] RuntimeGeneratedFunctions v0.5.13
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`
Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Describe the bug 🐞
Using
IfLifting
additional pass, I am not able to interpolate the solution beyond the first event.Expected behavior
I should be able to interpolate the solution at all the the same time instants as I was able to when
IfLifting
was not being performed.Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: