From a41be9c36263227544748f689035bd554696d266 Mon Sep 17 00:00:00 2001 From: Jiang Date: Fri, 6 Feb 2026 18:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=20emitter=5Fdemand=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=20pattern=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E7=9A=84=20pattern=20=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E7=AE=A1=E9=81=93=E5=86=B2=E6=B4=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/algorithms/simulations.py | 37 ++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/app/algorithms/simulations.py b/app/algorithms/simulations.py index 4c5e79d..4eaa1cb 100644 --- a/app/algorithms/simulations.py +++ b/app/algorithms/simulations.py @@ -348,16 +348,39 @@ def flushing_analysis( options = get_option(new_name) units = options["UNITS"] # step 2. set the emitter coefficient of drainage node or add flush flow to the drainage node + # 新建 pattern + time_option = get_time(new_name) + hydraulic_step = time_option["HYDRAULIC TIMESTEP"] + secs = from_clock_to_seconds_2(hydraulic_step) + cs_pattern = ChangeSet() + pt = {} + factors = [] + tmp_duration = modify_total_duration + while tmp_duration > 0: + factors.append(1.0) + tmp_duration = tmp_duration - secs + pt["id"] = "flushing_pt" + pt["factors"] = factors + cs_pattern.append(pt) + add_pattern(new_name, cs_pattern) + # 为 emitter_demand 添加新的 pattern emitter_demand = get_demand(new_name, drainage_node_ID) cs = ChangeSet() if flushing_flow > 0: - for r in emitter_demand["demands"]: - if units == "LPS": - r["demand"] += flushing_flow / 3.6 - elif units == "CMH": - r["demand"] += flushing_flow - cs.append(emitter_demand) - set_demand(new_name, cs) + if units == "LPS": + emitter_demand["demands"].append( + { + "demand": flushing_flow / 3.6, + "pattern": "flushing_pt", + "category": None, + } + ) + elif units == "CMH": + emitter_demand["demands"].append( + {"demand": flushing_flow, "pattern": "flushing_pt", "category": None} + ) + cs.append(emitter_demand) + set_demand(new_name, cs) else: pipes = get_node_links(new_name, drainage_node_ID) flush_diameter = 50