减少爆管定位代码中引入的不确定性

This commit is contained in:
2026-03-09 11:29:57 +08:00
parent d55e23bc44
commit f9111ab9c1
5 changed files with 145 additions and 31 deletions
@@ -474,6 +474,7 @@ def cal_signature_pipe_multi_pf(
float(leak_mag),
list(sensor_name),
option_values,
list(candidate_center),
),
) as pool:
for i, (center_name, pressure_array) in enumerate(
@@ -482,6 +483,9 @@ def cal_signature_pipe_multi_pf(
pressure_leak.loc[(center_name, slice(None)), :] = pressure_array
sys.stdout.write("\r" + "已经完成计算" + str(i + 1) + "个特征中心")
else:
# Pre-insert all mid-nodes so every simulation sees the same topology
for center in candidate_center:
ensure_mid_node(wn, center)
for i in range(candidate_center_num):
temp_prefix = _make_temp_prefix(f"sig_{i}")
wn, pressure_output = leak_simulation_pipe_dd_multi_pf(
@@ -500,10 +504,17 @@ def cal_signature_pipe_multi_pf(
return pressure_leak, candidate_center
def _signature_worker_init(inp_path, leak_mag, sensor_name, option_values):
def _signature_worker_init(
inp_path, leak_mag, sensor_name, option_values, candidate_centers=None
):
global _SIGNATURE_WORKER_DATA
wn = wntr.network.WaterNetworkModel(inp_path)
_apply_hydraulic_options(wn, option_values)
# Pre-insert ALL mid-nodes so every simulation runs on the same topology,
# regardless of which worker handles which task.
if candidate_centers is not None:
for center in candidate_centers:
ensure_mid_node(wn, center)
_SIGNATURE_WORKER_DATA = {
"wn": wn,
"leak_mag": leak_mag,