Setting of valve [GPV] should be string

This commit is contained in:
WQY\qiong
2023-03-01 23:20:04 +08:00
parent 628258ef52
commit 3665e15c92
3 changed files with 21 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ def get_valve_schema(name: str) -> dict[str, dict[str, Any]]:
'node2' : {'type': 'str' , 'optional': False , 'readonly': False},
'diameter' : {'type': 'float' , 'optional': False , 'readonly': False},
'v_type' : {'type': 'str' , 'optional': False , 'readonly': False},
'setting' : {'type': 'float' , 'optional': False , 'readonly': False},
'setting' : {'type': 'str' , 'optional': False , 'readonly': False},
'minor_loss' : {'type': 'float' , 'optional': False , 'readonly': False} }
@@ -28,7 +28,7 @@ def get_valve(name: str, id: str) -> dict[str, Any]:
d['node2'] = str(p['node2'])
d['diameter'] = float(p['diameter'])
d['v_type'] = str(p['type'])
d['setting'] = float(p['setting'])
d['setting'] = str(p['setting'])
d['minor_loss'] = float(p['minor_loss'])
return d
@@ -41,7 +41,7 @@ class Valve(object):
self.node2 = str(input['node2'])
self.diameter = float(input['diameter'])
self.v_type = str(input['v_type'])
self.setting = float(input['setting'])
self.setting = str(input['setting'])
self.minor_loss = float(input['minor_loss'])
self.f_type = f"'{self.type}'"
@@ -50,7 +50,7 @@ class Valve(object):
self.f_node2 = f"'{self.node2}'"
self.f_diameter = self.diameter
self.f_v_type = f"'{self.v_type}'"
self.f_setting = self.setting
self.f_setting = f"'{self.setting}'"
self.f_minor_loss = self.minor_loss
def as_dict(self) -> dict[str, Any]:
@@ -126,7 +126,7 @@ def delete_valve(name: str, cs: ChangeSet) -> ChangeSet:
# [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
# [NOT SUPPORT] for PCV, add loss curve if present
#--------------------------------------------------------------
class InpValve:
def __init__(self, line: str) -> None:
@@ -141,7 +141,7 @@ class InpValve:
self.node2 = str(tokens[2])
self.diameter = float(tokens[3])
self.v_type = str(tokens[4].upper())
self.setting = float(tokens[5])
self.setting = str(tokens[5])
self.minor_loss = float(tokens[6])
self.desc = str(tokens[-1]) if has_desc else None