InspiralBankGeneration.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Chad Hanna, Duncan Brown, Benjamin Owen, B.S. Sathyaprakash, Anand Sengupta, Thomas Cokelaer, Evan Ochsner
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 
00021 
00022 #include<lal/LALStdlib.h>
00023 #include<lal/LALStatusMacros.h>
00024 #include<lal/LALInspiral.h>
00025 #include<lal/LALInspiralBank.h>
00026 #include<lal/LIGOMetadataTables.h>
00027 
00028 
00029 NRCSID(INSPIRALBANKGENERATIONC, "$Id: InspiralBankGeneration.c,v 1.37 2008/07/05 18:42:20 lppekows Exp $");
00030 
00031 void
00032 LALInspiralBankGeneration(
00033      LALStatus *status,
00034      InspiralCoarseBankIn *input,
00035      SnglInspiralTable **first,
00036      INT4 *ntiles )
00037 {
00038   InspiralTemplateList *coarseList = NULL;
00039   SnglInspiralTable *bank;
00040   InspiralMomentsEtc moments;
00041   INT4 cnt        = 0;
00042   REAL8 fFinal    = 0;
00043   REAL8 minfFinal = 0;
00044   REAL8 maxfFinal = 0;
00045   REAL8 q         = 0;
00046   INT4  chicnt    = 0;
00047   INT4  kappacnt  = 0;
00048   INT4  numTmplts = 0;
00049   INT4  i;
00050   REAL4 chi[3], kappa[4];
00051   
00052   INITSTATUS(status, "LALInspiralBankGeneration", INSPIRALBANKGENERATIONC);
00053   ATTATCHSTATUSPTR(status);
00054     
00055   ASSERT( input != NULL, status, LALINSPIRALBANKH_ENULL,
00056           LALINSPIRALBANKH_MSGENULL );
00057   ASSERT( *first == NULL, status, LALINSPIRALBANKH_ENULL,
00058           LALINSPIRALBANKH_MSGENULL );
00059   ASSERT( input->numFreqCut >= 1, status, LALINSPIRALBANKH_ENUMFCUT,
00060           LALINSPIRALBANKH_MSGENUMFCUT );
00061 
00062   
00063   
00064   /* For nonspinning approximants, call LALInspiralCreateCoarseBank(). */
00065   switch( input->approximant )
00066   {
00067   case BCV:
00068   case EOB:
00069   case EOBNR:
00070   case PadeT1:
00071   case PadeF1:
00072   case TaylorF1:
00073   case TaylorF2:
00074   case TaylorT1:
00075   case TaylorT2:
00076   case TaylorT3:
00077   case AmpCorPPN:
00078   case Eccentricity:
00079 
00080     /* Use LALInspiralCreateCoarseBank(). */
00081     TRY( LALInspiralCreateCoarseBank( status->statusPtr, &coarseList, ntiles,
00082          *input ), status );
00083     /* */ 
00084     /* Convert output data structure. */
00085     bank = (SnglInspiralTable *) LALCalloc(1, sizeof(SnglInspiralTable));
00086     if (bank == NULL){
00087       ABORT( status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM );
00088     }
00089     *first = bank;
00090     for( cnt = 0; cnt < *ntiles; cnt++ )
00091     {
00092       /* Set the min and max fFinals using the appropriate formula*/
00093       if( input->maxFreqCut == SchwarzISCO )
00094         {
00095           maxfFinal = 1.0 / (6.0 * sqrt(6.0)*LAL_PI
00096                       *coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00097         }
00098       else if( input->maxFreqCut == BKLISCO )
00099         {
00100           if( coarseList[cnt].params.mass1 > coarseList[cnt].params.mass2 )
00101             {
00102               q = coarseList[cnt].params.mass2 / coarseList[cnt].params.mass1;
00103             }
00104           else
00105               q = coarseList[cnt].params.mass1 / coarseList[cnt].params.mass2;
00106           maxfFinal = 1.0 / (6.0 * sqrt(6.0)*LAL_PI*coarseList[cnt].params.totalMass*LAL_MTSUN_SI) * ( 1 + 2.8*q - 2.6*q*q + 0.8*q*q*q );
00107         }
00108       else if( input->maxFreqCut == LightRing )
00109         {
00110           maxfFinal = 1.0 / (3.0 * sqrt(3.0)*LAL_PI
00111                       *coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00112         }
00113       else if( input->maxFreqCut == ERD )
00114         {
00115           maxfFinal = 1.07*0.5326/(2*LAL_PI*0.955*coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00116         }
00117       else if( input->maxFreqCut == FRD )
00118         {
00119           maxfFinal = ( 1. - 0.63*pow(1. - 3.4641016*coarseList[cnt].params.eta
00120                     + 2.9*coarseList[cnt].params.eta*coarseList[cnt].params.eta
00121                     , 0.3) )/( 2.*LAL_PI*(1. - 0.057191
00122                     *coarseList[cnt].params.eta - 0.498
00123                     *coarseList[cnt].params.eta*coarseList[cnt].params.eta)
00124                     *coarseList[cnt].params.totalMass*LAL_MTSUN_SI );
00125         }
00126       else if( input->maxFreqCut == LRD )
00127         {
00128           maxfFinal = 1.2* ( 1. - 0.63*pow(1. - 3.4641016*coarseList[cnt].params.eta
00129                     + 2.9*coarseList[cnt].params.eta*coarseList[cnt].params.eta
00130                     , 0.3) )/( 2.*LAL_PI*(1. - 0.057191
00131                     *coarseList[cnt].params.eta - 0.498
00132                     *coarseList[cnt].params.eta*coarseList[cnt].params.eta)
00133                     *coarseList[cnt].params.totalMass*LAL_MTSUN_SI );
00134         }
00135       else
00136         ABORT( status, LALINSPIRALBANKH_EFCUT, LALINSPIRALBANKH_MSGEFCUT );
00137 
00138       if( input->minFreqCut == SchwarzISCO )
00139         {
00140           minfFinal = 1.0 / (6.0 * sqrt(6.0)*LAL_PI
00141                       *coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00142         }
00143       else if( input->minFreqCut == BKLISCO )
00144         {
00145           if( coarseList[cnt].params.mass1 > coarseList[cnt].params.mass2 )
00146             {
00147               q = coarseList[cnt].params.mass2 / coarseList[cnt].params.mass1;
00148             }
00149           else
00150               q = coarseList[cnt].params.mass1 / coarseList[cnt].params.mass2;
00151           minfFinal = 1.0 / (6.0 * sqrt(6.0)*LAL_PI*coarseList[cnt].params.totalMass*LAL_MTSUN_SI) * ( 1 + 2.8*q - 2.6*q*q + 0.8*q*q*q );
00152         }
00153       else if( input->minFreqCut == LightRing )
00154         {
00155           minfFinal = 1.0 / (3.0 * sqrt(3.0)*LAL_PI
00156                       *coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00157         }
00158       else if( input->minFreqCut == ERD )
00159         {
00160           minfFinal = 1.07*0.5326/(2*LAL_PI*0.955*coarseList[cnt].params.totalMass*LAL_MTSUN_SI);
00161         }
00162       else if( input->minFreqCut == FRD )
00163         {
00164           minfFinal = ( 1. - 0.63*pow(1. - 3.4641016*coarseList[cnt].params.eta
00165                     + 2.9*coarseList[cnt].params.eta*coarseList[cnt].params.eta
00166                     , 0.3) )/( 2.*LAL_PI*(1. - 0.057191
00167                     *coarseList[cnt].params.eta - 0.498
00168                     *coarseList[cnt].params.eta*coarseList[cnt].params.eta)
00169                     *coarseList[cnt].params.totalMass*LAL_MTSUN_SI );
00170         }
00171       else if( input->minFreqCut == LRD )
00172         {
00173           minfFinal = 1.2* ( 1. - 0.63*pow(1. - 3.4641016*coarseList[cnt].params.eta
00174                     + 2.9*coarseList[cnt].params.eta*coarseList[cnt].params.eta
00175                     , 0.3) )/( 2.*LAL_PI*(1. - 0.057191
00176                     *coarseList[cnt].params.eta - 0.498
00177                     *coarseList[cnt].params.eta*coarseList[cnt].params.eta)
00178                     *coarseList[cnt].params.totalMass*LAL_MTSUN_SI );
00179         }
00180       else
00181         ABORT( status, LALINSPIRALBANKH_EFCUT, LALINSPIRALBANKH_MSGEFCUT );
00182 
00183       /* For 1 upper frequency cutoff, fill the bank as usual with the
00184        * specified fFinal (checked minFreqCut = maxFreqCut in tmpltbank.c)
00185        */
00186       if( input->numFreqCut == 1 )
00187         {
00188           bank = bank->next = (SnglInspiralTable *) LALCalloc( 1, sizeof(
00189              SnglInspiralTable ) );
00190           if (bank == NULL)
00191             {
00192               ABORT( status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM );
00193             }
00194           bank->mass1 = coarseList[cnt].params.mass1;
00195           bank->mass2 = coarseList[cnt].params.mass2;
00196           bank->mchirp = coarseList[cnt].params.chirpMass;
00197           bank->mtotal = coarseList[cnt].params.totalMass;
00198           bank->eta = coarseList[cnt].params.eta;
00199           bank->tau0 = coarseList[cnt].params.t0;
00200           bank->tau2 = coarseList[cnt].params.t2;
00201           bank->tau3 = coarseList[cnt].params.t3;
00202           bank->tau4 = coarseList[cnt].params.t4;
00203           bank->tau5 = coarseList[cnt].params.t5;
00204           bank->ttotal = coarseList[cnt].params.tC;
00205           bank->psi0 = coarseList[cnt].params.psi0;
00206           bank->psi3 = coarseList[cnt].params.psi3;
00207       
00208           /* If fFinal > fNyquist, end template at fNyquist */
00209           fFinal = minfFinal;
00210           if (fFinal > input->fUpper)
00211             {
00212               fFinal = input->fUpper;
00213             }
00214           coarseList[cnt].params.fFinal = fFinal;
00215     
00216           /* Update the Gamma parameter if requested, using the proper cut-off 
00217            * frequency */
00218           if ( input->computeMoments )
00219             {
00220               coarseList[cnt].params.fCutoff = coarseList[cnt].params.fFinal;
00221               LALGetInspiralMoments( status->statusPtr, &moments, &(input->shf), 
00222                                      &(coarseList[cnt].params) );
00223 
00224               LALInspiralComputeMetric(status->statusPtr, &(coarseList[cnt].metric),
00225                                        &(coarseList[cnt].params), &moments);
00226             }
00227 
00228 
00229           bank->f_final = coarseList[cnt].params.fFinal;
00230           bank->eta = coarseList[cnt].params.eta;
00231           bank->beta = coarseList[cnt].params.beta;
00232       
00233           /* Copy the 10 metric co-efficients ... */
00234           memcpy (bank->Gamma, coarseList[cnt].metric.Gamma, 10*sizeof(REAL4));
00235         }
00236 
00237       /* If we have multiple frequency cutoffs, create duplicate
00238        * templates evenly incremented between minfFinal and maxfFinal
00239        */
00240       else for( i = 0; i < input->numFreqCut; i++ )
00241       {
00242       bank = bank->next = (SnglInspiralTable *) LALCalloc( 1, sizeof(
00243              SnglInspiralTable ) );
00244       if (bank == NULL)
00245       {
00246         ABORT( status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM );
00247       }
00248       bank->mass1 = coarseList[cnt].params.mass1;
00249       bank->mass2 = coarseList[cnt].params.mass2;
00250       bank->mchirp = coarseList[cnt].params.chirpMass;
00251       bank->mtotal = coarseList[cnt].params.totalMass;
00252       bank->eta = coarseList[cnt].params.eta;
00253       bank->tau0 = coarseList[cnt].params.t0;
00254       bank->tau2 = coarseList[cnt].params.t2;
00255       bank->tau3 = coarseList[cnt].params.t3;
00256       bank->tau4 = coarseList[cnt].params.t4;
00257       bank->tau5 = coarseList[cnt].params.t5;
00258       bank->ttotal = coarseList[cnt].params.tC;
00259       bank->psi0 = coarseList[cnt].params.psi0;
00260       bank->psi3 = coarseList[cnt].params.psi3;
00261       
00262       /* This calucation is only valid for the PN case. For EOB, we 
00263        * should use the correct value of v (close to lightring). What 
00264        * about the amplitude corrected one ? */
00265       fFinal = minfFinal + i *
00266         (maxfFinal - minfFinal)/(input->numFreqCut - 1);
00267       if (fFinal > input->fUpper)
00268       {
00269         fFinal = input->fUpper;
00270       }
00271       coarseList[cnt].params.fFinal = fFinal;
00272     
00273       /* Update the Gamma parameter if requested, using the proper cut-off 
00274        * frequency */
00275       if ( input->computeMoments )
00276       {
00277         coarseList[cnt].params.fCutoff = coarseList[cnt].params.fFinal;
00278         LALGetInspiralMoments( status->statusPtr, &moments, &(input->shf), 
00279             &(coarseList[cnt].params) );
00280 
00281         LALInspiralComputeMetric(status->statusPtr, &(coarseList[cnt].metric),
00282             &(coarseList[cnt].params), &moments);
00283       }
00284 
00285 
00286       bank->f_final = coarseList[cnt].params.fFinal;
00287       bank->eta = coarseList[cnt].params.eta;
00288       bank->beta = coarseList[cnt].params.beta;
00289       
00290       /* Copy the 10 metric co-efficients ... */
00291       memcpy (bank->Gamma, coarseList[cnt].metric.Gamma, 10*sizeof(REAL4));
00292       }
00293       
00294     }
00295     /* Free first template, which is blank. */
00296     bank = (*first)->next;
00297     LALFree( *first );
00298     *first = bank;
00299     /* free the coarse list returned by create coarse bank */
00300     LALFree( coarseList );
00301     break;
00302   
00303   case FindChirpPTF:
00304     
00305     for (i=0; i<5; i++)
00306     {
00307       if ( i < 3 ) chi[i]     = 0.1 + i * 0.4 ;
00308       if ( i < 2 ) kappa[i]   = -0.9 + i * 0.4 ;
00309       if ( i > 2 ) kappa[i-1] = 0.5 + (i-3) * 0.4;
00310     }
00311     
00312     /* Use LALInspiralCreateCoarseBank(). */
00313     TRY( LALInspiralCreateCoarseBank( status->statusPtr, &coarseList, ntiles,
00314          *input ), status );
00315  
00316     /* Convert output data structure. */
00317     bank = (SnglInspiralTable *) LALCalloc(1, sizeof(SnglInspiralTable));
00318     if (bank == NULL){
00319       ABORT( status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM );
00320     }
00321     *first = bank;
00322 
00323     for ( chicnt = 0; chicnt < 3; chicnt++ )
00324     {
00325       for( kappacnt = 0; kappacnt < 4; kappacnt++ )
00326       {
00327         for( cnt = 0; cnt < *ntiles; cnt++ )
00328         {
00329           /* restrict the bank boundaries to the region of validity of PTF */
00330           if ( coarseList[cnt].params.mass1 < 6.0 || 
00331                coarseList[cnt].params.mass2 > 3.0 ) continue;
00332           bank = bank->next = (SnglInspiralTable *) LALCalloc( 1, sizeof(
00333                 SnglInspiralTable ) );
00334           if (bank == NULL)
00335           {
00336             ABORT( status, LALINSPIRALBANKH_EMEM, LALINSPIRALBANKH_MSGEMEM );
00337           }
00338           numTmplts     = numTmplts + 1 ;
00339           bank->mass1   = coarseList[cnt].params.mass1;
00340           bank->mass2   = coarseList[cnt].params.mass2;
00341           bank->mchirp  = coarseList[cnt].params.chirpMass;
00342           bank->mtotal  = coarseList[cnt].params.totalMass;
00343           bank->eta     = coarseList[cnt].params.eta;
00344           bank->kappa   = kappa[kappacnt];
00345           bank->chi     = chi[chicnt];
00346           bank->tau0    = coarseList[cnt].params.t0;
00347           bank->tau2    = coarseList[cnt].params.t2;
00348           bank->tau3    = coarseList[cnt].params.t3;
00349           bank->tau4    = coarseList[cnt].params.t4;
00350           bank->tau5    = coarseList[cnt].params.t5;
00351           bank->ttotal  = coarseList[cnt].params.tC;
00352           bank->psi0    = coarseList[cnt].params.psi0;
00353           bank->psi3    = coarseList[cnt].params.psi3;
00354           bank->f_final = coarseList[cnt].params.fFinal;
00355           bank->eta     = coarseList[cnt].params.eta;
00356           bank->beta    = coarseList[cnt].params.beta;
00357           
00358 
00359           /* Copy the 10 metric co-efficients ... */
00360           memcpy (bank->Gamma, coarseList[cnt].metric.Gamma, 10*sizeof(REAL4));
00361 
00362         }
00363       }
00364     }
00365 
00366     /* Free first template, which is blank. */
00367     bank = (*first)->next;
00368     LALFree( *first );
00369     *first = bank;
00370     /* free the coarse list returned by create coarse bank */
00371     LALFree( coarseList );
00372     *ntiles = numTmplts;
00373     break;
00374 
00375   case BCVSpin:
00376     if (input->spinBank==0)
00377     {
00378     /* Use LALInspiralSpinBank(); no need to convert output. */
00379     TRY( LALInspiralSpinBank( status->statusPtr, first, ntiles, input ),
00380          status );   
00381     }
00382     else if (input->spinBank==1)
00383     {
00384     /* For extended bank use LALInspiralBCVSpinBank() */
00385     /*
00386     TRY( LALInspiralBCVSpinBank( status->statusPtr, first, ntiles, input ),
00387          status );   
00388     */
00389     }
00390     else if (input->spinBank==2)
00391     {
00392     /* For extended bank use LALInspiralBCVSpinBank() */
00393     
00394     /*
00395     TRY( LALInspiralBCVSpinRandomBank( status->statusPtr, first, ntiles, input ),
00396          status );   
00397      */
00398      
00399     }
00400     else
00401     {
00402       ABORT( status, LALINSPIRALBANKH_ECHOICE, LALINSPIRALBANKH_MSGECHOICE );
00403     }
00404 
00405     if (*ntiles < 1){       
00406       ABORT( status, LALINSPIRALBANKH_ENULL, LALINSPIRALBANKH_MSGENULL );
00407     }
00408     break;
00409 
00410   default:
00411     ABORT( status, LALINSPIRALBANKH_ECHOICE, LALINSPIRALBANKH_MSGECHOICE );
00412 
00413   }
00414 
00415   DETATCHSTATUSPTR(status);
00416   RETURN(status); 
00417 }

Generated on Mon Oct 6 02:31:39 2008 for LAL by  doxygen 1.5.2