Physical Modelling With Simscape
Physical Modelling With Simscape
Physical Modelling With Simscape
Rick Hyde
1
© 2013 The MathWorks, Inc.
Outline
Part 1: Introduction to Simscape
– Review approaches to modelling
– Overview of Simscape-based libraries
– Introduction to physical networks
– Simscape tutorial: DC motor
Part 2: Application examples
– PMSM and drive
– Landing gear extension/retraction
– Engine cooling system
2
Designing physical systems
Multi-domain
– Mechanical
R 6 5
– Electrical
– Hydraulic/pneumatic
– Thermal 2 43 1
Modelling environment
– Multi-domain
– Mix with algorithms/control
– Multiple levels of fidelity
– Optimization tools
– Code generation
3
Data-driven versus physics-based modelling
Data-driven Physics-based
Data sources Mathematical paradigms
– Experimental data – ODEs & DAEs
– External tool (complexity- – State charts
reduction exercise) – Physical networks
Complex behaviour with many Behaviour is adequately
unknowns approximated by limited set of
Examples equations
– Combustion engine Examples
– Aerodynamics – Algorithms/control
– Gears & clutches
E ( x, ) x
f ( x, u, )
4
Extending Simulink® using Simscape™
Simulink Simscape extension
Equation set Equation set
– x f e ( x, u, ) – E ( x, ) x f ( x, u, )
– Explicit equation – Implicit equation
Relevance Relevance
– Single body motion – 1-D multi-body systems e.g.
– Multiple-body motion when drivelines
there is compliance – Electrical networks
– Most algorithms (control) – Hydraulic/pneumatic networks
s1 s2
s3
5
What does this model represent?
6
What does this model represent?
7
Modelling an electrical circuit in Simulink
Step 1: figure out the equations
Step 2: build the model
8
Modelling an electrical circuit in Simscape
9
Modelling an electrical circuit in Simscape
Component equations
from library blocks
Additional constraints
from circuit topology
11
Algebraic loops in Simscape
12
Signal-based modelling methods
pose challenges
Very flexible, but can be difficult
to use efficiently
Requires expertise in
several areas
– Physics, math, programming
Deriving system level equations
is difficult and error prone
Resulting model can be
difficult to read and maintain
13
Physical modelling methods
ideal for plant models
Build accurate models quickly
– System-level equations
derived automatically
Model is easier to read
– Reflects structure of system
Easier to update model
– New technologies or designs
can be easily incorporated
into the model
14
SimPowerSystems
SimMechanics
SimHydraulics
Simscape libraries
Simscape
SimDriveline
MATLAB, Simulink
15 SimElectronics
Extensive Component
Libraries
SimElectronics > 90
component models
– Actuators, drivers
– Sensors
– Semiconductors
– Integrated circuits
– Run hardware-in-the-loop
u s3
simulations
17
Outline
Part 1: Introduction to Simscape
– Review approaches to modelling
– Overview of Simscape-based libraries
– Introduction to physical networks
– Simscape tutorial: DC motor
Part 2: Application examples
– PMSM and drive
– Landing gear extension/retraction
– Engine cooling system
18
Through & across variables
q p3
p1 p2 p1 p2
p4
Translational mechanical
Hydraulic
21
Components
Domain Resistance Inductance Capacitance
Electrical (v, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper
Translational mechanical
Hydraulic
22
Components
Domain Resistance Inductance Capacitance
Electrical (v, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper
23
Components
Domain Resistance Inductance Capacitance
Electrical (v, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper
Hydraulic (p, Q) ?
24
Components
Domain Resistance Inductance Capacitance
Electrical (V, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper
p=kQn
25
Components
Domain Resistance Inductance Capacitance
Electrical (v, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper ?
p=kQn
p=kQn
p=kQn
28
Components
Domain Resistance Inductance Capacitance
Electrical (v, i) Resistor Inductor Capacitor
Rotational mechanical (w, trq) Rotational damper Rotational Spring Inertia
p=kQn
30
Outline
Part 1: Introduction to Simscape
– Review approaches to modelling
– Overview of Simscape-based libraries
– Introduction to physical networks
– Simscape tutorial: DC motor
Part 2: Application examples
– PMSM and drive
– Landing gear extension/retraction
– Engine cooling system
31
DC Motor: Modelling options
1. Use SimElectronics DC Motor
block
2. Build an equivalent circuit
using Simscape foundation
library
3. Define a custom component
using Simscape language
– Equation-based
– Composite
32
SimElectronics® pre-built component
33
SimElectronics DC motor parameterization options
Parameterized according
to datasheet standards
Multiple methods for
assigning parameters
Description,
functionality and
formulation provided
in Help dialog
34
SimElectronics pre-built component example
35
Equivalent circuit based on Simscape foundation
library components
36
Equation-based Simscape language component
1. Define equations
2. Define ports/connections
3. Define variables 𝑑𝑖
𝑣 = 𝑅𝑖 + 𝐿 + 𝑘𝜔
4. Define parameters 𝑑𝑡
5. Write block help
6. Add icon [optional]
7. Publish
37
Equation-based Simscape language example
38
Equation-based Simscape language component
𝑑𝑖
𝑣 = 𝑅𝑖 + 𝐿 + 𝑘𝜔
𝑑𝑡
𝜏 = 𝑘𝑖
39
Composite Simscape language component
Connect components
in Simscape language file
– Refer to existing components
– Overwrite parameter values if necessary
– Connect components
40
Outline
Part 1: Introduction to Simscape
– Review approaches to modelling
– Overview of Simscape-based libraries
– Introduction to physical networks
– Simscape tutorial: DC motor
Part 2: Application examples
– PMSM and drive
– Landing gear extension/retraction
– Engine cooling system
41
PMSM and drive modelling
Components
– PMSM
– Switching devices (IGBTs)
– Controller
Tools
– SimPowerSystems
System-level to support circuit and controller design
– SimElectronics
Detailed switching device models – fine-tuning and losses prediction
42
IGBT modelling
I-V characteristic Dynamics
Complexity
Piecewise linear No dynamics
Lookup table Behavioural
Physics-based Constant capacitance
Composite/complex Nonlinear charge model
Complexity:
Slower simulations, detailed parameterization required
Higher-fidelity/better predictions
43
IGBT modelling SimPowerSystems
– Piecewise linear
– No dynamics or constant capacitance
SimElectronics
Complexity
– Nonlinear, physics-based, simple
– Datasheet parameterization
– Easily tuneable by optimization
SPICE
– Composite from complex physics-based
components
– Manufacturer NETLIST
44
pmsm_drive
45
System-level equivalent of PMSM and drive
Example pmsm_drive suitable for
– Component design
– Electrical system design
What about the system designer e.g. for a hybrid
vehicle?
– Model the whole system and predict efficiency/performance
– Multiple drive cycles
– HIL test
46
Abstracted PMSM drive
Energy-based
– Mechanical power out = power in minus losses
– Losses (physics-based analysis)
Copper losses proportional to the torque
Iron losses dependent on voltage and switching frequency
– Losses (empirical approach)
Tabulate as function of torque and speed (and possibly DC volts)
Table derived from detailed PMSM and drive model
47
Abstracted PMSM drive
48
sm_landing_gear
49
Landing Gear Design
Model:
Applications
– Heat exchangers
– Pipelines
51
Engine cooling example
52
Challenges in Thermal Fluid Simulation Fluid
Volume
55
Conclusions
Simscape extends Simulink to
– Support a network approach
– Create models that topologically match the physical system
Create component models by
– Using ready-made blocks from MathWorks’ libraries
– Constructing composite components from Simscape
foundation library blocks
– Writing custom equations in Simscape language
All the benefits of Simulink apply e.g.
– Code generation
– Tight integration with MATLAB® 56
LINKS
Physical modelling central web-page:
http://www.mathworks.co.uk/physical-modeling/
57
Viewing Simscape Simulations Results
ssc_explore
Explore simulation results
from entire physical network
– Select multiple signals
– Overlay or separate plots
– Arrange plots
– Extract plot to separate window
Spend more time analyzing,
less time simulating
Download from
MATLAB Central
http://www.mathworks.com/matlabcentral/fileexchange/28184-simscape-simulation-results-explorer
58
Zero-Crossing Statistics
Log zero-crossing statistics
for Simscape networks
– Shows when ZCs occur
– Can help indicate location
of simulation bottlenecks
59
Local Solvers Improve Variable step, implicit (ODE15s)
Simulation Performance Controller
Physical
Network
Physical
Use fixed-step, implicit solvers Network
locally on Simscape networks
– Use implicit solvers only
Fixed step, explicit (ODE1)
where necessary
Local fixed step
Fixed-step, implicit (ODE14x)
Configure solver per implicit solver #1
Physical
Network
physical network Controller
Physical
– Run different physical networks Network
at different sample rates Local fixed step
Electrical (higher), mechanical (lower) implicit solver #2