© 2009 Maplesoft, a division of Waterloo Maple Inc. Chad Schmitke, Ph.D. Director of Maplesim Development, Maplesoft Physical Modelling
Feb 08, 2016
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Chad Schmitke, Ph.D.Director of Maplesim Development, Maplesoft
Physical Modelling
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Goal: • To clearly define the concepts of:• Causal/Acausal modelling• Symbolic/Numeric formulation
• Highlight the differences between these modelling and formulation approaches
• Clearly communicate why these differences matter
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Getting Context: Plant modelling
Problem it is trying to solve: Create a mathematical description of a system given:1. Mathematical models of the components included in the
system – for example:• Resistor: v = i*R• Mass: F = m*a
2. How the components are interconnected
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Getting Context: Controller modelling
Problem it is trying to solve: Create a procedure to control how a target plant model will behave given:1. Desired behaviour of the system2. Plant model inputs that can be controlled (voltages, motions,
pressures, temperatures, etc.) 3. Outputs that can be measured (voltages, motions, pressures,
temperatures, etc.)
Control laws are more algorithmic than physical in nature
Controller Plant
modelinputs
measuredoutputs
desiredbehaviour
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Getting Context: Causal vs. AcausalCasaul modelling:
• Based on the flow of a signal through a diagram• Well suited to Controller Modelling
Acasaul modelling: • Based on interconnection of components• Well suited to Plant Modelling
R Lv(t) J
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: How it’s done...Basic steps for building a causal model:
1. Formulate the differential equations and manipulate them to solve for the desired form (different depending on if you’re modelling a plant or a controller)
~
R L
V
∫ 𝑑2θ 𝑑 𝑡2
𝑑𝑡=𝑑θ 𝑑𝑡
∫ d i 𝑑𝑡 𝑑𝑡= i
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: How it’s done...Basic steps for building a causal model:
2. Transform equations into signal flow diagrams block by block using atomic operators (gains, adders, etc)
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: Why it’s used...This modelling approach is often used for the following
reasons:
• Controller Modelling: Intuitive way to model controllers
• Forced Insight: Process of formulating the equations can yield insight into how the system works
• Familiarity: Design tools of this nature have been around for decades
• Legacy Models: All of the previous models they have were built this way – they want to extend them or connect to them
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: Challenges...1. Complexity of equations does not scale linearly with the size of
the system• As complexity/size increases, so does the chance of errors• Prevents high fidelity modelling of larger systems,
particularly when applied to plant models
# of Links # of Additions # of Multiplications # of Acausal Blocks
1 2 7 5
2 21 82 9
3 135 660 13
4 669 3,974 17
5 2,726 19,224 21
* Cost of dynamic equations, joint coordinate formulation, basic symbolic simplify()
Example: 3D pendulum with increasing number of links:
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: Challenges...2. Generated model looks nothing like the formulated
equations or model diagram• Assumptions made during equation formulation lost• Hard to track errors• Hard to visually understand the purpose of the system
~R L
V ?
?
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: Challenges...3. Since these models have predefined inputs/outputs, it is difficult
to (properly) connect two causal models• This becomes more important as the scope of models
increases (i.e. connect powertrain model to chassis/tire model)
• In some cases this can require an equation re-formulation (to be done properly)
?
Engine/Powertrain
AngleInputs
Chassis/TireTorque Outputs
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Causal Modelling: Why MapleSim...
1. MapleSim/Maple has tools for deriving, checking, and manipulating equations• Saves time and reduces errors during the 1st stage of causal
model creation (equation generation stage)
2. MapleSim/Maple can automatically convert equations to a component block (causal or acausal)• Automates the 2nd stage of causal model creation (saves
time, reduces error)
3. MapleSim/Maple provides a live document detailing the assumptions and equations that created the model• Saves time and reduces errors when modifying the model
equations in the future• Simplifies (and makes possible) the ability to properly link
two causal models together
MapleSim/Maple is an excellent causal modelling tool
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Acausal Modelling: How it’s done...Basic steps for building an acausal model:
1. Use blocks or components to define the topology of your system
R Lv(t) J
~
R L
V
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Acausal Modelling: Why it’s used...This modelling approach is often used for the following
reasons:
• Plant Modelling: Intuitive way to model plants – this approach is not used for controller modelling since controller models assume causal relationships
• Ease of Modifying Models: Changing the model only requires changing the way you’ve connected components
• Ease of Combining Systems: Combining separately created systems is trivial – details of connecting them automatically handled by the modelling tool
• Visual Clarity: Diagrams are easier to understand via visual inspection
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Acausal Modelling: Challenges...
• Too Powerful, Too Easy: Some feel there is a loss of system insight because you don’t have to manually derive the equations
• Cannot Convert Legacy Models: There is no mapping between a legacy causal model and an acausal model…you can’t automatically convert/update your causal models
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Acausal Modelling: Why MapleSim...
1. MapleSim/Maple can automatically generate the governing equations for any model and provides powerful tools for inspecting/manipulating those equations
2. MapleSim/Maple can automatically convert equations to a component block (causal or acausal)• Useful to researches who want to introduce a particular
physical phenomena• Ability to extend the MapleSim blockset without being a
programmer
3. As of MapleSim V2, 3D systems can be automatically visualized, providing additional insight into the behaviour/motion of a system
MapleSim/Maple is an excellent acausal modelling tool
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Simulation: Two approaches...
User presses “Simulate”
Program generates the simulation procedure and integrates the system forward in time
Program displays results
Symbolic Formulation Numeric Formulation
User creates model (Causal, Acausal, or Both)
OR
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Different formulation approaches
Coordinate Selection
Equation Generation
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
MapleSim Symbolic Formulation Standard Numeric Formulation
Model Definition
Simulation Procedure Generation with Limited
Optimization
Simulation
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Standard Numeric Formulation
Model Definition
Simulation Procedure Generation with Limited
Optimization
Simulation
• Generated procedure is a set of routines that multiply/add numerical matrices to reformulate the equations at each time step
-6 multiplications, 4 additions per step
• Certain optimizations can be built into these routines but these are limited, and must be defined ahead of time
© 2009 Maplesoft, a division of Waterloo Maple Inc.
MapleSim Symbolic Formulation • A model’s chosen state variables directly impact the number and complexity of the resulting equations
Coordinate Selection
Equation Generation
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
Absolute coordinates (e.g. ADAMS):• 78 coords (12 per leg, 6 for the platform), • 78 dynamic equations, +72 constraint equations = 150 equations
Hybrid coordinates (MapleSim):•24 coords( 3 per leg, 6 for the platform)•24 dynamic equations+ 18 constraints = 42 equations
Example: Stewart Platform
© 2009 Maplesoft, a division of Waterloo Maple Inc.
MapleSim Symbolic Formulation • Generated equations are true for all time, using the previous example:
-2 multiplications, 1 addition per step (versus original 6 and 4, respectively)
• Equations can be viewed, analyzed and manipulated in the Maple environment
Coordinate Selection
Equation Generation
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
© 2009 Maplesoft, a division of Waterloo Maple Inc.
MapleSim Symbolic Formulation • Multiplications by 1’s, 0’s automatically removed (previous slide)
• Simple equations directly solved, reducing the number of variables to integrate
• Trigonometric simplifications:
Coordinate Selection
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
Equation Generation
© 2009 Maplesoft, a division of Waterloo Maple Inc.
MapleSim Symbolic Formulation • Expressions that are repeated within the equations are identified and isolated so they are only computed onceCoordinate Selection
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
Equation Generation
© 2009 Maplesoft, a division of Waterloo Maple Inc.
MapleSim Symbolic Formulation • Using MapleSim’s Addons, optimized procedures can be exported to a variety of targets:• LabVIEW RT Toolchain• Simulink RTW Toolchain
• Alternatively, these procedures can be generated in Standalone C-code (no Connectivity Toolboxes required)
Coordinate Selection
Symbolic Simplification
Code Optimization
Simulation Procedure Generation
Model Definition
Simulation
Equation Generation
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Simulation: Why does this matter...MapleSim uses a symbolic formulation strategy.
Key Challenge when using a symbolic formulation:• Individuals who are used to numeric formulations will notice a
“slow-down” between when the press “simulate” and when they see their results
Key Advantage of using a symbolic formulation:• This is an enabling technology – it allows the generation of
real-time code for systems that numeric formulations cannot
PhysicalController
Code GeneratedPlant
Real-time code to test controller
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Integrator
Desktop
• When simulating an entire system on an engineer’s desktop, a faster simulation procedure means quicker iterations through design modifications.
Plant ModelController Model
Simulation Procedure Result Visualization
Simulation: Why does this matter...
© 2009 Maplesoft, a division of Waterloo Maple Inc.
• When trying to simulate the plant model in real-time with external hardware, a faster simulation procedure is the difference between “possible” and “not possible”.
Integrator
Plant Model- Controller- User Feedback
Simulation Procedure
Real-time PlatformExternal Hardware
Simulation: Why does this matter...
© 2009 Maplesoft, a division of Waterloo Maple Inc.
• Therefore, a better way to formulate the simulation procedure means that larger, higher-fidelity models can be tested in a real-time environment
• MapleSim uses the power of symbolics to generate extremely efficient simulation procedures
Integrator
Plant Model- Controller- User Feedback
Simulation Procedure
Real-time PlatformExternal Hardware
Simulation: Why does this matter...
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. Symbolics: A key difference
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
What about symbolics…The connection between MapleSim and it’s connection to the Maple
environtment is the key difference between MapleSim and other modelling tools.
1. If you’re deriving equations (plant or controller)…• Manage/manipulate/formulate equations• View/analyse equations• Automatically convert equations into component models
2. If you’re doing plant modelling…• Automatically generate equations for analysis• Tools to work with the equations (see 1.)
3. If you’re generating real-time code…• Enabling technology – fast, efficient code
© 2009 Maplesoft, a division of Waterloo Maple Inc.
1. Getting Context: Plants, Controllers, Causal, Acausal
2. Causal Modelling: How, Why, Why MapleSim
3. Acausal Modelling: How, Why, Why MapleSim
4. Simulation: What happens when you press “Simulate”
5. How Symbolics fit in
6. Summary
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Summary1. MapleSim is an excellent tool for causal modelling
1. Tools to naturally view/manipulate equations2. Equations can be automatically turned into components3. Knowledge capture
2. MapleSim is an exceptional tool for acausal modelling1. Equations can be viewed for added insight and analysis2. 3D visualization3. Knowledge capture
3. MapleSim can model both Acausal and Causal system in the same environment
4. The symbolic formulation strategies used by MapleSim allow the creation of real-time code for more complicated systems
© 2009 Maplesoft, a division of Waterloo Maple Inc.
Questions?
© 2009 Maplesoft, a division of Waterloo Maple Inc.
User
User
Hum
an e
ffort
Computer effort
Problem Analysis
Intuition & physics
Model equations
Execute numericalalgorithms
Numerical algorithms
General purposelanguages
e.g. FORTRAN
Specialized numericalmathematics
e.g. NAG, MATLAB
State-basedsimulation
e.g. Simulink
Acausal modelingenvironmentse.g. MapleSim
Simulation model
Problem Analysis Problem Analysis
Intuition & physics Intuition & physics
Model equations Model equations
Execute numericalalgorithms
Execute numericalalgorithms
Numerical algorithms
Numerical algorithms
Problem Analysis
Intuition & physics
Model equations
Numerical algorithms
Execute numericalalgorithms
Simulation model Simulation model Simulation model
Numerical experts
Math experts
Modeling experts
Engineers
User
User
Math experts
Modeling experts
Engineers
User
UserModeling experts
Engineers
Engineers
The Evolution of Multi-Domain Modeling
© 2009 Maplesoft, a division of Waterloo Maple Inc.
What about symbolics…
Non-symbolic tools
Modelling Formulation
• Insight and Analysis• Equation Derivation Tools• Equations -> Components• more to come…
• Enabling Technology• Flexibility• more to come…
Current Requirements Desired/Perceived Requirements
MapleSim
Additional potential largely because of symbolic approach