RingTest.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Bernd Machenschalk, Jolien Creighton
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="RingTestCV">
00021  * Author: Jolien Creighton
00022  * $Id: RingTest.c,v 1.3 2007/06/08 14:41:52 bema Exp $
00023  **** </lalVerbatim> */
00024 
00025 /**** <lalLaTeX>
00026  * \subsection{Program \texttt{RingTest.c}}
00027  * 
00028  * Calls the various routines in \verb+Ring.h+.
00029  *
00030  * \subsubsection*{Usage}
00031  *
00032  * \begin{verbatim}
00033  * RingTest
00034  * \end{verbatim}
00035  *
00036  * \subsubsection*{Description}
00037  *
00038  * The program creates a ring template, which is output to the file
00039  * \verb+ring.out+, and a black hole ring waveform, which is output to the
00040  * file \verb+bhring.out+.  The program then generates a template bank,
00041  * which is written to the file \verb+bank.out+.
00042  * 
00043  * \vfill{\footnotesize\input{RingTestCV}}
00044  **** </lalLaTeX> */
00045 
00046 #include <stdio.h>
00047 #include <stdlib.h>
00048 #include <math.h>
00049 #include <lal/LALStdlib.h>
00050 #include <lal/LALConstants.h>
00051 #include <lal/AVFactories.h>
00052 #include <lal/Ring.h>
00053 
00054 NRCSID (RINGTESTC,"$Id: RingTest.c,v 1.3 2007/06/08 14:41:52 bema Exp $");
00055 
00056 #define TestStatus( ps ) \
00057   if ( (ps)->statusCode ) { \
00058     fprintf( stderr, "Failed LAL routine near line %d\n", __LINE__ ); \
00059     exit( 1 ); \
00060   } else ((void)0)
00061 
00062 int lalDebugLevel = LALMSGLVL3;
00063 
00064 int main( void )
00065 {
00066   const UINT4 npts = 4096;
00067   const REAL4 srate = 2048;
00068   static LALStatus status;
00069   static REAL4TimeSeries ring;
00070   static RingTemplateInput tmplt;
00071   static BlackHoleRingInput bhring;
00072   static RingTemplateBank *bank;
00073   static RingTemplateBankInput bankin;
00074 
00075   UINT4 i;
00076   FILE *fp;
00077 
00078 
00079   LALCreateVector( &status, &ring.data, npts );
00080   TestStatus( &status );
00081   ring.deltaT = 1 / srate;
00082 
00083   tmplt.frequency = 10;
00084   tmplt.quality = 10;
00085 
00086   LALComputeRingTemplate( &status, &ring, &tmplt );
00087   TestStatus( &status );
00088   
00089   fp = fopen( "ring.out", "w" );
00090   for ( i = 0; i < ring.data->length; ++i )
00091     fprintf( fp, "%e\t%e\t%e\n", i * ring.deltaT, ring.data->data[i],
00092         sqrt( 2 * LAL_PI )
00093         * exp( - LAL_PI * tmplt.frequency * ring.deltaT * i / tmplt.quality )
00094         * cos( 2 * LAL_PI * tmplt.frequency * ring.deltaT * i ) );
00095   fclose( fp );
00096 
00097   bhring.solarMasses = 100;
00098   bhring.dimensionlessSpin = 0.98;
00099   bhring.percentMassLoss = 1;
00100   bhring.distanceMpc = 1;
00101 
00102   LALComputeBlackHoleRing( &status, &ring, &bhring );
00103   TestStatus( &status );
00104 
00105   fp = fopen( "bhring.out", "w" );
00106   for ( i = 0; i < ring.data->length; ++i )
00107     fprintf( fp, "%e\t%e\n", i * ring.deltaT, ring.data->data[i] );
00108   fclose( fp );
00109 
00110   bankin.minFrequency = 100;
00111   bankin.maxFrequency = 500;
00112   bankin.minQuality = 2;
00113   bankin.maxQuality = 20;
00114   bankin.maxMismatch = 0.03;
00115 
00116   LALCreateRingTemplateBank( &status, &bank, &bankin );
00117   TestStatus( &status );
00118   fp = fopen( "bank.out", "w" );
00119   for ( i = 0; i < bank->numTmplt; ++i )
00120     fprintf( fp, "%e\t%e\n", bank->tmplt[i].frequency, bank->tmplt[i].quality );
00121   fclose( fp );
00122 
00123   LALDestroyRingTemplateBank( &status, &bank );
00124   TestStatus( &status );
00125   LALDestroyVector( &status, &ring.data );
00126   TestStatus( &status );
00127 
00128   LALCheckMemoryLeaks();
00129   return 0;
00130 }

Generated on Sat Aug 30 03:13:08 2008 for LAL by  doxygen 1.5.2