Skip to content

Commit 56b3755

Browse files
committed
feat: Add more debug outputs
1 parent b1abd94 commit 56b3755

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

src/radiosim/ppdisks/setup.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ def compile(
5454
)
5555
print("Cleaning up make process ...")
5656

57+
clean_cmd = ["make mrproper"]
58+
59+
if verbose:
60+
print(f"CMD @ {Variables.get('FARGO_ROOT')} $ " + " ".join(clean_cmd))
61+
5762
subprocess.run(
58-
["make mrproper"],
63+
clean_cmd,
5964
cwd=Variables.get("FARGO_ROOT"),
6065
stdout=subprocess.DEVNULL if not show_fargo_output else None,
6166
stderr=subprocess.DEVNULL if not show_fargo_output else None,
@@ -65,14 +70,18 @@ def compile(
6570
if verbose:
6671
print("Starting compilation ...")
6772

73+
run_cmd = [
74+
f"make SETUP={self._name} "
75+
f"GPU={1 if gpu else 0} "
76+
f"PARALLEL={1 if parallel else 0} "
77+
f"UNITS={unit_system.key} "
78+
f"RESCALE={1 if rescale else 0}"
79+
]
80+
if verbose:
81+
print(f"CMD @ {Variables.get('FARGO_ROOT')} $ " + " ".join(run_cmd))
82+
6883
subprocess.run(
69-
[
70-
f"make SETUP={self._name} "
71-
f"GPU={1 if gpu else 0} "
72-
f"PARALLEL={1 if parallel else 0} "
73-
f"UNITS={unit_system.key} "
74-
f"RESCALE={1 if rescale else 0}"
75-
],
84+
run_cmd,
7685
cwd=Variables.get("FARGO_ROOT"),
7786
stdout=subprocess.DEVNULL if not show_fargo_output else None,
7887
stderr=subprocess.DEVNULL if not show_fargo_output else None,
@@ -93,6 +102,7 @@ def run(
93102
parallel: bool = False,
94103
num_nodes: int = 1,
95104
cuda_device_id: int = 0,
105+
verbose: bool = False,
96106
) -> None:
97107
total_steps = self._param_config["output_parameters.ntot"].value
98108
steps_between_outputs = self._param_config["output_parameters.ninterm"].value
@@ -111,6 +121,9 @@ def run(
111121
]
112122
)
113123

124+
if verbose:
125+
print(f"CMD @ {Variables.get('FARGO_ROOT')} $ " + " ".join(processes))
126+
114127
# >>> BEGIN
115128
with (
116129
tqdm(
@@ -121,7 +134,7 @@ def run(
121134
subprocess.Popen(
122135
processes,
123136
stdout=subprocess.PIPE,
124-
stderr=subprocess.DEVNULL,
137+
stderr=None if verbose else subprocess.DEVNULL,
125138
bufsize=1,
126139
universal_newlines=True,
127140
shell=True,

src/radiosim/ppdisks/simulation.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def get_runs(self) -> list["SimulationRun"]:
120120
run_ids = [int(str(d.name).removeprefix("run_")) for d in dirs]
121121
return [SimulationRun(id=run_id, sim=self) for run_id in run_ids]
122122

123+
def get_run(self, run_id: int) -> "SimulationRun":
124+
return SimulationRun(id=run_id, sim=self)
125+
123126
def simulate(
124127
self,
125128
num_models: int,
@@ -133,7 +136,6 @@ def simulate(
133136
parallel: bool = False,
134137
num_nodes: int = 1,
135138
show_progress: bool = True,
136-
show_fargo_output: bool = False,
137139
verbose: bool = False,
138140
overwrite: bool = False,
139141
) -> None:
@@ -148,6 +150,8 @@ def simulate(
148150
else:
149151
run = SimulationRun(id=run_id, sim=self, resume_rng=resume)
150152

153+
print(f"------ STARTING RUN {run._id} ------")
154+
151155
start_idx = 0 if not resume else run.get_next_model_id()
152156
for i in np.arange(start_idx, num_models):
153157
try:
@@ -278,8 +282,7 @@ def simulate(
278282

279283
max_orbit_radius = distances.max()
280284
param_config["mesh_parameters.ymax"] = (
281-
mesh_parameters["y_max_ratio"]
282-
* max_orbit_radius.to(self._unit_system.length).value
285+
mesh_parameters["y_max_ratio"] * max_orbit_radius
283286
)
284287

285288
param_config["mesh_parameters.nx"] = run.get_polar_img_size()[1]
@@ -295,7 +298,9 @@ def orbital_period(mass, radius, G):
295298
return np.sqrt((4 * np.pi**2 * radius**3) / (mass * G))
296299

297300
period = orbital_period(
298-
mass=m_star, radius=max_orbit_radius, G=self._constants["G"]
301+
mass=m_star,
302+
radius=max_orbit_radius * self._unit_system.length,
303+
G=self._constants["G"],
299304
)
300305

301306
total_time = num_orbits * period
@@ -364,7 +369,7 @@ def toml_serialize_dict(read_dict):
364369
model_id=model._id,
365370
show_progress=show_progress,
366371
verbose=verbose,
367-
show_fargo_output=show_fargo_output,
372+
show_fargo_output=verbose,
368373
)
369374

370375
self._setup.run(
@@ -373,14 +378,18 @@ def toml_serialize_dict(read_dict):
373378
parallel=parallel,
374379
show_progress=show_progress,
375380
cuda_device_id=cuda_device_id,
381+
verbose=verbose,
376382
)
377383

378384
# Move the data files to the correct directory
379385
model.get_data_directory().mkdir()
380-
shutil.move(
381-
src=Variables.get("FARGO_ROOT") / model.get_fargo_output_path(),
382-
dst=model.get_data_directory(),
383-
)
386+
for file in (
387+
Variables.get("FARGO_ROOT") / model.get_fargo_output_path()
388+
).glob("*.*"):
389+
shutil.move(
390+
src=file,
391+
dst=model.get_data_directory(),
392+
)
384393
shutil.rmtree(
385394
path=Variables.get("FARGO_ROOT") / model.get_fargo_output_path()
386395
)

0 commit comments

Comments
 (0)