LALBCVWaveform.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 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="LALBCVWaveformCV">
00021  * Author: B.S. Sathyaprakash
00022  * $Id: LALBCVWaveform.c,v 1.15 2007/09/27 16:48:33 gareth Exp $  
00023  **** </lalVerbatim> */
00024 
00025 /**** <lalLaTeX>
00026  *
00027  * \subsection{Module \texttt{LALBCVWaveform.c}}
00028  *
00029  * This module contains a single function {\tt LALBCVWaveform.}
00030  * \subsubsection*{Prototypesc}
00031  * \input{LALBCVWaveformCP}
00032  * \idx{LALLALBCVWaveform()} 
00033  * \begin{itemize} 
00034  * \item {\tt signal:} Output containing the \emph {Fourier transform} of the inspiral waveform.  
00035  * \item {\tt params:} Input containing binary chirp parameters; 
00036  * it is necessary and sufficent to specify the following parameters
00037  * of the {\tt params} structure: 
00038  * {\tt psi0, psi3, alpha, fendBCV(fFinal), nStartPad, fLower, tSampling}.  
00039  * All other parameters in {\tt params} are ignored.  \end{itemize} 
00040  * \input{LALBCVSpinWaveformCP}
00041  * \idx{LALLALBCVSpinWaveform()} 
00042  * \begin{itemize} 
00043  * \item {\tt signal:} Output containing the \emph {Fourier transform} of the inspiral waveform.  
00044  * \item {\tt params:} Input containing binary chirp parameters; 
00045  * it is necessary and sufficent to specify the following parameters
00046  * of the {\tt params} structure: 
00047  * {\tt psi0, psi3, alpha1, alpha2, beta, fendBCV(fFinal), nStartPad, fLower, tSampling}.  
00048  * All other parameters in {\tt params} are ignored.  \end{itemize} * 
00049  * 
00050  * \subsubsection*{Description}
00051  * This module can be used to generate {\it detection template 
00052  * family} of Buonanno, Chen and Vallisneri \cite{BCV03,BCV03b}.
00053  * There are two modules: {\tt LALBCVWaveform.} and {\tt LALBCVSpinWaveform.}
00054  * The former can be used to generate non-spinning waveforms and the DTF
00055  * it implements is given in Sec.~\ref{sec:BCV} and 
00056  * Eq.(\ref{eq:BCV:NonSpinning}) and the latter
00057  * to generate spinning waveforms (Eq.~\ref{eq:BCV:Spinning}).
00058  *
00059  * \subsubsection*{Algorithm}
00060  * A straightforward implementation of the formula. Note that the routine returns
00061  * {\bf Fourier transform} of the signal as opposed to most other modules in this 
00062  * package which return time-domain signals. Also, the amplitude is quite arbitrary.
00063  * 
00064  * \subsubsection*{Uses}
00065  * \begin{verbatim} 
00066  * ASSERT 
00067  * ATTATCHSTATUSPTR
00068  * DETATCHSTATUSPTR 
00069  * INITSTATUS 
00070  * RETURN
00071  * \end{verbatim}
00072  * 
00073  * \subsubsection*{Notes}
00074  * 
00075  * %% Any relevant notes.
00076  * 
00077  * \vfill{\footnotesize\input{LALBCVWaveformCV}}
00078  * 
00079  **** </lalLaTeX> */ 
00080 
00081 #include <lal/LALInspiral.h>
00082 
00083 /** DEFINE RCS ID STRING **/
00084 NRCSID (LALBCVWAVEFORMC, "$Id: LALBCVWaveform.c,v 1.15 2007/09/27 16:48:33 gareth Exp $");
00085 
00086 
00087 /*  <lalVerbatim file="LALBCVWaveformCP"> */
00088 void 
00089 LALBCVWaveform(
00090    LALStatus        *status, 
00091    REAL4Vector      *signal, 
00092    InspiralTemplate *params
00093    )
00094  { /* </lalVerbatim>  */
00095 
00096   REAL8 f, df;
00097   REAL8 shift, phi, psi, amp0, amp;
00098   REAL8 Sevenby6, Fiveby3, Twoby3, alpha;
00099   INT4 n, i;
00100 
00101   INITSTATUS(status, "LALBCVWaveform", LALBCVWAVEFORMC);
00102   ATTATCHSTATUSPTR(status);
00103 
00104   ASSERT (signal,  status,       LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00105   ASSERT (signal->data,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00106   ASSERT (params,  status,       LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00107   ASSERT (params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00108   ASSERT (params->fLower > 0, status,     LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00109   ASSERT (params->tSampling > 0, status,  LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00110 
00111   n = signal->length;
00112   Twoby3 = 2.L/3.L;
00113   Sevenby6 = 7.L/6.L;
00114   Fiveby3 = 5.L/3.L;
00115 
00116   df = params->tSampling/(REAL8)n;
00117   params->fFinal = params->fCutoff; 
00118   alpha = params->alpha / pow(params->fCutoff, Twoby3);
00119 
00120 
00121   /* to do : check that a_f in [0,1]??*/
00122 
00123   /*
00124   totalMass = params->totalMass * LAL_MTSUN_SI;
00125   shift = LAL_TWOPI * (params->tC - (float)n /params->tSampling 
00126                   - params->startTime - params->nStartPad/params->tSampling);
00127   */
00128   /*
00129   shift = LAL_TWOPI * ((double) params->nStartPad/params->tSampling + params->startTime);
00130   phi = params->startPhase + params->psi0 * pow(params->fLower, -Fiveby3) 
00131           + params->psi3 * pow(params->fLower, -Twoby3);
00132    */
00133   shift = -LAL_TWOPI * ((double)params->nStartPad/params->tSampling);
00134   phi = - params->startPhase;
00135 
00136   /*
00137   amp0 = params->signalAmplitude * pow(5./(384.*params->eta), 0.5) * 
00138            totalMass * pow(LAL_PI * totalMass,-Sevenby6) * 
00139            params->tSampling * (2. / signal->length); 
00140 
00141    */
00142 
00143   amp0 = params->signalAmplitude;
00144   /*  Computing BCV waveform */
00145 
00146   signal->data[0] = 0.0;
00147   signal->data[n/2] = 0.0;
00148 
00149   for(i=1;i<n/2;i++)
00150   {
00151           f = i*df;
00152     
00153           if (f < params->fLower || f > params->fFinal)
00154           {
00155           /* 
00156            * All frequency components below params->fLower and above fn are set to zero  
00157            */
00158               signal->data[i] = 0.;
00159               signal->data[n-i] = 0.;
00160             
00161           }
00162           else
00163           {
00164           /* What shall we put for sign phi? for uspa it must be "-" */
00165               psi =  (shift*f + phi + params->psi0*pow(f,-Fiveby3) + params->psi3*pow(f,-Twoby3));
00166               amp = amp0 * (1. - alpha * pow(f,Twoby3)) * pow(f,-Sevenby6);
00167               
00168               signal->data[i] = (REAL4) (amp * cos(psi));
00169               signal->data[n-i] = (REAL4) (-amp * sin(psi));
00170           }
00171   }
00172   DETATCHSTATUSPTR(status);
00173   RETURN(status);
00174 }
00175 
00176 
00177 
00178 
00179 /*  <lalVerbatim file="LALBCVSpinWaveformCP"> */
00180 
00181 void 
00182 LALBCVSpinWaveform(
00183    LALStatus        *status, 
00184    REAL4Vector      *signal, 
00185    InspiralTemplate *params
00186    )
00187  { /* </lalVerbatim>  */
00188 
00189   REAL8 f, df;
00190   REAL8 shift, phi, psi, amp0, ampRe, ampIm, modphase;
00191   REAL8 Sevenby6, Fiveby3, Twoby3; 
00192   INT4 n, i;
00193 
00194   INITSTATUS(status, "LALBCVSpinWaveform", LALBCVWAVEFORMC);
00195   ATTATCHSTATUSPTR(status);
00196 
00197   ASSERT (signal,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00198   ASSERT (signal->data,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00199   ASSERT (params,  status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00200   ASSERT (params->nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00201   ASSERT (params->fLower > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00202   ASSERT (params->tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00203 
00204   n = signal->length;
00205   Twoby3 = 2.L/3.L;
00206   Sevenby6 = 7.L/6.L;
00207   Fiveby3 = 5.L/3.L;
00208 
00209   df = params->tSampling/(REAL8)n;
00210 
00211   /*
00212   totalMass = params->totalMass * LAL_MTSUN_SI;
00213   shift = LAL_TWOPI * (params->tC - (float)n /params->tSampling 
00214                   - params->startTime - params->nStartPad/params->tSampling);
00215   */
00216   shift = -LAL_TWOPI * (params->nStartPad/params->tSampling);
00217 
00218   /* use this to shift waveform start time by hand... */
00219   /*shift = -LAL_TWOPI * (131072/params->tSampling);*/
00220       
00221   phi = - params->startPhase;    
00222 
00223   /*
00224   amp0 = params->signalAmplitude * pow(5./(384.*params->eta), 0.5) * 
00225            totalMass * pow(LAL_PI * totalMass,-Sevenby6) * 
00226            params->tSampling * (2. / signal->length); 
00227 
00228    */
00229   amp0 = params->signalAmplitude;
00230   /*  Computing BCV waveform */
00231 
00232   signal->data[0] = 0.0;
00233   signal->data[n/2] = 0.0;
00234 
00235   for(i=1;i<n/2;i++)
00236   {
00237           f = i*df;
00238           if (f < params->fLower || f > params->fCutoff)
00239           {
00240           /* 
00241            * All frequency components below params->fLower and above fn are set to zero  
00242            */
00243               signal->data[i] = 0.;
00244               signal->data[n-i] = 0.;
00245             
00246           }
00247           else
00248           {
00249           /* What shall we put for sign phi? for uspa it must be "-" */
00250            
00251             psi = (shift*f + phi + params->psi0*pow(f,-Fiveby3) + params->psi3*pow(f,-Twoby3)); 
00252             modphase = params->beta * pow(f,-Twoby3);  
00253             
00254             ampRe = amp0 * pow(f,-Sevenby6) 
00255                          * (params->alpha1 
00256                          + (params->alpha2 * cos(modphase)) 
00257                          + (params->alpha3 * sin(modphase)));
00258             ampIm = amp0 * pow(f,-Sevenby6) 
00259                          * (params->alpha4 
00260                          + (params->alpha5 * cos(modphase)) 
00261                          + (params->alpha6 * sin(modphase)));
00262                       
00263             signal->data[i]   = (REAL4) ((ampRe * cos(psi)) - (ampIm * sin(psi)));
00264             signal->data[n-i] = (REAL4) -1.*((ampRe * sin(psi)) + (ampIm * cos(psi)));
00265           }
00266   }
00267 
00268   params->fFinal = params->fCutoff;
00269 
00270   DETATCHSTATUSPTR(status);
00271   RETURN(status);
00272 }

Generated on Tue Oct 14 02:31:54 2008 for LAL by  doxygen 1.5.2