00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
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 }