LALInspiralWave1.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Stas Babak, David Churches, Alexander Dietz, 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="LALInspiralWave1CV">
00021 Author: Sathyaprakash, B. S.
00022 $Id: LALInspiralWave1.c,v 1.27 2008/03/06 13:04:18 sathya Exp $
00023 </lalVerbatim>  */
00024 
00025 /*  <lalLaTeX>
00026 
00027 \subsection{Module \texttt{LALInspiralWave1.c} and \texttt{LALInspiralWave1Templates.c}}
00028 
00029 The code \texttt{LALInspiralWave1} generates an time-domain inspiral waveform corresponding to the 
00030 \texttt{approximant} \texttt{TaylorT1} and \texttt{PadeT1} as outlined in the
00031 documentation for the function \texttt{LALInspiralWave}. 
00032 
00033 \subsubsection*{Prototypes}
00034 \vspace{0.1in}
00035 \input{LALInspiralWave1CP}
00036 \index{\verb&LALInspiralWave1()&}
00037 \begin{itemize}
00038 \item {\tt signal:} Output containing the inspiral waveform.
00039 \item {\tt params:} Input containing binary chirp parameters.
00040 \end{itemize}
00041 
00042 \input{LALInspiralWave1TemplatesCP}
00043 \index{\verb&LALInspiralWave1Templates()&}
00044 \begin{itemize}
00045 \item {\tt signal1:} Output containing the 0-phase inspiral waveform.
00046 \item {\tt signal2:} Output containing the $\pi/2$-phase inspiral waveform.
00047 \item {\tt params:} Input containing binary chirp parameters.
00048 \end{itemize}
00049 
00050 \subsubsection*{Description}
00051 
00052 \texttt{LALInspiralWave1} is called if the user has specified the 
00053 \texttt{enum} \texttt{approximant} to be
00054 either \texttt{TaylorT1} or \texttt{PadeT1}.
00055 {\tt LALInspiralWave1Templates} is exactly the same as \texttt{LALInspiralWave1,} except that
00056 it generates two templates one for which the starting phase is 
00057 \texttt{params.startPhase} and the other for which the phase is
00058 \texttt{params.startPhase + $\pi/2$}.
00059 
00060 
00061 \subsubsection*{Algorithm}
00062 This code uses a fourth-order Runge-Kutta algorithm to solve the ODEs 
00063 in Equation (\ref{eq:ode2}).
00064 
00065 \subsubsection*{Uses}
00066 
00067 \texttt{LALInspiralSetup}\\
00068 \texttt{LALInspiralChooseModel}\\
00069 \texttt{LALInspiralVelocity}\\
00070 \texttt{LALInspiralPhasing1}\\
00071 \texttt{LALInspiralDerivatives}\\
00072 \texttt{LALRungeKutta4}.
00073  
00074 
00075 \subsubsection*{Notes}
00076 
00077 \vfill{\footnotesize\input{LALInspiralWave1CV}}
00078 
00079 </lalLaTeX>  */
00080 
00081 /* 
00082    Interface routine needed to generate time-domain T- or a P-approximant
00083    waveforms by solving the ODEs using a 4th order Runge-Kutta; April 5, 00.
00084 */
00085 #include <lal/LALInspiral.h>
00086 #include <lal/LALStdlib.h>
00087 #include <lal/Units.h>
00088 #include <lal/SeqFactories.h>
00089 
00090 static void
00091 LALInspiralWave1Engine(
00092    LALStatus        *status,
00093    REAL4Vector      *signal1,
00094    REAL4Vector      *signal2,
00095    REAL4Vector      *h,
00096    REAL4Vector      *a,
00097    REAL4Vector      *ff,
00098    REAL8Vector      *phi,
00099    INT4             *countback,
00100    InspiralTemplate *params
00101    );
00102 
00103 
00104 NRCSID (LALINSPIRALWAVE1C, "$Id: LALInspiralWave1.c,v 1.27 2008/03/06 13:04:18 sathya Exp $");
00105 
00106 /*  <lalVerbatim file="LALInspiralWave1CP"> */
00107 void 
00108 LALInspiralWave1(
00109    LALStatus        *status,
00110    REAL4Vector      *signal,
00111    InspiralTemplate *params
00112    )
00113  { /* </lalVerbatim>  */
00114 
00115    INT4 count;
00116    
00117    INITSTATUS(status, "LALInspiralWave1", LALINSPIRALWAVE1C);
00118    ATTATCHSTATUSPTR(status);
00119 
00120    ASSERT(signal, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00121    ASSERT(signal->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00122 
00123 
00124    /* Initially the waveform is empty*/
00125    memset(signal->data, 0, signal->length*sizeof(REAL4));
00126 
00127    /*Call the engine function*/
00128    LALInspiralWave1Engine(status->statusPtr, signal, NULL, NULL, NULL, NULL, NULL, &count, params);
00129    CHECKSTATUSPTR(status);
00130    
00131    DETATCHSTATUSPTR(status);
00132    RETURN (status);
00133 
00134 }
00135 
00136 
00137 
00138 /* 
00139    Interface routine needed to generate time-domain T- or a P-approximant
00140    waveforms by solving the ODEs using a 4th order Runge-Kutta; April 5, 00.
00141 */
00142 
00143 NRCSID (LALINSPIRALWAVE1TEMPLATESC, "$Id: LALInspiralWave1.c,v 1.27 2008/03/06 13:04:18 sathya Exp $");
00144 
00145 /*  <lalVerbatim file="LALInspiralWave1TemplatesCP"> */
00146 void 
00147 LALInspiralWave1Templates(
00148    LALStatus        *status,
00149    REAL4Vector      *signal1,
00150    REAL4Vector      *signal2,
00151    InspiralTemplate *params
00152    )
00153  { /* </lalVerbatim>  */
00154 
00155    INT4 count;
00156    
00157    INITSTATUS(status, "LALInspiralWave1Templates", LALINSPIRALWAVE1TEMPLATESC);
00158    ATTATCHSTATUSPTR(status);
00159 
00160    ASSERT(signal1, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00161    ASSERT(signal2, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00162    ASSERT(signal1->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00163    ASSERT(signal2->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00164 
00165    /* Initially the waveforms are empty */
00166    memset(signal1->data, 0, signal1->length * sizeof(REAL4));
00167    memset(signal2->data, 0, signal2->length * sizeof(REAL4));
00168 
00169    /* Call the engine function */
00170    LALInspiralWave1Engine(status->statusPtr, signal1, signal2, NULL, NULL, NULL, NULL, &count, params);
00171    CHECKSTATUSPTR(status);   
00172 
00173    DETATCHSTATUSPTR(status);
00174    RETURN (status);
00175 
00176 }
00177 
00178 /* 
00179    Interface routine needed to generate time-domain T- or a P-approximant
00180    waveforms for injection packages T.Cokelaer sept 2003
00181 */
00182 
00183 NRCSID (LALINSPIRALWAVE1FORINJECTIONC, "$Id: LALInspiralWave1.c,v 1.27 2008/03/06 13:04:18 sathya Exp $");
00184 
00185 /*  <lalVerbatim file="LALInspiralWave1ForInjectionCP"> */
00186 void 
00187 LALInspiralWave1ForInjection(
00188                              LALStatus        *status,
00189                              CoherentGW       *waveform,
00190                              InspiralTemplate *params,
00191                              PPNParamStruc  *ppnParams                       
00192                              )
00193 { /* </lalVerbatim>  */
00194  
00195   INT4        count, i;
00196   REAL8       p, phiC;  
00197   
00198   REAL4Vector *a   = NULL;      /* pointers to generated amplitude  data */
00199   REAL4Vector *h   = NULL;      /* pointers to generated polarizations */
00200   REAL4Vector *ff  = NULL;      /* pointers to generated  frequency data */
00201   REAL8Vector *phi = NULL;      /* pointer to generated phase data */
00202 
00203   
00204   CreateVectorSequenceIn in;
00205   
00206   CHAR message[256];
00207   
00208   InspiralInit paramsInit; 
00209 
00210 
00211   INITSTATUS(status, "LALInspiralWave1ForInjection", LALINSPIRALWAVE1TEMPLATESC);
00212   ATTATCHSTATUSPTR(status);
00213   
00214   /* Make sure parameter and waveform structures exist. */
00215   ASSERT( params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00216   ASSERT(waveform, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);  
00217   ASSERT( !( waveform->a ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00218   ASSERT( !( waveform->h ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00219   ASSERT( !( waveform->f ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00220   ASSERT( !( waveform->phi ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00221   
00222   params->ampOrder = 0;
00223   sprintf(message, "WARNING: Amp Order has been reset to %d", params->ampOrder);
00224   LALInfo(status, message);
00225   /* Compute some parameters*/
00226   LALInspiralInit(status->statusPtr, params, &paramsInit);
00227   CHECKSTATUSPTR(status);   
00228   
00229   if (paramsInit.nbins == 0){
00230       DETATCHSTATUSPTR(status);
00231       RETURN (status);
00232   }
00233 
00234   /* Now we can allocate memory and vector for coherentGW structure*/     
00235   LALSCreateVector(status->statusPtr, &ff, paramsInit.nbins);
00236   CHECKSTATUSPTR(status);   
00237   LALSCreateVector(status->statusPtr, &a, 2*paramsInit.nbins);
00238   CHECKSTATUSPTR(status);   
00239   LALDCreateVector(status->statusPtr, &phi, paramsInit.nbins);
00240   CHECKSTATUSPTR(status);
00241   
00242   /* By default the waveform is empty */
00243   memset(ff->data, 0, paramsInit.nbins * sizeof(REAL4));
00244   memset(a->data, 0, 2 * paramsInit.nbins * sizeof(REAL4));
00245   memset(phi->data, 0, paramsInit.nbins * sizeof(REAL8));
00246 
00247 
00248   if( params->ampOrder )
00249   {
00250     LALSCreateVector(status->statusPtr, &h, 2*paramsInit.nbins);
00251     CHECKSTATUSPTR(status);   
00252     memset(h->data, 0, 2 * paramsInit.nbins * sizeof(REAL4));
00253   }
00254 
00255   count = 0;
00256 
00257   /* Call the engine function */
00258   LALInspiralWave1Engine(status->statusPtr, NULL, NULL, h, a, ff, 
00259                              phi, &count, params);
00260   BEGINFAIL( status )
00261   {
00262      LALSDestroyVector(status->statusPtr, &ff);
00263      CHECKSTATUSPTR(status);
00264      LALSDestroyVector(status->statusPtr, &a);
00265      CHECKSTATUSPTR(status);
00266      LALDDestroyVector(status->statusPtr, &phi);
00267      CHECKSTATUSPTR(status);
00268      if( params->ampOrder )
00269      {
00270        LALSDestroyVector(status->statusPtr, &h);
00271        CHECKSTATUSPTR(status);
00272      }
00273   }
00274   ENDFAIL( status );
00275      
00276   p = phi->data[count-1];
00277   
00278   params->fFinal = ff->data[count-1];
00279   sprintf(message, "cycles = %f", fabs(p)/(double)LAL_TWOPI);
00280   LALInfo(status, message);
00281 
00282   if ( (INT4)(p/LAL_TWOPI) < 2 ){
00283     sprintf(message, "The waveform has only %f cycles; we don't keep waveform with less than 2 cycles.", 
00284                fabs(p)/(double)LAL_TWOPI );
00285     XLALPrintError(message);
00286     LALWarning(status, message);
00287   }
00288   else
00289   {
00290 
00291       /*wrap the phase vector*/
00292       phiC =  phi->data[count-1] ;
00293       for (i = 0; i < count; i++)
00294         {
00295           phi->data[i] =  phi->data[i] - phiC + ppnParams->phi;
00296         }
00297       
00298       /* Allocate the waveform structures. */
00299       if ( ( waveform->a = (REAL4TimeVectorSeries *)
00300              LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) {
00301         ABORT( status, LALINSPIRALH_EMEM,
00302                LALINSPIRALH_MSGEMEM );
00303       }
00304       if ( ( waveform->f = (REAL4TimeSeries *)
00305              LALCalloc(1, sizeof(REAL4TimeSeries) ) ) == NULL ) {
00306         LALFree( waveform->a ); waveform->a = NULL;
00307         ABORT( status, LALINSPIRALH_EMEM,
00308                LALINSPIRALH_MSGEMEM );
00309       }
00310       if ( ( waveform->phi = (REAL8TimeSeries *)
00311              LALCalloc(1, sizeof(REAL8TimeSeries) ) ) == NULL ) {
00312         LALFree( waveform->a ); waveform->a = NULL;
00313         LALFree( waveform->f ); waveform->f = NULL;
00314         ABORT( status, LALINSPIRALH_EMEM,
00315                LALINSPIRALH_MSGEMEM );
00316       }
00317       
00318       in.length = (UINT4)(count);
00319       in.vectorLength = 2;
00320       
00321       LALSCreateVectorSequence( status->statusPtr, &( waveform->a->data ), &in );
00322       CHECKSTATUSPTR(status);      
00323       
00324       LALSCreateVector( status->statusPtr, &( waveform->f->data ), count);
00325       CHECKSTATUSPTR(status);      
00326       
00327       LALDCreateVector( status->statusPtr, &( waveform->phi->data ), count );
00328       CHECKSTATUSPTR(status);        
00329       
00330      
00331       memcpy(waveform->f->data->data , ff->data, count*(sizeof(REAL4)));
00332       memcpy(waveform->a->data->data , a->data, 2*count*(sizeof(REAL4)));
00333       memcpy(waveform->phi->data->data ,phi->data, count*(sizeof(REAL8)));
00334       
00335       waveform->a->deltaT = waveform->f->deltaT = waveform->phi->deltaT
00336         = ppnParams->deltaT;
00337       
00338       waveform->a->sampleUnits    = lalStrainUnit;
00339       waveform->f->sampleUnits    = lalHertzUnit;
00340       waveform->phi->sampleUnits  = lalDimensionlessUnit;
00341       waveform->position = ppnParams->position;
00342       waveform->psi = ppnParams->psi;
00343 
00344       LALSnprintf( waveform->a->name, LALNameLength,   "T1 inspiral amplitude" );
00345       LALSnprintf( waveform->f->name, LALNameLength,   "T1 inspiral frequency" );
00346       LALSnprintf( waveform->phi->name, LALNameLength, "T1 inspiral phase" );
00347       
00348       /* --- fill some output ---*/
00349       ppnParams->tc     = (double)(count-1) / params->tSampling ;
00350       ppnParams->length = count;
00351       ppnParams->dfdt   = ((REAL4)(waveform->f->data->data[count-1] 
00352                         - waveform->f->data->data[count-2])) * ppnParams->deltaT;
00353       ppnParams->fStop  = params->fFinal;
00354       ppnParams->termCode        = GENERATEPPNINSPIRALH_EFSTOP;
00355       ppnParams->termDescription = GENERATEPPNINSPIRALH_MSGEFSTOP;
00356       
00357       ppnParams->fStart   = ppnParams->fStartIn;
00358 
00359       if ( params->ampOrder )
00360       {
00361         if ( ( waveform->h = (REAL4TimeVectorSeries *)
00362                LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) 
00363         {
00364            ABORT( status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM );
00365         }
00366         LALSCreateVectorSequence( status->statusPtr, &( waveform->h->data ), &in );
00367         CHECKSTATUSPTR(status);
00368         memcpy(waveform->h->data->data , h->data, 2*count*(sizeof(REAL4)));
00369         waveform->h->deltaT = ppnParams->deltaT;
00370         waveform->h->sampleUnits    = lalStrainUnit;
00371         LALSnprintf( waveform->h->name, LALNameLength,   "T1 inspiral polarizations" );
00372         LALSDestroyVector(status->statusPtr, &h);
00373         CHECKSTATUSPTR(status);
00374       }
00375   }
00376 
00377   /* --- free memory --- */
00378   LALSDestroyVector(status->statusPtr, &ff);
00379   CHECKSTATUSPTR(status);
00380   LALSDestroyVector(status->statusPtr, &a);
00381   CHECKSTATUSPTR(status);
00382   LALDDestroyVector(status->statusPtr, &phi);
00383   CHECKSTATUSPTR(status);
00384   
00385   DETATCHSTATUSPTR(status);
00386   RETURN (status);
00387 }
00388 
00389 /*
00390  *  Engine function for use by other LALInspiralWave1* functions
00391  *  Craig Robinson April 2005
00392  */
00393 
00394 NRCSID (LALINSPIRALWAVE1ENGINEC, "$Id: LALInspiralWave1.c,v 1.27 2008/03/06 13:04:18 sathya Exp $");
00395 
00396 void
00397 LALInspiralWave1Engine(
00398                 LALStatus        *status,
00399                 REAL4Vector      *signal1,
00400                 REAL4Vector      *signal2,
00401                 REAL4Vector      *h,
00402                 REAL4Vector      *a,
00403                 REAL4Vector      *ff,
00404                 REAL8Vector      *phi,
00405                 INT4             *countback,
00406                 InspiralTemplate *params)
00407 {
00408    INT4 n=2, count;
00409    REAL8 omega;
00410    REAL8 amp, m, dt, t, v, p, h1, h2, f, fu, fHigh, piM;
00411    REAL8Vector dummy, values, dvalues, valuesNew, yt, dym, dyt;
00412    TofVIn in1;
00413    InspiralPhaseIn in2;
00414    InspiralDerivativesIn in3;
00415    rk4In in4;
00416    rk4GSLIntegrator *integrator;
00417    void *funcParams;
00418    expnCoeffs ak;
00419    expnFunc func;
00420 
00421      REAL8 mTot = 0;
00422      REAL8 unitHz = 0;
00423      REAL8 f2a = 0;
00424      REAL8 mu = 0; 
00425      REAL8 cosI = 0;/* cosine of system inclination */
00426      REAL8 etab = 0;
00427      REAL8 fFac = 0; /* SI normalization for f and t */
00428      REAL8 f2aFac = 0;/* factor multiplying f in amplitude function */
00429      REAL8 apFac = 0, acFac = 0;/* extra factor in plus and cross amplitudes */
00430   
00431      
00432    INITSTATUS(status, "LALInspiralWave1Engine", LALINSPIRALWAVE1ENGINEC);
00433    ATTATCHSTATUSPTR(status);
00434 
00435    ASSERT (params,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00436    ASSERT (params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00437    ASSERT (params->nEndPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00438    ASSERT (params->fLower > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00439    ASSERT (params->tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00440 
00441    LALInspiralSetup (status->statusPtr, &ak, params);
00442    CHECKSTATUSPTR(status);
00443    LALInspiralChooseModel(status->statusPtr, &func, &ak, params);
00444    CHECKSTATUSPTR(status);
00445 
00446    values.length = dvalues.length = valuesNew.length =
00447    yt.length = dym.length = dyt.length = n;
00448    dummy.length = n * 6;
00449    if (!(dummy.data = (REAL8 * ) LALMalloc(sizeof(REAL8) * n * 6))) {
00450       ABORT(status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM);
00451    }
00452 
00453    values.data = &dummy.data[0];
00454    dvalues.data = &dummy.data[n];
00455    valuesNew.data = &dummy.data[2*n];
00456    yt.data = &dummy.data[3*n];
00457    dym.data = &dummy.data[4*n];
00458    dyt.data = &dummy.data[5*n];
00459 
00460    m = ak.totalmass;
00461    dt = 1./params->tSampling;
00462 
00463    if (a || h)
00464    {
00465       mTot   = params->mass1 + params->mass2;
00466       etab   = params->mass1 * params->mass2;
00467       etab  /= mTot;
00468       etab  /= mTot;
00469       unitHz = mTot *LAL_MTSUN_SI*(REAL8)LAL_PI;
00470       cosI   = cos( params->inclination );
00471       mu     = etab * mTot;  
00472       fFac   = 1.0 / ( 4.0*LAL_TWOPI*LAL_MTSUN_SI*mTot );
00473       f2aFac = LAL_PI*LAL_MTSUN_SI*mTot*fFac;   
00474       apFac  = acFac = -2.0 * mu * LAL_MRSUN_SI/params->distance;
00475       apFac *= 1.0 + cosI*cosI;
00476       acFac *= 2.0*cosI;
00477       params->nStartPad = 0;
00478    }
00479    
00480    ASSERT(ak.totalmass > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00481 
00482    t = 0.0;
00483    in1.t = t;
00484    in1.t0=ak.t0;
00485    in1.v0 = ak.v0;
00486    in1.vlso = ak.vlso;
00487    in1.totalmass = ak.totalmass;
00488    in1.dEnergy = func.dEnergy;
00489    in1.flux = func.flux;
00490    in1.coeffs = &ak;
00491 
00492    in2.v0 = ak.v0;
00493    in2.phi0 = params->startPhase;
00494    in2.dEnergy = func.dEnergy;
00495    in2.flux = func.flux;
00496    in2.coeffs = &ak;
00497 
00498    in3.totalmass = ak.totalmass;
00499    in3.dEnergy = func.dEnergy;
00500    in3.flux = func.flux;
00501    in3.coeffs = &ak;
00502    funcParams = (void *) &in3;
00503 
00504    LALInspiralVelocity(status->statusPtr, &v, &in1);
00505    CHECKSTATUSPTR(status);
00506 
00507    piM = LAL_PI * m;
00508    f = (v*v*v)/piM;
00509 
00510    fu = params->fCutoff;
00511    if (fu) 
00512       fHigh = (fu < ak.flso) ? fu : ak.flso; 
00513    else 
00514       fHigh = ak.flso;
00515    f = (v*v*v)/(LAL_PI*m);
00516 
00517 /* 
00518     Check that the highest frequency is less than half 
00519     the sampling frequency - the Nyquist theorem 
00520 */
00521 
00522    ASSERT(fHigh < 0.5/dt, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00523    ASSERT(fHigh > params->fLower, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00524 
00525    
00526    LALInspiralPhasing1(status->statusPtr, &p, v, &in2);
00527    CHECKSTATUSPTR(status);
00528 
00529 
00530    *(values.data) = v; 
00531    *(values.data+1) = p;
00532 
00533    in4.function = LALInspiralDerivatives;
00534    in4.x = t;
00535    in4.y = &values;
00536    in4.h = dt;
00537    in4.n = n;
00538    in4.yt = &yt;
00539    in4.dym = &dym;
00540    in4.dyt = &dyt;
00541    
00542    xlalErrno = 0;
00543    /* Initialize GSL integrator */
00544    if (!(integrator = XLALRungeKutta4Init(n, &in4)))
00545    {
00546      INT4 errNum = XLALClearErrno();
00547      LALFree(dummy.data);
00548 
00549      if (errNum == XLAL_ENOMEM)
00550        ABORT(status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM);
00551      else
00552        ABORTXLAL( status );
00553    }
00554 
00555    count = 0;
00556    if (signal2) {
00557    params->nStartPad = 0;} /* for template generation, that value must be zero*/
00558    
00559    else if (signal1) {
00560      count = params->nStartPad;
00561    }
00562 
00563    t = 0.0;
00564    do {
00565       /* Free up memory and abort if writing beyond the end of vector*/
00566       if ((signal1 && (UINT4)count >= signal1->length) || (ff && (UINT4)count >= ff->length))
00567       {
00568           XLALRungeKutta4Free( integrator );
00569           LALFree(dummy.data);
00570           ABORT(status, LALINSPIRALH_EVECTOR, LALINSPIRALH_MSGEVECTOR);
00571       }
00572 
00573       /* Non-injection case */
00574       if (signal1)
00575       {
00576          amp = params->signalAmplitude * v*v;
00577          h1 = amp * cos(p);
00578          *(signal1->data + count) = (REAL4) h1;
00579          if (signal2)
00580          {
00581             h2 = amp * cos(p+LAL_PI_2);
00582             *(signal2->data + count) = (REAL4) h2;
00583          }
00584       } 
00585       /* Injection case */
00586       else if (a)
00587       {
00588           int ice, ico;
00589           ice = 2*count;
00590           ico = ice + 1;
00591           omega = v*v*v;
00592     
00593           ff->data[count]       = (REAL4)(omega/unitHz);
00594           f2a                   = pow (f2aFac * omega, 2./3.);
00595           a->data[ice]      = (REAL4)(4.*apFac * f2a);
00596           a->data[ico]    = (REAL4)(4.*acFac * f2a);
00597           phi->data[count]      = (REAL8)(p);
00598 
00599           if (h)
00600           {
00601             h->data[ice] = LALInspiralHPlusPolarization( p, v, params );
00602             h->data[ico] = LALInspiralHCrossPolarization( p, v, params );
00603           }
00604 
00605       }
00606     
00607       LALInspiralDerivatives(&values, &dvalues, funcParams);
00608       CHECKSTATUSPTR(status);
00609       
00610       in4.dydx = &dvalues;
00611       in4.x=t;
00612       
00613       LALRungeKutta4(status->statusPtr, &valuesNew, integrator, funcParams);
00614       CHECKSTATUSPTR(status);
00615       
00616       *(values.data) = v = *(valuesNew.data);
00617       *(values.data+1) = p = *(valuesNew.data+1);
00618       
00619       t = (++count-params->nStartPad) * dt;
00620       f = v*v*v/piM;
00621       
00622    } while (t < ak.tn && f<fHigh);
00623    
00624    params->vFinal = p;
00625    params->fFinal = f;
00626    params->tC = t;
00627 
00628    *countback = count;
00629 
00630    XLALRungeKutta4Free( integrator );
00631    LALFree(dummy.data);
00632 
00633    DETATCHSTATUSPTR(status);
00634    RETURN (status);
00635 
00636 }                      

Generated on Sat Aug 30 03:12:49 2008 for LAL by  doxygen 1.5.2