Gravity Engine 12.0
Unity Asset for Gravity
Loading...
Searching...
No Matches
AZTripleIntegrator Class Reference

Special purpose integrator for precise integration of the three body problem. More...

Inheritance diagram for AZTripleIntegrator:
INBodyIntegrator

Public Member Functions

void Setup (int maxBodies, double timeStep)
 Setup the specified maxBodies and timeStep. Must be called prior to PreEvolve/Evolve.
 
void Clear ()
 Clear internal information so no bodies are evolved.
 
INBodyIntegrator DeepClone ()
 Clone this instance, replicating internal arrays. Copy across any internal state required for continued evolution.
 
void AddNBody (int bodyNum, NBody nbody, GravityState.NbodyState[] nbodyStates)
 Adds the N body. Implementation may support the case where the initial number of bodies in Setup() is exceeded, creating space, or may ignore additions that exceed this limit (e.g. AZTTriple).
 
void RemoveBodyAtIndex (int atIndex)
 Removes NBody at index i.
 
void GrowArrays (int growBy)
 Grows the arrays. Called by GravityEngine when it changes internal data sizes.
 
Vector3 GetVelocityForIndex (int i)
 
void GetVelocityDoubleForIndex (int i, ref double[] vel)
 
void SetVelocityForIndex (int i, Vector3 vel)
 
void SetVelocityDoubleForIndex (int i, ref double[] v)
 
Vector3d GetAccelerationForIndex (int i)
 
float GetEnergy (GravityState gravityState)
 Gets the energy of the system.
 
float GetInitialEnergy (GravityState gravityState)
 Gets the initial energy.
 
void PreEvolve (GravityState gravityState)
 Call ONCE after all game objects have been added to allow integrator to pre-calc starting quantities required for integration.
 
double Evolve (double evolveTime, GravityState gravityState, bool exactTime=false)
 Evolve the specified evolveTime, m_arg and r_arg.
 
void SetPositionDoubleForIndex (int i, ref double[] v)
 
string GetExternalAccelForIndex (int i)
 
void Setup (int maxBodies, double timeStep)
 Setup the specified maxBodies and timeStep. Must be called prior to PreEvolve/Evolve.
 
void Clear ()
 Clear internal information so no bodies are evolved.
 
INBodyIntegrator DeepClone ()
 Clone this instance, replicating internal arrays. Copy across any internal state required for continued evolution.
 
void AddNBody (int bodyNum, NBody nbody, GravityState.NbodyState[] nbodyState)
 Adds the N body. Implementation may support the case where the initial number of bodies in Setup() is exceeded, creating space, or may ignore additions that exceed this limit (e.g. AZTTriple).
 
void RemoveBodyAtIndex (int atIndex)
 Removes NBody at index i.
 
void GrowArrays (int growBy)
 Grows the arrays. Called by GravityEngine when it changes internal data sizes.
 
Vector3d GetAccelerationForIndex (int i)
 
string GetExternalAccelForIndex (int i)
 
void PreEvolve (GravityState gravityState)
 Call ONCE after all game objects have been added to allow integrator to pre-calc starting quantities required for integration.
 
double Evolve (double time, GravityState gravityState, bool exactTime=false)
 Evolve the specified time, m, r and info.
 
float GetEnergy (GravityState gs)
 Gets the energy of the system.
 
float GetInitialEnergy (GravityState gs)
 Gets the initial energy.
 

Detailed Description

Special purpose integrator for precise integration of the three body problem.

The code derives from Fortran code written by Sevre Aarseth in the 1970s.

The key algorithm detail is the use of mathematical regularization to handle close encounters where the use of 1/r^2 would result in numerical instability. The "trick" is to use a change of variables to u=1/r for the two interacting bodies.

The integrator has been extended to handle additional bodies by using Leapfrog to evolve the additional bodies subject to the gravity of the AZT controlled bodies. Adding more than three massive bodies will result in inaccurate modelling, since first three bodies added will not be affected by the fourth.

Member Function Documentation

◆ AddNBody()

void AZTripleIntegrator.AddNBody ( int  bodyNum,
NBody  nbody,
GravityState.NbodyState[]  nbodyState 
)

Adds the N body. Implementation may support the case where the initial number of bodies in Setup() is exceeded, creating space, or may ignore additions that exceed this limit (e.g. AZTTriple).

Parameters
nbodyNBody component

Implements INBodyIntegrator.

◆ Clear()

void AZTripleIntegrator.Clear ( )

Clear internal information so no bodies are evolved.

Implements INBodyIntegrator.

◆ DeepClone()

INBodyIntegrator AZTripleIntegrator.DeepClone ( )

Clone this instance, replicating internal arrays. Copy across any internal state required for continued evolution.

Implements INBodyIntegrator.

◆ Evolve()

double AZTripleIntegrator.Evolve ( double  evolveTime,
GravityState  gravityState,
bool  exactTime = false 
)

Evolve the specified evolveTime, m_arg and r_arg.

AZT is focused on accuracy and the time it evolves for can vary over several orders of magnitude.

Parameters
evolveTimeEvolve time.
m_argM_arg. NOT USED
r_argR_arg. passes results back

Implements INBodyIntegrator.

◆ GetAccelerationForIndex()

Vector3d AZTripleIntegrator.GetAccelerationForIndex ( int  i)

Implements INBodyIntegrator.

◆ GetEnergy()

float AZTripleIntegrator.GetEnergy ( GravityState  gs)

Gets the energy of the system.

Returns
The energy.
Parameters
massMass.
posPosition.

Implements INBodyIntegrator.

◆ GetExternalAccelForIndex()

string AZTripleIntegrator.GetExternalAccelForIndex ( int  i)

Implements INBodyIntegrator.

◆ GetInitialEnergy()

float AZTripleIntegrator.GetInitialEnergy ( GravityState  gs)

Gets the initial energy.

Returns
The initial energy.
Parameters
massMass.
posPosition.

Implements INBodyIntegrator.

◆ GrowArrays()

void AZTripleIntegrator.GrowArrays ( int  growBy)

Grows the arrays. Called by GravityEngine when it changes internal data sizes.

Parameters
growByGrow by.

Implements INBodyIntegrator.

◆ PreEvolve()

void AZTripleIntegrator.PreEvolve ( GravityState  gravityState)

Call ONCE after all game objects have been added to allow integrator to pre-calc starting quantities required for integration.

To avoid copies of mass and position arrays in integrators provide a reference to these for Evolve and PreEvolve

Some implementations (e.g. AZTriple) may make their own copies and then copy the result back into these arrays ///

Parameters
mM.
rThe red component.
infoInfo.

Implements INBodyIntegrator.

◆ RemoveBodyAtIndex()

void AZTripleIntegrator.RemoveBodyAtIndex ( int  atIndex)

Removes NBody at index i.

Parameters
atIndexAt index.

Implements INBodyIntegrator.

◆ Setup()

void AZTripleIntegrator.Setup ( int  maxBodies,
double  timeStep 
)

Setup the specified maxBodies and timeStep. Must be called prior to PreEvolve/Evolve.

Parameters
maxBodiesMax bodies.
timeStepTime step.

Implements INBodyIntegrator.


The documentation for this class was generated from the following file: