Skip to content

Commit 9422935

Browse files
committed
add specification of op for original inputs
does not work, since the original inputs have the wrong namespace
1 parent 0153147 commit 9422935

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ode_system.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ Linearize `sys` around the trajectory `sol` at times `t`. Returns a vector of `S
419419
- `verbose`: If `true`, print warnings for variables that are not found in `sol`.
420420
- `kwargs`: Are sent to the linearization functions.
421421
"""
422-
function trajectory_ss(sys, inputs, outputs, sol; t = _max_100(sol.t), allow_input_derivatives = false, fuzzer = nothing, verbose = true,kwargs...)
422+
function trajectory_ss(sys, inputs, outputs, sol; t = _max_100(sol.t), allow_input_derivatives = false, fuzzer = nothing, verbose = true, kwargs...)
423423
maximum(t) > maximum(sol.t) && @warn("The maximum time in `t`: $(maximum(t)), is larger than the maximum time in `sol.t`: $(maximum(sol.t)).")
424424
minimum(t) < minimum(sol.t) && @warn("The minimum time in `t`: $(minimum(t)), is smaller than the minimum time in `sol.t`: $(minimum(sol.t)).")
425425
# NOTE: we call linearization_funciton twice :( The first call is to get x=unknowns(ssys), the second call provides the operating points.
@@ -428,12 +428,12 @@ function trajectory_ss(sys, inputs, outputs, sol; t = _max_100(sol.t), allow_inp
428428
x = unknowns(ssys)
429429

430430
# TODO: The value of the output (or input) of the input analysis points should be mapped to the perturbation vars
431-
@show perturbation_vars = ModelingToolkit.inputs(ssys)
432-
# original_inputs = [ap.input.u for ap in vcat(inputs)] # assuming all inputs are analysis points for now
431+
perturbation_vars = ModelingToolkit.inputs(ssys)
432+
original_inputs = [ap.input.u for ap in vcat(inputs)] # assuming all inputs are analysis points for now
433433
op_nothing = Dict(unknowns(sys) .=> nothing) # Remove all defaults present in the original system
434434
defs = ModelingToolkit.defaults(sys)
435435
ops = map(t) do ti
436-
opsol = Dict(x => robust_sol_getindex(sol, ti, x, defs; verbose) for x in x)
436+
opsol = Dict(x => robust_sol_getindex(sol, ti, x, defs; verbose) for x in [x; original_inputs])
437437
# opsolu = Dict(new_u => robust_sol_getindex(sol, ti, u, defs; verbose) for (new_u, u) in zip(perturbation_vars, original_inputs))
438438
merge(op_nothing, opsol)
439439
end

0 commit comments

Comments
 (0)