Large scale physics simulations in industrial vehicle simulators Kenneth Bodin Algoryx Simulation, Umeå, Sweden http://www.algoryx.se/ kenneth@aloryx.se
Scope The anatomy, models and methods of a Phyics Engine Use in vehicle simulators
Acknowledgements Martin Servin Anders Backman Claude Lacoursiére
http://www.youtube.com/watch?v=q8yrs5rcrb0
http://www.youtube.com/watch?v=av9qqavvcw4
http://www.youtube.com/watch?v=cht1akbsgbo
Atlas Copco Surface Drilling Rig
Atlas Copco Surface Drilling Rig physics
System diagram Models Dynamics Graphics (CAD) Environment HCI 3D IG Display Control Physics Audio Speakers Manager Platform driver Platform
Physics models Vehicle geometry Engine Drive train Suspension Hydraulics Tools Wheel-ground Environment (soils, rocks, trees, objects)
Tasks of a physics engine read models and initialize while (simulating) broad phase proximity detection near phase proximity detection contact set read: control build constraint Jacobians solve mixed LCP for constraint forces integrate velocities and positions write: graphics, audio, platform, control end Generally this loop is soft real-time at 60-200 Hz.
Anatomy of a physics engine AGX Multiphysics SDK AGX API Physics Models Solvers and Algos Kernel library Platform integration Platforms Hardware Declarative.agx.aagx Contact Friction Partitioner BLAS agx::kernel Native C/C++ GPU C/C++/C# Lua/Python WWW Joints Fluids Direct solver Iterative solvers Math Reductions Scans Agx::Buffer OpenCL OpenGL Multi CPU Network Simulink Wires Geometry FMI/FMU Elastic Interference Space Agx::Device CUDA... User exposed. Platform independent XML Declared/configurable
Constraint based physics Use of constraints to model mechanical systems Non smooth rigid body contacts with friction Jointed, articulated systems, joint limits Motors Constrained lumped elements Cables and wires Cloth Elastic and deformable bodies Multiphysics Constraint fluids Hydraulics Electro mechanical systems
Joints, motors, and frictional contacts http://youtu.be/8yrayjcipk8
Joints, motors and frictional contacts http://www.youtube.com/watch?v=trutnhjkzeo
http://youtu.be/r0_4f7ri440 Large contact systems
Constraint based physics Advantages with constraint based physics Efficient handling of stiff forces, non-smooth mechanics, transients Stability for large timesteps (fundamental for real-time) Leads to sparse blocked linear systems that can be solved efficiently Can also handle handle soft forces and potentials Consistent multiphysics coupling, e.g. rigid body contacts, wires, fluids. Easy-to-grasp modeling paradigm and API s Constraints and contacts created or deleted on the fly No recompilation, preprocessing or code generation required. Constraints have real physics based modeling parameters! Can be modeled with elasticity and dissipation. Limitations Not efficient in the smooth limit (typically when sound speed is important), But can be switched to smooth model in this limit. Not per se a general modeling language, but still pretty general.
Constraint physics A constraint is satisfied when the constraint function defining the constraint is zero, g q = 0 where q are the variables of the system (e.g. position, orientation). The Jacobian of the constraint is defined as the gradient of this function, G = δg δq If g = 0 and g is stationary, so is its time derivative g = dg dt = 0. Chain rule gives, dg dt = δg dq δq dt = Gv = 0 v are the system velocities (e.g. translational, rotational). The constraint Jacobian is a matrix with each row corresponding to a specific constraint. Gv = 0 means that the projection of the velocities in the direction of the Jacobian are zero. Or, velocities normal to the constraint surface are zero, and will thus not break the constraint.
Discrete variational mechanics
Constraint based physics These equations of motions are then time discretized with a timestep, h, via a discrete variational principle with the result (lots of analysis left out here ), M G k G k T Σ v k+1 hλ = 4 Mv k + hf e h(1 + 4γ h ) g k + 1 h(1 + 4γ h ) G k v k with the block Σ being a diagonal matrix, modeling elasticity and dissipation, Σ = 4ε h 2 (1 + 4γ 1 h ) The task is now to solve for the new velocities v k+1 and the constraint forces λ.
http://www.youtube.com/watch?v=bxjszji1sg Elasticity and plasticity
http://www.youtube.com/watch?v=agl4ohj1dli Elasticity and plasticity
http://www.youtube.com/watch?v=vvg-lpyfzcy Elasticity and plasticity
http://vimeo.com/16372553 Incompressible particle fluids
http://www.youtube.com/watch?v=xto4dmebv34 Incompressible particle fluids
http://www.youtube.com/watch?v=0izhymfn2-k CASE: VCE Wheel loader
Solvers Conjugate Gradient iterations Projected Gauss-Seidel Direct Sparse Blocked LCP Fluid: 150K x 150K Rocks: 2K x 2K Loader: 150 x 150
Performance Accessible real-time performance, e.g. Quad i7 ~ 10.000 jointed bodies solved with direct sparse solver, at 100 Hz (much depending on structure) ~ 5.000 bodies with 5 contacts per body, and dry friction, e.g. 50.000 equations, at 100Hz, using iterative PGS solver.
Performance Non-realtime performance (often memory bound) ~ 2M bodies, 10M contacts, 30M equations One timestep in 10s with PGS iterations on i7 PC. ~ 3M fluid particles, 4 timesteps per second on GPU with PC-CG solver. Generally 50% time on collision detection, and 50% on mixed LCP/QP solves.
Conclusions Physics engine paradigm efficient for: Realtime, stiff, large timesteps Scaling to very large systems Strongly varying systems (contacts, interactive CAD) Constraint based modeling pretty general for multiphysics. A physics engine has no modeling language per se. No code generation! Declarative, event and data driven! Underlying physics can be modeled Connection with Modelica and FMI/FMU under investigation. - Modeling with Modelica? - Back-end solves with AGX for Modelica? - Extensions to Modelica language needed?
References Selected references and further reading Ghosts and machines: regularized variational methods for interactive simulations of multibodies with dry frictional contacts. Lacoursière, Claude, Umeå universitet (2007). http://urn.kb.se/resolve?urn=urn:nbn:se:umu:diva-1143 Hybrid, multi-resolution wires with massless frictional contacts, M. Servin, C. Lacoursière, K. Bodin, IEEE Transactions on Visualization and Computer Graphics, Volume: 17 Issue:7, On page(s): 970-982, July (2011). IEEE computer Society Digital Library. IEEE Computer Society, Examining the smooth and nonsmooth discrete element approaches to granular matter, M. Servin, C. Lacoursère, D. Wang, K. Bodin, Particles 2011 ECCOMAS International Conference on Particle-based Methods, Barcelona (2011). abstract slides Outlet design optimization based on large-scale nonsmooth DEM simulation, D. Wang, M. Servin, K. Mickelsson, Particles 2011 ECCOMAS International Conference on Particle-based Methods, Barcelona (2011).abstract Constraint based particle fluids on GPGPU, K. Bodin, C. Lacoursière, M. Nilsson, M. Servin, Particles 2011 ECCOMAS International Conference on Particle-based Methods, Barcelona (2011). abstract Regularized multibody dynamics with dry frictional contacts, C. Lacoursière and M. Servin, Euromech Colloquium: Nonsmooth contact and impact laws in mechanics, July 6th - 8th 2011, Grenoble, France, (2011) pdf, web Constraint fluids, K. Bodin, C. Lacoursière, M. Servin, IEEE Transactions on Visualization and Computer Graphics, Vol pp, Issue 99. 2011. IEEE computer Society Digital Library. IEEE Computer Society, <http://doi.ieeecomputersociety.org/10.1109/tvcg.2011.29> Interactive simulation of elastic deformable materials, by M. Servin, C. Lacoursière and N. Melin, In Proceedings of SIGRAD Conference 2006 in Skövde, Sweden, Linköping University Electronic Press, Linköping, 22-32 (2006) A regularized time stepper for multibody systems, C. Lacoursière. In J. Sporring, K. Erleben, and H. Dohlmann, editors, PDE Methods in Computer Graphics. Charles River Media, 2005. Regularized, stabilized, variational methods for multibodies, C. Lacoursière, In Dag Fritzson Peter Bunus and Claus Führer, editors, The 48th Scandinavian Conference on Simulation and Modeling (SIMS 2007), 30-31 October, 2007, Göteborg (Särö), Sweden, Linköping Electronic Conference Proceedings, pages 40 48. Linköping University Electronic Press, December 2007. A parallel block iterative method for interactive contacting rigid multibody simulations on multicore PCs, C. Lacoursière. A, In PARA 06, pages 956 965, 2006. Visual Simulation of Machine Concepts for Forest Biomass Harvesting, M. Servin, A. Backman, K. Bodin, U. Bergsten, D. Bergström, B. Löfgren, T. Nordfjell, I. Wästerlund, VRIC 2008-10 th International Conference on Virtual Reality (Laval Virtual), (2008).