astro/
force_newton.pro
top source force_newton
Astro
result = force_newton(x, y, z, xpart, ypart, zpart, mass, lengthunit=lengthunit, massunit=massunit, astro=astro, softening=softening)
Calculates the gravitational force from a particle distribution at a list of positions.
Return value
This function returns the gravitational force at each X,Y,Z position. If there are NPOS positions, Result is an NPOSx3 matrix.
Parameters
- x in
X coordinates at which to calculate forces.
- y in
Y coordinates at which to calculate forces.
- z in
Z coordinates at which to calculate forces.
- xpart in
X coordinates of particle positions defining the mass distribution.
- ypart in
Y coordinates of particle positions defining the mass distribution.
- zpart in
Z coordinates of particle positions defining the mass distribution.
- mass in
Mass of each particle.
Keywords
- lengthunit in
Length unit, in cm (or kpc if /ASTRO is set). Default: 1kpc.
- massunit in
Mass unit, in grams (or solar masses if /ASTRO is set). Default: 1 solar mass.
- astro in
If /ASTRO is set then LENGTHUNIT and MASSUNIT are given in kpc and solar masses respectively, otherwise they are in CGS (Lengthunit in cm, Massunit in grams).
- softening in
Plummer softening length. Default: 0 (no softening).
Examples
Calculate the gravitational force on a line along the x-axis from
6 point masses placed at the vertices of a cube:
xmasspos = [-1,-1,-1,-1,1,1,1,1]
ymasspos = [-1,-1,1,1,-1,-1,1,1]
zmasspos = [-1,1,-1,1,-1,1,-1,1]
masses = REPLICATE(1.,8)
xlinepos = 0.1*FINDGEN(20)
ylinepos = REPLICATE(0.,20)
zlinepos = REPLICATE(0.,20)
forces = FORCE_NEWTON(xlinepos, ylinepos, zlinepos, xmasspos, ymasspos,
zmasspos, masses)
Author information
- History:
Written by: Jeremy Bailin 10 June 2008 Public release in JBIU
File attributes
| Modification date: | Wed Apr 15 16:07:41 2009 |
| Lines: | 120 |
![[attach.png]](../idldoc-resources/attach.png)