GenerateInspiral.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Stas Babak, Drew Keppel, Duncan Brown, Eirini Messaritaki, Gareth Jones, 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 #if 0
00021 <lalVerbatim file="GenerateInspiralCV">
00022 Author: Thomas Cokelaer
00023 $Id: GenerateInspiral.c,v 1.34 2008/08/18 10:00:53 mckechan Exp $
00024 </lalVerbatim>
00025 #endif
00026 
00027 #if 0
00028 <lalLaTeX>
00029 \subsection{Module \texttt{GenerateInspiral.c}}
00030 \label{ss:GenerateInspiral.c}
00031 \noindent Generates a CoherentGW inspiral waveform for injection.
00032 
00033 \subsubsection*{Prototypes}
00034 \vspace{0.1in}
00035 \input{LALGenerateInspiralCP}
00036 \input{LALGetApproxFromStringCP}
00037 \input{LALGetOrderFromStringCP}
00038 \input{LALGenerateInspiralPopulatePPNCP}
00039 \input{LALGenerateInspiralPopulateInspiralCP}
00040 
00041 
00042 \idx{LALGenerateInspiral}
00043 \idx{LALGetApproxFromString}
00044 \idx{LALGetOrderFromString}
00045 \idx{LALGenerateInspiralPopulatePPN}
00046 \idx{LALGenerateInspiralPopulateInspiral}
00047 
00048 
00049 \begin{description}
00050 \item[\texttt{LALGenerateInspiral()}] create an inspiral binary
00051 waveform generated either by the \texttt{inspiral} package (EOB,
00052 EOBNR, PadeT1, TaylorT1, TaylorT2, TaylorT3, SpinTaylor) or the
00053 \texttt{inject} package (GeneratePPN).  It is used in the module
00054 \texttt{FindChirpSimulation} in \texttt{findchirp} package.
00055  
00056 There are three  parsed arguments
00057 \begin{itemize}
00058 \item a \texttt{CoherentGW}  structure which stores amplitude, 
00059 frequency and phase of the  waveform (output)
00060 \item a \texttt{thisEvent}  structure which provides some 
00061 waveform parameters (input)
00062 \item a \texttt{PPNParamStruc} which gives some input 
00063 parameters needed by the GeneratePPN waveform  generation. That 
00064 arguments is also used as an output by all the different
00065 approximant  (output/input).
00066 \end{itemize}
00067 
00068 The input must be composed of a valid thisEvent structure as well as 
00069 the  variable deltaT of the PPNparamsStruct. All others variables 
00070 of the PPNParamStruc are populated within that function.
00071 
00072 \item[\texttt{LALGetOrderFromString()}] convert a string  
00073 provided by the \texttt{CoherentGW} structure in order to retrieve the 
00074 order of the waveform to generate. 
00075 
00076 \item[\texttt{LALGetApproximantFromString()}] convert a string  
00077 provided by the \texttt{CoherentGW} structure in order to retrieve the 
00078 approximant of the waveform to generate. 
00079 
00080 \item[\texttt{LALGenerateInspiralPopulatePPN()}] Populate the 
00081 PPNParamsStruc with the input argument \texttt{thisEvent}. That 
00082 structure is used by both inspiral waveforms inject waveforms.
00083 
00084 \item[\texttt{LALGenerateInspiralPopulateInspiral()}]  Populate the 
00085 InspiralTemplate structure if the model chosen belongs to the 
00086 inspiral package.
00087 
00088 \end{description}
00089 
00090 \subsubsection*{Algorithm}
00091 \noindent None.
00092 
00093 \subsubsection*{Notes}
00094 Inject only time-domain waveforms for the time being such as GeneratePPN, 
00095 TaylorT1, TaylorT2, TaylorT3, PadeT1 and EOB , Spintaylor..
00096 \subsubsection*{Uses}
00097 \begin{verbatim}
00098 None.
00099 \end{verbatim}
00100   
00101 \vfill{\footnotesize\input{GenerateInspiralCV}}
00102 </lalLaTeX> 
00103 #endif
00104 
00105 #include <lal/LALInspiral.h>
00106 #include <lal/LALStdlib.h>
00107 #include <lal/GenerateInspiral.h>
00108 #include <lal/GeneratePPNInspiral.h>
00109 #include <lal/SeqFactories.h>
00110 #include <lal/Units.h>
00111 
00112 NRCSID( GENERATEINSPIRALC,
00113 "$Id: GenerateInspiral.c,v 1.34 2008/08/18 10:00:53 mckechan Exp $" );
00114 
00115 /* <lalVerbatim file="LALGenerateInspiralCP"> */
00116 void 
00117 LALGenerateInspiral(
00118     LALStatus           *status,
00119     CoherentGW          *waveform,
00120     SimInspiralTable    *thisEvent,
00121     PPNParamStruc       *ppnParams
00122     )
00123 /* </lalVerbatim> */
00124 {
00125   Order             order;              /* Order of the model             */
00126   Approximant       approximant;        /* And its approximant value      */
00127   InspiralTemplate  inspiralParams;     /* structure for inspiral package */
00128   CHAR              warnMsg[1024];
00129 
00130   INITSTATUS(status, "LALGenerateInspiral",GENERATEINSPIRALC);
00131   ATTATCHSTATUSPTR(status);
00132 
00133   ASSERT(thisEvent, status,
00134       GENERATEINSPIRALH_ENULL, GENERATEINSPIRALH_MSGENULL);
00135 
00136   /* read the event waveform approximant and order */
00137   LALGetApproximantFromString(status->statusPtr, thisEvent->waveform,
00138       &approximant);
00139   CHECKSTATUSPTR(status);
00140 
00141   LALGetOrderFromString(status->statusPtr, thisEvent->waveform, &order);
00142   CHECKSTATUSPTR(status);
00143 
00144   /* when entering here, approximant is in principle well defined.  */
00145   /* We dont need any else if or ABORT in the if statement.         */
00146   /* Depending on the apporixmant we use inject or inspiral package */
00147   if ( approximant == GeneratePPN )
00148   {
00149     /* fill structure with input parameters */
00150     LALGenerateInspiralPopulatePPN(status->statusPtr, ppnParams, thisEvent);
00151     CHECKSTATUSPTR(status);
00152 
00153     /* generate PPN waveform */
00154     LALGeneratePPNInspiral(status->statusPtr, waveform, ppnParams);
00155     CHECKSTATUSPTR(status);
00156   }
00157   else if ( approximant == AmpCorPPN )
00158   {
00159     int i;
00160 
00161     /* fill structure with input parameters */
00162     LALGenerateInspiralPopulatePPN(status->statusPtr, ppnParams, thisEvent);
00163     CHECKSTATUSPTR(status);
00164 
00165     /* PPN parameter. */
00166     ppnParams->ppn = NULL;
00167     LALSCreateVector( status->statusPtr, &(ppnParams->ppn), order + 1 );
00168     ppnParams->ppn->length = order + 1;
00169     
00170     ppnParams->ppn->data[0] = 1.0;
00171     if ( order > 0 )
00172     {
00173       ppnParams->ppn->data[1] = 0.0;
00174       for ( i = 2; i <= (INT4)( order ); i++ )
00175       {  
00176         ppnParams->ppn->data[i] = 1.0;
00177       }
00178     }
00179     
00180     /* generate PPN waveform */
00181     LALGeneratePPNAmpCorInspiral(status->statusPtr, waveform, ppnParams);
00182     CHECKSTATUSPTR(status);
00183     
00184     LALSDestroyVector(status->statusPtr, &(ppnParams->ppn) );
00185     CHECKSTATUSPTR(status);
00186   }
00187   else
00188   {
00189     inspiralParams.approximant = approximant;
00190     inspiralParams.order       = order;
00191 
00192     /* We fill ppnParams */
00193     LALGenerateInspiralPopulatePPN(status->statusPtr, ppnParams, thisEvent);
00194     CHECKSTATUSPTR(status);
00195 
00196     /* we fill inspiralParams structure as well.*/
00197     LALGenerateInspiralPopulateInspiral(status->statusPtr, &inspiralParams,
00198         thisEvent, ppnParams);
00199     CHECKSTATUSPTR(status);
00200 
00201     /* the waveform generation itself */
00202     LALInspiralWaveForInjection(status->statusPtr, waveform, &inspiralParams,
00203         ppnParams);
00204     /* we populate the simInspiral table with the fFinal needed for 
00205        template normalisation. */
00206     thisEvent->f_final = inspiralParams.fFinal;
00207     CHECKSTATUSPTR(status);
00208   }
00209 
00210   /* If no waveform has been generated. (AmpCorPPN fills waveform.h) */
00211   if ( waveform->a == NULL && approximant != AmpCorPPN )
00212   {     
00213     LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00214         "No waveform generated (check lower frequency)\n");
00215     LALInfo( status, warnMsg );
00216     ABORT( status, LALINSPIRALH_ENOWAVEFORM, LALINSPIRALH_MSGENOWAVEFORM );
00217   }
00218 
00219 
00220   /* If sampling problem. (AmpCorPPN may not be compatible) */
00221   if ( ppnParams->dfdt > 2.0 && approximant != AmpCorPPN )
00222   {
00223     LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00224         "Waveform sampling interval is too large:\n"
00225         "\tmaximum df*dt = %f", ppnParams->dfdt );
00226     LALInfo( status, warnMsg );
00227     ABORT( status, GENERATEINSPIRALH_EDFDT, GENERATEINSPIRALH_MSGEDFDT );
00228   }
00229 
00230   /* Some info should add everything (spin and so on) */
00231   LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00232       "Injected waveform parameters:\n"
00233       "ppnParams->mTot\t= %"LAL_REAL4_FORMAT"\n"
00234       "ppnParams->eta\t= %"LAL_REAL4_FORMAT"\n"
00235       "ppnParams->d\t= %"LAL_REAL4_FORMAT"\n"
00236       "ppnParams->inc\t= %"LAL_REAL4_FORMAT"\n"
00237       "ppnParams->phi\t= %"LAL_REAL4_FORMAT"\n"
00238       "ppnParams->psi\t= %"LAL_REAL4_FORMAT"\n"
00239       "ppnParams->fStartIn\t= %"LAL_REAL4_FORMAT"\n"
00240       "ppnParams->fStopIn\t= %"LAL_REAL4_FORMAT"\n"
00241       "ppnParams->position.longitude\t= %"LAL_REAL8_FORMAT"\n"
00242       "ppnParams->position.latitude\t= %"LAL_REAL8_FORMAT"\n"
00243       "ppnParams->position.system\t= %d\n"
00244       "ppnParams->epoch.gpsSeconds\t= %"LAL_INT4_FORMAT"\n" 
00245       "ppnParams->epoch.gpsNanoSeconds\t= %"LAL_INT4_FORMAT"\n"
00246       "ppnParams->tC\t= %"LAL_REAL8_FORMAT"\n"
00247       "ppnParams->dfdt\t =%"LAL_REAL4_FORMAT"\n", 
00248       ppnParams->mTot, 
00249       ppnParams->eta, 
00250       ppnParams->d,
00251       ppnParams->inc,
00252       ppnParams->phi,
00253       ppnParams->psi, 
00254       ppnParams->fStartIn,
00255       ppnParams->fStopIn,       
00256       ppnParams->position.longitude,
00257       ppnParams->position.latitude,
00258       ppnParams->position.system,
00259       ppnParams->epoch.gpsSeconds,      
00260       ppnParams->epoch.gpsNanoSeconds,
00261       ppnParams->tc,
00262       ppnParams->dfdt );
00263   LALInfo( status, warnMsg );
00264 
00265   DETATCHSTATUSPTR( status );
00266   RETURN( status );
00267 }
00268 
00269 
00270 /* <lalVerbatim file="LALGetOrderFromStringCP"> */
00271 void 
00272 LALGetOrderFromString(
00273     LALStatus *status,
00274     CHAR      *thisEvent,
00275     Order     *order
00276     )
00277 /* </lalVerbatim> */
00278 {
00279   CHAR  warnMsg[1024];
00280 
00281   INITSTATUS( status, "LALGetOrderFromString", GENERATEINSPIRALC );
00282   ATTATCHSTATUSPTR( status );
00283   
00284   ASSERT( thisEvent, status, 
00285       GENERATEINSPIRALH_ENULL, GENERATEINSPIRALH_MSGENULL );
00286  
00287   if ( strstr(thisEvent, "newtonian") )
00288   {
00289     *order = newtonian;
00290   }
00291   else if ( strstr(thisEvent, "oneHalfPN") )
00292   {
00293     *order = oneHalfPN;
00294   }
00295   else if ( strstr(thisEvent, "onePN") )
00296   {
00297     *order = onePN;
00298   }
00299   else if ( strstr(thisEvent, "onePointFivePN") )
00300   {
00301     *order = onePointFivePN;
00302   }
00303   else if ( strstr(thisEvent, "twoPN") )
00304   {
00305     *order = twoPN;
00306   }
00307   else if ( strstr(thisEvent, "twoPointFivePN") )
00308   {
00309     *order = twoPointFivePN;
00310   }
00311   else if (strstr(thisEvent, "threePN") )
00312   {
00313     *order = threePN;
00314   }
00315   else if ( strstr(thisEvent,   "threePointFivePN") )
00316   {
00317     *order = threePointFivePN;
00318   }
00319   else if ( strstr(thisEvent,   "pseudoFourPN") )
00320   {
00321     *order = pseudoFourPN;
00322   }
00323   else
00324   {
00325     LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00326         "Cannot parse order from string: %s\n", thisEvent );
00327     LALInfo( status, warnMsg );
00328     ABORT(status, LALINSPIRALH_EORDER, LALINSPIRALH_MSGEORDER);
00329   }
00330   
00331   DETATCHSTATUSPTR( status );
00332   RETURN( status );
00333 }
00334 
00335 
00336 /* <lalVerbatim file="LALGetApproxFromStringCP"> */
00337 void 
00338 LALGetApproximantFromString(
00339     LALStatus   *status,
00340     CHAR        *thisEvent,
00341     Approximant *approximant
00342     )
00343 /* </lalVerbatim> */
00344 {
00345   /* Function to search for the approximant into a string */
00346   CHAR warnMsg[1024];
00347 
00348   INITSTATUS( status, "LALGenerateInspiralGetApproxFromString",
00349       GENERATEINSPIRALC );
00350   ATTATCHSTATUSPTR( status );
00351 
00352   ASSERT( thisEvent, status,
00353       GENERATEINSPIRALH_ENULL, GENERATEINSPIRALH_MSGENULL );
00354 
00355   if ( strstr(thisEvent, "TaylorT1" ) )
00356   {
00357     *approximant = TaylorT1;
00358   }
00359   else if ( strstr(thisEvent, "TaylorT2" ) )
00360   {
00361     *approximant = TaylorT2;
00362   }
00363   else if ( strstr(thisEvent, "TaylorT3" ) )
00364   {
00365     *approximant = TaylorT3;
00366   }
00367   else if ( strstr(thisEvent, "EOBNR" ) )
00368   {
00369     *approximant = EOBNR;
00370   }
00371   else if ( strstr(thisEvent, "EOB" ) )
00372   {
00373     *approximant = EOB;
00374   }
00375   else if ( strstr(thisEvent, "SpinTaylor" ) )
00376   {
00377     *approximant = SpinTaylor;
00378   }
00379   else if ( strstr(thisEvent, "PadeT1" ) )
00380   {
00381     *approximant = PadeT1;
00382   }
00383   else if ( strstr(thisEvent, "AmpCorPPN" ) )
00384   {
00385     *approximant = AmpCorPPN;
00386   }
00387   else if ( strstr(thisEvent, "GeneratePPN" ) )
00388   {
00389     *approximant = GeneratePPN;
00390   }
00391   else if ( strstr(thisEvent, "NumRel" ) )
00392   {
00393     *approximant = NumRel;
00394   }
00395   else
00396   {
00397     LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00398         "Cannot parse approximant from string: %s \n", thisEvent );
00399     LALInfo( status, warnMsg );
00400     ABORT( status, LALINSPIRALH_EAPPROXIMANT, LALINSPIRALH_MSGEAPPROXIMANT );
00401   }
00402 
00403   DETATCHSTATUSPTR( status );
00404   RETURN( status );
00405 }
00406 
00407 
00408 /* <lalVerbatim file="LALGenerateInspiralPopulatePPNCP"> */
00409 void
00410 LALGenerateInspiralPopulatePPN(
00411     LALStatus             *status,
00412     PPNParamStruc         *ppnParams,
00413     SimInspiralTable      *thisEvent
00414     )
00415 /* </lalVerbatim> */
00416 {
00417   CHAR warnMsg[1024];
00418 
00419   INITSTATUS( status, "LALGenerateInspiralPopulatePPN", GENERATEINSPIRALC );
00420   ATTATCHSTATUSPTR( status );
00421 
00422   /* input fields */
00423   ppnParams->mTot     = thisEvent->mass1 + thisEvent->mass2;
00424   ppnParams->eta      = thisEvent->eta;
00425   ppnParams->d        = thisEvent->distance* 1.0e6 * LAL_PC_SI; /*in Mpc*/
00426   ppnParams->inc      = thisEvent->inclination;
00427   ppnParams->phi      = thisEvent->coa_phase;
00428   ppnParams->ampOrder = thisEvent->amp_order;
00429 
00430   /* frequency cutoffs */
00431   if ( thisEvent->f_lower > 0 )
00432   {
00433     ppnParams->fStartIn = thisEvent->f_lower;
00434   }
00435   else
00436   {
00437     LALSnprintf( warnMsg, sizeof(warnMsg)/sizeof(*warnMsg),
00438         "f_lower must be specified in the injection file generation.\n" );
00439     LALInfo( status, warnMsg );
00440     ABORT( status, LALINSPIRALH_EFLOWERINJ, LALINSPIRALH_MSGEFLOWERINJ );
00441   }
00442   ppnParams->fStopIn  = -1.0 /
00443     (6.0 * sqrt(6.0) * LAL_PI * ppnParams->mTot * LAL_MTSUN_SI);
00444 
00445   /* passed fields */
00446   ppnParams->position.longitude   = thisEvent->longitude;
00447   ppnParams->position.latitude    = thisEvent->latitude;
00448   ppnParams->position.system      = COORDINATESYSTEM_EQUATORIAL;
00449   ppnParams->psi                  = thisEvent->polarization;
00450   ppnParams->epoch.gpsSeconds     = 0;
00451   ppnParams->epoch.gpsNanoSeconds = 0;
00452 
00453   DETATCHSTATUSPTR( status );
00454   RETURN( status );
00455 }
00456 
00457 
00458 /* <lalVerbatim file="LALGenerateInspiralPopulateInspiralCP"> */
00459 void 
00460 LALGenerateInspiralPopulateInspiral(
00461     LALStatus           *status,
00462     InspiralTemplate    *inspiralParams,
00463     SimInspiralTable    *thisEvent,
00464     PPNParamStruc       *ppnParams
00465     )
00466      
00467 /* </lalVerbatim> */
00468 {
00469   INITSTATUS( status, "LALGenerateInspiralPopulateInspiral",
00470       GENERATEINSPIRALC );
00471   ATTATCHSTATUSPTR( status );
00472 
00473   /* --- Let's fill the inspiral structure now --- */
00474   inspiralParams->mass1   =  thisEvent->mass1;          /* masses 1 */
00475   inspiralParams->mass2   =  thisEvent->mass2;          /* masses 2 */
00476   inspiralParams->fLower  =  ppnParams->fStartIn; /* lower cutoff frequency */
00477   inspiralParams->fCutoff = 1./ (ppnParams->deltaT)/2.-1; 
00478 
00479   /* -1 to be  in agreement with the inspiral assert. */
00480   inspiralParams->tSampling       = 1./ (ppnParams->deltaT); /* sampling*/
00481   inspiralParams->signalAmplitude = 1.;
00482   inspiralParams->distance        =  thisEvent->distance * LAL_PC_SI * 1e6;
00483  
00484   /* distance in Mpc */
00485   inspiralParams->startTime       =  0.0;
00486   inspiralParams->startPhase      =  thisEvent->coa_phase;
00487   inspiralParams->startPhase      = 0.0;
00488 
00489   inspiralParams->OmegaS = GENERATEINSPIRAL_OMEGAS;/* EOB 3PN contribution */
00490   inspiralParams->Theta  = GENERATEINSPIRAL_THETA; /* EOB 3PN contribution */
00491   inspiralParams->Zeta2  = GENERATEINSPIRAL_ZETA2; /* EOB 3PN contribution */
00492 
00493   inspiralParams->alpha  = -1.;      /* bcv useless for the time being */
00494   inspiralParams->psi0   = -1.;      /* bcv useless for the time being */
00495   inspiralParams->psi3   = -1.;      /* bcv useless for the time being */
00496   inspiralParams->alpha1 = -1.;      /* bcv useless for the time being */
00497   inspiralParams->alpha2 = -1.;      /* bcv useless for the time being */
00498   inspiralParams->beta   = -1.;      /* bcv useless for the time being */
00499 
00500   /* inclination of the binary */
00501   /* inclination cannot be equal to zero for SpinTaylor injections */
00502   if ( inspiralParams->approximant == SpinTaylor && thisEvent->inclination == 0 )
00503   {
00504     ABORT( status, GENERATEINSPIRALH_EZERO, GENERATEINSPIRALH_MSGEZERO );
00505   }
00506   inspiralParams->inclination =  thisEvent->inclination;
00507 
00508   inspiralParams->ieta      =  1;
00509   inspiralParams->nStartPad =  0;
00510   /* increased end padding from zero so that longer waveforms do not
00511   have errors due to underestimation of number of bins requred */
00512   inspiralParams->nEndPad   =  16384;
00513 
00514   inspiralParams->massChoice  = m1Andm2;
00515 
00516   /* spin parameters */
00517   inspiralParams->sourceTheta = GENERATEINSPIRAL_SOURCETHETA;
00518   inspiralParams->sourcePhi   = GENERATEINSPIRAL_SOURCEPHI;
00519   inspiralParams->spin1[0]    = thisEvent->spin1x;
00520   inspiralParams->spin2[0]    = thisEvent->spin2x;
00521   inspiralParams->spin1[1]    = thisEvent->spin1y;
00522   inspiralParams->spin2[1]    = thisEvent->spin2y;
00523   inspiralParams->spin1[2]    = thisEvent->spin1z;
00524   inspiralParams->spin2[2]    = thisEvent->spin2z;
00525 
00526   inspiralParams->orbitTheta0 = thisEvent->theta0;
00527   inspiralParams->orbitPhi0   = thisEvent->phi0;
00528 
00529   DETATCHSTATUSPTR( status );
00530   RETURN( status );
00531 }

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