Skip to content

Commit 5f5c4e7

Browse files
committed
add operating point to System constructor
1 parent 24796be commit 5f5c4e7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ControlSystemsMTK"
22
uuid = "687d7614-c7e5-45fc-bfc3-9ee385575c88"
33
authors = ["Fredrik Bagge Carlson"]
4-
version = "2.5.0"
4+
version = "2.5.1"
55

66
[deps]
77
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"

src/ode_system.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ function ModelingToolkit.System(
2626
x = ControlSystemsBase.state_names(sys),
2727
u = ControlSystemsBase.input_names(sys),
2828
y = ControlSystemsBase.output_names(sys),
29+
u0 = zeros(sys.nu),
30+
y0 = zeros(sys.ny),
2931
)
3032
ControlSystemsBase.isdiscrete(sys) && error(
3133
"Discrete systems not yet supported due to https://github.com/SciML/ModelingToolkit.jl/issues?q=is%3Aopen+is%3Aissue+label%3Adiscrete-time",
3234
)
3335
uc = [Blocks.RealInput(; name = Symbol(u)) for u in u]
3436
yc = [Blocks.RealOutput(; name = Symbol(y)) for y in y]
35-
@named ssblock = Blocks.StateSpace(ssdata(sys)...; x = x0)
37+
@named ssblock = Blocks.StateSpace(ssdata(sys)...; x = x0, u0, y0)
3638
@unpack input, output = ssblock
3739
systems = [uc; yc; input; output]
3840
eqs = [
@@ -191,6 +193,7 @@ function causal_simplification(sys, u2duinds::Vector{Pair{Int, Int}}; balance=fa
191193
bq > 10000 && @warn("The numerical balancing of the system is poor (gbalqual = $bq), consider using `balance=true` to balance the system before conversion to StateSpace to improve accuracy of the result.")
192194
end
193195

196+
# NOTE: the conversion implemented in ss(dss) uses gss2ss due to it's initial call to gir to produce a reduced order model and then an SVD-based alg to improve numerics. Should we use this by default?
194197
return ss(RobustAndOptimalControl.DescriptorSystems.dss2ss(dsys; simple_infeigs, fast=false)[1])
195198
else
196199
b = balance ? s->balance_statespace(sminreal(s))[1] : identity
@@ -497,6 +500,7 @@ function trajectory_ss(sys, inputs, outputs, sol; t = _max_100(sol.t), allow_inp
497500
defs = ModelingToolkit.defaults(sys)
498501
ops = map(t) do ti
499502
opsol = Dict(x => robust_sol_getindex(sol, ti, x, defs; verbose) for x in x)
503+
# When the new behavior of Break is introduced, speficy the value for all inupts in ssys by `for x in [x; perturbation_vars]` on the line above
500504
# opsolu = Dict(new_u => robust_sol_getindex(sol, ti, u, defs; verbose) for (new_u, u) in zip(perturbation_vars, original_inputs))
501505
merge(op_nothing, opsol)
502506
end

0 commit comments

Comments
 (0)