# Maple Sim and the Advantages of Physical Modeling

• Slides: 25

Please try to model this plant • • V=220 V R = 10 KΩ L=100 Hn J=5 Kg m^2 R L V~ • Open Simulink and try it… • In 30 min from now we will do it with Maple. Sim

The Evolution of Multi-Domain Modeling Specialized numerical mathematics e. g. NAG, MATLAB State-based simulation e. g. Simulink Acausal modeling environments e. g. Maple. Sim Problem Analysis Intuition & physics Model equations Simulation model Numerical algorithms Execute numerical algorithms Numerical experts Math experts Modeling experts Engineers User Problem Analysis Engineers Computer effort Human effort General purpose languages e. g. FORTRAN

Why is physical modeling so difficult? • Multidomain/multiphysics • Legacy of causal (signal-flow) modeling tools • Differential-algebraic equations (DAEs) • Fundamental principles in physics and mathematics

The Story of the Analog Computer An analog computer “program” Simulink is essentially an analog computer running on a PC … A “virtual” analog computer

Causal modeling: 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 modeling of larger systems, particularly when applied to plant models Example: 3 D pendulum with increasing number of links: # 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()

Causal modeling: 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 V~ L ? ?

Causal modeling: 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 most cases this can require an equation re-formulation (to be done properly) Inputs Engine/ Powertrain Angle ? Torque Chassis/Tire Outputs

Physical Modelling – Faster & Intuitive F(t) x 1(t) M 1 d 1 k 1 F(t) x 2(t) M 2 d 2 k 2 • Model maps directly to physical components of system Double mass spring-damper system • Automatically generates equations of motion

Physical Modelling – Faster & Intuitive Basic steps for building an acausal model: Use blocks or components to define the topology of your system R V L ~ R v(t) L J

Control Maplesoft engineering solution Maple. Sim 6. 1 Design Toolbox Connectivity Toolboxes Simulink RTW Toolchain Lab. VIEW RT Toolchain CAD Toolchain Maple 17 Maple Toolboxes

Symbolic computation for plant modelling Maple. Sim Symbolic Formulation Standard Numeric Formulation Model Definition Coordinate Selection Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation Simulation Numerical black box Simulation Procedure Generation with Limited Optimization Simulation

Standard Numeric Formulation Model Definition Numerical • Generated procedure is a set of routines that multiply/add numerical matrices to reformulate the equations at each time step black box Simulation Procedure Generation with Limited Optimization Simulation -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

Symbolic computation for plant modelling Maple. Sim Symbolic Formulation Standard Numeric Formulation Model Definition Maple. Sim applies 4 levels of model optimization Model Definition Coordinate Selection Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation Simulation Numerical black box Simulation Procedure Generation with Limited Optimization Simulation

• A model’s chosen state variables directly impact the number and complexity of Maple. Sim Symbolic Formulation the resulting equations Model Definition Coordinate Selection Example: Stewart Platform Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation 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 (Maple. Sim): • 24 coords( 3 per leg, 6 for the platform) • 24 dynamic equations + 18 constraints = 42 equations

Maple. Sim Symbolic Formulation • Generated equations are true for all time, using the previous example: Model Definition Coordinate Selection Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation -2 multiplications, 1 addition per step (versus original 6 and 4, respectively) Simulation • Equations can be viewed, analyzed and manipulated in the Maple environment

• Multiplications by 1’s, 0’s Maple. Sim Symbolic Formulation automatically removed (previous slide) Model Definition • Simple equations directly solved, Coordinate Selection reducing the number of variables to integrate Equation Generation • Trigonometric simplifications: Symbolic Simplification Code Optimization Simulation Procedure Generation Simulation

Maple. Sim Symbolic Formulation Model Definition Coordinate Selection Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation Simulation • Expressions that are repeated within the equations are identified and isolated so they are only computed once

Maple. Sim Symbolic Formulation Model Definition Coordinate Selection Equation Generation Symbolic Simplification Code Optimization Simulation Procedure Generation Simulation • Using Maple. Sim’s Addons, optimized procedures can be exported to a variety of targets: • Lab. VIEW RT Toolchain • Simulink RTW Toolchain • Alternatively, these procedures can be generated in Standalone C-code (no Connectivity Toolboxes required)

Faster real time simulation • Symbolic multibody model formulation • Model simplification and optimized code generation • More systems become feasible for RT sim Sim. Mechanics (ms) Maple. Sim S-function Simulink (ms) Speed advantage Double Pendulum 137 14 9. 9 x Four Bar Linkage 288 70 4. 1 x Stewart Platform 710 74 9. 6 x Simulation cycle time = 10 ms

Multi-Domain Modeling

Simple Example Simulink Equivalent Maple. Sim Equivalent Advantages • Interactive Graphical Modeling of functional elements which interact with each other (acausal) • Automatically builds the Mathematical Model of System which can be viewed, analyzed and fully documented

Generated Equations from RLC Example

The Evolution of Multi-Domain Modeling Specialized numerical mathematics e. g. NAG, MATLAB State-based simulation e. g. Simulink Acausal modeling environments e. g. Maple. Sim Problem Analysis Intuition & physics Model equations Simulation model Numerical algorithms Execute numerical algorithms Numerical experts Math experts Modeling experts Engineers User Problem Analysis Engineers Computer effort Human effort General purpose languages e. g. FORTRAN

Case studies and demonstrations