Modeling and Simulation of Physical Systems for Hobbyists Manuel Aiple 35C3 — 29 December 2018 CC-BY 4.0 version f59c89b
Modeling and Simulation of Physical Systems for Hobbyists Mathematical Running Hardware With commonly description a model available tools of a system
Why use Simulation? Motivation
Why use Simulation? • Placeholder for hardware components • Virtual test bench Motivation
Very Simple Detailed Detailed Apple Moves Apple Accelerates Apple Accelerates Down Down Down Until Saturation x x x t t t As simple as possible, as detailed as necessary Modeling Picture: Newton portrait with apple tree by Mariana Ruiz Villarreal (LadyofHats) CC0-1.0 (Recomposed)
Differentiation & Integration Differentiation & Integration
Differentiation & Integration Position x ( t ) Velocity v ( t ) Acceleration a ( t ) Differentiation & Integration
Differentiation & Integration Position x ( t ) Velocity Differentiate v ( t ) Acceleration a ( t ) Differentiation & Integration
Differentiation & Integration Position x ( t ) Velocity Integrate Differentiate v ( t ) Acceleration a ( t ) Differentiation & Integration
Differentiation & Integration Position x ( t ) x ( t + h ) − x ( t ) v ( t ) = lim h h→ 0 Velocity Integrate Differentiate v ( t ) Acceleration a ( t ) Differentiation & Integration
Differentiation & Integration Position x ( t ) x ( t + h ) − x ( t ) h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h v ( t ) = lim h h→ 0 Velocity Integrate Differentiate v ( t ) Acceleration a ( t ) Differentiation & Integration
Differentiation & Integration Position x ( t ) Looking into the future Looking into the past x ( t + h ) − x ( t ) h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h v ( t ) = lim h h→ 0 Velocity Integrate Differentiate v ( t ) Acceleration a ( t ) Always integrate for simulation Differentiation & Integration
Euler Method h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h → Not usable for computation Euler Method
Euler Method h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h → Not usable for computation Replace infinitesimal lim h→ 0 h with finite T s and only calculate for integer multiples k of T s : t = k T s Euler Method
Euler Method h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h → Not usable for computation Replace infinitesimal lim h→ 0 h with finite T s and only calculate for integer multiples k of T s : t = k T s � t + T s � � t � � t � x = x + v T s T s T s T s Euler Method
Euler Method h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h → Not usable for computation Replace infinitesimal lim h→ 0 h with finite T s and only calculate for integer multiples k of T s : t = k T s � t + T s � � t � � t � x = x + v T s T s T s T s x ( k + 1) = x ( k ) + v ( k ) T s Euler Method
Euler Method h→ 0 x ( t + h ) = x ( t ) + lim lim h→ 0 v ( t ) h → Not usable for computation Replace infinitesimal lim h→ 0 h with finite T s and only calculate for integer multiples k of T s : t = k T s � t + T s � � t � � t � x = x + v T s T s T s T s x ( k + 1) = x ( k ) + v ( k ) T s Keep T s small Euler Method
Building Blocks Mechanics Building Blocks Mechanics
Building Blocks Mechanics v M · Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v M · d t Second law of motion Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v M · I d t ω Second law of motion Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v T = I d ω M · I d t d t ω Second law of motion T Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v T = I d ω M · I d t d t ω Second law of motion T F = M g Weight Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v T = I d ω M · I d t d t ω Second law of motion T F = M g Weight x F = −κ ( x − x 0 ) F Spring force κ Building Blocks Mechanics
Building Blocks Mechanics v F F = M d v T = I d ω M · I d t d t ω Second law of motion T F = M g Weight x F = −κ ( x − x 0 ) F Spring force κ F = −b v Viscous damping Building Blocks Mechanics
Building Blocks Electric Building Blocks Electric
Building Blocks Electric R V = R i Resistor Building Blocks Electric
Building Blocks Electric R V = R i Resistor L V = L d i d t Inductance Building Blocks Electric
Building Blocks Electric R V = R i Resistor L V = L d i d t Inductance C i = C d V d t Capacitor Building Blocks Electric
Building Blocks Electromechanics ω T M Building Blocks Electromechanics
Building Blocks Electromechanics T = K t i Motor ω T M Building Blocks Electromechanics
Building Blocks Electromechanics T = K t i Motor ω V = K v ω Generator T M Building Blocks Electromechanics
Building Blocks Electromechanics T = K t i Motor ω V = K v ω Generator T V = R i + L d i M d t + K v ω I d ω d t = K t i − b ω Electric motor Building Blocks Electromechanics
Tips & Tricks 1. Sampling Period ( T s ): min. 100x faster than system time constant 2. Block Diagram: helps to keep overview 3. Adapt the model to your needs: different questions might need different models 4. Specialized Tools (SciPy, OpenModelica/OMEdit, Scilab/XCos): • for complex models or as reference • better differential equation solving (BDF, Runge-Kutta, etc.) • efficient through variable time-step • nice data logging and visualization tools Tips & Tricks
B d ω − d t � ω � + T ext 1 / I θ + K v K t d i + d t � i + V sup 1 /L i − R Motor Model Block Diagram
Background & Further Reading (Wikipedia) • Scientific modeling • Ordinary differential equation • Numerical methods for ordinary differential equations – Euler Method – Runge-Kutta – Backward differentiation formula (BDF) • Discrete time and continuous time • State-space representation Background & Further Reading
Recommend
More recommend