Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
XLALSimBurstCherenkovRadiationTest.c
Go to the documentation of this file.
1#include <math.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <stdbool.h>
6
7#include <lal/Date.h>
8#include <lal/LALSimulation.h>
9#include <lal/LALSimBurst.h>
10#include <lal/TimeSeries.h>
11#include <lal/Units.h>
12
13#define DELTA_T (1.0 / 16384) /* seconds */
14#define SOURCE_LENGTH 642. /* metre */
15
16/* In some error, the hplus wave only takes 0, and this is the test to check hplus surely has some value. */
17static int check_nonzero(REAL8TimeSeries **target){
18 unsigned i;
19
20 for(i=0; i<(*target)->data->length; i++){
21 if((*target)->data->data[i] != 0){
22 return 1;
23 }
24 }
25 return 0;
26}
27
28/* hcross must only get the value of 0, and this test return 0 if hcross has nonzero value. */
29static int check_zero(REAL8TimeSeries **target){
30 unsigned i;
31
32 for(i=0; i<(*target)->data->length; i++){
33 if((*target)->data->data[i] != 0){
34 return 0;
35 }
36 }
37 return 1;
38}
39
40
41/* If the spectrum of low freauency is too influential to the waveform, the waveform becomes only taking
42 * positve value although it unlikes the wave form of Cherenkov Burst. This test return 0 if the wave
43 * only gets positive value. */
44static int check_positive(REAL8TimeSeries **target){
45 unsigned i;
46
47 for(i=0; i<(*target)->data->length; i++){
48 if((*target)->data->data[i] < 0){
49 return 1;
50 }
51 }
52 return 0;
53}
54
55/* Perforiming the tests above. */
56static int TestWaveform(void)
57{
58 REAL8TimeSeries *hplus = NULL, *hcross = NULL;
59 double dE_over_dA = 1.;
60 int ret = XLALSimBurstCherenkovRadiation(&hplus,&hcross,SOURCE_LENGTH,dE_over_dA,DELTA_T);
61 if(ret != XLAL_SUCCESS){
64 }
65 else if(check_nonzero(&hplus) || check_zero(&hcross) || check_positive(&hplus)){
66 fprintf(stderr, "error waveform");
69
70 return 0;
71 }
72 return 1;
73
74}
75
76int main(void)
77{
78 return TestWaveform();
79}
#define fprintf
static int TestWaveform(void)
static int check_zero(REAL8TimeSeries **target)
static int check_nonzero(REAL8TimeSeries **target)
static int check_positive(REAL8TimeSeries **target)
double i
Definition: bh_ringdown.c:118
int XLALSimBurstCherenkovRadiation(REAL8TimeSeries **hplus, REAL8TimeSeries **hcross, double source_length, double dE_over_dA, double deltaT)
Generates Cherenkov like waveforms.
Definition: LALSimBurst.c:1683
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
XLAL_SUCCESS