Add option to utilize GPR model to create zero eccentricity initial orbital parameters - #12
Open
vtommasini wants to merge 1 commit into
Open
Conversation
…rbital parameters
There was a problem hiding this comment.
Pull request overview
This PR extends SimulationSupport.EccentricityControl.InitialOrbitalParameters to optionally compute zero-eccentricity initial orbital parameters using a PN baseline plus a Gaussian Process Regression (GPR) correction, and adds a Click-based CLI wrapper for the same functionality.
Changes:
- Add
method=("PN"|"GPR")andgpr_checkpointsto select PN-only vs. PN+GPR-corrected parameter estimation. - Refactor PN computation into a dedicated helper and add GPR helpers for feature vector assembly and checkpoint-based corrections.
- Add a CLI command (
initial-orbital-parameters) with text/JSON output.
Suppressed comments (2)
src/SimulationSupport/EccentricityControl/InitialOrbitalParameters.py:429
NotImplementedErroris raised with an empty message. Since this is a user-facing code path (selected bymethod == "GPR"and nonzero eccentricity), it should explain the limitation (e.g. GPR currently supports only zero eccentricity).
raise NotImplementedError("")
src/SimulationSupport/EccentricityControl/InitialOrbitalParameters.py:161
- Spelling typo in the comment (
supperted->supported).
# Only zero eccentricity is supperted here, since it utilizes ZeroEccParamsFromPN
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+449
to
+471
| """Estimate the initial orbital parameters for a BBH evolution. | ||
|
|
||
| Estimates the initial coordinate separation, D_0, orbital angular velocity, Omega_0, and | ||
| radial expansion velocity, adot_0, from a Post-Newtonian approximation, optionally | ||
| corrected by a trained Gaussian Process Regression (GPR) model. | ||
|
|
||
| Specify the target eccentricity and either '--separation', '--orbital-angular-velocity', | ||
| '--num-orbits', or '---time-to-merger'. | ||
| """ | ||
| orbital_params_specified = [ | ||
| param is not None | ||
| for param in [ | ||
| separation, | ||
| orbital_angular_velocity, | ||
| num_orbits, | ||
| time_to_merger, | ||
| ] | ||
| ] | ||
| if sum(orbital_params_specified) != 1: | ||
| raise click.UsageError( | ||
| "Specify either '--separation', '--orbital-angular-velocity'," | ||
| "'--num-orbits', or '---time-to-merger'." | ||
| ) |
| if gpr_adot_checkpoint: | ||
| gpr_checkpoints["adot"] = gpr_adot_checkpoint | ||
| if not gpr_checkpoints: | ||
| raise click.UsagError( |
Comment on lines
+11
to
+13
| import click | ||
| import numpy as np | ||
| import rich |
Comment on lines
+327
to
+330
| from SimulationSupport.gpr import ( | ||
| load_gpr_checkpoint, | ||
| predict_with_gpr_model, | ||
| ) |
Comment on lines
+310
to
+314
| f"GPR checkpoint expects input feature {missing_feature}," | ||
| "which is not available. Available features:" | ||
| f"{sorted(available_values.keys())}. Update the" | ||
| "'available_values' mapping in this module to match" | ||
| "the checkpoint's input_features metadata." |
Comment on lines
+389
to
+395
| corrected = {"omega": pn_omega, "adot": pn_adot} | ||
| for quantity_name, checkpoint_path in gpr_checkpoints.items(): | ||
| if quantity_name not in corrected: | ||
| raise ValueError( | ||
| f"Unknown quantity `{quantity_name}` in `gpr_checkpoints`." | ||
| "Expected one of `D_0`, `Omega_0`, or `adot_0`." | ||
| ) |
| separation: Optional[float] = None, | ||
| orbital_angular_velocity: Optional[float] = None, | ||
| radial_expansion_velocity: Optional[float] = None, | ||
| method: str = "PN", # accpets both "PN" and "GPR" |
Comment on lines
+551
to
+554
| help=( | ||
| "Dimensionless spin vector of the smaller black hole, for example," | ||
| "written as '--spin-b 0.0, 0.0, 0.1'." | ||
| ), |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Expanded file to allow option of utilizing either PN approximation or a pre-trained GPR model to create zero eccentricity initial orbital parameters. Original PN logic remains unchanged.
method = GPR option: first computes the standard PN baseline for D_0, Omega_0, and adot_0, then applies a correction from a trained GPR model on top of the PN baseline.
currently only works for zero eccentricity GPR; eccentric GPR option is left for a future PR.
runnable both in Python and as a CLI.