Skip to content

Commit

Permalink
Adding model.md and initial contents, see #96
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinVallejo committed Mar 13, 2023
1 parent 6c3907e commit c86e581
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
24 changes: 23 additions & 1 deletion doc/model.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
TODO model description
# My Solar System - Model Description

The My Solar System simulation is a model that allows users to explore the dynamics of our solar system. This document provides a brief description of the model and its underlying algorithm. It relies on the code found in both this repo and the solar-system-common one, which also supports the keplers-laws sim.

## Introduction
The My Solar System simulation is a tool that enables users to visualize the motion of planets, moons, and other celestial bodies in our solar system. By manipulating various parameters such as mass, velocity, and distance, users can gain insight into the complex interactions that govern the behavior of these objects.

## Algorithm
There are two arrays which keep track of the bodies:
- Available Bodies: It stores the 4 possible bodies in memory for the entire lifetime of the sim, to avoid memory allocation issues. The bodies are created in the constructor of the model and are never disposed.
- Bodies: Essentialy acting as Active Bodies. It stores the bodies that are currently being used in the sim. The bodies are added to this array when the user changes the body number in the control panel or selects a Lab preset. There are BodyNodes listening for this array, and when bodies leave the Bodies array, their BodyNode is disposed.

The simulation relies on the Position Extended Forest-Ruth Like algorithm (PEFRL) to compute the motion of the bodies [(Omelyan, Myrglod & Folk, 2001)](https://arxiv.org/abs/cond-mat/0110585). PEFRL is a numerical integration scheme that provides high accuracy and stability for simulations involving many bodies, especially those with periodic or quasi-periodic behavior. It essentially integrates the position and velocity over time in multiple intermediate steps.


## Units
Numbers in the model use the following units:
Mass - 10^28 kg
Distance - 1 AU, which is roughly 150 million km
Time - 1 year
Velocity - 1 km/s

We decided to not use SI units to better convey the scales of each dimension
7 changes: 3 additions & 4 deletions js/common/model/NumericalEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Logic that controls the gravitational interactions between bodies.
*
* The engine updates the position of the bodies on the run() function,
* inside it uses a Forrest-Ruth algorithm to calculate the position of the bodies.
* inside it uses a Position Extended Forest-Ruth Like algorithm (PEFRL) (Omelyan, Myrglod & Folk, 2001)
*
* There's also a function to use the Verlet algorithm, but it's deprecated.
*
* @author Agustín Vallejo
*/
Expand All @@ -19,7 +18,7 @@ import Engine from '../../../../solar-system-common/js/model/Engine.js';

const scratchVector = new Vector2( 0, 0 );

// constants for Forrest Ruth Integration Scheme (FRIS)
// constants for PEFRL algorithm
const XI = 0.1786178958448091;
const LAMBDA = -0.2123418310626054;
const CHI = -0.06626458266981849;
Expand Down Expand Up @@ -110,7 +109,7 @@ export default class NumericalEngine extends Engine {
accelerations[ i ].set( forces[ i ] ).multiplyScalar( 1 / masses[ i ] );
}

// Forrest Ruth Integration Scheme (FRIS)
// Position Extended Forest-Ruth Like algorithm (PEFRL) (Omelyan, Myrglod & Folk, 2001)

for ( let i = 0; i < N; i++ ) {

Expand Down

0 comments on commit c86e581

Please sign in to comment.