Commit b56879f0 authored by joanna_hurnowicz99's avatar joanna_hurnowicz99
Browse files

removed pressure input field from pressure source, added volume flow in m3/h...

removed pressure input field from pressure source, added volume flow in m3/h and velocity in control panel
parent 9a8fb61d
......@@ -98,6 +98,11 @@ class PropertyEditor(tk.Frame):
value = float(raw_value)
if isinstance(properties[property], flow_graph.Variable):
if property == "volume_flow_h":
properties["volume_flow"].set_value(value / 3600.0)
elif property == "volume_flow":
properties["volume_flow_h"].set_value(value * 3600.0)
properties[property].set_value(value)
else:
self.selection.set_property(property, value)
......
import numpy as np
import math
from model import flow_graph
from model import resistance_model
......@@ -135,9 +136,13 @@ class AbstractPipe(Component):
return self.inlet, self.outlet
def get_results(self):
volume_flow = self.component_graph.get_volume_flow(self.get_edge())
volume_flow_h = volume_flow.to_m3h()
return {"pressure_in": self.component_graph.get_node_pressure(self.inlet),
"pressure_out": self.component_graph.get_node_pressure(self.outlet),
"volume_flow": self.component_graph.get_volume_flow(self.get_edge())
"volume_flow": volume_flow,
"volume_flow_h": volume_flow_h,
"velocity": flow_graph.Velocity(None) if volume_flow.get_value() is None else flow_graph.Velocity((4 * volume_flow.get_value() / (math.pi * self.properties["diameter"] ** 2)))
}
def calculate_pressure_diff(self):
......@@ -206,17 +211,23 @@ class FlowController(ZetaPipe):
class PressureSource(Component):
PROPERTIES = {"name", "pressure"}
PROPERTIES = {"name", "volume_flow"}
def __init__(self, component_graph, pressure_val):
self.properties = {"pressure": flow_graph.PressureVar(pressure_val)}
def __init__(self, component_graph, volume_flow):
vf = flow_graph.VolumeFlowVar(volume_flow)
self.properties = {"volume_flow": vf,
"volume_flow_h": vf.to_m3h() }
super().__init__(component_graph, self.properties)
self.node = uuid.uuid4()
self.component_graph.add_node(self.node, pressure=self.properties["pressure"],
external_volume_inflow=flow_graph.UnknownVolumeFlowVar())
self.component_graph.add_node(self.node, pressure=flow_graph.UnknownPressureVar(),
external_volume_inflow=self.properties["volume_flow"])
def get_results(self):
return {"volume_flow": self.component_graph.get_node_external_volume_inflow(self.node),
volume_flow = self.component_graph.get_node_external_volume_inflow(self.node)
volume_flow_h = volume_flow.to_m3h()
return {"volume_flow": volume_flow,
"volume_flow_h": volume_flow_h,
"pressure": self.component_graph.get_node_pressure(self.node),
}
......@@ -264,12 +275,26 @@ class TeePipe(Component):
return self.branch, self.__internal
def get_results(self):
flow_in = self.component_graph.get_volume_flow((self.inlet, self.__internal))
flow_out = self.component_graph.get_volume_flow((self.__internal, self.outlet))
flow_branch = self.component_graph.get_volume_flow((self.branch, self.__internal))
flow_branch.set_abs()
return {"pressure_in": self.component_graph.get_node_pressure(self.inlet),
"pressure_out": self.component_graph.get_node_pressure(self.outlet),
"pressure_branch": self.component_graph.get_node_pressure(self.branch),
"flow_in": self.component_graph.get_volume_flow((self.inlet, self.__internal)),
"flow_out": self.component_graph.get_volume_flow((self.__internal, self.outlet)),
"flow_branch": self.component_graph.get_volume_flow((self.branch, self.__internal))
"flow_in": flow_in,
"flow_out": flow_out,
"flow_branch": flow_branch,
"flow_in_h": flow_in.to_m3h(),
"flow_out_h": flow_out.to_m3h(),
"flow_branch_h": flow_branch.to_m3h(),
"velocity_in": flow_graph.Velocity(None) if flow_in.get_value() is None else flow_graph.Velocity(
(4 * flow_in.get_value() / (math.pi * self.properties["diameter_in"] ** 2))),
"velocity_out": flow_graph.Velocity(None) if flow_out.get_value() is None else flow_graph.Velocity(
(4 * flow_out.get_value() / (math.pi * self.properties["diameter_out"] ** 2))),
"velocity_branch": flow_graph.Velocity(None) if flow_branch.get_value() is None else flow_graph.Velocity(
(4 * flow_branch.get_value() / (math.pi * self.properties["diameter_branch"] ** 2)))
}
def calculate_pressure_diff(self):
......
......@@ -15,6 +15,10 @@ class Variable:
def get_value(self):
return self.value
def set_abs(self):
if self.value is not None and self.value < 0:
self.value = self.value * -1
def set_value(self, value, stay_unknown=False):
if not stay_unknown:
self.unknown = False
......@@ -46,6 +50,13 @@ class Unit:
return self.symbol
class Velocity(Variable):
UNIT = Unit("velocity", "m/s")
def __init__(self, value, unknown=False):
super().__init__(self.UNIT, unknown, value)
class PressureVar(Variable):
UNIT = Unit("pressure", "Pa")
......@@ -64,11 +75,22 @@ class ZeroPressureVar(PressureVar):
class VolumeFlowVar(Variable):
UNIT = Unit("volume_flow", "m^3/s")
def __init__(self, value, unknown=False):
def __init__(self, value, unknown=False, unit="m^3/s"):
self.UNIT = Unit("volume_flow", unit)
super().__init__(self.UNIT, unknown, value)
def to_m3h(self):
if self.UNIT.symbol == "m^3/h":
return self
else:
return VolumeFlowVar(None if self.value is None else self.value * 3600.0, unit="m^3/h")
def to_m3s(self):
if self.UNIT.symbol == "m^3/s":
return self
else:
return VolumeFlowVar(None if self.value is None else self.value / 3600.0, unit="m^3/s")
class UnknownVolumeFlowVar(VolumeFlowVar):
def __init__(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment