00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 #include <lal/LALStdio.h>
00165 #include <lal/LALStdlib.h>
00166 #include <lal/LALConstants.h>
00167 #include <lal/Units.h>
00168 #include <lal/AVFactories.h>
00169 #include <lal/SeqFactories.h>
00170 #include <lal/SimulateCoherentGW.h>
00171 #include <lal/GenerateSpinOrbitCW.h>
00172
00173 NRCSID( GENERATEPARABOLICSPINORBITCWC, "$Id: GenerateParabolicSpinOrbitCW.c,v 1.6 2007/06/08 14:41:47 bema Exp $" );
00174
00175
00176 void
00177 LALGenerateParabolicSpinOrbitCW( LALStatus *stat,
00178 CoherentGW *output,
00179 SpinOrbitCWParamStruc *params )
00180 {
00181 UINT4 n, i;
00182 UINT4 nSpin = 0, j;
00183 REAL8 t, dt, tPow;
00184 REAL8 phi0, f0, twopif0;
00185 REAL8 f, fPrev;
00186 REAL4 df = 0.0;
00187 REAL8 phi;
00188 REAL8 vp;
00189 REAL8 argument;
00190 REAL8 fourCosOmega;
00191 REAL8 twoSinOmega;
00192 REAL8 vpCosOmega;
00193 REAL8 vpSinOmega;
00194 REAL8 vpSinOmega2;
00195 REAL8 vDot6;
00196 REAL8 oneBy12vDot;
00197 REAL8 pBy3;
00198 REAL8 p32;
00199 REAL8 c, c0, dc;
00200 REAL8 e, e2, e0;
00201 REAL8 de;
00202 REAL8 tpOff;
00203 REAL8 spinOff;
00204 REAL8 *fSpin = NULL;
00205 REAL4 *fData;
00206 REAL8 *phiData;
00207
00208 INITSTATUS( stat, "LALGenerateParabolicSpinOrbitCW",
00209 GENERATEPARABOLICSPINORBITCWC );
00210 ATTATCHSTATUSPTR( stat );
00211
00212
00213 ASSERT( params, stat, GENERATESPINORBITCWH_ENUL,
00214 GENERATESPINORBITCWH_MSGENUL );
00215 ASSERT( output, stat, GENERATESPINORBITCWH_ENUL,
00216 GENERATESPINORBITCWH_MSGENUL );
00217
00218
00219 ASSERT( !( output->a ), stat, GENERATESPINORBITCWH_EOUT,
00220 GENERATESPINORBITCWH_MSGEOUT );
00221 ASSERT( !( output->f ), stat, GENERATESPINORBITCWH_EOUT,
00222 GENERATESPINORBITCWH_MSGEOUT );
00223 ASSERT( !( output->phi ), stat, GENERATESPINORBITCWH_EOUT,
00224 GENERATESPINORBITCWH_MSGEOUT );
00225 ASSERT( !( output->shift ), stat, GENERATESPINORBITCWH_EOUT,
00226 GENERATESPINORBITCWH_MSGEOUT );
00227
00228
00229 if ( params->f ) {
00230 ASSERT( params->f->data, stat, GENERATESPINORBITCWH_ENUL,
00231 GENERATESPINORBITCWH_MSGENUL );
00232 nSpin = params->f->length;
00233 fSpin = params->f->data;
00234 }
00235
00236
00237
00238 vp = params->rPeriNorm*params->angularSpeed;
00239 vDot6 = 6.0*params->angularSpeed;
00240 n = params->length;
00241 dt = params->deltaT;
00242 f0 = fPrev = params->f0;
00243 if ( params->oneMinusEcc != 0.0 ) {
00244 ABORT( stat, GENERATESPINORBITCWH_EECC,
00245 GENERATESPINORBITCWH_MSGEECC );
00246 }
00247 if ( vp >= 1.0 ) {
00248 ABORT( stat, GENERATESPINORBITCWH_EFTL,
00249 GENERATESPINORBITCWH_MSGEFTL );
00250 }
00251 if ( vp <= 0.0 || dt <= 0.0 || f0 <= 0.0 || vDot6 <= 0.0 ||
00252 n == 0 ) {
00253 ABORT( stat, GENERATESPINORBITCWH_ESGN,
00254 GENERATESPINORBITCWH_MSGESGN );
00255 }
00256 #ifndef NDEBUG
00257 if ( lalDebugLevel & LALWARNING ) {
00258 if ( f0*n*dt*vp*vp > 0.5 )
00259 LALWarning( stat, "Orbit may have significant relativistic"
00260 " effects that are not included" );
00261 }
00262 #endif
00263
00264
00265
00266 tpOff = (REAL8)( params->orbitEpoch.gpsSeconds -
00267 params->epoch.gpsSeconds );
00268 tpOff += 1.0e-9 * (REAL8)( params->orbitEpoch.gpsNanoSeconds -
00269 params->epoch.gpsNanoSeconds );
00270 spinOff = (REAL8)( params->orbitEpoch.gpsSeconds -
00271 params->spinEpoch.gpsSeconds );
00272 spinOff += 1.0e-9 * (REAL8)( params->orbitEpoch.gpsNanoSeconds -
00273 params->spinEpoch.gpsNanoSeconds );
00274
00275
00276 twopif0 = f0*LAL_TWOPI;
00277 phi0 = params->phi0;
00278 argument = params->omega;
00279 oneBy12vDot = 0.5/vDot6;
00280 fourCosOmega = 4.0*cos( argument );
00281 twoSinOmega = 2.0*sin( argument );
00282 vpCosOmega = 0.25*vp*fourCosOmega;
00283 vpSinOmega = 0.5*vp*twoSinOmega;
00284 vpSinOmega2 = vpSinOmega*vpSinOmega;
00285 pBy3 = sqrt( 4.0*( 1.0 + vpCosOmega ) - vpSinOmega2 );
00286 p32 = 1.0/( pBy3*pBy3*pBy3 );
00287 c0 = p32*( vpSinOmega*( 6.0*vpCosOmega - 12.0 + vpSinOmega2 ) -
00288 tpOff*vDot6 );
00289 dc = p32*vDot6*dt;
00290 e0 = 3.0*vpSinOmega;
00291 de = 2.0*pBy3;
00292
00293
00294 #ifndef NDEBUG
00295 if ( lalDebugLevel & LALWARNING ) {
00296 REAL8 x = fabs( c0 + n*dc );
00297 if ( x < fabs( c0 ) )
00298 x = fabs( c0 );
00299 x = 6.0 + log( x + sqrt( x*x + 1.0 ) );
00300 if ( LAL_REAL8_EPS*f0*dt*n*x > 0.01 )
00301 LALWarning( stat, "REAL8 arithmetic may not have sufficient"
00302 " precision for this orbit" );
00303 }
00304 #endif
00305
00306
00307 if ( ( output->a = (REAL4TimeVectorSeries *)
00308 LALMalloc( sizeof(REAL4TimeVectorSeries) ) ) == NULL ) {
00309 ABORT( stat, GENERATESPINORBITCWH_EMEM,
00310 GENERATESPINORBITCWH_MSGEMEM );
00311 }
00312 memset( output->a, 0, sizeof(REAL4TimeVectorSeries) );
00313 if ( ( output->f = (REAL4TimeSeries *)
00314 LALMalloc( sizeof(REAL4TimeSeries) ) ) == NULL ) {
00315 LALFree( output->a ); output->a = NULL;
00316 ABORT( stat, GENERATESPINORBITCWH_EMEM,
00317 GENERATESPINORBITCWH_MSGEMEM );
00318 }
00319 memset( output->f, 0, sizeof(REAL4TimeSeries) );
00320 if ( ( output->phi = (REAL8TimeSeries *)
00321 LALMalloc( sizeof(REAL8TimeSeries) ) ) == NULL ) {
00322 LALFree( output->a ); output->a = NULL;
00323 LALFree( output->f ); output->f = NULL;
00324 ABORT( stat, GENERATESPINORBITCWH_EMEM,
00325 GENERATESPINORBITCWH_MSGEMEM );
00326 }
00327 memset( output->phi, 0, sizeof(REAL8TimeSeries) );
00328
00329
00330 output->position = params->position;
00331 output->psi = params->psi;
00332 output->a->epoch = output->f->epoch = output->phi->epoch
00333 = params->epoch;
00334 output->a->deltaT = n*params->deltaT;
00335 output->f->deltaT = output->phi->deltaT = params->deltaT;
00336 output->a->sampleUnits = lalStrainUnit;
00337 output->f->sampleUnits = lalHertzUnit;
00338 output->phi->sampleUnits = lalDimensionlessUnit;
00339 LALSnprintf( output->a->name, LALNameLength, "CW amplitudes" );
00340 LALSnprintf( output->f->name, LALNameLength, "CW frequency" );
00341 LALSnprintf( output->phi->name, LALNameLength, "CW phase" );
00342
00343
00344 LALSCreateVector( stat->statusPtr, &( output->f->data ), n );
00345 BEGINFAIL( stat ) {
00346 LALFree( output->a ); output->a = NULL;
00347 LALFree( output->f ); output->f = NULL;
00348 LALFree( output->phi ); output->phi = NULL;
00349 } ENDFAIL( stat );
00350 LALDCreateVector( stat->statusPtr, &( output->phi->data ), n );
00351 BEGINFAIL( stat ) {
00352 TRY( LALSDestroyVector( stat->statusPtr, &( output->f->data ) ),
00353 stat );
00354 LALFree( output->a ); output->a = NULL;
00355 LALFree( output->f ); output->f = NULL;
00356 LALFree( output->phi ); output->phi = NULL;
00357 } ENDFAIL( stat );
00358
00359
00360 {
00361 CreateVectorSequenceIn in;
00362 in.length = 2;
00363 in.vectorLength = 2;
00364 LALSCreateVectorSequence( stat->statusPtr, &(output->a->data), &in );
00365 BEGINFAIL( stat ) {
00366 TRY( LALSDestroyVector( stat->statusPtr, &( output->f->data ) ),
00367 stat );
00368 TRY( LALDDestroyVector( stat->statusPtr, &( output->phi->data ) ),
00369 stat );
00370 LALFree( output->a ); output->a = NULL;
00371 LALFree( output->f ); output->f = NULL;
00372 LALFree( output->phi ); output->phi = NULL;
00373 } ENDFAIL( stat );
00374 output->a->data->data[0] = output->a->data->data[2] = params->aPlus;
00375 output->a->data->data[1] = output->a->data->data[3] = params->aCross;
00376 }
00377
00378
00379 fData = output->f->data->data;
00380 phiData = output->phi->data->data;
00381 for ( i = 0; i < n; i++ ) {
00382
00383
00384 c = c0 + dc*i;
00385 if ( c > 0 )
00386 e = e0 + de*sinh( log( c + sqrt( c*c + 1.0 ) )/3.0 );
00387 else
00388 e = e0 + de*sinh( -log( -c + sqrt( c*c + 1.0 ) )/3.0 );
00389 e2 = e*e;
00390 phi = t = tPow = oneBy12vDot*e*( 12.0 + e2 );
00391
00392
00393 f = 1.0;
00394 for ( j = 0; j < nSpin; j++ ) {
00395 f += fSpin[j]*tPow;
00396 phi += fSpin[j]*( tPow*=t )/( j + 2.0 );
00397 }
00398
00399
00400 f *= f0 / ( 1.0 + vp*( fourCosOmega - e*twoSinOmega )
00401 /( 4.0 + e2 ) );
00402 phi *= twopif0;
00403 if ( fabs( f - fPrev ) > df )
00404 df = fabs( f - fPrev );
00405 *(fData++) = fPrev = f;
00406 *(phiData++) = phi + phi0;
00407 }
00408
00409
00410 params->dfdt = df*dt;
00411 DETATCHSTATUSPTR( stat );
00412 RETURN( stat );
00413 }