LALInspiralWave2.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Stas Babak, David Churches, Jolien Creighton, B.S. Sathyaprakash, Craig Robinson , Thomas Cokelaer
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /*  <lalVerbatim file="LALInspiralWave2CV">
00021 Author: Sathyaprakash, B. S.
00022 $Id: LALInspiralWave2.c,v 1.25 2008/03/06 13:04:36 sathya Exp $
00023 </lalVerbatim>  */
00024 
00025 /*  <lalLaTeX>
00026 
00027 \subsection{Module \texttt{LALInspiralWave2.c} and \texttt{LALInspiralWave2Templates.c}}
00028 
00029 These modules generate a time-domain chirp waveform of type {\tt TaylorT2}.
00030 
00031 \subsubsection*{Prototypes}
00032 \vspace{0.1in}
00033 \input{LALInspiralWave2CP}
00034 \index{\verb&LALInspiralWave2()&}
00035 \begin{itemize}
00036 \item {\tt output:} Output containing the inspiral waveform.
00037 \item {\tt params:} Input containing binary chirp parameters.
00038 \end{itemize}
00039 \vspace{0.1in}
00040 \input{LALInspiralWave2TemplatesCP}
00041 \index{\verb&LALInspiralWave2Templates()&}
00042 \begin{itemize}
00043 \item {\tt output1:} Output containing the 0-phase inspiral waveform.
00044 \item {\tt output2:} Output containing the $\pi/2$-phase inspiral waveform.
00045 \item {\tt params:} Input containing binary chirp parameters.
00046 \end{itemize}
00047 
00048 \subsubsection*{Description}
00049 
00050 \texttt{LALInspiralWave2} generates {\tt TaylorT2} approximant wherein 
00051 the phase of the waveform is given as an implicit function of time
00052 as in Equation (\ref{eq:InspiralWavePhase2}). A template is required
00053 to be sampled at equal intervals of time. Thus, first of the equations
00054 in Equation (\ref{eq:InspiralWavePhase2}) is solved for $v$ at equally
00055 spaced values of the time steps
00056 $t_k$ and the resulting value of $v_k$ is used in the second equation to
00057 obtain the phase $\phi_k$. 
00058 
00059 \texttt{LALInspiralWave2Templates} is exactly the same as \texttt{LALInspiralWave2}
00060 except that it generates two waveforms that differ in phase by $\pi/2.$
00061 
00062 \subsubsection*{Uses}
00063 
00064 \texttt{LALInspiralParameterCalc}\\
00065 \texttt{LALDBisectionFindRoot}\\
00066 \texttt{LALInspiralPhasing2}\\
00067 
00068 \subsubsection*{Notes}
00069 
00070 \vfill{\footnotesize\input{LALInspiralWave2CV}}
00071 
00072 </lalLaTeX>  */
00073 
00074 #include <lal/LALStdlib.h>
00075 #include <lal/LALInspiral.h>
00076 #include <lal/FindRoot.h>
00077 #include <lal/Units.h>
00078 #include <lal/SeqFactories.h>
00079 
00080 static void
00081 LALInspiralWave2Engine(
00082                 LALStatus        *status,
00083                 REAL4Vector      *output1,
00084                 REAL4Vector      *output2,
00085                 REAL4Vector      *h,
00086                 REAL4Vector      *a,
00087                 REAL4Vector      *ff,
00088                 REAL8Vector      *phi,
00089                 UINT4            *countback,
00090                 InspiralTemplate *params,
00091                 InspiralInit     *paramsInit
00092                 );
00093 
00094 
00095 
00096 NRCSID (LALINSPIRALWAVE2C, "$Id: LALInspiralWave2.c,v 1.25 2008/03/06 13:04:36 sathya Exp $");
00097 
00098 /*  <lalVerbatim file="LALInspiralWave2CP"> */
00099 
00100 void 
00101 LALInspiralWave2(
00102    LALStatus        *status, 
00103    REAL4Vector      *output, 
00104    InspiralTemplate *params
00105    )
00106 { /* </lalVerbatim>  */
00107 
00108   UINT4 count;
00109 
00110   InspiralInit paramsInit;
00111 
00112   INITSTATUS (status, "LALInspiralWave2", LALINSPIRALWAVE2C);
00113   ATTATCHSTATUSPTR(status);
00114 
00115   ASSERT(output,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00116   ASSERT(output->data,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00117   ASSERT(params,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00118   ASSERT((INT4)params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00119   ASSERT((REAL8)params->fLower > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00120   ASSERT((REAL8)params->tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00121   ASSERT((INT4)params->order >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00122   ASSERT((INT4)params->order <= 8, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00123 
00124   /* Initially the waveform is empty */
00125   memset(output->data, 0, output->length * sizeof(REAL4));
00126 
00127   LALInspiralSetup(status->statusPtr, &(paramsInit.ak), params);
00128   CHECKSTATUSPTR(status);
00129   LALInspiralChooseModel(status->statusPtr, &(paramsInit.func), 
00130                                         &(paramsInit.ak), params);
00131   CHECKSTATUSPTR(status);
00132 
00133   /* Call the engine function */
00134   LALInspiralWave2Engine(status->statusPtr, output, NULL, NULL, NULL, 
00135                         NULL, NULL, &count, params, &paramsInit);
00136   CHECKSTATUSPTR(status);
00137 
00138   DETATCHSTATUSPTR(status);
00139   RETURN(status);
00140 
00141 }
00142 
00143 NRCSID (LALINSPIRALWAVE2TEMPLATESC, "$Id: LALInspiralWave2.c,v 1.25 2008/03/06 13:04:36 sathya Exp $");
00144 
00145 /*  <lalVerbatim file="LALInspiralWave2TemplatesCP"> */
00146 
00147 void 
00148 LALInspiralWave2Templates(
00149                           LALStatus        *status, 
00150                           REAL4Vector      *output1, 
00151                           REAL4Vector      *output2, 
00152                           InspiralTemplate *params
00153                           )
00154 
00155 { /* </lalVerbatim>  */
00156   
00157   UINT4 count;
00158 
00159   InspiralInit paramsInit;
00160 
00161   INITSTATUS (status, "LALInspiralWave2Templates", LALINSPIRALWAVE2TEMPLATESC);
00162   ATTATCHSTATUSPTR(status);
00163 
00164   ASSERT(output1,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00165   ASSERT(output2,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00166   ASSERT(output1->data,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00167   ASSERT(output2->data,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00168   ASSERT(params,status,LALINSPIRALH_ENULL,LALINSPIRALH_MSGENULL);
00169   ASSERT((INT4)params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00170   ASSERT((REAL8)params->fLower > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00171   ASSERT((REAL8)params->tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00172   ASSERT((INT4)params->order >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00173   ASSERT((INT4)params->order <= 8, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00174 
00175   /* Initially the waveforms are empty */
00176   memset(output1->data, 0, output1->length * sizeof(REAL4));
00177   memset(output2->data, 0, output2->length * sizeof(REAL4));
00178 
00179   LALInspiralSetup(status->statusPtr, &(paramsInit.ak), params);
00180   CHECKSTATUSPTR(status);
00181   LALInspiralChooseModel(status->statusPtr, &(paramsInit.func), 
00182                                         &(paramsInit.ak), params);
00183   CHECKSTATUSPTR(status);
00184 
00185   /* Call the engine function */
00186   LALInspiralWave2Engine(status->statusPtr, output1, output2, NULL, NULL, 
00187                            NULL, NULL, &count, params, &paramsInit);
00188   CHECKSTATUSPTR(status);
00189 
00190   DETATCHSTATUSPTR(status);
00191   RETURN(status);
00192 
00193 }
00194 
00195 
00196 
00197 
00198 NRCSID (LALINSPIRALWAVE2FORINJECTIONC, "$Id: LALInspiralWave2.c,v 1.25 2008/03/06 13:04:36 sathya Exp $");
00199 
00200 /*  <lalVerbatim file="LALInspiralWave2ForInjectionCP"> */
00201 
00202 void 
00203 LALInspiralWave2ForInjection(
00204    LALStatus        *status, 
00205    CoherentGW *waveform,   
00206    InspiralTemplate *params,
00207    PPNParamStruc  *ppnParams                         
00208    )
00209 
00210 { /* </lalVerbatim>  */
00211 
00212   UINT4 count, i;
00213 
00214   REAL4Vector *a   = NULL;/* pointers to generated amplitude  data */
00215   REAL4Vector *h   = NULL;/* pointers to generated polarizations */
00216   REAL4Vector *ff  = NULL;/* pointers to generated  frequency data */
00217   REAL8Vector *phi = NULL;/* pointer to generated phase data */
00218 
00219   CreateVectorSequenceIn in;
00220 
00221   REAL8 phiC;/* phase at coalescence */
00222 
00223   CHAR message[256];
00224   
00225   InspiralInit paramsInit;  
00226 
00227   /** -- -- */
00228   INITSTATUS (status, "LALInspiralWave2ForInjection", LALINSPIRALWAVE2FORINJECTIONC);
00229   ATTATCHSTATUSPTR(status);
00230 
00231   /* Make sure parameter and waveform structures exist. */
00232   ASSERT( params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00233   ASSERT(waveform, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);  
00234   ASSERT( !( waveform->a ), status, LALINSPIRALH_ENULL,  LALINSPIRALH_MSGENULL );
00235   ASSERT( !( waveform->h ), status, LALINSPIRALH_ENULL,  LALINSPIRALH_MSGENULL );
00236   ASSERT( !( waveform->f ), status, LALINSPIRALH_ENULL,  LALINSPIRALH_MSGENULL );
00237   ASSERT( !( waveform->phi ), status, LALINSPIRALH_ENULL,  LALINSPIRALH_MSGENULL );
00238   ASSERT( !( waveform->shift ), status, LALINSPIRALH_ENULL,  LALINSPIRALH_MSGENULL );
00239    
00240   
00241   params->ampOrder = 0;
00242   sprintf(message, "WARNING: Amp Order has been reset to %d", params->ampOrder);
00243   LALInfo(status, message);
00244   /* Compute some parameters*/
00245   LALInspiralInit(status->statusPtr, params, &paramsInit);
00246   CHECKSTATUSPTR(status);   
00247 
00248   if (paramsInit.nbins == 0)
00249     {
00250       DETATCHSTATUSPTR(status);
00251       RETURN (status);
00252       
00253     }
00254 
00255   /* Now we can allocate memory and vector for coherentGW structure*/     
00256   LALSCreateVector(status->statusPtr, &ff, paramsInit.nbins);
00257   CHECKSTATUSPTR(status);   
00258   LALSCreateVector(status->statusPtr, &a, 2*paramsInit.nbins);
00259   CHECKSTATUSPTR(status);   
00260   LALDCreateVector(status->statusPtr, &phi, paramsInit.nbins);
00261   CHECKSTATUSPTR(status);
00262   
00263   /* By default the waveform is empty */
00264   memset(ff->data, 0, paramsInit.nbins * sizeof(REAL4));
00265   memset(a->data, 0, 2 * paramsInit.nbins * sizeof(REAL4));
00266   memset(phi->data, 0, paramsInit.nbins * sizeof(REAL8));
00267 
00268   if( params->ampOrder )
00269   {
00270     LALSCreateVector(status->statusPtr, &h, 2*paramsInit.nbins);
00271     CHECKSTATUSPTR(status);   
00272     memset(h->data, 0, 2 * paramsInit.nbins * sizeof(REAL4));
00273   }
00274 
00275   count = 0;
00276 
00277 
00278   /* Call the engine function */
00279   LALInspiralWave2Engine(status->statusPtr, NULL, NULL, h, a, ff,
00280                              phi, &count, params, &paramsInit);
00281 
00282   BEGINFAIL(status)
00283   {
00284      LALSDestroyVector(status->statusPtr, &ff);
00285      CHECKSTATUSPTR(status);
00286      LALSDestroyVector(status->statusPtr, &a);
00287      CHECKSTATUSPTR(status);
00288      LALDDestroyVector(status->statusPtr, &phi);
00289      CHECKSTATUSPTR(status);
00290      if( params->ampOrder )
00291      {
00292        LALSDestroyVector(status->statusPtr, &h);
00293        CHECKSTATUSPTR(status);
00294      }
00295   }
00296   ENDFAIL(status);
00297   
00298   if ( fabs(phi->data[count-1]/2.)/LAL_PI < 2. ){
00299         sprintf(message, "The waveform has only %f cycles; we don't keep waveform with less than 2 cycles.", 
00300                (double)(fabs(phi->data[count-1]/2.)/LAL_PI) );
00301     XLALPrintError(message);
00302     LALWarning(status, message);
00303 
00304 
00305   }
00306   else
00307     {
00308       /*wrap the phase vector*/
00309       phiC =  phi->data[count-1] ;
00310       for (i=0; i<count; i++)
00311         {
00312           phi->data[i] =  phi->data[i] - phiC + ppnParams->phi;
00313         }
00314       /* Allocate the waveform structures. */
00315       if ( ( waveform->a = (REAL4TimeVectorSeries *)
00316              LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) {
00317         ABORT( status, LALINSPIRALH_EMEM,
00318                LALINSPIRALH_MSGEMEM );
00319       }
00320       if ( ( waveform->f = (REAL4TimeSeries *)
00321              LALCalloc(1, sizeof(REAL4TimeSeries) ) ) == NULL ) {
00322         LALFree( waveform->a ); waveform->a = NULL;
00323         ABORT( status, LALINSPIRALH_EMEM,
00324                LALINSPIRALH_MSGEMEM );
00325       }
00326       if ( ( waveform->phi = (REAL8TimeSeries *)
00327              LALCalloc(1, sizeof(REAL8TimeSeries) ) ) == NULL ) {
00328         LALFree( waveform->a ); waveform->a = NULL;
00329         LALFree( waveform->f ); waveform->f = NULL;
00330         ABORT( status, LALINSPIRALH_EMEM,
00331                LALINSPIRALH_MSGEMEM );
00332       }
00333       
00334       
00335       in.length = (UINT4)count;
00336       in.vectorLength = 2;
00337       LALSCreateVectorSequence( status->statusPtr, &( waveform->a->data ), &in );
00338       CHECKSTATUSPTR(status);      
00339       LALSCreateVector( status->statusPtr, &( waveform->f->data ), count);
00340       CHECKSTATUSPTR(status);      
00341       LALDCreateVector( status->statusPtr, &( waveform->phi->data ), count );
00342       CHECKSTATUSPTR(status);        
00343       
00344       memcpy(waveform->f->data->data , ff->data, count*(sizeof(REAL4)));
00345       memcpy(waveform->a->data->data , a->data, 2*count*(sizeof(REAL4)));
00346       memcpy(waveform->phi->data->data ,phi->data, count*(sizeof(REAL8)));
00347       
00348       
00349       waveform->a->deltaT = waveform->f->deltaT = waveform->phi->deltaT
00350         = ppnParams->deltaT;
00351       
00352       waveform->a->sampleUnits   = lalStrainUnit;
00353       waveform->f->sampleUnits   = lalHertzUnit;
00354       waveform->phi->sampleUnits = lalDimensionlessUnit;
00355       waveform->position = ppnParams->position;
00356       waveform->psi = ppnParams->psi;
00357 
00358       LALSnprintf( waveform->a->name, LALNameLength,   "T2 inspiral amplitude" );
00359       LALSnprintf( waveform->f->name, LALNameLength,   "T2 inspiral frequency" );
00360       LALSnprintf( waveform->phi->name, LALNameLength, "T2 inspiral phase" );
00361       
00362       
00363       /* --- fill some output ---*/
00364       ppnParams->tc     = (double)(count-1) / params->tSampling ;
00365       ppnParams->length = count;
00366       ppnParams->dfdt   = ((REAL4)(waveform->f->data->data[count-1] 
00367                         - waveform->f->data->data[count-2])) * ppnParams->deltaT;
00368       ppnParams->fStop  = params->fFinal;
00369       ppnParams->termCode        = GENERATEPPNINSPIRALH_EFSTOP;
00370       ppnParams->termDescription = GENERATEPPNINSPIRALH_MSGEFSTOP;
00371       
00372       ppnParams->fStart   = ppnParams->fStartIn;
00373 
00374       if( params->ampOrder )
00375       {  
00376         if ( ( waveform->h = (REAL4TimeVectorSeries *)
00377                LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) 
00378         {
00379           ABORT( status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM );
00380         }
00381         LALSCreateVectorSequence( status->statusPtr,
00382                                   &( waveform->h->data ), &in );
00383         CHECKSTATUSPTR(status);      
00384         memcpy(waveform->h->data->data , h->data, 2*count*(sizeof(REAL4)));
00385         waveform->h->deltaT = 1./params->tSampling;
00386         waveform->h->sampleUnits   = lalStrainUnit;
00387         LALSnprintf( waveform->h->name, LALNameLength,   "T2 inspiral polarizations" );
00388         LALSDestroyVector(status->statusPtr, &h);
00389         CHECKSTATUSPTR(status);
00390       }
00391     }/*end of coherentGW storage */
00392 
00393   
00394   /* --- free memory --- */
00395   LALSDestroyVector(status->statusPtr, &ff);
00396   CHECKSTATUSPTR(status);
00397   LALSDestroyVector(status->statusPtr, &a);
00398   CHECKSTATUSPTR(status);
00399   LALDDestroyVector(status->statusPtr, &phi);
00400   CHECKSTATUSPTR(status);
00401   
00402 
00403   DETATCHSTATUSPTR(status);
00404   RETURN(status);
00405 }
00406 
00407 
00408 NRCSID (LALINSPIRALWAVE2ENGINEC, "$Id: LALInspiralWave2.c,v 1.25 2008/03/06 13:04:36 sathya Exp $");
00409 
00410 /* 'Engine' function upon which all the other functions invoke
00411     Craig Robinson 04/05 */
00412 
00413 /* <lalVerbatim file="LALInspiralWave2EngineCP"> */
00414 
00415 static void 
00416 LALInspiralWave2Engine(
00417                 LALStatus        *status,
00418                 REAL4Vector      *output1,
00419                 REAL4Vector      *output2,
00420                 REAL4Vector      *h,
00421                 REAL4Vector      *a,
00422                 REAL4Vector      *ff,
00423                 REAL8Vector      *phi,
00424                 UINT4            *countback,
00425                 InspiralTemplate *params,
00426                 InspiralInit     *paramsInit
00427                 )
00428 { /* </lalVerbatim> */
00429 
00430   REAL8 amp, eta, dt, fs, fu, fHigh, phase0, phase1, tC;
00431   REAL8 phase, v, totalMass, fLso, freq, fOld;
00432   INT4 i, startShift, count;
00433   DFindRootIn rootIn;
00434   InspiralToffInput toffIn;
00435   void *funcParams;
00436   expnCoeffs ak;
00437   expnFunc func;
00438 
00439   /* Variables only used in injection case.. */
00440   REAL8 omega;
00441   REAL8 unitHz = 0;
00442   REAL8 f2a = 0;
00443   REAL8 mu = 0;
00444   REAL8 mTot = 0;
00445   REAL8 cosI = 0;/* cosine of system inclination */
00446   REAL8 etab =0;
00447   REAL8 fFac = 0; /* SI normalization for f and t */
00448   REAL8 f2aFac = 0;/* factor multiplying f in amplitude function */
00449   REAL8 apFac = 0, acFac = 0;/* extra factor in plus and cross amplitudes */
00450                                                                                                                              
00451                                                                                                                              
00452   INITSTATUS(status, "LALInspiralWave2Engine", LALINSPIRALWAVE2ENGINEC);
00453   ATTATCHSTATUSPTR(status);
00454 
00455   ak   = paramsInit->ak;
00456   func = paramsInit->func;
00457   
00458   if (output2 || a)
00459          params->nStartPad = 0;   /* that value must be zero for template generation */
00460   dt = 1.0/(params->tSampling);   /* sampling interval */
00461   fs = params->fLower;            /* lower frequency cutoff */
00462   fu = params->fCutoff;           /* upper frequency cutoff */
00463   startShift = params->nStartPad; /* number of bins to pad at the beginning */
00464   phase0 = params->startPhase;    /* initial phasea */
00465   phase1 = phase0 + LAL_PI_2;
00466                                                                                                                              
00467   rootIn.function = func.timing2; /* function to solve for v, given t:*/
00468 
00469   if (a || h)           /* Only used in injection case */
00470   {
00471     mTot   =  params->mass1 + params->mass2;
00472     etab   =  params->mass1 * params->mass2;
00473     etab  /= mTot;
00474     etab  /= mTot;
00475     unitHz = (mTot) *LAL_MTSUN_SI*(REAL8)LAL_PI;
00476     cosI   = cos( params->inclination );
00477     mu     = etab * mTot;
00478     fFac   = 1.0 / ( 4.0*LAL_TWOPI*LAL_MTSUN_SI*mTot );
00479     f2aFac = LAL_PI*LAL_MTSUN_SI*mTot*fFac;
00480     apFac  = acFac = -2.0 * mu * LAL_MRSUN_SI/params->distance;
00481     apFac *= 1.0 + cosI*cosI;
00482     acFac *= 2.0 * cosI;
00483   }
00484 
00485 /* Calculate the three unknown paramaters in (m1,m2,M,eta,mu) from the two
00486    which are given.  */
00487                                                                                                                              
00488   LALInspiralParameterCalc(status->statusPtr, params);
00489   CHECKSTATUSPTR(status);
00490                                                                                                                              
00491   ASSERT(params->totalMass > 0., status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00492   ASSERT(params->eta >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00493   ASSERT(params->eta <=0.25, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00494                                                                                                                              
00495   eta = params->eta;
00496   totalMass = params->totalMass*LAL_MTSUN_SI; /* solar mass in seconds */
00497                                                                                                                              
00498   toffIn.tN = ak.tvaN;
00499   toffIn.t2 = ak.tva2;
00500   toffIn.t3 = ak.tva3;
00501   toffIn.t4 = ak.tva4;
00502   toffIn.t5 = ak.tva5;
00503   toffIn.t6 = ak.tva6;
00504   toffIn.t7 = ak.tva7;
00505   toffIn.tl6 = ak.tvl6;
00506   toffIn.piM = ak.totalmass * LAL_PI;
00507                                                                                                                              
00508   /* Determine the total chirp-time tC: the total chirp time is
00509      timing2(v0;tC,t) with t=tc=0*/
00510                                                                                                                              
00511   toffIn.t = 0.;
00512   toffIn.tc = 0.;
00513   funcParams = (void *) &toffIn;
00514   func.timing2(status->statusPtr, &tC, fs, funcParams);
00515   CHECKSTATUSPTR(status);
00516   /* Reset chirp time in toffIn structure */
00517   toffIn.tc = -tC;
00518                                                                                                                              
00519   /* Determine the initial phase: it is phasing2(v0) with ak.phiC=0 */
00520   v = pow(fs * LAL_PI * totalMass, oneby3);
00521   ak.phiC = 0.0;
00522   func.phasing2(status->statusPtr, &phase, v, &ak);
00523   CHECKSTATUSPTR(status);
00524   ak.phiC = -phase;
00525                                                                                                                              
00526   /*
00527      If flso is less than the user inputted upper frequency cutoff fu,
00528   */
00529                                                                                                                              
00530   fLso = ak.fn;
00531   if (fu)
00532     fHigh = (fu < fLso) ? fu : fLso;
00533   else
00534     fHigh = fLso;
00535                                                                                                                              
00536   /* Is the sampling rate large enough? */
00537                                                                                                                              
00538   ASSERT(fHigh < 0.5/dt, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00539   ASSERT(fHigh > params->fLower, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00540                                                                                                                              
00541   rootIn.xmax = 1.1*fu;
00542   rootIn.xacc = 1.0e-8;
00543   rootIn.xmin = 0.999999*fs;
00544                                                                                                                              
00545   i = startShift;
00546                                                                                                                              
00547   /* Now cast the input structure to argument 4 of BisectionFindRoot so that it
00548      of type void * rather than InspiralToffInput  */
00549                                                                                                                              
00550   funcParams = (void *) &toffIn;
00551                                                                                                                              
00552   toffIn.t = 0.0;
00553   freq = fs;
00554   count=0;
00555   do
00556     {
00557     /*
00558     Check we're not writing past the end of the vector
00559     */
00560     if ((output1 && ((UINT4)i >= output1->length)) || (ff && ((UINT4)count >= ff->length)))
00561     {
00562         ABORT(status, LALINSPIRALH_EVECTOR, LALINSPIRALH_MSGEVECTOR);
00563     }
00564                                                                                                                              
00565     fOld = freq;
00566     v = pow(freq*toffIn.piM, oneby3);
00567     func.phasing2(status->statusPtr, &phase, v, &ak); /* phase at given v */
00568     CHECKSTATUSPTR(status);
00569     amp = params->signalAmplitude*v*v;
00570 
00571     if (output1)
00572     {
00573       output1->data[i]=(REAL4)(amp*cos(phase+phase0));
00574       if (output2)
00575         output2->data[i]=(REAL4)(amp*cos(phase+phase1));
00576     }
00577     else
00578     {
00579       int ice, ico;
00580       ice = 2*count;
00581       ico = ice + 1;
00582       omega = v*v*v;
00583                                                                                                                              
00584       ff->data[count]= (REAL4)(omega/unitHz);
00585       f2a = pow (f2aFac * omega, 2./3.);
00586       a->data[ice]          = (REAL4)(4.*apFac * f2a);
00587       a->data[ico]        = (REAL4)(4.*acFac * f2a);
00588       phi->data[count]          = (REAL8)(phase);
00589 
00590       if(h)
00591       {
00592         h->data[ice] = LALInspiralHPlusPolarization( phase, v, params );
00593         h->data[ico] = LALInspiralHCrossPolarization( phase, v, params );
00594       }
00595     }
00596     i++;
00597     ++count;
00598     toffIn.t=count*dt;
00599     /*
00600        Determine the frequency at the current time by solving timing2(v;tC,t)=0
00601     */
00602     LALDBisectionFindRoot(status->statusPtr, &freq, &rootIn, funcParams);
00603     CHECKSTATUSPTR(status);
00604     } while (freq < fHigh && freq > fOld && toffIn.t < -tC);
00605   params->fFinal = fOld;
00606   if (output1 && !(output2))   params->tC = toffIn.t;
00607 
00608   *countback = count;
00609 
00610   DETATCHSTATUSPTR(status);
00611   RETURN(status);
00612                                                                                                                              
00613 }

Generated on Sun Sep 7 03:06:56 2008 for LAL by  doxygen 1.5.2