Unity 5: Visual ODE solver

David Joiner, Kean University

Using Unity as a modeling engine poses some challenges, but benefits from having a native, high quality 3D display.

Many simulation environments in computational science education function essentially as visual ordinary differential equation solvers. Systems Dynamics packages allow you to describe ODE systems graphically and tie the solution into plots whose parameters can be varied easily (see for example VenSim – https://vensim.com). Easy Java Simulations (http://fem.um.es/Ejs) creates a run-time loop with rules coupled to ODE methods and a rapid-app tool for building GUIs. While not designed for this, Unity Game Engine can, with some tailoring, be used in a similar fashion as a ODE modeling environment tied to a 3D scene.

The following three lessons describe 2 steps in this process with helper code, and a full implementation for a 3D problem.

Solving ODEs in Unity (https://joinerda.github.io/Solving-ODEs-in-Unity) will cover a Unity class used for describing and solving simple system of ODEs using a Runge Kutta 4th order method.

Threading (https://joinerda.github.io/Threading-In-Unity) will cover how to use a threaded model in Unity. While Unity is not a thread safe environment for the game engine purposes, you can use C#’s threading features to thread non-game calculations, such as the solution of a system of ODEs. A helper class is provided to easily build time-stepped, threaded calculations to run in Unity.

Finally, N-Body with threads (https://joinerda.github.io/NBody-With-Threads) will put together these two helper classes in a specific application, a RK4 solution of a 3D Gravitational N-Body problem, run in a thread.

Unity 4 |

Leave a Reply

Your email address will not be published. Required fields are marked *