Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_IMRPhenomXP_NRTidalv3.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2024 Adrian Abac
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http: //www.gnu.org/licenses/>.
17
18"""
19Simple test to see if IMRPhenomXP_NRTidalv3 have changed
20Adapted from test_SEOBNRv5HM_ROM.py.
21"""
22
23import sys
24import pytest
25import lal
26import lalsimulation
27import numpy as np
28
29# -- utility functions ---------------------
30
32 amp = np.abs(h)
33 phase = np.unwrap(np.angle(h))
34 return amp, phase
35
36def sum_sqr_diff(x, y):
37 return np.sqrt( np.sum( (x-y)**2 ) )
38
39def gen_test_data(approximant):
40 """
41 compute the difference between two waveforms
42 and compare to expected value
43 """
44
45 LALparams = lal.CreateDict()
46 lambda1 = 400.0
47 lambda2 = 600.0
48 lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(LALparams, lambda1)
49 lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(LALparams, lambda2)
50 common_pars=dict(
51 m1=1.4*lal.MSUN_SI,
52 m2=1.2*lal.MSUN_SI,
53 S1x=0,
54 S1y=0,
55 S1z=-0.45,
56 S2x=0,
57 S2y=0,
58 S2z=0.98,
59 distance=1,
60 inclination=0.,
61 phiRef=0.,
62 longAscNodes=0.,
63 eccentricity=0.,
64 meanPerAno=0.,
65 deltaF=1./4.,
66 f_min=30.,
67 f_max=512.,
68 f_ref=30.,
69 LALpars=LALparams,
70 approximant=approximant
71 )
72
73 pars1 = common_pars.copy()
74
75 pars2 = common_pars.copy()
76 pars2.update({"m2":1.0*lal.MSUN_SI})
77 hp1, hc1 = lalsimulation.SimInspiralChooseFDWaveform(**pars1)
78 hp2, hc2 = lalsimulation.SimInspiralChooseFDWaveform(**pars2)
79
80 # compute amp and phase
81 hp1_amp, hp1_phase = get_amp_phase(hp1.data.data)
82 hc1_amp, hc1_phase = get_amp_phase(hc1.data.data)
83
84 hp2_amp, hp2_phase = get_amp_phase(hp2.data.data)
85 hc2_amp, hc2_phase = get_amp_phase(hc2.data.data)
86
87 hp_amp_diff = sum_sqr_diff(hp1_amp, hp2_amp)
88 hp_phase_diff = sum_sqr_diff(hp1_phase, hp2_phase)
89
90 hc_amp_diff = sum_sqr_diff(hc1_amp, hc2_amp)
91 hc_phase_diff = sum_sqr_diff(hc1_phase, hc2_phase)
92
93 return hp_amp_diff, hp_phase_diff, hc_amp_diff, hc_phase_diff
94
95
96
97# -- test functions ---------------------
98
99
101 """
102 This test checks that IMRPhenomXP_NRTidalv3 hasn't changed.
103 It does this by generating two IMRPhenomXP_NRTidalv3 waveforms and computing
104 their difference (according to their amplitude and phases)
105 and compares them to pre-computed values.
106
107 these pre-computed values were computed using the following line:
108
109 `expected_result = np.array(gen_test_data(lalsimulation.IMRPhenomXP_NRTidalv3))`
110 """
111
112 expected_result = np.array([34.92128149, 1092.39559414, 34.92128149, 1092.55480085])
113 new_result = np.array(gen_test_data(lalsimulation.IMRPhenomXP_NRTidalv3))
114 np.testing.assert_allclose(new_result, expected_result, rtol=0.002, err_msg="IMRPhenomXP_NRTidalv3 test failed", verbose=True)
115
116#-- run the tests ------------------------------
117
118if __name__ == '__main__':
119 args = sys.argv[1:] or ["-v", "-rs", "--junit-xml=junit-IMRPhenomXP_NRTidalv3.xml"]
120 sys.exit(pytest.main(args=[__file__] + args))
def test_IMRPhenomXP_NRTidalv3()
This test checks that IMRPhenomXP_NRTidalv3 hasn't changed.
def gen_test_data(approximant)
compute the difference between two waveforms and compare to expected value