Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
TascPorbTiling.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 John T. Whelan
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20/**
21 * \author John T. Whelan
22 * \date 2019
23 * \file
24 * \brief Functions for tiling the orbital phase and period space for
25 * Sco X-1 and other binaries
26 */
27
28
29/*---------- INCLUDES ----------*/
30
31#include <config.h>
32#include <stdbool.h>
33#include <stdlib.h>
34#include <stdio.h>
35#include <float.h>
36#include <math.h>
37
38#include <gsl/gsl_math.h>
39#include <gsl/gsl_blas.h>
40#include <gsl/gsl_linalg.h>
41#include <gsl/gsl_eigen.h>
42#include <gsl/gsl_roots.h>
43
44#include <lal/TascPorbTiling.h>
45#include <lal/LALConstants.h>
46#include <lal/LogPrintf.h>
47
48#include <lal/GSLHelpers.h>
49
50/*---------- DEFINES ----------*/
51
52#ifdef __GNUC__
53#define UNUSED __attribute__ ((unused))
54#else
55#define UNUSED
56#endif
57
58// Square of a number
59#define SQR(x) ((x)*(x))
60
61// Real part of square root of a number, i.e. zero if x < ~0
62#define RE_SQRT(x) sqrt(GSL_MAX(DBL_EPSILON, (x)))
63
64typedef struct {
65 size_t tasc_dim;
66 int norb;
67 double T0p;
68 double P0;
69 double sigTp;
70 double pmsigT;
71 double sigP;
72 double ksq;
75
76static double PorbEllipticalBound(
77 const void *data,
78 const size_t dim UNUSED,
79 const gsl_matrix *cache UNUSED,
80 const gsl_vector *point
81)
82{
83
84 // Get bounds info
86
87 // Get current value of Tasc
88 const double Tasc = gsl_vector_get( point, info->tasc_dim );
89
90 double Tscaled = ( Tasc - info->T0p ) / info->sigTp;
91 double Pscaled = info->pmsigT * RE_SQRT( info->ksq - SQR( Tscaled ) ) / info->sigTp;
92 if ( !( info->sheared ) ) {
93 Pscaled += info->norb * info->sigP * Tscaled / info->sigTp;
94 }
95 // fprintf(stdout,"n=%d\n",info->norb);
96 // fprintf(stdout,"sigP=%g\n",info->sigP);
97 // fprintf(stdout,"sigTp=%g\n",info->sigTp);
98 // fprintf(stdout,"pmsigT=%g\n",info->pmsigT);
99 // fprintf(stdout,"Tscaled=%g\n",Tscaled);
100 // fprintf(stdout,"Pscaled=%g\n",Pscaled);
101 // fprintf(stdout,"Tasc = %.0f + %g\n",info->T0p,(Tasc-info->T0p));
102 // fprintf(stdout,"+/-sigT=%g\n", info->pmsigT);
103 // fprintf(stdout,"n*sigP*Tscaled/sigTp=%g\n",
104 // info->norb * info->sigP * Tscaled / info->sigTp);
105 // fprintf(stdout,"+/-sigT*sqrt(disc)/sigTp=%g\n",
106 // info->pmsigT * RE_SQRT( info->ksq - SQR(Tscaled) ) / info->sigTp);
107 // fprintf(stdout,"n*sigP/sigTp=%g\n",info->norb * info->sigP / info->sigTp);
108 // fprintf(stdout,"+/-sigT/sigTp=%g\n",info->pmsigT / info->sigTp);
109 // fprintf(stdout,"Porb bound = %g + %g\n",info->P0,info->sigP*Pscaled);
110
111 // Return bounds on Porb
112 return info->P0 + info->sigP * Pscaled;
113
114}
115
117 LatticeTiling *tiling,
118 const size_t tasc_dimension,
119 const size_t porb_dimension,
120 const double P0,
121 const double sigP,
122 const double T0,
123 const double sigT,
124 const int norb,
125 const double nsigma,
126 const BOOLEAN useShearedPeriod
127)
128{
129 // Check input
130 XLAL_CHECK( tiling != NULL, XLAL_EFAULT );
131 XLAL_CHECK( tasc_dimension < porb_dimension, XLAL_EINVAL );
132 XLAL_CHECK( nsigma >= 0.0, XLAL_EINVAL );
133 XLAL_CHECK( P0 > 0.0, XLAL_EINVAL );
134 XLAL_CHECK( sigP >= 0.0, XLAL_EINVAL );
135 XLAL_CHECK( T0 > 0.0, XLAL_EINVAL );
136 XLAL_CHECK( sigT >= 0.0, XLAL_EINVAL );
137
138 // Set the parameter-space bound
141 info_lower.tasc_dim = info_upper.tasc_dim = tasc_dimension;
142 info_lower.norb = info_upper.norb = norb;
143 info_lower.T0p = info_upper.T0p = T0 + norb * P0;
144 info_lower.P0 = info_upper.P0 = P0;
145 info_lower.sigTp = info_upper.sigTp = sqrt( SQR( sigT ) + SQR( norb ) * SQR( sigP ) );
146 info_lower.pmsigT = -sigT;
147 info_upper.pmsigT = sigT;
148 info_lower.sigP = info_upper.sigP = sigP;
149 info_lower.ksq = info_upper.ksq = SQR( nsigma );
150 info_lower.sheared = info_upper.sheared = useShearedPeriod;
151
152 XLAL_CHECK( XLALSetLatticeTilingBound( tiling, porb_dimension, PorbEllipticalBound, sizeof( info_lower ), &info_lower, &info_upper ) == XLAL_SUCCESS, XLAL_EFAILED );
153
154 return XLAL_SUCCESS;
155
156}
#define RE_SQRT(x)
int XLALSetLatticeTilingPorbEllipticalBound(LatticeTiling *tiling, const size_t tasc_dimension, const size_t porb_dimension, const double P0, const double sigP, const double T0, const double sigT, const int norb, const double nsigma, const BOOLEAN useShearedPeriod)
Set an orbital period as a function of time of ascension.
#define SQR(x)
static double PorbEllipticalBound(const void *data, const size_t dim UNUSED, const gsl_matrix *cache UNUSED, const gsl_vector *point)
unsigned char BOOLEAN
#define XLAL_INIT_DECL(var,...)
int XLALSetLatticeTilingBound(LatticeTiling *tiling, const size_t dim, const LatticeTilingBound func, const size_t data_len, const void *data_lower, const void *data_upper)
Set a parameter-space bound on a dimension of the lattice tiling.
#define XLAL_CHECK(assertion,...)
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EINVAL
XLAL_EFAILED
float data[BLOCKSIZE]
Definition: hwinject.c:360
int T0