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
gte_and_other_methods.py
Go to the documentation of this file.
1# Copyright (C) 2019--2023 Benjamin Grace
2#
3# This program is free software; you can redistribute it and/or modify it
4# under the terms of the GNU General Public License as published by the
5# Free Software Foundation; either version 2 of the License, or (at your
6# option) any later version.
7#
8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11# Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along
14# with this program; if not, write to the Free Software Foundation, Inc.,
15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17## \file
18## \ingroup lalpulsar_python_piecewise_model
19"""
20Implementations of the general torque equation and other useful functions.
21"""
22
23import logging
24
25import numpy as np
26
27
28# The general torque equation we have formulated
29def gte(t, f0, ngte, kgte):
30 return f0 * (1 + (ngte - 1) * f0 ** (ngte - 1) * kgte * t) ** (1 / (1 - ngte))
31
32
33# Inverse of the GTE
34def gteinv(freq, f0, ngte, kgte):
35 return ((freq / f0) ** (1 - ngte) - 1) / ((ngte - 1) * f0 ** (ngte - 1) * kgte)
36
37
38# Returns value of kgte for a purely GW (ngte=5) source. Typical values: Izz \in [1, 3] * 10^38, ellip \in [1e-4, 1e-8].
39# Izz default value is the same as that from the long transient search paper. Defaults give kgte=1.7182e-20
40def kforGWsource(Izz=4.34e38, ellip=1e-4, radius=1e4):
41 c = 299792458
42 G = 6.6743e-11
43
44 numerator = 32 * G * Izz * np.pi**4 * ellip**2
45 denominator = 5 * c**5
46
47 return numerator / denominator # units: s^3
48
49
50# The matrix which transforms from the PW parameters to tref parameters
51def ParamTransformationMatrix(tstart, tend, reftime, s):
52
53 dt = tend - tstart
54 dref = reftime - tstart
55
56 if s == 3:
57 matrix = [
58 [
59 1
60 - (6 * dref**5) / dt**5
61 + (15 * dref**4) / dt**4
62 - (10 * dref**3) / dt**3,
63 dref
64 - (3 * dref**5) / dt**4
65 + (8 * dref**4) / dt**3
66 - (6 * dref**3) / dt**2,
67 dref**2 / 2.0
68 - dref**5 / (2.0 * dt**3)
69 + (3 * dref**4) / (2.0 * dt**2)
70 - (3 * dref**3) / (2.0 * dt),
71 (6 * dref**5) / dt**5
72 - (15 * dref**4) / dt**4
73 + (10 * dref**3) / dt**3,
74 (-3 * dref**5) / dt**4
75 + (7 * dref**4) / dt**3
76 - (4 * dref**3) / dt**2,
77 dref**5 / (2.0 * dt**3)
78 - dref**4 / dt**2
79 + dref**3 / (2.0 * dt),
80 ],
81 [
82 (-30 * dref**4) / dt**5
83 + (60 * dref**3) / dt**4
84 - (30 * dref**2) / dt**3,
85 1
86 - (15 * dref**4) / dt**4
87 + (32 * dref**3) / dt**3
88 - (18 * dref**2) / dt**2,
89 dref
90 - (5 * dref**4) / (2.0 * dt**3)
91 + (6 * dref**3) / dt**2
92 - (9 * dref**2) / (2.0 * dt),
93 (30 * dref**4) / dt**5
94 - (60 * dref**3) / dt**4
95 + (30 * dref**2) / dt**3,
96 (-15 * dref**4) / dt**4
97 + (28 * dref**3) / dt**3
98 - (12 * dref**2) / dt**2,
99 (5 * dref**4) / (2.0 * dt**3)
100 - (4 * dref**3) / dt**2
101 + (3 * dref**2) / (2.0 * dt),
102 ],
103 [
104 (-120 * dref**3) / dt**5
105 + (180 * dref**2) / dt**4
106 - (60 * dref) / dt**3,
107 (-60 * dref**3) / dt**4
108 + (96 * dref**2) / dt**3
109 - (36 * dref) / dt**2,
110 1
111 - (10 * dref**3) / dt**3
112 + (18 * dref**2) / dt**2
113 - (9 * dref) / dt,
114 (120 * dref**3) / dt**5
115 - (180 * dref**2) / dt**4
116 + (60 * dref) / dt**3,
117 (-60 * dref**3) / dt**4
118 + (84 * dref**2) / dt**3
119 - (24 * dref) / dt**2,
120 (10 * dref**3) / dt**3
121 - (12 * dref**2) / dt**2
122 + (3 * dref) / dt,
123 ],
124 [
125 (-360 * dref**2) / dt**5 + (360 * dref) / dt**4 - 60 / dt**3,
126 (-180 * dref**2) / dt**4 + (192 * dref) / dt**3 - 36 / dt**2,
127 (-30 * dref**2) / dt**3 + (36 * dref) / dt**2 - 9 / dt,
128 (360 * dref**2) / dt**5 - (360 * dref) / dt**4 + 60 / dt**3,
129 (-180 * dref**2) / dt**4 + (168 * dref) / dt**3 - 24 / dt**2,
130 (30 * dref**2) / dt**3 - (24 * dref) / dt**2 + 3 / dt,
131 ],
132 [
133 (-720 * dref) / dt**5 + 360 / dt**4,
134 (-360 * dref) / dt**4 + 192 / dt**3,
135 (-60 * dref) / dt**3 + 36 / dt**2,
136 (720 * dref) / dt**5 - 360 / dt**4,
137 (-360 * dref) / dt**4 + 168 / dt**3,
138 (60 * dref) / dt**3 - 24 / dt**2,
139 ],
140 [
141 -720 / dt**5,
142 -360 / dt**4,
143 -60 / dt**3,
144 720 / dt**5,
145 -360 / dt**4,
146 60 / dt**3,
147 ],
148 ]
149
150 elif s == 2:
151
152 matrix = [
153 [
154 1 - (3 * dref**2) / dt**2 - (2 * dref**3) / dt**3,
155 dref + (2 * dref**2) / dt + dref**3 / dt**2,
156 (3 * dref**2) / dt**2 + (2 * dref**3) / dt**3,
157 dref**2 / dt + dref**3 / dt**2,
158 ],
159 [
160 (-6 * dref) / dt**2 - (6 * dref**2) / dt**3,
161 1 + (4 * dref) / dt + (3 * dref**2) / dt**2,
162 (6 * dref) / dt**2 + (6 * dref**2) / dt**3,
163 (2 * dref) / dt + (3 * dref**2) / dt**2,
164 ],
165 [
166 -6 / dt**2 - (12 * dref) / dt**3,
167 4 / dt + (6 * dref) / dt**2,
168 6 / dt**2 + (12 * dref) / dt**3,
169 2 / dt + (6 * dref) / dt**2,
170 ],
171 [-12 / dt**3, 6 / dt**2, 12 / dt**3, 6 / dt**2],
172 ]
173
174 return matrix
175
176
177# An alternative method to transoform our PW parameters to Doppler parameters in a taylor expansion with (t - tref) terms.
178# Like the above methods, this is ill-conditioned, however less so than the above. Again similar to the above methods,
179# this method works best if the start time (bf.knotslist[0]) of your data is subtracted from all time elements, p0, p1
180# and tref. If you are using the conditioning in this method, it slows down dramatically. Good luck
181def PWParamstoTrefParams(pwparams, p0, p1, tref, s):
182
183 matrix = ParamTransformationMatrix(p0, p1, tref, s)
184
185 logging.debug(len(matrix))
186 logging.debug(len(pwparams))
187 logging.debug(pwparams)
188 # If no conditioning is required
189 return np.matmul(matrix, pwparams)
def kforGWsource(Izz=4.34e38, ellip=1e-4, radius=1e4)
def ParamTransformationMatrix(tstart, tend, reftime, s)