home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
DE118I.ZIP
/
OBLATE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-06
|
16KB
|
562 lines
/* oblate.c
*/
#ifndef NOINCS
#include "mconf.h"
#include "prec.h"
#include "ssystem.h"
#include "const.h"
#endif
#ifdef DEBUG
#undef DEBUG
#endif
#define DEBUG 0
extern DOUBLE GMs[];
extern DOUBLE Rij[NTOTAL][NTOTAL];
extern DOUBLE Rij3[NTOTAL][NTOTAL];
extern DOUBLE AM, AE, LOVENO, PHASE, EMRAT;
extern DOUBLE PSLP1, PSLPI, PSLPIA, PSLPIB, JDEPOCH;
extern DOUBLE LBET, LGAM, LGAMBET;
extern DOUBLE Jm[], Je[], Cnm[], Snm[];
DOUBLE ofdate[3];
DOUBLE phi, th, psi, phi1, th1, psi1, Nx, Ny, Nz;
DOUBLE sinpsi, cospsi, sinth, costh, sinphi, cosphi;
DOUBLE X00, X01, X02, X10, X11, X12, X20, X21, X22;
extern DOUBLE B1950;
DOUBLE SQRT(), SIN(), COS(), FLOOR();
#if LDOUBLE
#if IBMPC
short Cr375i[] = {0x0000,0x0000,0x0000,0xc000,0x3ffd, XPD};
short C2r5i[] = {0x0000,0x0000,0x0000,0xa000,0x4000, XPD};
short C3r75i[] = {0x0000,0x0000,0x0000,0xf000,0x4000, XPD};
short C4r375i[] = {0x0000,0x0000,0x0000,0x8c00,0x4001, XPD};
short C7r5i[] = {0x0000,0x0000,0x0000,0xf000,0x4001, XPD};
short C15i[] = {0x0000,0x0000,0x0000,0xf000,0x4002, XPD};
short C17r5i[] = {0x0000,0x0000,0x0000,0x8c00,0x4003, XPD};
short C52r5i[] = {0x0000,0x0000,0x0000,0xd200,0x4004, XPD};
short C105i[] = {0x0000,0x0000,0x0000,0xd200,0x4005, XPD};
#endif
#if MIEEE
long Cr375i[] = {0x3ffd0000,0xc0000000,0x00000000};
long C2r5i[] = {0x40000000,0xa0000000,0x00000000};
long C3r75i[] = {0x40000000,0xf0000000,0x00000000};
long C4r375i[] = {0x40010000,0x8c000000,0x00000000};
long C7r5i[] = {0x40010000,0xf0000000,0x00000000};
long C15i[] = {0x40020000,0xf0000000,0x00000000};
long C17r5i[] = {0x40030000,0x8c000000,0x00000000};
long C52r5i[] = {0x40040000,0xd2000000,0x00000000};
long C105i[] = {0x40050000,0xd2000000,0x00000000};
#endif
#define Cr375 (*(long double *)Cr375i)
#define C2r5 (*(long double *)C2r5i)
#define C3r75 (*(long double *)C3r75i)
#define C4r375 (*(long double *)C4r375i)
#define C7r5 (*(long double *)C7r5i)
#define C15 (*(long double *)C15i)
#define C17r5 (*(long double *)C17r5i)
#define C52r5 (*(long double *)C52r5i)
#define C105 (*(long double *)C105i)
#else /* LDOUBLE */
DOUBLE Cr375 = 3.75000000000000000000E-1;
DOUBLE C2r5 = 2.50000000000000000000E0;
DOUBLE C3r75 = 3.75000000000000000000E0;
DOUBLE C4r375 = 4.37500000000000000000E0;
DOUBLE C7r5 = 7.50000000000000000000E0;
DOUBLE C15 = 1.50000000000000000000E1;
DOUBLE C17r5 = 1.75000000000000000000E1;
DOUBLE C52r5 = 5.25000000000000000000E1;
DOUBLE C105 = 1.05000000000000000000E2;
#endif /* not LDOUBLE */
oblate( JD, yp, v, ymoon )
DOUBLE JD;
DOUBLE yp[], v[], ymoon[];
{
DOUBLE f, a, b, rem, res;
DOUBLE xyz[3], c, s;
int i;
/* x, y, z are the the (equatorial J2000)
* solar system barycentric Cartesian coordinates
* of the external point mass relative to the center of
* the extended body.
* Bx, By, Bz are the principal axes of inertia of the extended body.
* The Euler angles are
* theta, the angle from the z axis to the Bz axis
* phi, measured in the x-y plane from the x axis to the line of nodes
* psi, measured in the body's equatorial (Bx-By) plane
* from the line of nodes to the Bx axis.
*/
phi1 = yp[0];
phi = yp[1];
th1 = yp[2];
th = yp[3];
psi1 = yp[4];
v[1] = phi1; /* Copy the first derivative vector */
v[3] = th1;
v[5] = psi1;
/* Add slope representing the Moon's mean rotation */
psi1 += PSLP1;
/* Calculate psi = yp[5] + PSLP1*(JD - JDEPOCH).
* Since only the sine and cosine of psi are needed, psi may
* here be reduced accurately modulo the mean rotation period
* of 2 pi / PSLP1 days.
*/
b = JD - JDEPOCH; /* elapsed days assumed arithmetically exact */
/* Subtract nearest integer number of rotation periods from the time */
f = FLOOR( b/PSLPI ); /* integer number of periods elapsed */
a = b - f * PSLPIA; /* arithmetic is exact while f < 2^26 periods */
b = a - f * PSLPIB; /* note, PSLPIA + PSLPIB = 1 period */
psi = yp[5] + PSLP1*b; /* yp[5] is the integrator output for psi */
#if DEBUG
printf( "phi %.5e, th %.5e, psi %.5e\n", (double) phi, (double) th, (double) psi );
#endif
/* Construct matrix elements that will be used by mfigure()
* to convert the extended-body-to-point-mass vector
* from space (xyz) coordinates to body (Bxyz) coordinates.
* This is a composite of three rotations:
* first by an angle phi about the z axis,
* second by an angle theta about the new x axis,
* third by an angle psi about the final z axis.
* Each rotation is counter-clockwise, looking toward the
* origin along the indicated axis. See H. Goldstein,
* _Classsical Mechanics_, Addison-Wesley, 1950, pp 107-109.
*/
sinpsi = SIN(psi);
cospsi = COS(psi);
sinth = SIN(th);
costh = COS(th);
sinphi = SIN(phi);
cosphi = COS(phi);
a = costh*sinphi;
b = costh*cosphi;
X00 = cospsi*cosphi - a*sinpsi;
X01 = cospsi*sinphi + b*sinpsi;
X02 = sinpsi*sinth;
X10 = -sinpsi*cosphi - a*cospsi;
X11 = -sinpsi*sinphi + b*cospsi;
X12 = cospsi*sinth;
X20 = sinth*sinphi;
X21 = -sinth*cosphi;
X22 = costh;
/* Initialize the torque accumulators.
*/
Nx = Zero;
Ny = Zero;
Nz = Zero;
/* Accelerations due to the figure of the Moon.
*/
/* effect of the point-mass Earth : 2e-12 au/d^2 */
xyz[0] = -ymoon[1];
xyz[1] = -ymoon[3];
xyz[2] = -ymoon[5];
mfigure( IEARTH, xyz, v );
/* effect of the point-mass Sun: 1e-17 au/d^2 */
xyz[0] = yp[6*ISUN+1] - yp[6*IMOON+1];
xyz[1] = yp[6*ISUN+3] - yp[6*IMOON+3];
xyz[2] = yp[6*ISUN+5] - yp[6*IMOON+5];
#if DEBUG
printf( "Moon->Sun %.5e %.5e %.5e\n", (double) xyz[0], (double) xyz[1], (double) xyz[2] );
#endif
/* a = Rij[ISUN][IMOON]; */
mfigure( ISUN, xyz, v );
/* Update accelerations of libration angles */
librate( v );
/* Oblateness of the earth
*/
/* effect of the point-mass Moon : 7e-11 au/d^2
*/
for( i=0; i<3; i++ )
ofdate[i] = ymoon[2*i+1];
/* Precess from basic epoch to date */
precess( ofdate, JD, -1 );
nutate( JD, ofdate );
rem = Rij[IEARTH][IMOON];
legendre( ofdate, AE, rem, Je, xyz, 0 );
invnut( xyz );
precess( xyz, JD, 1 );
a = -GMs[IMOON];
i = 6 * IEARTH;
v[i] += a * xyz[0];
v[i+2] += a * xyz[1];
v[i+4] += a * xyz[2];
a = GMs[IEARTH];
#if DEBUG
printf( "E,M %.5e %.5e %.5e\n",
(double )(a*xyz[0]), (double )(a*xyz[1]), (double )(a*xyz[2]) );
#endif
i = 6 * IMOON;
v[i] += a * xyz[0];
v[i+2] += a * xyz[1];
v[i+4] += a * xyz[2];
/* tides: 1e-15 au/d^2
*/
a = AE * rem;
b = a*a;
a = b*b*a*(One + One/EMRAT);
a = -Three*LOVENO*a*GMs[IMOON] * Rij3[IEARTH][IMOON];
xyz[0] = a * (ofdate[0] + PHASE * ofdate[1]);
xyz[1] = a * (ofdate[1] - PHASE * ofdate[0]);
xyz[2] = a * ofdate[2];
invnut( xyz );
precess( xyz, JD, 1 );
c = One/(One+EMRAT);
s = EMRAT*c;
i = 6 * IEARTH;
v[i] -= c * xyz[0];
v[i+2] -= c * xyz[1];
v[i+4] -= c * xyz[2];
#if DEBUG
printf( "T,M %.5e %.5e %.5e\n",
(double )(s*xyz[0]), (double )(s*xyz[1]), (double )(s*xyz[2]) );
#endif
i = 6 * IMOON;
v[i] += s * xyz[0];
v[i+2] += s * xyz[1];
v[i+4] += s * xyz[2];
/* effect of the Sun: 7e-16 au/d^2
*/
res = Rij[ISUN][IEARTH];
ofdate[0] = yp[6*ISUN+1] - yp[6*IEARTH+1];
ofdate[1] = yp[6*ISUN+3] - yp[6*IEARTH+3];
ofdate[2] = yp[6*ISUN+5] - yp[6*IEARTH+5];
precess( ofdate, JD, -1 );
nutate( JD, ofdate );
legendre( ofdate, AE, res, Je, xyz, 0 );
invnut( xyz );
precess( xyz, JD, 1 );
a = -GMs[ISUN];
#if DEBUG
printf( "E,S %.5e %.5e %.5e\n",
(double )(a*xyz[0]), (double )(a*xyz[1]), (double )(a*xyz[2]) );
#endif
i = 6 * IEARTH;
v[i] += a * xyz[0];
v[i+2] += a * xyz[1];
v[i+4] += a * xyz[2];
a = GMs[IEARTH];
i = 6 * ISUN;
v[i] += a * xyz[0];
v[i+2] += a * xyz[1];
v[i+4] += a * xyz[2];
}
mfigure( iobj, xyz, v )
int iobj; /* Index of distance from center of extended body to point mass */
DOUBLE xyz[]; /* space coordinates of point mass */
DOUBLE v[]; /* Velocity and acceleration state vector */
{
DOUBLE a, rem;
DOUBLE Bxyz[3], Fxyz[3];
int i;
/* Apply the transformation from space to body coordinates.
*/
Bxyz[0] = X00*xyz[0] + X01*xyz[1] + X02*xyz[2];
Bxyz[1] = X10*xyz[0] + X11*xyz[1] + X12*xyz[2];
Bxyz[2] = X20*xyz[