Table of Contents


bodytrans - test and optionally save body to scalar mapping


bodytrans expr=expression [parameter=value] ...


bodytrans is a testbed for saving/debugging a user-specified mapping from a body(3NEMO) to a real or integer value. These mappings are given by an arbitrary C expression involving any of the variables m, x, y, z, vx, vy, vz, phi, ax, ay, az, aux, key, t, and i, using various math library functions, e.g. cbrt(), sqrt(), qbe(), sqr(), sin(), cos(), asin(), acos(), tan(), atan(), atan2(), exp(), dex(), log(), log10(), pow(), fabs(), floor(), ceil(), and rint(). (assuming 3 dimensional body’s, see ENVIRONMENT below).

Given such an expression, bodytrans invokes the C compiler, which is general but can be rather slow. To speed things up, an expression is first treated as a name and checked against a collection of precompiled expressions stored as ".o" (see a.out(5) )files. If the expression is a real/int expression, it will search for an object file btr_expr.o, bti_expr.o resp. If a match is found, the precompiled object is used instead. If bodytrans has been compiled with auto-saving object files a next search will be performed on the $NEMOOBJ/bodytrans/BTNAMES database. This contains a list of expressions and names of their object files, these object files were previously generated by any program which used the bodytrans(3NEMO) routines.

A number of precompiled transformations already exist, e.g.: x, y, z, vx, vy, vz, r, v, vr, vt, jtot, phi, etot, t, and i. A complete list may be deduced by looking in $NEMOOBJ/bodytrans/, which is the default repository. It is possible to customize your own transformations and collections; see $NEMO/src/nbody/core/bodysub/ for model routines.

If bodytrans has been compiled with auto-saving (the default), the object file will be saved in the standard repository directory $NEMOOBJ/bodytrans, and the corresponding database file-list BTNAMES will be updated. When using the same expression expr at a later time not only can the user then refer to the expression by it’s original expression, but also by its pseudo-name file (see keyword file and examples below).

For an alternative approach to use dynamic analysis routines, see mkbodyfunc(1falcON) and mkbodiesfunc(1falcON) .


The following parameters are recognized.
Scalar-valued C-language expression specifying the transformation to test. If keyword file is present (see below) a mapping file of the name btX_file is tried before the expression is turned into a mapping file. Default: x.
Type of value returned; currently either real or int. Default: real.
Mass of body used to test mapping. Default: 0.125.
Position of body, specified by a comma-separated list of components. Default: 0.5,-0.5,1.0.
Velocity of body. Default: 0.1,0.2,-0.3.
Gravitational potential at position of body. Default: -1.2.
Acceleration of body. Default: -0.5,0.7,0.1.
Real auxiliary value associated with body. Default: 3.141592.
Integer key value associated with body. Default: 3.
Time value available to expression. Default: 2.5.
Body index available to expression. Default: 1.
Tail of the filename under which the expr transformation is to be saved for later recovery. Note that the first four characters of the filename are already fixed and will be btX_, where X is either r or i, depending on the type (see above) of the expression. The full filename will hence be btX_file. [default: not used].
File containing a database of expression and filenames under which they are to be saved. When used, the program (re) creates all bodytrans(5) files and exits. [default: no used].
Show the currently saved bodytrans functions (from the BTNAMES files). [Default: f].


The following command
    % bodytrans expr=x+y+z alias=sum
saves the mapping in an object file btr_sum.o, and can be later used as in:
    % snapprint snap-file x+y+z
or using this alias
    % snapprint snap-file sum
It is not necessary to provide a pseudonym using the keyword alias, although recommended if bodytrans is used. As an example, the command
    % bodytrans expr=x+y+z
could save the mapping in an object file btr__24, and can later be referred to as
    % snapprint snap-file x+y+z
or the more cryptic
    % snapprint snap-file _24
The relationship between _24 and x+y+z is saved in the file BTNAMES and resolved at run-time.


There is a shell script BTclean that selectively cleans up object files listed in the BTNAMES file. A new ’BTNAMES’ file is generated. You can run it interactively (have to be NEMO user though) and answer some simple questions.


By default, body to scalar transformations are applied to bodies which have vectors of lenght 3 (see also vectmath(3NEMO) ). By adding -DTWODIM to the environment variable CFLAGS, newly created bodytrans variables are compiled with 2D bodies. Obviously it is very dangerous to mix 2D and 3D bodies, but the possibility exists.

See Also

body(3NEMO) , bodytrans(3NEMO) , vectmath(3NEMO) , snapshot(5NEMO) , mkbodyfunc(1falcON) , mkbodiesfunc(1falcON)


Joshua E. Barnes, Peter Teuben


~/src/nbody/core/bodytrans.c    code
~/src/nbody/core/bodysub/*    default standard bodytrans(5) files


xx-xxx-87    V1.0 Created         JEB
8-jul-89    V1.1 saving bodytrans mappings into user files    PJT
19-nov-89    V1.2 BTNAMES database used for saving    PJT
10-dec-91    some more doc    PJT
12-aug-92    documented CFLAGS usage     PJT
2-aug-06    V3.3 add show=    PJT

Table of Contents