|
numerics
|
#include <nbody.hpp>
Public Member Functions | |
| void | reset (Scenario s) |
| Reset to a preset scenario. | |
| void | step (double dt) |
| Advance by exactly one time step dt. | |
| std::vector< std::pair< int, int > > | check_merges () |
| int | n () const |
| double | kinetic_energy () const |
| double | potential_energy () const |
| double | total_energy () const |
| double | energy_drift () const |
| Relative energy drift since reset: (E - E0) / |E0|. | |
| void | make_accel (const num::Vector &pos, num::Vector &acc) const |
| Fill acc from current positions (gravitational acceleration on each body). | |
Public Attributes | |
| std::vector< Body > | bodies |
| num::Vector | q |
| Positions: [x0,y0, x1,y1, ...]. | |
| num::Vector | v |
| Velocities: [vx0,vy0, vx1,vy1, ...]. | |
| double | t = 0.0 |
| double | G = 1.0 |
| double | E0 = 0.0 |
| Initial total energy (for drift tracking) | |
| double | soft = 1e-3 |
| Softening length (avoids singularities) | |
| bool | use_verlet = true |
| true = Verlet (symplectic), false = RK4 | |
| bool | enable_merges = false |
| true = check_merges() is active (Galaxy scenario) | |
| std::vector< std::pair< int, int > > nbody::NBodySim::check_merges | ( | ) |
|
inline |
Relative energy drift since reset: (E - E0) / |E0|.
Definition at line 82 of file nbody.hpp.
References E0, and total_energy().
Referenced by main().
| double nbody::NBodySim::kinetic_energy | ( | ) | const |
| void nbody::NBodySim::make_accel | ( | const num::Vector & | pos, |
| num::Vector & | acc | ||
| ) | const |
Fill acc from current positions (gravitational acceleration on each body).
Definition at line 53 of file main.cpp.
References num::BasicVector< T >::begin(), bodies, num::BasicVector< T >::end(), G, n(), and soft.
Referenced by step().
|
inline |
Definition at line 75 of file nbody.hpp.
References bodies.
Referenced by check_merges(), kinetic_energy(), main(), make_accel(), potential_energy(), and step().
| double nbody::NBodySim::potential_energy | ( | ) | const |
| void nbody::NBodySim::reset | ( | Scenario | s | ) |
Reset to a preset scenario.
Definition at line 165 of file main.cpp.
References nbody::BinaryPlus, bodies, E0, enable_merges, nbody::Figure8, G, q, soft, nbody::SolarSystem, t, total_energy(), and v.
Referenced by main().
| void nbody::NBodySim::step | ( | double | dt | ) |
Advance by exactly one time step dt.
Definition at line 89 of file main.cpp.
References make_accel(), n(), num::ode_rk4(), num::ode_verlet(), q, t, use_verlet, and v.
Referenced by main().
|
inline |
Definition at line 79 of file nbody.hpp.
References kinetic_energy(), and potential_energy().
Referenced by energy_drift(), and reset().
| std::vector<Body> nbody::NBodySim::bodies |
Definition at line 53 of file nbody.hpp.
Referenced by check_merges(), kinetic_energy(), main(), make_accel(), n(), potential_energy(), and reset().
| double nbody::NBodySim::E0 = 0.0 |
Initial total energy (for drift tracking)
Definition at line 58 of file nbody.hpp.
Referenced by energy_drift(), and reset().
| bool nbody::NBodySim::enable_merges = false |
true = check_merges() is active (Galaxy scenario)
| double nbody::NBodySim::G = 1.0 |
Definition at line 57 of file nbody.hpp.
Referenced by make_accel(), potential_energy(), and reset().
| num::Vector nbody::NBodySim::q |
Positions: [x0,y0, x1,y1, ...].
Definition at line 54 of file nbody.hpp.
Referenced by check_merges(), main(), potential_energy(), reset(), and step().
| double nbody::NBodySim::soft = 1e-3 |
Softening length (avoids singularities)
Definition at line 59 of file nbody.hpp.
Referenced by make_accel(), potential_energy(), and reset().
| double nbody::NBodySim::t = 0.0 |
| bool nbody::NBodySim::use_verlet = true |
| num::Vector nbody::NBodySim::v |
Velocities: [vx0,vy0, vx1,vy1, ...].
Definition at line 55 of file nbody.hpp.
Referenced by check_merges(), kinetic_energy(), reset(), and step().