This model was inspired by the classic paper "Galactic Bridges and Tails" (Toomre & Toomre 1972). Two disc shape galaxies are setup to almost collide. Once the galaxies are close enough, mutual gravitational forces give the two spiral arm effect.
Standard Newtonian dynamics are applied at each time step. We approximate the massive cloud of stars with a single black hole at the center of the galaxy. We also partition the stars into heavy and light bodies and skip the computation between light and light bodies to improve performance.
The green blocks initialize the simulation, the orange blocks are the core of the simulation, and the yellow block is used to make the galaxy animation view.
Except for the "PlotAll" visualization block's use of plotting routines, all of the Embedded MATLAB function blocks in this model support code generation with Real-Time Workshop and Real-Time Workshop Embedded Coder.
Demo Requirements
During this demonstration, Simulink generates code for the simulation in a Simulink project directory created in the current working directory (pwd). If you do not want to affect the current directory (or if you cannot) generate files in this directory, you should change your working directory.
Embedded MATLAB parsing for model "sldemo_eml_galaxy"...Done
Embedded MATLAB code generation for model "sldemo_eml_galaxy".........Done
Embedded MATLAB compilation for model "sldemo_eml_galaxy"... 1 file(s) copied.
1 file(s) copied.
Done