forked from tedwards2412/ripple
-
Notifications
You must be signed in to change notification settings - Fork 4
Separate IMRPhenomHM implementation #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robkamcha
wants to merge
14
commits into
ripple-dev
Choose a base branch
from
IMRPhenomHM
base: ripple-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
61268d9
Separated IMRPhenomHM
robkamcha 5655b02
Merge branch 'ripple-dev' into IMRPhenomHM
thomasckng 86e7672
fix: simplify LALSuite availability check and remove debug print stat…
thomasckng 1f22d37
feat: add IMRPhenomHM waveform class and update imports
thomasckng a448fb8
fix: update IMRPhenomHM waveform import and simplify function calls
thomasckng 9bedcfc
Update uv.lock
thomasckng f8d0ae0
Formatting
thomasckng dd05cb0
feat: add IMRPhenomHM waveform to documentation and timing scripts
thomasckng 70f5035
fix: remove outdated comment regarding precessing-waveform convention…
thomasckng 20d14fe
fix: update pre-commit configuration to skip pyright checks
thomasckng 9a6c916
feat: add IMRPhenomHM to waveform presets in integration tests
thomasckng 536b2e4
Update uv.lock
thomasckng 4783800
Update uv.lock
thomasckng 7f75381
Merge branch 'ripple-dev' into IMRPhenomHM
thomasckng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import jax | ||
| import jax.numpy as jnp | ||
| from ..constants import MSUN, MTSUN, MRSUN, MPC | ||
| from jaxtyping import Array | ||
| from .spherical_harmonics import ( | ||
| compute_sminus2_l2, | ||
| compute_sminus2_l3, | ||
| compute_sminus2_l4, | ||
| ) | ||
|
|
||
|
|
||
| # Some pre-XPHM ripple code | ||
| from .IMRPhenomXPHM import ( | ||
| XLALSimIMRPhenomHMGethlmModes, | ||
| ) | ||
|
thomasckng marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def gen_IMRPhenomHM( | ||
| frequency_array, | ||
| mass_1, | ||
| mass_2, | ||
| chi1, | ||
| chi2, | ||
| distance, # in Mpc | ||
| inclination, | ||
| phi0, | ||
| reference_frequency, | ||
| ): | ||
| """Generate IMRPhenomHM plus and cross polarizations.""" | ||
|
|
||
| m1_SI = mass_1 * MSUN | ||
| m2_SI = mass_2 * MSUN | ||
| Mtot = mass_1 + mass_2 | ||
|
|
||
| # Overall amplitude prefactor from LAL's XLALSimPhenomUtilsFDamp0: | ||
| # amp0 = Mtot * MRSUN * Mtot * MTSUN / distance | ||
| # where Mtot is in solar masses and distance is in meters | ||
| dist_m = distance * MPC # distance in meters | ||
| amp0 = Mtot * MRSUN * Mtot * MTSUN / dist_m | ||
|
|
||
| extra_params = { | ||
| "ModeArray": jnp.array( | ||
| [[2, 1], [2, 2], [3, 2], [3, 3], [4, 4]], dtype=jnp.int32 | ||
| ) | ||
| } | ||
|
|
||
| hlm = XLALSimIMRPhenomHMGethlmModes( | ||
| frequency_array, | ||
| m1_SI, | ||
| m2_SI, | ||
| 0, | ||
| 0, | ||
| chi1, | ||
| 0, | ||
| 0, | ||
| chi2, | ||
| phi0, | ||
| frequency_array[1] - frequency_array[0], | ||
| reference_frequency, | ||
| extra_params, | ||
| ) | ||
|
|
||
| ells = extra_params["ModeArray"][:, 0] | ||
| minus1l = jnp.where(ells % 2 != 0, -1, 1) | ||
| mode_projections = jax.vmap( | ||
| get_phenomHMFD_mode_projection, | ||
| in_axes=(None, 0, 0, 0), | ||
| )( | ||
| inclination, | ||
| minus1l, | ||
| extra_params["ModeArray"][:, 0], | ||
| extra_params["ModeArray"][:, 1], | ||
| ) | ||
|
|
||
| # Reshape to (n_modes, 2, 1) and (n_modes, 1, f_sampling) so they broadcast to (n_modes, 2, f_sampling) | ||
| projected = mode_projections[:, :, None] * hlm[:, None, :] * amp0 | ||
| hp, hc = jnp.sum(projected, axis=0) | ||
|
|
||
| return hp, hc | ||
|
|
||
|
|
||
| def get_phenomHMFD_mode_projection( | ||
| theta: float, | ||
| minus1l: int | Array, | ||
| ell: int | Array, | ||
| m: int | Array, | ||
| ) -> Array: | ||
| """ | ||
| Helper function to compute mode-by-mode plus- and cross-polarisation prefactors | ||
| """ | ||
|
|
||
| Y = jax.lax.switch( | ||
| ell - 2, | ||
| [ | ||
| lambda: compute_sminus2_l2(theta, m), | ||
| lambda: compute_sminus2_l3(theta, m), | ||
| lambda: compute_sminus2_l4(theta, m), | ||
| ], | ||
| ) | ||
|
|
||
| def sym_branch(): | ||
| # Equatorial symmetry: add in -m mode | ||
| Ymstar = jax.lax.switch( | ||
| ell - 2, | ||
| [ | ||
| lambda: compute_sminus2_l2(theta, -m), | ||
| lambda: compute_sminus2_l3(theta, -m), | ||
| lambda: compute_sminus2_l4(theta, -m), | ||
| ], | ||
| ) | ||
| Ymstar = jnp.conj(Ymstar) | ||
| factorp = 0.5 * (Y + minus1l * Ymstar) | ||
| factorc = -1j * 0.5 * (Y - minus1l * Ymstar) | ||
| return jnp.array([factorp, factorc]) | ||
|
|
||
| def asym_branch(): # NOTE This is for hypothetical m=0 modes, not currently implemented. Structure is there in case we ever want to use it | ||
| # Not adding in the -m mode | ||
| factorp = Y | ||
| factorc = -1j * factorp | ||
| return jnp.array([factorp, factorc]) | ||
|
|
||
| return jax.lax.select( | ||
| m == 0, | ||
| asym_branch(), | ||
| sym_branch(), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.