LALInspiralEccentricity.c

Go to the documentation of this file.
00001 /**
00002 *  Copyright (C) 2007 
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="LALInspiralEccentricityCV">
00021 Author: Devanka Pathak and Thomas Cokelaer
00022 $Id: LALInspiralEccentricity.c,v 1.8 2008/07/07 17:22:23 thomas Exp $
00023 </lalVerbatim>  */
00024 
00025 /*  <lalLaTeX>
00026 
00027 \subsection{Module \texttt{LALInspiralEccentricity.c} and \texttt{LALInspiralEccentricityTemplates.c}}
00028 
00029 The code \texttt{LALInspiralEccentricity} generates a time-domain inspiral waveform corresponding to the 
00030 \texttt{approximant} \texttt{Eccentricity} as outlined PRD 60 for the Newtonian case. 
00031 
00032 \subsubsection*{Prototypes}
00033 \vspace{0.1in}
00034 \input{LALInspiralEccentricityCP}
00035 \index{\verb&LALInspiralEccentricity()&}
00036 \begin{itemize}
00037 \item {\tt signal:} Output containing the inspiral waveform.
00038 \item {\tt params:} Input containing binary chirp parameters and eccentricity.
00039 \end{itemize}
00040 
00041 \input{LALInspiralEccentricityTemplatesCP}
00042 \index{\verb&LALInspiralEccentricityTemplates()&}
00043 \begin{itemize}
00044 \item {\tt signal1:} Output containing the 0-phase inspiral waveform.
00045 \item {\tt signal2:} Output containing the $\pi/2$-phase inspiral waveform.
00046 \item {\tt params:} Input containing binary chirp parameters.
00047 \end{itemize}
00048 
00049 \subsubsection*{Description}
00050 
00051 \texttt{LALInspiralEccentricity} is called if the user has specified the 
00052 \texttt{enum} \texttt{approximant} to be
00053 either \texttt{TaylorT1} or \texttt{PadeT1}.
00054 {\tt LALInspiralEccentricityTemplates} is exactly the same as \texttt{LALInspiralEccentricity,} except that
00055 it generates two templates one for which the starting phase is 
00056 \texttt{params.startPhase} and the other for which the phase is
00057 \texttt{params.startPhase + $\pi/2$}.
00058 
00059 
00060 \subsubsection*{Algorithm}
00061 This code uses a fourth-order Runge-Kutta algorithm to solve the ODEs 
00062 in Equation (\ref{eq:ode2}).
00063 
00064 \subsubsection*{Uses}
00065 
00066 \texttt{LALInspiralSetup}\\
00067 \texttt{LALInspiralChooseModel}\\
00068 \texttt{LALInspiralVelocity}\\
00069 \texttt{LALInspiralPhasing1}\\
00070 \texttt{LALInspiralDerivatives}\\
00071 \texttt{LALRungeKutta4}.
00072  
00073 
00074 \subsubsection*{Notes}
00075 
00076 \vfill{\footnotesize\input{LALInspiralEccentricityCV}}
00077 
00078 </lalLaTeX>  */
00079 
00080 /* 
00081    Interface routine needed to generate time-domain T- or a P-approximant
00082    waveforms by solving the ODEs using a 4th order Runge-Kutta; April 5, 00.
00083 */
00084 #include <lal/LALInspiral.h>
00085 #include <lal/LALStdlib.h>
00086 #include <lal/Units.h>
00087 #include <lal/SeqFactories.h>
00088 
00089 
00090 /* structure to provide M and eta. */
00091 typedef struct
00092 tagecc_CBC_ODE_Struct
00093 {
00094   double totalMass; /* M=m1+m2 */
00095   double eta;       /* eta=m1 m2/M^2 */
00096 }
00097 ecc_CBC_ODE_Input;
00098 
00099 
00100 void 
00101 LALInspiralEccentricityDerivatives (
00102    REAL8Vector *values,
00103    REAL8Vector *dvalues,
00104    void        *params
00105    );
00106 
00107 static void
00108 LALInspiralEccentricityEngine(
00109    LALStatus        *status,
00110    REAL4Vector      *signal1,
00111    REAL4Vector      *signal2,
00112    REAL4Vector      *a,
00113    REAL4Vector      *ff,
00114    REAL8Vector      *phi,
00115    INT4             *countback,
00116    InspiralTemplate *params
00117    );
00118 
00119 
00120 NRCSID (LALINSPIRALECCENTRICITYC, "$Id: LALInspiralEccentricity.c,v 1.8 2008/07/07 17:22:23 thomas Exp $");
00121 
00122 /*  <lalVerbatim file="LALInspiralEccentricityCP"> */
00123 void 
00124 LALInspiralEccentricity(
00125    LALStatus        *status,
00126    REAL4Vector      *signal,
00127    InspiralTemplate *params
00128    )
00129  { /* </lalVerbatim>  */
00130 
00131    INT4 count;
00132    
00133    INITSTATUS(status, "LALInspiralEccentricity", LALINSPIRALECCENTRICITYC);
00134    ATTATCHSTATUSPTR(status);
00135 
00136    ASSERT(signal, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00137    ASSERT(signal->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00138 
00139 
00140    /* Initially the waveform is empty*/
00141    memset(signal->data, 0, signal->length*sizeof(REAL4));
00142 
00143    /*Call the engine function*/
00144    LALInspiralEccentricityEngine(status->statusPtr, signal, NULL, NULL, NULL, NULL, &count, params);
00145    CHECKSTATUSPTR(status);
00146    
00147    DETATCHSTATUSPTR(status);
00148    RETURN (status);
00149 
00150 }
00151 
00152 
00153 
00154 /* 
00155    Interface routine needed to generate time-domain T- or a P-approximant
00156    waveforms by solving the ODEs using a 4th order Runge-Kutta; April 5, 00.
00157 */
00158 
00159 NRCSID (LALINSPIRALECCENTRICITYTEMPLATESC, "$Id: LALInspiralEccentricity.c,v 1.8 2008/07/07 17:22:23 thomas Exp $");
00160 
00161 /*  <lalVerbatim file="LALInspiralEccentricityTemplatesCP"> */
00162 void 
00163 LALInspiralEccentricityTemplates(
00164    LALStatus        *status,
00165    REAL4Vector      *signal1,
00166    REAL4Vector      *signal2,
00167    InspiralTemplate *params
00168    )
00169  { /* </lalVerbatim>  */
00170 
00171    INT4 count;
00172    
00173    INITSTATUS(status, "LALInspiralEccentricityTemplates", LALINSPIRALECCENTRICITYTEMPLATESC);
00174    ATTATCHSTATUSPTR(status);
00175 
00176    ASSERT(signal1, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00177    ASSERT(signal2, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00178    ASSERT(signal1->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00179    ASSERT(signal2->data, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00180 
00181    /* Initially the waveforms are empty */
00182    memset(signal1->data, 0, signal1->length * sizeof(REAL4));
00183    memset(signal2->data, 0, signal2->length * sizeof(REAL4));
00184 
00185    /* Call the engine function */
00186    LALInspiralEccentricityEngine(status->statusPtr, signal1, signal2, NULL, NULL, NULL, &count, params);
00187    CHECKSTATUSPTR(status);   
00188 
00189    DETATCHSTATUSPTR(status);
00190    RETURN (status);
00191 
00192 }
00193 
00194 /* 
00195    Interface routine needed to generate time-domain T- or a P-approximant
00196    waveforms for injection packages T.Cokelaer sept 2003
00197 */
00198 
00199 NRCSID (LALINSPIRALECCENTRICITYFORINJECTIONC, "$Id: LALInspiralEccentricity.c,v 1.8 2008/07/07 17:22:23 thomas Exp $");
00200 
00201 /*  <lalVerbatim file="LALInspiralEccentricityForInjectionCP"> */
00202 void 
00203 LALInspiralEccentricityForInjection(
00204                              LALStatus        *status,
00205                              CoherentGW       *waveform,
00206                              InspiralTemplate *params,
00207                              PPNParamStruc  *ppnParams                       
00208                              )
00209 { /* </lalVerbatim>  */
00210  
00211   INT4        count, i;
00212   REAL8       p, phiC;  
00213   
00214   REAL4Vector a;           /* pointers to generated amplitude  data */
00215   REAL4Vector ff;          /* pointers to generated  frequency data */
00216   REAL8Vector phi;         /* generated phase data */
00217   
00218   CreateVectorSequenceIn in;
00219   
00220   CHAR message[256];
00221   
00222   InspiralInit paramsInit;  
00223 
00224   INITSTATUS(status, "LALInspiralEccentricityForInjection", LALINSPIRALECCENTRICITYTEMPLATESC);
00225   ATTATCHSTATUSPTR(status);
00226   
00227   /* Make sure parameter and waveform structures exist. */
00228   ASSERT( params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00229   ASSERT(waveform, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);  
00230   ASSERT( !( waveform->a ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00231   ASSERT( !( waveform->f ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00232   ASSERT( !( waveform->phi ), status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL );
00233   
00234   /* Compute some parameters*/
00235   LALInspiralInit(status->statusPtr, params, &paramsInit);
00236   CHECKSTATUSPTR(status);   
00237   
00238   if (paramsInit.nbins == 0){
00239       DETATCHSTATUSPTR(status);
00240       RETURN (status);
00241   }
00242 
00243   /* Now we can allocate memory and vector for coherentGW structure*/     
00244 
00245   ff.length  = paramsInit.nbins;
00246   a.length   = 2* paramsInit.nbins;
00247   phi.length = paramsInit.nbins;
00248   
00249   ff.data = (REAL4 *) LALCalloc(paramsInit.nbins, sizeof(REAL4));
00250   a.data  = (REAL4 *) LALCalloc(2 * paramsInit.nbins, sizeof(REAL4));
00251   phi.data= (REAL8 *) LALCalloc(paramsInit.nbins, sizeof(REAL8));
00252 
00253   /* Check momory allocation is okay */
00254   if (!(ff.data) || !(a.data) || !(phi.data))
00255   {
00256     if (ff.data)  LALFree(ff.data);
00257     if (a.data)   LALFree(a.data);
00258     if (phi.data) LALFree(phi.data);
00259 
00260     ABORT( status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM );
00261   }
00262 
00263   count = 0;
00264 
00265   /* Call the engine function */
00266   LALInspiralEccentricityEngine(status->statusPtr, NULL, NULL, &a, &ff, &phi, &count, params);
00267   BEGINFAIL( status )
00268   {
00269     LALFree(ff.data);
00270     LALFree(a.data);
00271     LALFree(phi.data);
00272   }
00273   ENDFAIL( status );
00274      
00275   p = phi.data[count-1];
00276   
00277   params->fFinal = ff.data[count-1];
00278   sprintf(message, "cycles = %f", p/(double)LAL_TWOPI);
00279   LALInfo(status, message);
00280 
00281   if ( (INT4)(p/LAL_TWOPI) < 2 ){
00282     sprintf(message, "The waveform has only %f cycles; we don't keep waveform with less than 2 cycles.", 
00283                p/(double)LAL_TWOPI );
00284     XLALPrintError(message);
00285     LALWarning(status, message);
00286   }
00287 
00288       /*wrap the phase vector*/
00289       phiC =  phi.data[count-1] ;
00290       for (i = 0; i < count; i++)
00291         {
00292           phi.data[i] =  phi.data[i] - phiC + ppnParams->phi;
00293         }
00294       
00295       /* Allocate the waveform structures. */
00296       if ( ( waveform->a = (REAL4TimeVectorSeries *)
00297              LALCalloc(1, sizeof(REAL4TimeVectorSeries) ) ) == NULL ) {
00298         ABORT( status, LALINSPIRALH_EMEM,
00299                LALINSPIRALH_MSGEMEM );
00300       }
00301       if ( ( waveform->f = (REAL4TimeSeries *)
00302              LALCalloc(1, sizeof(REAL4TimeSeries) ) ) == NULL ) {
00303         LALFree( waveform->a ); waveform->a = NULL;
00304         ABORT( status, LALINSPIRALH_EMEM,
00305                LALINSPIRALH_MSGEMEM );
00306       }
00307       if ( ( waveform->phi = (REAL8TimeSeries *)
00308              LALCalloc(1, sizeof(REAL8TimeSeries) ) ) == NULL ) {
00309         LALFree( waveform->a ); waveform->a = NULL;
00310         LALFree( waveform->f ); waveform->f = NULL;
00311         ABORT( status, LALINSPIRALH_EMEM,
00312                LALINSPIRALH_MSGEMEM );
00313       }
00314       
00315       
00316       in.length = (UINT4)(count);
00317       in.vectorLength = 2;
00318       
00319       LALSCreateVectorSequence( status->statusPtr, &( waveform->a->data ), &in );
00320       CHECKSTATUSPTR(status);      
00321       
00322       LALSCreateVector( status->statusPtr, &( waveform->f->data ), count);
00323       CHECKSTATUSPTR(status);      
00324       
00325       LALDCreateVector( status->statusPtr, &( waveform->phi->data ), count );
00326       CHECKSTATUSPTR(status);        
00327      
00328       memcpy(waveform->f->data->data , ff.data, count*(sizeof(REAL4)));
00329       memcpy(waveform->a->data->data , a.data, 2*count*(sizeof(REAL4)));
00330       memcpy(waveform->phi->data->data ,phi.data, count*(sizeof(REAL8)));
00331       
00332       waveform->a->deltaT = waveform->f->deltaT = waveform->phi->deltaT
00333         = ppnParams->deltaT;
00334       
00335       waveform->a->sampleUnits    = lalStrainUnit;
00336       waveform->f->sampleUnits    = lalHertzUnit;
00337       waveform->phi->sampleUnits  = lalDimensionlessUnit;
00338       waveform->position = ppnParams->position;
00339       waveform->psi = ppnParams->psi;
00340 
00341       LALSnprintf( waveform->a->name, LALNameLength,   "T1 inspiral amplitude" );
00342       LALSnprintf( waveform->f->name, LALNameLength,   "T1 inspiral frequency" );
00343       LALSnprintf( waveform->phi->name, LALNameLength, "T1 inspiral phase" );
00344       
00345       /* --- fill some output ---*/
00346       ppnParams->tc     = (double)(count-1) / params->tSampling ;
00347       ppnParams->length = count;
00348       ppnParams->dfdt   = ((REAL4)(waveform->f->data->data[count-1] 
00349                                    - waveform->f->data->data[count-2]))
00350         * ppnParams->deltaT;
00351       ppnParams->fStop  = params->fFinal;
00352       ppnParams->termCode        = GENERATEPPNINSPIRALH_EFSTOP;
00353       ppnParams->termDescription = GENERATEPPNINSPIRALH_MSGEFSTOP;
00354       
00355       ppnParams->fStart   = ppnParams->fStartIn;
00356 
00357   /* --- free memory --- */
00358   LALFree(ff.data);
00359   LALFree(a.data);
00360   LALFree(phi.data); 
00361  
00362   DETATCHSTATUSPTR(status);
00363   RETURN (status);
00364 }
00365 
00366 /*
00367  *  Engine function for use by other LALInspiralEccentricity* functions
00368  *  Craig Robinson April 2005
00369  */
00370 
00371 NRCSID (LALINSPIRALECCENTRICITYENGINEC, "$Id: LALInspiralEccentricity.c,v 1.8 2008/07/07 17:22:23 thomas Exp $");
00372 
00373 void
00374 LALInspiralEccentricityEngine(
00375                 LALStatus        *status,
00376                 REAL4Vector      *signal1,
00377                 REAL4Vector      *signal2,
00378                 REAL4Vector      *a,
00379                 REAL4Vector      *ff,
00380                 REAL8Vector      *phi,
00381                 INT4             *countback,
00382                 InspiralTemplate *params)
00383 {
00384    INT4 number_of_diff_equations = 3;
00385    INT4 count = 0;
00386    ecc_CBC_ODE_Input in3;
00387    REAL8 phase; 
00388    REAL8 orbital_element_p,orbital_element_e_squared; 
00389    REAL8 orbital_element_e; 
00390    REAL8 twoPhim2Beta = 0;
00391    REAL8 threePhim2Beta = 0;
00392    REAL8 phim2Beta = 0;
00393    REAL8 twoBeta;
00394    REAL8 rbyM=1e6, rbyMFlso=6.;
00395    REAL8 sin2Beta,cos2Beta,iota,onepCosSqI, SinSqI, cosI, e0, fmin, beta, p0;
00396 
00397  
00398    
00399    REAL8 amp, m, dt, t,  h1, h2, f,  fHigh, piM, fu;
00400    REAL8Vector dummy, values, dvalues, valuesNew, yt, dym, dyt;
00401    INT4 done=0;
00402    rk4In in4;
00403    rk4GSLIntegrator *integrator;
00404    void *funcParams;
00405    expnCoeffs ak;
00406    expnFunc func;
00407 
00408 #if 0
00409    REAL8 mTot = 0;
00410    REAL8 unitHz = 0;
00411    REAL8 f2a = 0;
00412    REAL8 mu = 0; 
00413    REAL8 etab = 0;
00414    REAL8 fFac = 0; /* SI normalization for f and t */
00415    REAL8 f2aFac = 0;/* factor multiplying f in amplitude function */
00416    REAL8 apFac = 0, acFac = 0;/* extra factor in plus and cross amplitudes */
00417 #endif
00418      
00419    INITSTATUS(status, "LALInspiralEccentricityEngine", LALINSPIRALECCENTRICITYENGINEC);
00420    ATTATCHSTATUSPTR(status);
00421 
00422    ASSERT (params,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00423    ASSERT (params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00424    ASSERT (params->nEndPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00425    ASSERT (params->fLower > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00426    ASSERT (params->tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00427 
00428    LALInspiralSetup (status->statusPtr, &ak, params);
00429    CHECKSTATUSPTR(status);
00430    LALInspiralChooseModel(status->statusPtr, &func, &ak, params);
00431    CHECKSTATUSPTR(status);
00432   
00433    m = ak.totalmass = params->mass1+params->mass2;
00434    
00435    values.length = dvalues.length = valuesNew.length =
00436    yt.length = dym.length = dyt.length = number_of_diff_equations;
00437    dummy.length = number_of_diff_equations * 6;
00438    if (!(dummy.data = (REAL8 * ) LALMalloc(sizeof(REAL8) * number_of_diff_equations * 6))) {
00439       ABORT(status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM);
00440    }
00441 
00442    values.data = &dummy.data[0];
00443    dvalues.data = &dummy.data[number_of_diff_equations];
00444    valuesNew.data = &dummy.data[2*number_of_diff_equations];
00445    yt.data = &dummy.data[3*number_of_diff_equations];
00446    dym.data = &dummy.data[4*number_of_diff_equations];
00447    dyt.data = &dummy.data[5*number_of_diff_equations];
00448 
00449 /*   m = ak.totalmass;*/
00450    dt = 1./params->tSampling;
00451 
00452    if (a)
00453    {
00454      /*to be implemented. */
00455 
00456      
00457 /*      mTot   = params->mass1 + params->mass2;
00458       etab   = params->mass1 * params->mass2;
00459       etab  /= mTot;
00460       etab  /= mTot;
00461       unitHz = mTot *LAL_MTSUN_SI*(REAL8)LAL_PI;
00462       cosI   = cos( params->inclination );
00463       mu     = etab * mTot;  
00464       fFac   = 1.0 / ( 4.0*LAL_TWOPI*LAL_MTSUN_SI*mTot );
00465       f2aFac = LAL_PI*LAL_MTSUN_SI*mTot*fFac;   
00466       apFac  = acFac = -2.0 * mu * LAL_MRSUN_SI/params->distance;
00467       apFac *= 1.0 + cosI*cosI;
00468       acFac *= 2.0*cosI;
00469       params->nStartPad = 0;
00470       */
00471    }
00472    
00473    ASSERT(ak.totalmass > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00474 
00475    t = 0.0;
00476 
00477 
00478 
00479    in3.totalMass = (params->mass1 + params->mass2) * LAL_MTSUN_SI ;
00480    in3.eta = (params->mass1 * params->mass2) /(params->mass1 + params->mass2) / (params->mass1 + params->mass2);
00481    funcParams = (void *) &in3;
00482 
00483    
00484    piM = LAL_PI * m * LAL_MTSUN_SI;
00485 /*   f = (v*v*v)/piM;
00486 
00487    fu = params->fCutoff;
00488    if (fu) 
00489       fHigh = (fu < ak.flso) ? fu : ak.flso; 
00490    else 
00491       fHigh = ak.flso;
00492    f = (v*v*v)/(LAL_PI*m);
00493 
00494    ASSERT(fHigh < 0.5/dt, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00495    ASSERT(fHigh > params->fLower, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00496 */
00497    
00498 
00499    /* e0 is set at fmin */
00500    e0 = params->eccentricity;
00501 
00502    /* the second harmonic will start at fLower*2/3 */
00503    fmin = params->fLower;
00504    iota = params->inclination; /*overwritten later */
00505    
00506    beta = 0.;
00507    twoBeta = 2.* beta;
00508    cos2Beta = cos(twoBeta);
00509    sin2Beta = sin(twoBeta);
00510    iota = LAL_PI/4.;
00511    onepCosSqI = 1. + cos(iota) * cos(iota);
00512    SinSqI = sin(iota) * sin(iota);
00513    cosI = cos(iota);
00514 
00515    p0 = (1. - e0*e0)/pow(2. * LAL_PI * m * LAL_MTSUN_SI* fmin/3. , 2./3.);
00516        
00517    *(values.data) = orbital_element_p = p0;
00518    *(values.data+1) = phase = params->startPhase;
00519    *(values.data+2) = orbital_element_e = e0; 
00520 
00521    
00522 
00523     
00524    in4.function = LALInspiralEccentricityDerivatives;
00525    in4.x = t;
00526    in4.y = &values;
00527    in4.h = dt;
00528    in4.n = number_of_diff_equations;
00529    in4.yt = &yt;
00530    in4.dym = &dym;
00531    in4.dyt = &dyt;
00532    
00533    xlalErrno = 0;
00534    /* Initialize GSL integrator */
00535    if (!(integrator = XLALRungeKutta4Init(number_of_diff_equations, &in4)))
00536    {
00537      INT4 errNum = XLALClearErrno();
00538      LALFree(dummy.data);
00539 
00540      if (errNum == XLAL_ENOMEM)
00541        ABORT(status, LALINSPIRALH_EMEM, LALINSPIRALH_MSGEMEM);
00542      else
00543        ABORTXLAL( status );
00544    }
00545 
00546    count = 0;
00547    if (signal2) {
00548    params->nStartPad = 0;} /* for template generation, that value must be zero*/
00549    
00550    else if (signal1) {
00551      count = params->nStartPad;
00552    }
00553 
00554    t = 0.0;
00555 
00556    
00557    fu = params->fCutoff;
00558    if (fu) 
00559       fHigh = (fu < ak.flso) ? fu : ak.flso; 
00560    else 
00561       fHigh = ak.flso;
00562       
00563    f = 1./(pow(orbital_element_p, 3./2.))/piM;
00564  
00565 
00566    /*fprintf(stderr, "fFinal = %f %f %f %f\n", fu,fHigh,f,ak.flso);*/
00567  done = 0;
00568    do {
00569       /* Free up memory and abort if writing beyond the end of vector*/
00570       /*if ((signal1 && (UINT4)count >= signal1->length) || (ff && (UINT4)count >= ff->length))*/
00571       if ((signal1 && (UINT4)count >= signal1->length))
00572       {
00573           XLALRungeKutta4Free( integrator );
00574           LALFree(dummy.data);
00575           ABORT(status, LALINSPIRALH_EVECTOR, LALINSPIRALH_MSGEVECTOR);
00576       }
00577 
00578       /* Non-injection case */
00579       if (signal1)
00580       {
00581         twoPhim2Beta = 2.* phase - twoBeta;
00582         phim2Beta = phase - twoBeta;
00583         threePhim2Beta = 3.* phase - twoBeta;
00584         orbital_element_e_squared = orbital_element_e * orbital_element_e;
00585         amp = params->signalAmplitude / orbital_element_p;
00586    
00587 /*        fprintf(stderr, "%e %e %e %e %e\n", twoBeta, twoPhim2Beta, phim2Beta, threePhim2Beta, orbital_element_e_squared);*/
00588          
00589 
00590         h1 = amp * ( ( 2. * cos(twoPhim2Beta) + 2.5 * orbital_element_e * cos(phim2Beta) 
00591           + 0.5 * orbital_element_e * cos(threePhim2Beta) + orbital_element_e_squared * cos2Beta) * onepCosSqI +
00592           + ( orbital_element_e * cos(orbital_element_p) + orbital_element_e_squared) * SinSqI);
00593         if (f>=params->fLower & done==0)
00594         {
00595         /*fprintf(stderr, "freq=%e p=%e, e=%e, phase = %e\n", f,orbital_element_p, orbital_element_e, phase);fflush(stderr);
00596 */
00597         params->alpha1 =  orbital_element_e;
00598         done = 1;
00599          }
00600          /*if (f>=params->fLower)*/
00601         {
00602           *(signal1->data + count) = (REAL4) h1;
00603          }
00604 
00605          if (signal2)
00606          {
00607             h2 = amp * ( ( 4. * sin(twoPhim2Beta) + 5 * orbital_element_e * sin(phim2Beta) 
00608           + orbital_element_e * sin(threePhim2Beta) - 2. * orbital_element_e_squared * sin2Beta) * cosI);
00609 /*           if (f>=params->fLower)*/
00610            {
00611               *(signal2->data + count) = (REAL4) h2;
00612             }
00613          }
00614       }
00615 
00616       /* Injection case */
00617       else if (a)
00618       {
00619         /*to be done*/  
00620         /*
00621         omega = v*v*v;
00622     
00623           ff->data[count]       = (REAL4)(omega/unitHz);
00624           f2a                   = pow (f2aFac * omega, 2./3.);
00625           a->data[2*count]      = (REAL4)(4.*apFac * f2a);
00626           a->data[2*count+1]    = (REAL4)(4.*acFac * f2a);
00627           phi->data[count]      = (REAL8)(p);
00628           */
00629       }
00630     
00631       LALInspiralEccentricityDerivatives(&values, &dvalues,funcParams);
00632       CHECKSTATUSPTR(status);
00633       
00634       in4.dydx = &dvalues;
00635       in4.x=t;
00636       
00637       LALRungeKutta4(status->statusPtr, &valuesNew, integrator, funcParams);
00638       CHECKSTATUSPTR(status);
00639       
00640       *(values.data) = orbital_element_p = *(valuesNew.data);
00641       *(values.data+1) = phase = *(valuesNew.data+1);
00642       *(values.data+2) = orbital_element_e = *(valuesNew.data+2);
00643 
00644       t = (++count-params->nStartPad) * dt;
00645       /* v^3 is equal to p^(3/2)*/
00646       f = 1./(pow(orbital_element_p, 3./2.))/piM;
00647 /*      fprintf(stderr, "p=%e, e=%e, phase = %e\n", orbital_element_p, orbital_element_e, phase);
00648       fflush(stderr);*/
00649       rbyM = orbital_element_p/(1.+orbital_element_e * cos(phase));
00650       /*fprintf(stderr, "rbyM=%e rbyMFlso=%e t=%e, ak.tn=%e f=%e e=%e\n",rbyM, rbyMFlso, t, ak.tn,f,orbital_element_e);
00651       fflush(stderr);*/
00652       
00653    } while ( (t < ak.tn) && (rbyM>rbyMFlso) && (f<fHigh));
00654 
00655 
00656    /*fprintf(stderr, "t=%e ak.tn=%e rbyM=%e rbyMFlso=%e f=%f fHigh=%f", t, ak.tn, rbyM, rbyMFlso, f, fHigh);*/
00657    
00658    /*also need to add for the fupper nyquist frequency**/
00659    params->vFinal = orbital_element_p;
00660    params->fFinal = f;
00661    params->tC = t;
00662    *countback = count;
00663 
00664    XLALRungeKutta4Free( integrator );
00665    LALFree(dummy.data);
00666 
00667    DETATCHSTATUSPTR(status);
00668    RETURN (status);
00669 
00670 }                      
00671 
00672 
00673 
00674 
00675 void 
00676 LALInspiralEccentricityDerivatives (
00677    REAL8Vector *values,
00678    REAL8Vector *dvalues,
00679    void        *params
00680    )
00681  { /* </lalVerbatim> */
00682 
00683   ecc_CBC_ODE_Input *par;
00684   double M, eta, mu, c1, e0, e2, p0, p2, p3, p4, phi;
00685   par = (ecc_CBC_ODE_Input *) params;
00686 
00687   /* affectation */
00688   M = par->totalMass; /* in MTSUN*/
00689   eta = par->eta;  /*dimensionless*/
00690   mu = eta * M; /*therefore in MTSUN*/
00691   phi = values->data[1];
00692   e0 = values->data[2];
00693   e2 = values->data[2] * values->data[2];
00694   p0 = values->data[0];
00695   p2 = values->data[0] * values->data[0];
00696   p3 = p2 * values->data[0];
00697   p4 = p3 * values->data[0];
00698   
00699   c1 = pow(1. - e2, 1.5);
00700 
00701   /* y[0] is p
00702      y[1] is phase
00703    * y[2] is e
00704    */
00705 
00706 /*  fprintf(stderr, "before=%e %e %e\n", p0, e0, phi);*/
00707   /* Eq 6 */
00708   dvalues->data[1] = 1./(M * sqrt (p3)) * ( 1. + e0 * cos(phi) ) * ( 1. + e0 * cos(phi) );
00709   
00710   /* Eq 8 */
00711   dvalues->data[0] = (-64./5.) * mu / M / M * c1 / p3 * (1 + 7./8. * e2);
00712 
00713   /* Eq 9*/
00714   dvalues->data[2] = (-304./15.) * mu / M / M / p4 * c1 * e0 * (1. + 121./304. * e2);       
00715       
00716 /*  fprintf(stderr, "new values p=%e, e=%e, phase = %e\n", 
00717       dvalues->data[0], 
00718       dvalues->data[2], 
00719       dvalues->data[1]);*/
00720 
00721   return;
00722 }
00723 
00724 
00725 

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