Skip to content

Commit

Permalink
Merge pull request #6379 from iago-mendes/control-dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsvu authored Nov 17, 2024
2 parents c05c009 + 895f423 commit c81f01f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
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")

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

0 comments on commit c81f01f

Please sign in to comment.