LALInspiralStationaryPhaseApprox2.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton, B.S. Sathyaprakash, 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="LALInspiralStationaryPhaseApprox2CV">
00021  * Author: B.S. Sathyaprakash
00022  **** </lalVerbatim> */
00023 
00024 /**** <lalLaTeX>
00025  *
00026  *
00027  * \subsection{Module \texttt{LALInspiralStationaryPhaseApprox2.c}}
00028  * %% A one-line description of the function(s) defined in this module.
00029  * This module computes the usual stationary phase approximation to the
00030  * Fourier transform of a chirp waveform
00031  * given by Eq.~(\ref{eq:InspiralFourierPhase:f2}).
00032  *
00033  * \subsubsection*{Prototypes}
00034  * \input{LALInspiralStationaryPhaseApprox2CP}
00035  * \idx{LALInspiralStationaryPhaseApprox2()}
00036  * \begin{itemize}
00037  * \item {\tt signal:} Output containing the inspiral waveform.
00038  * \item {\tt params:} Input containing binary chirp parameters.
00039  * \end{itemize}
00040  *
00041  * \subsubsection*{Description}
00042  *
00043  * %% A description of the data analysis task performed by this function;
00044  * %% this is the main place to document the module.
00045  * Computes the Fourier transform of the chirp signal in the stationary 
00046  * phase approximation and returns the real and imagninary parts of the 
00047  * Fourier domain signal in the convention of fftw. For a signal vector 
00048  * of length {\tt n=signal->length} ({\tt n} even):
00049  * \begin{itemize}
00050  * \item {\tt signal->data[0]} is the {\it real} 0th frequency component of the Fourier transform.
00051  * \item {\tt signal->data[n/2]} is the {\it real} Nyquist frequency component of the Fourier transform.
00052  * \item {\tt signal->data[k]} and {\tt signal->data[n-k],} for {\tt k=1,\ldots, n/2-1,} are
00053  * the real and imaginary parts of the Fourier transform at a frequency $k\Delta f=k/T,$ $T$ being
00054  * the duration of the signal and $\Delta f=1/T$ is the frequency resolution.
00055  * \end{itemize}
00056  *
00057  * \subsubsection*{Algorithm}
00058  *
00059  * %% A description of the method used to perform the calculation.
00060  *
00061  * The standard SPA is given by Eq.~(\ref{eq:InspiralFourierPhase:f2}).
00062  * We define a variable function pointer {\tt LALInspiralTaylorF2Phasing} and point
00063  * it to one of the {\texttt static} functions defined within this function
00064  * that explicitly calculates the Fourier phase at the PN order chosen by the user.
00065  * The reference points are chosen so that on inverse Fourier transforming
00066  * the time-domain waveform will 
00067  * \begin{itemize}
00068  * \item be padded with zeroes in the first {\tt params->nStartPad} bins,
00069  * \item begin with a phase shift of {\tt params->nStartPhase} radians,
00070  * \item have an amplitude of ${\tt n} v^2.$ 
00071  * \end{itemize}
00072  * \subsubsection*{Uses}
00073  * \begin{verbatim} 
00074    LALInspiralSetup 
00075    LALInspiralChooseModel 
00076    LALInspiralTaylorF2Phasing[0234567]PN
00077  * \end{verbatim}
00078  *
00079  * %% List of any external functions called by this function.
00080  * \begin{verbatim}
00081  * None
00082  * \end{verbatim}
00083  * \subsubsection*{Notes}
00084  *
00085  * %% Any relevant notes.
00086  *
00087  * If it is required to compare the output of this module with a time domain
00088  * signal one should use an inverse Fourier transform routine that packs data
00089  * in the same way as fftw. Moreover, one should divide the resulting inverse
00090  * Fourier transform by a factor ${\tt n}/2$ to be consistent with the 
00091  * amplitude used in time-domain signal models.
00092  *
00093  * \vfill{\footnotesize\input{LALInspiralStationaryPhaseApprox2CV}}
00094  *
00095  **** </lalLaTeX> */
00096 
00097 #include "LALInspiral.h"
00098 
00099 static void LALInspiralTaylorF2Phasing0PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00100 static void LALInspiralTaylorF2Phasing2PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00101 static void LALInspiralTaylorF2Phasing3PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00102 static void LALInspiralTaylorF2Phasing4PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00103 static void LALInspiralTaylorF2Phasing5PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00104 static void LALInspiralTaylorF2Phasing6PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00105 static void LALInspiralTaylorF2Phasing7PN (REAL8 v, REAL8 *phase, expnCoeffs *ak);
00106 
00107 NRCSID (LALINSPIRALSTATIONARYPHASEAPPROX2C, "$Id: LALInspiralStationaryPhaseApprox2.c,v 1.13 2007/08/20 11:51:40 thomas Exp $");
00108 
00109 /*  <lalVerbatim file="LALInspiralStationaryPhaseApprox2CP"> */
00110 void 
00111 LALInspiralStationaryPhaseApprox2 (
00112    LALStatus        *status,
00113    REAL4Vector      *signal,
00114    InspiralTemplate *params
00115    ) 
00116 { /* </lalVerbatim>  */
00117    REAL8 Oneby3, h1, h2, pimmc, f, v, df, shft, phi, amp0, amp, psif, psi;
00118    INT4 n, nby2, i, f0, fn;
00119    expnCoeffs ak;
00120    expnFunc func;
00121    void (*LALInspiralTaylorF2Phasing)(REAL8, REAL8 *, expnCoeffs *) = NULL;
00122 
00123    INITSTATUS (status, "LALInspiralStationaryPhaseApprox2", LALINSPIRALSTATIONARYPHASEAPPROX2C);
00124    ATTATCHSTATUSPTR(status);
00125    ASSERT (signal,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00126    ASSERT (signal->data,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00127    ASSERT (params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00128    ASSERT (signal->length>2,  status, LALINSPIRALH_ECHOICE, LALINSPIRALH_MSGECHOICE);
00129 
00130    switch (params->order) 
00131    {
00132            case newtonian:
00133            case oneHalfPN:
00134                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing0PN;
00135                    break;
00136            case onePN:
00137                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing2PN;
00138                    break;
00139            case onePointFivePN:
00140                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing3PN;
00141                    break;
00142            case twoPN:
00143                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing4PN;
00144                    break;
00145            case twoPointFivePN:
00146                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing5PN;
00147                    break;
00148            case threePN:
00149                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing6PN;
00150                    break;
00151            case threePointFivePN:
00152                    LALInspiralTaylorF2Phasing = LALInspiralTaylorF2Phasing7PN;
00153                    break;
00154    }
00155    n = signal->length;
00156    nby2 = n/2;
00157    memset( &ak, 0, sizeof( ak ) );
00158    LALInspiralSetup(status->statusPtr, &ak, params);
00159    CHECKSTATUSPTR(status);
00160    LALInspiralChooseModel(status->statusPtr, &func, &ak, params);
00161    CHECKSTATUSPTR(status);
00162 
00163    Oneby3 = 1.L/3.L;
00164    df = params->tSampling/signal->length;
00165    pimmc = LAL_PI * params->totalMass * LAL_MTSUN_SI;
00166    f0 = params->fLower;
00167    fn = (params->fCutoff < ak.fn) ? params->fCutoff : ak.fn; 
00168    v = pow(pimmc*f0, Oneby3); 
00169 
00170    /* If we want to pad with zeroes in the beginning then the instant of
00171     * coalescence will be the chirp time + the duration for which padding
00172     * is needed. Thus, in the equation below nStartPad occurs with a +ve sign.
00173     * This code doesn't support non-zero start-time. i.e. params->startTime
00174     * should be necessarily zero.
00175     */
00176    shft = 2.L*LAL_PI * (ak.tn + params->nStartPad/params->tSampling + params->startTime);
00177    phi =  params->startPhase + LAL_PI/4.L;
00178    amp0 = params->signalAmplitude * ak.totalmass * pow(LAL_PI/12.L, 0.5L) * df;
00179 /* 
00180    Compute the standard stationary phase approximation. 
00181 */
00182    h1 = signal->data[0] = 0.L;
00183    h2 = signal->data[nby2] = 0.L;
00184    for (i=1; i<nby2; i++) {
00185       f = i * df;
00186       if (f < f0 || f > fn)
00187       {
00188               /* 
00189                * All frequency components below f0 and above fn are set to zero  
00190                */
00191               signal->data[i] = 0.;
00192               signal->data[n-i] = 0.;
00193       }
00194       else
00195       {
00196               v = pow(pimmc * f, Oneby3);
00197               LALInspiralTaylorF2Phasing(v, &psif, &ak);
00198               psi = shft * f + phi + psif;
00199               /* 
00200                  dEnergybyFlux computes 1/(dv/dt) while what we need is 1/(dF/dt):
00201                  dF/dt=(dF/dv)(dv/dt)=-dEnergybyFlux/(dF/dv)=-dEnergybyFlux 3v^2/(pi m^2)
00202                  Note that our energy is defined as E=-eta v^2/2 and NOT -eta m v^2/2.
00203                  This is the reason why there is an extra m in the last equation above
00204                  amp = amp0 * pow(-dEnergybyFlux(v)/v^2, 0.5) * v^2;
00205                      = amp0 * pow(-dEnergybyFlux(v), 0.5) * v;
00206               */
00207               amp = amp0 * pow(-func.dEnergy(v,&ak)/func.flux(v,&ak),0.5L) * v;
00208               signal->data[i] = (REAL4) (amp * cos(psi));
00209               signal->data[n-i] = (REAL4) (-amp * sin(psi));
00210 
00211       }
00212       /*
00213          printf ("%e %e \n", v, psif);
00214          printf ("%e %e %e %e %e\n", f, pow(h1,2.)+pow(h2,2.), h2, psi, psif);
00215          printf ("&\n");
00216        */
00217    
00218    }
00219    params->fFinal = fn;
00220    DETATCHSTATUSPTR(status);
00221    RETURN(status);
00222 }
00223 
00224 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing0PNCP"> */
00225 static void LALInspiralTaylorF2Phasing0PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00226 /* </lalVerbatim>  */
00227 
00228    REAL8 x;
00229    x = v*v;
00230    *phase = ak->pfaN/pow(v,5.);
00231 }
00232 
00233 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing2PNCP"> */
00234 static void LALInspiralTaylorF2Phasing2PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00235 /* </lalVerbatim>  */
00236    REAL8 x;
00237    x = v*v;
00238    *phase = ak->pfaN * (1. + ak->pfa2 * x)/pow(v,5.);
00239 }
00240 
00241 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing3PNCP"> */
00242 static void LALInspiralTaylorF2Phasing3PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00243 /* </lalVerbatim>  */
00244    REAL8 x;
00245    x = v*v;
00246    *phase = ak->pfaN * (1. + ak->pfa2 * x + ak->pfa3 * v*x)/pow(v,5.);
00247 }
00248 
00249 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing4PNCP"> */
00250 static void LALInspiralTaylorF2Phasing4PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00251 /* </lalVerbatim>  */
00252    REAL8 x;
00253    x = v*v;
00254    *phase = ak->pfaN * (1. + ak->pfa2 * x + ak->pfa3 * v*x + ak->pfa4 * x*x)/pow(v,5.);
00255 }
00256 
00257 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing5PNCP"> */
00258 static void LALInspiralTaylorF2Phasing5PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00259 /* </lalVerbatim>  */
00260    REAL8 x, y;
00261    x = v*v;
00262    y = x*x;
00263    *phase = ak->pfaN * (1. + ak->pfa2 * x + ak->pfa3 * v*x + ak->pfa4 * y
00264          + (ak->pfa5 + ak->pfl5 * log(v/ak->v0)) * y*v)/pow(v,5.);
00265 }
00266 
00267 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing6PNCP"> */
00268 static void LALInspiralTaylorF2Phasing6PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00269 /* </lalVerbatim>  */
00270    REAL8 x, y, z;
00271    x = v*v;
00272    y = x*x;
00273    z = y*x;
00274    
00275    *phase = ak->pfaN * (1. + ak->pfa2 * x + ak->pfa3 * v*x + ak->pfa4 * y
00276          + (ak->pfa5 + ak->pfl5 * log(v/ak->v0)) * y*v 
00277          + (ak->pfa6 + ak->pfl6 * log(4.*v) ) * z)
00278      /pow(v,5.);
00279 }
00280 
00281 /*  <lalVerbatim file="LALInspiralTaylorF2Phasing7PNCP"> */
00282 static void LALInspiralTaylorF2Phasing7PN (REAL8 v, REAL8 *phase, expnCoeffs *ak) {
00283 /* </lalVerbatim>  */
00284    REAL8 x, y, z;
00285    x = v*v;
00286    y = x*x;
00287    z = y*x;
00288    
00289    *phase = ak->pfaN * (1. + ak->pfa2 * x + ak->pfa3 * v*x + ak->pfa4 * y
00290          + (ak->pfa5 + ak->pfl5 * log(v/ak->v0)) * y*v 
00291          + (ak->pfa6 + ak->pfl6 * log(4.*v) ) * z
00292          + ak->pfa7 * z*v)
00293      /pow(v,5.);
00294 }

Generated on Tue Oct 7 02:40:01 2008 for LAL by  doxygen 1.5.2