Skip to content

Commit 47a7a33

Browse files
committed
feat: Add parallel runs
1 parent f188629 commit 47a7a33

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/radiosim/ppdisks/setup.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,27 @@ def run(
9090
self,
9191
show_progress: bool = True,
9292
model_id: int | None = None,
93+
parallel: bool = False,
94+
num_nodes: int = 1,
9395
cuda_device_id: int = 0,
9496
) -> None:
9597
total_steps = self._param_config["output_parameters.ntot"].value
9698
steps_between_outputs = self._param_config["output_parameters.ninterm"].value
9799

98100
model_desc = f" | Model {model_id}" if model_id is not None else ""
99101

102+
processes = []
103+
104+
if parallel:
105+
processes.append(f"mpirun -np {num_nodes} ")
106+
107+
processes.extend(
108+
[
109+
f"./fargo3d -D {cuda_device_id} "
110+
f"setups/{self._name}/{self._param_config._path.name}"
111+
]
112+
)
113+
100114
# >>> BEGIN
101115
with (
102116
tqdm(
@@ -105,10 +119,7 @@ def run(
105119
disable=not show_progress,
106120
) as progress,
107121
subprocess.Popen(
108-
[
109-
f"./fargo3d -D {cuda_device_id} "
110-
f"setups/{self._name}/{self._param_config._path.name}"
111-
],
122+
processes,
112123
stdout=subprocess.PIPE,
113124
stderr=subprocess.DEVNULL,
114125
bufsize=1,

src/radiosim/ppdisks/simulation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_default_sampling_config():
4242
"eccentricity": [0.0, 0.9], # 0 = Circle, 0 < e < 1 = Ellipse
4343
},
4444
"mesh_parameters": {
45-
"y_min": [4.0, 6.0], # Astronomical Units
45+
"y_min": [6.0, 8.0], # Astronomical Units
4646
"y_max_ratio": [1.2, 3], # Multiple of max(orbital_radius)
4747
},
4848
"output_parameters": {
@@ -130,6 +130,7 @@ def simulate(
130130
gpu: bool = True,
131131
cuda_device_id: int = 0,
132132
parallel: bool = False,
133+
num_nodes: int = 1,
133134
show_progress: bool = True,
134135
verbose: bool = False,
135136
overwrite: bool = False,
@@ -352,16 +353,19 @@ def toml_serialize_dict(read_dict):
352353
model_id=model._id,
353354
show_progress=show_progress,
354355
verbose=verbose,
356+
show_fargo_output=True,
355357
)
356358

357359
self._setup.run(
358360
model_id=model._id,
361+
num_nodes=num_nodes,
362+
parallel=parallel,
359363
show_progress=show_progress,
360364
cuda_device_id=cuda_device_id,
361365
)
362366

363367
# Move the data files to the correct directory
364-
model.get_data_directory(temp_fargo=False).mkdir()
368+
model.get_data_directory().mkdir()
365369
shutil.move(
366370
src=Variables.get("FARGO_ROOT") / model.get_fargo_output_path(),
367371
dst=model.get_data_directory(),

0 commit comments

Comments
 (0)