From e83d3a83a5db60d4ee27fda21015a2a0b2273d07 Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Wed, 1 Mar 2023 22:05:34 +0800 Subject: [PATCH] Add EPANET2 output format --- api/s10_status.py | 2 +- api/s11_patterns.py | 3 ++- api/s12_curves.py | 3 ++- api/s15_energy.py | 2 +- api/s16_emitters.py | 2 +- api/s17_quality.py | 2 +- api/s18_sources.py | 2 +- api/s19_reactions.py | 2 +- api/s20_mixing.py | 2 +- api/s24_coordinates.py | 2 +- api/s25_vertices.py | 2 +- api/s2_junctions.py | 5 ++++- api/s3_reservoirs.py | 4 ++-- api/s4_tanks.py | 6 ++++-- api/s5_pipes.py | 5 ++++- api/s6_pumps.py | 4 ++-- api/s7_valves.py | 2 +- api/s9_demands.py | 5 ++--- 18 files changed, 32 insertions(+), 23 deletions(-) diff --git a/api/s10_status.py b/api/s10_status.py index 2c7dd9b..c103635 100644 --- a/api/s10_status.py +++ b/api/s10_status.py @@ -69,7 +69,7 @@ def set_status(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # link value #-------------------------------------------------------------- class InpStatus: diff --git a/api/s11_patterns.py b/api/s11_patterns.py index 7fa4048..8099abf 100644 --- a/api/s11_patterns.py +++ b/api/s11_patterns.py @@ -94,7 +94,8 @@ def delete_pattern(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] +# ;desc # id mult1 mult2 ..... #-------------------------------------------------------------- def inp_in_pattern(section: list[str]) -> ChangeSet: diff --git a/api/s12_curves.py b/api/s12_curves.py index 4f7e5a9..b0e6e71 100644 --- a/api/s12_curves.py +++ b/api/s12_curves.py @@ -122,7 +122,8 @@ def delete_curve(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] +# ;type: desc # id x y #-------------------------------------------------------------- def inp_in_curve(section: list[str]) -> ChangeSet: diff --git a/api/s15_energy.py b/api/s15_energy.py index 8591215..cb8fab1 100644 --- a/api/s15_energy.py +++ b/api/s15_energy.py @@ -132,7 +132,7 @@ def set_pump_energy(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # GLOBAL {PRICE/PATTERN/EFFIC} value # PUMP id {PRICE/PATTERN/EFFIC} value # DEMAND CHARGE value diff --git a/api/s16_emitters.py b/api/s16_emitters.py index a5d7a12..751782d 100644 --- a/api/s16_emitters.py +++ b/api/s16_emitters.py @@ -60,7 +60,7 @@ def set_emitter(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # node Ke #-------------------------------------------------------------- class InpEmitter: diff --git a/api/s17_quality.py b/api/s17_quality.py index 8d90065..620e8d5 100644 --- a/api/s17_quality.py +++ b/api/s17_quality.py @@ -60,7 +60,7 @@ def set_quality(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # node initqual #-------------------------------------------------------------- class InpQuality: diff --git a/api/s18_sources.py b/api/s18_sources.py index d43b06f..47d8797 100644 --- a/api/s18_sources.py +++ b/api/s18_sources.py @@ -103,7 +103,7 @@ def delete_source(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # node sourcetype quality (pattern) #-------------------------------------------------------------- class InpSource: diff --git a/api/s19_reactions.py b/api/s19_reactions.py index 1366f28..859d63c 100644 --- a/api/s19_reactions.py +++ b/api/s19_reactions.py @@ -182,7 +182,7 @@ def set_tank_reaction(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # ORDER {BULK/WALL/TANK} value # GLOBAL BULK coeff # GLOBAL WALL coeff diff --git a/api/s20_mixing.py b/api/s20_mixing.py index 7e4a4a9..cd1d52d 100644 --- a/api/s20_mixing.py +++ b/api/s20_mixing.py @@ -97,7 +97,7 @@ def delete_mixing(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # TankID MixModel FractVolume #-------------------------------------------------------------- class InpMixing: diff --git a/api/s24_coordinates.py b/api/s24_coordinates.py index 82ac880..44cd2cd 100644 --- a/api/s24_coordinates.py +++ b/api/s24_coordinates.py @@ -12,7 +12,7 @@ def get_node_coord(name: str, id: str) -> dict[str, float]: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # id x y #-------------------------------------------------------------- # exception ! need merge to node change set ! diff --git a/api/s25_vertices.py b/api/s25_vertices.py index c82f052..0228927 100644 --- a/api/s25_vertices.py +++ b/api/s25_vertices.py @@ -76,7 +76,7 @@ def delete_vertex(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # id x y #-------------------------------------------------------------- def inp_in_vertex(section: list[str]) -> ChangeSet: diff --git a/api/s2_junctions.py b/api/s2_junctions.py index 1e9886d..c14677e 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -122,7 +122,10 @@ def delete_junction(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- # [EPANET2] -# id elev. (demand) (demand pattern) +# [IN] +# id elev. (demand) (demand pattern) ;desc +# [OUT] +# id elev. ;desc #-------------------------------------------------------------- class InpJunction: def __init__(self, line: str) -> None: diff --git a/api/s3_reservoirs.py b/api/s3_reservoirs.py index 23965ed..0235a8e 100644 --- a/api/s3_reservoirs.py +++ b/api/s3_reservoirs.py @@ -117,8 +117,8 @@ def delete_reservoir(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] -# id elev (pattern) +# [EPANET2][IN][OUT] +# id elev (pattern) ;desc #-------------------------------------------------------------- class InpReservoir: def __init__(self, line: str) -> None: diff --git a/api/s4_tanks.py b/api/s4_tanks.py index 7650520..53388f0 100644 --- a/api/s4_tanks.py +++ b/api/s4_tanks.py @@ -145,8 +145,10 @@ def delete_tank(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] -# id elev initlevel minlevel maxlevel diam (minvol vcurve) +# [EPANET2][IN][OUT] +# id elev initlevel minlevel maxlevel diam (minvol vcurve overflow) ;desc +# xxx +# * YES #-------------------------------------------------------------- class InpTank: def __init__(self, line: str) -> None: diff --git a/api/s5_pipes.py b/api/s5_pipes.py index 8ce833c..dd8b954 100644 --- a/api/s5_pipes.py +++ b/api/s5_pipes.py @@ -125,7 +125,10 @@ def delete_pipe(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- # [EPANET2] -# id node1 node2 length diam rcoeff (lcoeff) (status) +# [IN] +# id node1 node2 length diam rcoeff (lcoeff status) ;desc +# [OUT] +# id node1 node2 length diam rcoeff lcoeff (status) ;desc #-------------------------------------------------------------- class InpPipe: def __init__(self, line: str) -> None: diff --git a/api/s6_pumps.py b/api/s6_pumps.py index de32ff1..acef09e 100644 --- a/api/s6_pumps.py +++ b/api/s6_pumps.py @@ -115,8 +115,8 @@ def delete_pump(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] Version 1.x is deprecated -# id node1 node2 KEYWORD value {KEYWORD value ...} +# [EPANET2][IN][OUT] +# id node1 node2 KEYWORD value {KEYWORD value ...} ;desc # where KEYWORD = [POWER,HEAD,PATTERN,SPEED] #-------------------------------------------------------------- class InpPump: diff --git a/api/s7_valves.py b/api/s7_valves.py index 8b9fffe..ebf0bd0 100644 --- a/api/s7_valves.py +++ b/api/s7_valves.py @@ -123,7 +123,7 @@ def delete_valve(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] +# [EPANET2][IN][OUT] # id node1 node2 diam type setting (lcoeff lcurve) # for GPV, setting is string = head curve id # for PCV, add loss curve if present diff --git a/api/s9_demands.py b/api/s9_demands.py index b61c42b..355b4fe 100644 --- a/api/s9_demands.py +++ b/api/s9_demands.py @@ -86,9 +86,8 @@ def set_demand(name: str, cs: ChangeSet) -> ChangeSet: #-------------------------------------------------------------- -# [EPANET2] -# MULTIPLY factor -# node base_demand (pattern) +# [EPANET2][IN][OUT] +# node base_demand (pattern) ;category #-------------------------------------------------------------- class InpDemand: def __init__(self, line: str) -> None: