2 Modeling Dynamic Systems Data-Driven ModelingFirst-Principles Modeling Simscape SimMechanics SimHydraulics SimPowerSystems SimDriveline SimElectronics Aerospace Blockset Simulink Tools for Modeling Dynamic Systems Modeling Approaches Neural Network Toolbox Simulink Design Optimization System Identification Toolbox
3 The System rudders aileron thrust velocity pitch angle Input Output
4 The Model rudders aileron thrust velocity pitch angle Input Output u y u, y: measured time or frequency domain signals
5 The System and the Model System Model + - Minimize errorMeasured input
6 Fitting and Comparing Models Core feature: Estimating models by tuning its parameters such that model outputs is close to measured output COMPARE function: Plots measured and model output curves together Shows a numerical measure of fit: the percent of the output variation reproduced by the model DEMO: Model for data collected from a hair dryer Input signal: heating power Output signal: air temperature
7 Estimation and Validation Go Together A large enough model can reproduce a measured output arbitrarily well. We must verify that model is relevant for other data – data that was not used for estimation, but was collected for the same system. Error Number of parameters Estimation data Validation data DEMO: “Validate” the hair-dryer models on new data set
8 Process of Building Models from Data Gather experimental data Estimate model from data –Select a structure –Find a model in it Validate model with independent data
9 Various forms of data –Sampled inputs and outputs in discrete time IDDATA –Frequency Domain data –Frequency function measurements IDFRD Requires thought about how to “excite” the process –Sampling interval should fit the process dynamics –The input should have a suitable spectrum –The toolbox may generate suitable inputs IDINPUT Necessary to look at and “polish” data –Handle trends and offsets DETREND –Look for bad measurements (“outliers”) MISDATA –Is filtering required to reduce disturbances? IDFILT Collect the input-output data Select a model structure Find best model in a structure Evaluate the resulting model
10 The most difficult problem –There are a confusing multitude of possibilities. –The quality of the resulting model depends crucially on the chosen model structure Many structures to choose from –Transfer functions, state-space, ARX, nonlinear networks,… IDTF, IDSS, IDROC, IDNLARX, IDNLHW, IDPOLY, IDGREY,… How to know what to test? –May have prior insights. –May have preferences for the intended application. –Test many! Select a model structure Collect the input- output data Select a model structure Find best model in a structure Evaluate the resulting model
11 Collect the input- output data Select a model structure Find best model in a structure Evaluate the resulting model Find the model parameter values in the chosen model structure –Main feature of the toolbox! TFEST, SSEST, ARX, ARMAX, OE, PEM, NLARX, … –Conceptually easy but can be computationally intensive Find best model in a structure
12 Collect the input- output data Select a model structure Find best model in a structure Evaluate the resulting model Make a final choice of model structure –Includes choice model size (model orders and delays) Twist and turn it to see if it is good enough for the intended application –Simulate and look at model output for validation data SIM, COMPARE –Residual analysis, Uncertainty evaluation, … RESID, SIMSD, BODE, STEP, PZMAP, … Evaluate the resulting model
13 The Identification Process Collect the input- output data Select a model structure Find best model in a structure Evaluate the resulting model
14 Model Structures Do we know anything about the system apriori? –Black-Box models: Flexible structures with considerable approximation power –Grey-Box models: Taylor-made structures, made to incorporate prior knowledge: Structured differential equations with (some) parameters unknown. Is the output a linear or nonlinear function of the input? Do we want to describe also how disturbances affect the output? system uy inputoutput e: disturbance source
15 Model Structures in System Identification Tool (GUI) IDENT Linear Parametric Models Input-Output models (transfer functions) State-space models Linear Nonparametric models Impulse response model IMPULSE, STEP Frequency Response SPA, SPAFDR, ETFE Process Models PEM Nonlinear Models NLARX, NLHW
16 Transfer Functions and State Space Models Linear models are typically described by state-space models IDSS (SSST) or transfer functions IDTF (TFEST) State-space Number of states: n Both are just ways of writing a linear differential equation for relationship between input (u) and output (y) (take n=1) Transfer function B-order: n b (zeros) F-order: n f (poles)
17 Delays in TF and SS models There could also be a delay (dead time) in the system: It takes n k samples before a change in u is visible in y. y u nknk time state space transfer function Linear parametric model structures are characterized by a few integers: n, or (n p n z ) and n k. Commands such as n4sid, ssest, tfest use these integers to “create” models from data.
18 Handling Disturbance Knowledge of nature of disturbance is useful: –Essential for predicting future system outputs, by understanding correlations between disturbances Handling technique for identification: treat a disturbance source e as an extra unmeasured input. e is not measured; its properties (white noise) are characterized statistically – mean, covariance system uy inputoutput e: disturbance source state space transfer function DEMO: Models with disturbance component for hair-dryer data.
19 Non-Parametric Methods Linear systems can also be described by non- parametric models that is curves that capture the system properties: –Transient responses –Frequency response They can be estimated directly from data Often useful to take a first look at these before parametric model estimation to get a feel for system’s basic properties.
20 Transient Response A system’s transient response is its output to a transient like an impulse or step in its input. Can be found by special experimentation with such inputs For an existing model, its transient response is obtained by simulation with such inputs. IMPULSE, SIM, STEP Estimation: From experimental input/output data, transient response is typically estimated via a flexible (high order) linear model. system uy
21 Frequency Response A system’s frequency response H(ω) is its response to a sinusoidal input sin(ωt). The output has same frequency ω but a different amplitude and a phase shift y(t) = A(ω) sin(ωt+ ϕ (ω)) Plotting A(ω) and ϕ (ω) vs. ω gives Bode plot. Can be found experimentally by subjecting the system to sinusoidal inputs of various frequencies. For an existing model, it is obtained from the z- or Laplace transform of the transfer function using z = exp(jωT s ) or s = jω. Estimation: From experimental input-output data, it may be estimated directly by using various Fourier-transform inspired techniques. SPA, SPAFDR, ETFE system uy DEMO: Direct frequency and transient response estimation for dryer data
22 Process Models Use a combination of gain (K), delay (Td) and one or more time constants (T) to describe the model. Such forms are popular in process industry, hence called “process models”. IDPROC Can be expanded to contain more poles, zeros and integrators. Structure choices: –number/nature of poles –whether a delay element, a zero and/or an integrator should be included.
23 Use of Disturbance Model for Simulation and Prediction Measured outputs contain disturbances. If there is a correlation between disturbances it is possible to better predict the future outputs from observing the past ones. DEMO: Models with disturbance component for hair-dryer data.
24 Residual Analysis DEMO: Residual analysis on hair-dryer models System Model + - error input e(t) t acceptable Whiteness Test Independence Test Residuals = ”Leftovers” = 1-step-ahead prediction errors Check correlation functions! Should be uncorr- elated with known things
25 Model Uncertainty Estimated model is influenced by the disturbances –If we repeat identification on another data set with the same input u, we will get a different model since e is not the same. This is true even if no disturbance model is built. The model is an uncertain quantity. The amount of disturbance induced variations in model can be estimated. –We can create models with its uncertainty region; we can determine the uncertainty information on a model’s parameters. –We can visualize the uncertainty on model’s response in time and frequency domains (“confidence bounds”) DEMO: Studying model uncertainty
26 Putting the Model to Work Use them for understanding a system’s behavior, and predicting future response of a system Import estimated models into Simulink using dedicated blocks for simulation and code generation Controller design: Import into SISOTOOL and MPC design task
27 Simplifying Complex Systems DataModel u y Simplify complex Simulink model using simulation data. Use Identified model to describe a component of a larger system
28 Using Models for Control System Design Dynamic Model P + ∆P Current Position Noise ModelN Position Error Control Estimate plant with parameter uncertainties Estimate noise model Controller Control System Toolbox Simulink Control Design Robust Control Toolbox Model Predictive Control Toolbox System Identification Toolbox
29 More Information Product page on mathworks.com: –Reach demos, webinars and documentation from here Tech Support: Textbooks –System Identification – Theory for the User, Lennart Ljung –System Identification – A frequency domain approach, Rik Pintelon, Johan Schoukens –Others…
30 Residual Analysis Technique for validating a model’s quality. Works by analyzing the residues which are differences between model’s response and measured values: where is the model’s best prediction of y(t) made at time t-1. ε(t) should ideally be uncorrelated with information known at time t-1. Hence we test correlation between ε(t 1 ) and u(t 2 ) and also between ε(t 1 ) and ε(t 2 ), t 1 ≠ t 2