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
In the following example, there are three inputs passed along to io_preprocessing which in turn calls structural_simplify. All three inputs are present as states in the system upon calling io_preprocessing. Before markio! is called within structural_simplify, one of the inputs, (model₊input₊u(t))[2] has been removed from fullvars, leading to the error below:
ERROR: Some specified inputs were not found in system. The following Dict indicates the found variables
Dict{Num, Bool}(
u(t) =>1,
(model₊input₊u(t))[2] =>0,
d(t) =>1
)
Stacktrace:
[1] error(::String, ::Dict{Num, Bool})
@ Base ./error.jl:44
[2] markio!(state::TearingState{ODESystem}, inputs::Vector{Num}, outputs::Vector{Any}; check::Bool)
using ModelingToolkitStandardLibrary.Blocks
A,C = [randn(2,2) for i in1:2]
B = [1.00; 00]
@named model = Blocks.StateSpace(A,B,C)
@named integrator = Blocks.StateSpace( [-0.001;;], [1.0;;], [1.0;;], [0.0;;])
ins =collect(model.input.u)
disturbed_input = ins[1]
@named dist_integ = ModelingToolkit.DisturbanceModel(disturbed_input, integrator)
functionadd_input_disturbance_(sys, dist::DisturbanceModel, inputs)
t = ModelingToolkit.get_iv(sys)
@variablesd(t)=0 [disturbance =true]
@variablesu(t)=0 [input =true] # Potential new system input
dsys = ModelingToolkit.get_disturbance_system(dist)
all_inputs = inputs
all_inputs = Base.setindex(all_inputs, u, findfirst(isequal(dist.input), inputs)) # The input where the disturbance acts is no longer an input, the new
eqs = [dsys.input.u[1] ~ d
dist.input ~ u + dsys.output.u[1]]
augmented_sys =ODESystem(eqs, t, systems = [sys, dsys], name =gensym(:outer))
ModelingToolkit.generate_control_function(augmented_sys, all_inputs, [d])
endadd_input_disturbance_(model, dist_integ, ins)
The text was updated successfully, but these errors were encountered:
and note that (input₊u(t))[2] appear in the system. If you need to assume all states still exist, then I suggest to keep A, B, C, and D parameters making all variables structurally visible. But then, MTK could accidentally divide by 0. Or, just simply remove the check in IO.
YingboMa
changed the title
tearing may remove inputs before they have been marked as inputs by markio!
State space may not contain all states when there are zeros in the matrix entries
Nov 4, 2022
In the following example, there are three inputs passed along to
io_preprocessing
which in turn callsstructural_simplify
. All three inputs are present as states in the system upon callingio_preprocessing
. Beforemarkio!
is called withinstructural_simplify
, one of the inputs,(model₊input₊u(t))[2]
has been removed fromfullvars
, leading to the error below:The text was updated successfully, but these errors were encountered: