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

Update directory structure of ID parameter control #6379

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions support/Pipelines/Bbh/ControlId.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def control_id(
radial_expansion_velocity = binary_data["Expansion"]

# File to write control diagnostic data
data_file = open(f"{id_run_dir}/ControlParamsData.txt", "w")
data_file = open(f"{id_run_dir}/../ControlParamsData.txt", "w")
knelli2 marked this conversation as resolved.
Show resolved Hide resolved

iteration = 0
control_run_dir = id_run_dir
Expand All @@ -166,7 +166,7 @@ def Residual(u):
f" Control of BBH Parameters ({iteration}) "
"=========================================="
)
control_run_dir = f"{id_run_dir}/ControlParams{iteration:02}"
control_run_dir = f"{id_run_dir}/../ControlParams_{iteration:03}"

# Start with initial free data choices and update the ones being
# controlled in `control_params` with the numeric value from `u`
Expand Down
6 changes: 6 additions & 0 deletions support/Pipelines/Bbh/InitialData.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def generate_id(
pipeline_dir: Optional[Union[str, Path]] = None,
run_dir: Optional[Union[str, Path]] = None,
segments_dir: Optional[Union[str, Path]] = None,
out_file_name: str = "spectre.out",
**scheduler_kwargs,
):
"""Generate initial data for a BBH simulation.
Expand Down Expand Up @@ -169,6 +170,7 @@ def generate_id(
subdirectory '001_InitialData'.
run_dir: Directory where the initial data is generated. Mutually exclusive
with 'pipeline_dir'.
out_file_name: Optional. Name of the log file. (Default: "spectre.out")
"""
logger.warning(
"The BBH pipeline is still experimental. Please review the"
Expand Down Expand Up @@ -196,6 +198,9 @@ def generate_id(
)
if pipeline_dir and not run_dir:
run_dir = pipeline_dir / "001_InitialData"
if control:
run_dir = f"{run_dir}/ControlParams_000"
out_file_name = f"../{out_file_name}"

# Determine initial data parameters from options
id_params = id_parameters(
Expand Down Expand Up @@ -223,6 +228,7 @@ def generate_id(
pipeline_dir=pipeline_dir,
run_dir=run_dir,
segments_dir=segments_dir,
out_file_name=out_file_name,
)


Expand Down
8 changes: 6 additions & 2 deletions tests/support/Pipelines/Bbh/Test_InitialData.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def test_cli(self):
)
except SystemExit as e:
self.assertEqual(e.code, 0)
self.assertTrue((self.test_dir / "InitialData.yaml").exists())
self.assertTrue(
(self.test_dir / "ControlParams_000/InitialData.yaml").exists()
)
# Test with pipeline directory
try:
generate_id_command(
Expand All @@ -138,7 +140,9 @@ def test_cli(self):
except SystemExit as e:
self.assertEqual(e.code, 0)
with open(
self.test_dir / "Pipeline/001_InitialData/InitialData.yaml", "r"
self.test_dir
/ "Pipeline/001_InitialData/ControlParams_000/InitialData.yaml",
"r",
) as open_input_file:
metadata = next(yaml.safe_load_all(open_input_file))
self.assertEqual(
Expand Down
Loading