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
@@ -179,9 +179,6 @@ The return values also include the chosen state-realization (the remaining unkno
179
179
180
180
If `disturbance_inputs` is an array of variables, the generated dynamics function will preserve any state and dynamics associated with disturbance inputs, but the disturbance inputs themselves will (by default) not be included as inputs to the generated function. The use case for this is to generate dynamics for state observers that estimate the influence of unmeasured disturbances, and thus require unknown variables for the disturbance model, but without disturbance inputs since the disturbances are not available for measurement. To add an input argument corresponding to the disturbance inputs, either include the disturbance inputs among the control inputs, or set `disturbance_argument=true`, in which case an additional input argument `w` is added to the generated function `(x,u,p,t,w)->rhs`.
181
181
182
-
!!! note "Un-simplified system"
183
-
This function expects `sys` to be un-simplified, i.e., `structural_simplify` or `@mtkbuild` should not be called on the system before passing it into this function. `generate_control_function` calls a special version of `structural_simplify` internally.
184
-
185
182
# Example
186
183
187
184
```
@@ -200,16 +197,18 @@ function generate_control_function(sys::AbstractODESystem, inputs = unbound_inpu
200
197
simplify =false,
201
198
eval_expression =false,
202
199
eval_module =@__MODULE__,
200
+
check_simplified =true,
203
201
kwargs...)
202
+
# Remove this when the ControlFunction gets merged.
203
+
if check_simplified &&!iscomplete(sys)
204
+
error("A completed `ODESystem` is required. Call `complete` or `structural_simplify` on the system before creating the control function.")
205
+
end
204
206
isempty(inputs) &&@warn("No unbound inputs were found in system.")
`f_oop` will have an extra state corresponding to the integrator in the disturbance model. This state will not be affected by any input, but will affect the dynamics from where it enters, in this case it will affect additively from `model.torque.tau.u`.
Modify the variable metadata of system variables to indicate which ones are inputs, outputs, and disturbances. Needed for `inputs`, `outputs`, `disturbances`, `unbound_inputs`, `unbound_outputs` to return the proper subsets.
Copy file name to clipboardExpand all lines: src/systems/clock_inference.jl
+13
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
1
struct ClockInference{S}
2
+
"""Tearing state."""
2
3
ts::S
4
+
"""The time domain (discrete clock, continuous) of each equation."""
3
5
eq_domain::Vector{TimeDomain}
6
+
"""The output time domain (discrete clock, continuous) of each variable."""
4
7
var_domain::Vector{TimeDomain}
8
+
"""The set of variables with concrete domains."""
5
9
inferred::BitSet
6
10
end
7
11
@@ -67,6 +71,9 @@ function substitute_sample_time(ex, dt)
67
71
end
68
72
end
69
73
74
+
"""
75
+
Update the equation-to-time domain mapping by inferring the time domain from the variables.
76
+
"""
70
77
functioninfer_clocks!(ci::ClockInference)
71
78
@unpack ts, eq_domain, var_domain, inferred = ci
72
79
@unpack var_to_diff, graph = ts.structure
@@ -132,6 +139,9 @@ function is_time_domain_conversion(v)
132
139
input_timedomain(o) !=output_timedomain(o)
133
140
end
134
141
142
+
"""
143
+
For multi-clock systems, create a separate system for each clock in the system, along with associated equations. Return the updated tearing state, and the sets of clocked variables associated with each time domain.
144
+
"""
135
145
functionsplit_system(ci::ClockInference{S}) where {S}
136
146
@unpack ts, eq_domain, var_domain, inferred = ci
137
147
fullvars =get_fullvars(ts)
@@ -143,11 +153,14 @@ function split_system(ci::ClockInference{S}) where {S}
0 commit comments