Skip to content
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

Single iteration of eccentricity control reduction #6295

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

vtommasini
Copy link
Contributor

@vtommasini vtommasini commented Sep 18, 2024

Proposed changes

Added eccentricity control option to Next section of Inspiral.yaml. Options now after the inspiral ends are to either proceed with the ringdown, or choose eccentricity control instead. If eccentricity control is chosen, the output will include current eccentricity, suggested orbital parameter updates, and a pdf of dD/dt, Residual, and coordinate separation plots.

Example command line to run: spectre bbh start-inspiral --eccentricity-control -L 1 -P 10 -d ./segments ./bbh_id/InitialData.yaml -p reservation=sxs_standing -N 6

Option to test the function quickly without running an actual inspiral:
1.) make a directory
2.) carry in an old bbh_id directory from a past simulation
3.) run spectre bbh start-inspiral --eccentricity-control -L 1 -P 10 -d ./segments ./bbh_id/InitialData.yaml -p reservation=sxs_standing -N 6
4.) enter "n" when asked to submit job
5.)cd segments/002_Inspiral/Segment_0000 directory
6.) carry in an old BbhReductions.h5 file from a past simulation
7.) cd .. back into segments directory
8.) run spectre run-next ./002_Inspiral/Segment_0000/Inspiral.yaml

Output will look like this:
Screenshot 2024-09-17 at 3 47 39 PM

and in /segments/002_Inspiral/Segment_0000, there will also be an ecc_control.pdf file that looks like this:

Screenshot 2024-09-17 at 3 48 54 PM

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

@vtommasini vtommasini added the cli/pybindings Command line interface & Python bindings label Sep 18, 2024
@vtommasini vtommasini added this to the Eccentricity Control milestone Sep 18, 2024
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControlMinimal.py Outdated Show resolved Hide resolved
a = ecout["updated xcts values"]["expansion"]
print("current eccentricity = " + str(ecout["eccentricity"]))
print("updated value for omega = " + str(w))
print("updated value for expansion = " + str(a))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this add a CLI command that just calls your function, and where you can pick all the options (like tmin and tmax. You can copy this from support/Pipelines/EccentricityControl/EccentricityControl.py, and we will extend it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still missing (I didn't see it in the fixup 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, this might have gotten deleted during one of my branch switches

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save for next PR

support/Pipelines/Bbh/Inspiral.yaml Show resolved Hide resolved
support/Pipelines/Bbh/Inspiral.yaml Outdated Show resolved Hide resolved
support/Pipelines/Bbh/Inspiral.yaml Show resolved Hide resolved
a = ecout["updated xcts values"]["expansion"]
print("current eccentricity = " + str(ecout["eccentricity"]))
print("updated value for omega = " + str(w))
print("updated value for expansion = " + str(a))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will call generate_id() here to start the next ecc-control iteration. But let's do that in the next PR.

return functions["H4"]["fit result"]


def ecc_control_fit(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for the new code in this PR, similar to the general Test_EccentricityControl.py or Test_PlotTrajectories.py.

support/Pipelines/Bbh/EccentricityControl.py Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
# Suppress specific RuntimeWarnings
warnings.filterwarnings(
"ignore", message="Number of calls to functionhas reached maxfev"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's cool, I didn't know this exists.

support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/Inspiral.py Outdated Show resolved Hide resolved
a = ecout["updated xcts values"]["expansion"]
print("current eccentricity = " + str(ecout["eccentricity"]))
print("updated value for omega = " + str(w))
print("updated value for expansion = " + str(a))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still missing (I didn't see it in the fixup 1)

support/Pipelines/Bbh/Inspiral.yaml Outdated Show resolved Hide resolved
support/Pipelines/Bbh/Inspiral.yaml Outdated Show resolved Hide resolved
support/Pipelines/Bbh/Inspiral.yaml Outdated Show resolved Hide resolved
support/Pipelines/Bbh/__init__.py Outdated Show resolved Hide resolved
@vtommasini
Copy link
Contributor Author

Screenshot 2024-10-08 at 10 08 10 PM for this comment, I removed those lines and now I output this table instead: Screenshot 2024-10-08 at 10 08 45 PM

support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/EccentricityControl.py Outdated Show resolved Hide resolved
support/Pipelines/Bbh/__init__.py Outdated Show resolved Hide resolved
Comment on lines 123 to 126
num_obs = len(ObjectA_centers[:, 0])

if len(ObjectB_centers[:, 0]) < num_obs:
num_obs = len(ObjectB_centers[:, 0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop all changes to this file.

I think what happened is you copied this script a while ago, some updates were made since then, and now you copied your version back into this one. For example, in this line here you fixed the num_obs, and I also fixed it in a slightly different way with the min() function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good you can squash everything into a single commit, including these two extra changes. Now only the test is missing.

expansion_from_xcts: orbital parameter we are interested in updating;
optional parameter, if none is provided, defaults to None
tmin: sets starting point for eccentricity reduction script; defaults to
h5_file: file that contains the trajectory data; optional parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete "optional parameter" (it's not optional)

is provided, defaults to None
id_input_file_path: path to the input file of the initial data run; reads
from Inspiral.yaml, if none provided, defaults to None.
output: represents output of the function; optional parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be more specific. Should this be a directory where plots will be written to, or a file path for a plot? I don't remember.

@vtommasini vtommasini force-pushed the singleecccontrol branch 3 times, most recently from 6d24505 to 748a6fb Compare October 17, 2024 07:53
)

def create_yaml_file(self):
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the try/except


# Verify that the HDF5 file was created correctly and contains
# the expected data
def test_h5_file_created_correctly(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need this

nilsvu
nilsvu previously approved these changes Oct 21, 2024
Copy link
Member

@nilsvu nilsvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Nice job getting this finished.

@nilsvu nilsvu disabled auto-merge October 21, 2024 20:25
@nilsvu nilsvu merged commit e88482f into sxs-collaboration:develop Oct 21, 2024
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/pybindings Command line interface & Python bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants