00001 /* 00002 * Copyright (C) 2007 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="LALInspiralInitCV"> 00021 Author: Cokelaer T. 00022 $Id: LALInspiralInit.c,v 1.5 2007/06/08 14:41:49 bema Exp $ 00023 </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 00027 \subsection{Module \texttt{LALInspiralInit.c}} 00028 Module to initialize some parameters for waveform generation. 00029 00030 \subsubsection*{Prototypes} 00031 \vspace{0.1in} 00032 \input{LALInspiralRestrictedInitCP} 00033 \idx{LALInspiralRestrictedInit()} 00034 00035 \subsubsection*{Description} 00036 The input parameters is an InspiralTemplate structure which provides the waveform parameters 00037 such as masses, lower frequency\dots The function \texttt{LALInspiralInit} calls the 00038 \texttt{LALInspiralParameterCalc} function in order to compute all the mass parameters. Then, 00039 \texttt{LALInspiralRestrictedAmplitude} function is called to get the restricted newtonian 00040 amplitude. LALInspiralWavelength, LALInspiralSetup and LALInspiralChooseModel are also called 00041 in order to estimate the waveform length which is stored in an output structure called 00042 \texttt{InspiralInit}. We also stored Energy, flux and evolution function of flux and energy in 00043 that structure. 00044 00045 The \texttt{LALInspiralChooseModel} function might failed or send a non zero status code. 00046 That function force it to be zero therefore the codes which use LALInspiralInit (mainly 00047 injection code right now) won't stopped. Of course, if status code is non zero, we have to keep 00048 trace of it. Thus, the length of the waveform is fixed to zero in case of problems such as 00049 negative length, cutoff frequency lower than the lower cutoff frequency \dots. 00050 00051 \subsubsection*{Uses} 00052 \texttt{LALInspiralParameterCalc}\\ 00053 \noindent\texttt{LALInspiralRestrictedAmplitude}\\ 00054 \noindent\texttt{LALInspiralWaveLength} 00055 \noindent\texttt{LALInspiralChooseModel} 00056 \noindent\texttt{LALInspiralSetup} 00057 00058 \subsubsection*{Notes} 00059 There is only one assert on the InspiralTemplate variable since all relevant asserts 00060 are already included in the different functions which are called throughout the LALInspiralInit 00061 function. 00062 \vfill{\footnotesize\input{LALInspiralInitCV}} 00063 </lalLaTeX> */ 00064 00065 00066 #include <lal/LALInspiral.h> 00067 #define LALINSPIRALINIT_LENGTHOVERESTIMATION 0.1 /* 10 % */ 00068 00069 NRCSID (LALINSPIRALAMPLITUDEC, "$Id: LALInspiralInit.c,v 1.5 2007/06/08 14:41:49 bema Exp $"); 00070 00071 /* <lalVerbatim file="LALInspiralRestrictedInitCP"> */ 00072 void 00073 LALInspiralInit (LALStatus *status, 00074 InspiralTemplate *params, 00075 InspiralInit *paramsInit) 00076 { /* </lalVerbatim> */ 00077 00078 UINT4 ndx; 00079 REAL8 x; 00080 CHAR message[256]; 00081 00082 INITSTATUS (status, "LALInspiralInit", LALINSPIRALAMPLITUDEC ); 00083 ATTATCHSTATUSPTR(status); 00084 00085 ASSERT( params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL ); 00086 00087 00088 LALInspiralParameterCalc(status->statusPtr, params); 00089 CHECKSTATUSPTR(status); 00090 00091 LALInspiralRestrictedAmplitude(status->statusPtr, params); 00092 CHECKSTATUSPTR(status); 00093 00094 LALInspiralSetup(status->statusPtr, &(paramsInit->ak), params); 00095 CHECKSTATUSPTR(status); 00096 00097 LALInspiralChooseModel(status->statusPtr, &(paramsInit->func), &(paramsInit->ak), params); 00098 00099 /* The parameters have been initialized now. However, we can have some problems 00100 with the LALInspiralChooseModel related to bad estimation of the length. 00101 00102 We first need to check that the length is not wrong. 00103 Then, to check that flso is > fLow 00104 00105 keep a security length higher than the one given by ChooseModel 00106 */ 00107 00108 if( params->fCutoff < params->fLower){ 00109 LALWarning(status, LALINSPIRALH_MSGEFLOWER); 00110 status->statusPtr->statusCode = 0; 00111 paramsInit->nbins = 0; 00112 00113 sprintf(message, "#Estimated Length (seconds) requested = %f | fCutoff = %f", 00114 paramsInit->ak.tn, params->fCutoff); 00115 LALInfo(status, message); 00116 00117 00118 DETATCHSTATUSPTR(status); 00119 RETURN(status); 00120 } 00121 00122 if( paramsInit->ak.tn <=0 || params->tC <= 0){ 00123 LALWarning(status, LALINSPIRALH_MSGESIZE); 00124 status->statusPtr->statusCode = 0; 00125 paramsInit->nbins = 0; 00126 sprintf(message, "#Estimated Length (seconds) requested = %f ", 00127 paramsInit->ak.tn); 00128 LALInfo(status, message); 00129 00130 DETATCHSTATUSPTR(status); 00131 RETURN(status); 00132 } 00133 00134 if (status->statusPtr->statusCode == 0){/* if everything is fine is ChooseModel then we 00135 estimate the waveform length. */ 00136 /*we add a minimal value and 10 % of overestimation */ 00137 x = (1.+ LALINSPIRALINIT_LENGTHOVERESTIMATION) 00138 * (paramsInit->ak.tn + 1 ) * params->tSampling 00139 + params->nStartPad + params->nEndPad ; 00140 ndx = ceil(log10(x)/log10(2.)); 00141 paramsInit->nbins = pow(2, ndx) ; 00142 00143 00144 /*now we can free memory */ 00145 CHECKSTATUSPTR(status); 00146 00147 sprintf(message, "#Estimated Length (seconds) = %f | Allocated length (bins) = %d", 00148 paramsInit->ak.tn, 00149 paramsInit->nbins); 00150 LALInfo(status, message); 00151 00152 00153 DETATCHSTATUSPTR(status); 00154 RETURN(status); 00155 } 00156 else { /*otherwise size is zero */ 00157 sprintf(message, 00158 "Can't get size of the following waveform: totalMass = %f, fLower = %f, approximant = %d @ %fPN" 00159 , params->mass1 + params->mass2, params->fLower, params->approximant, params->order/2.); 00160 LALWarning(status, message); 00161 00162 status->statusPtr->statusCode = 0; 00163 paramsInit->nbins = 0; 00164 00165 /*now we can free memory */ 00166 CHECKSTATUSPTR(status); 00167 00168 DETATCHSTATUSPTR(status); 00169 RETURN(status); 00170 } 00171 00172 } 00173
1.5.2