ML4GW / ml4gw

Torch utilities for doing machine learning in gravitational wave physics
18 stars 13 forks source link

IMRPhenomPv2 can't interpolate correctly at high spin. #161

Open AndyC80297 opened 3 weeks ago

AndyC80297 commented 3 weeks ago

When the spin value is too large the approximate will produce error during interpolate.

`

import torch
import ml4gw.waveforms as waveforms

chirp_mass = 25.0
mass_ratio = 0.7

s1x = 0.1
s1y = 0.8
s1z = 0.8

s1x = 0.3
s2y = -0.55
s2z = 0.8

distance = 100.0
f_ref = 20.0
phic = 0.6
tc = 0.0
inclination = 0.5

params = torch.tensor(
    [
        chirp_mass,
        mass_ratio,
        s1x,
        s1y,
        s1z,
        s1x,
        s2y,
        s2z,
        distance,
        tc,
        phic,
        inclination,
    ]
).repeat(10, 1)

torch_freqs = torch_freqs = torch.arange(10, 100, 1/2048)
batched_chirp_mass = params[:, 0]
batched_mass_ratio = params[:, 1]
batched_s1x = torch.linspace(-0.2, 0.2, 10)
batched_s1y = params[:, 3]
batched_s1z = params[:, 4]
batched_s2x = params[:, 5]
batched_s2y = params[:, 6]
batched_s2z = params[:, 7]
batched_distance = params[:, 8]
batched_tc = params[:, 9]
batched_phic = params[:, 10]
batched_inclination = params[:, 11]

approximate = waveforms.IMRPhenomPv2()
approximate(
    torch_freqs, 
    batched_chirp_mass, 
    batched_mass_ratio, 
    batched_s1x, 
    batched_s1y, 
    batched_s1z, 
    batched_s2x, 
    batched_s2y, 
    batched_s2z, 
    batched_distance, 
    batched_tc, 
    batched_phic, 
    batched_inclination, 
    f_ref 
)

`

wbenoit26 commented 3 weeks ago

I think the issue is that you have s1x ** 2 + s1y ** 2 + s1z ** 2 > 1. We should add a check for that.

deepchatterjeeligo commented 3 weeks ago

yeah I was going to ask for an example where the spin magnitudes are physical