energy: Mechanical energy of an N-body system

View source: R/energy.R

energyR Documentation

Mechanical energy of an N-body system

Description

Computes the instantaneous potential and kinetic energies of all particles in an N-body system. Here, the potential energy of a particle i means the potential energy it has with all other particles (sum_j -G*m[i]*[j]/rij). Hence the total potential energy of the system is half the sum of the individual potential energies.

Usage

energy(m, x, v, rsmooth = 0, G = 6.67408e-11, cpp = TRUE)

Arguments

m

N-vector with the masses of the N particles. Negative masses are treated as positive masses of same magnitude, since negative masses normally represent positive background masses in the nbody package.

x

N-by-3 matrix specifying the initial position in Cartesian coordinates

v

N-by-3 matrix specifying the initial velocities

rsmooth

top-hat smoothing radius.

G

gravitational constant. The default is the measured value in SI units.

cpp

logical flag. If TRUE (default), the computation is performed efficiently in C++.

Value

Returns a list with vector items Ekin, Epot, Emec=Ekin+Epot; and the associated total quantities Ekin.tot, Epot.tot, Emec=Ekin+Epot.tot.

Author(s)

Danail Obreschkow


nbody documentation built on Sept. 11, 2024, 7:47 p.m.