Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

205 schema v2 #1

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
618 changes: 358 additions & 260 deletions chiller/chiller.py

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions chiller/conditions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from .fluid_properties import FluidState
from koozie import fr_u


class OperatingConditions:
def __init__(self, condenser_inlet, evaporator_outlet, compressor_speed=0):
self.condenser_inlet = condenser_inlet
self.evaporator_outlet = evaporator_outlet
self.compressor_speed = compressor_speed
def __init__(self, condenser_inlet, evaporator_outlet, compressor_speed=0):
self.condenser_inlet = condenser_inlet
self.evaporator_outlet = evaporator_outlet
self.compressor_speed = compressor_speed


AHRI_550_590_WATER_COOLED_CONDITIONS = OperatingConditions(condenser_inlet=FluidState(fr_u(85.0,"°F")), evaporator_outlet=FluidState(fr_u(44.0,"°F")))
AHRI_550_590_WATER_COOLED_CONDITIONS = OperatingConditions(
condenser_inlet=FluidState(fr_u(85.0, "°F")),
evaporator_outlet=FluidState(fr_u(44.0, "°F")),
)

AHRI_550_590_WATER_COOLED_CONDENSER_OUTLET = FluidState(fr_u(94.3,"°F"))
AHRI_550_590_WATER_COOLED_CONDENSER_OUTLET = FluidState(fr_u(94.3, "°F"))

AHRI_550_590_WATER_COOLED_EVAPORATOR_INLET = FluidState(fr_u(54.0,"°F"))
AHRI_550_590_WATER_COOLED_EVAPORATOR_INLET = FluidState(fr_u(54.0, "°F"))
110 changes: 60 additions & 50 deletions chiller/fluid_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,64 @@
import CoolProp.CoolProp as CP
from koozie import fr_u


class FluidState:
def __init__(self, temperature, pressure=fr_u(1.0,"atm"), volumetric_flow_rate=None, mass_flow_rate=None, fluid_name="Water"):
self.fluid_name = fluid_name
self.T = temperature
self.p = pressure
self.rho_set = False
self.cp_set = False
self.V_dot_set = False
if mass_flow_rate is not None and volumetric_flow_rate is not None:
raise Exception(f"Cannot set both 'volumetric_flow_rate' and 'mass_flow_rate'.")
if volumetric_flow_rate is None:
self.V_dot = None
else:
self.set_V_dot(volumetric_flow_rate)
return
if mass_flow_rate is None:
self.m_dot = None
else:
self.set_m_dot(mass_flow_rate)
return

def get_rho(self):
if not self.rho_set:
self.rho = CP.PropsSI("D", "P", self.p, "T", self.T, self.fluid_name)
self.rho_set = True
return self.rho

def get_cp(self):
if not self.cp_set:
self.cp = CP.PropsSI("C", "P", self.p, "T", self.T, self.fluid_name)
self.cp_set = True
return self.cp

def set_V_dot(self, volumetric_flow_rate):
self.V_dot = volumetric_flow_rate
self.m_dot = self.V_dot*self.get_rho()
self.c = self.m_dot*self.get_cp()
self.V_dot_set = True

def set_m_dot(self, mass_flow_rate):
self.m_dot = mass_flow_rate
self.V_dot = self.m_dot/self.get_rho()
self.c = self.m_dot*self.get_cp()
self.V_dot_set = True

def add_heat(self, heat):
return FluidState(temperature=self.T + heat/self.c, mass_flow_rate=self.m_dot)

def get_heat(self, other_state):
'''returns the amount of heat difference between this state and "other state"'''
return self.c*self.T - other_state.c*other_state.T
def __init__(
self,
temperature,
pressure=fr_u(1.0, "atm"),
volumetric_flow_rate=None,
mass_flow_rate=None,
fluid_name="Water",
):
self.fluid_name = fluid_name
self.T = temperature
self.p = pressure
self.rho_set = False
self.cp_set = False
self.V_dot_set = False
if mass_flow_rate is not None and volumetric_flow_rate is not None:
raise Exception(
f"Cannot set both 'volumetric_flow_rate' and 'mass_flow_rate'."
)
if volumetric_flow_rate is None:
self.V_dot = None
else:
self.set_V_dot(volumetric_flow_rate)
return
if mass_flow_rate is None:
self.m_dot = None
else:
self.set_m_dot(mass_flow_rate)
return

def get_rho(self):
if not self.rho_set:
self.rho = CP.PropsSI("D", "P", self.p, "T", self.T, self.fluid_name)
self.rho_set = True
return self.rho

def get_cp(self):
if not self.cp_set:
self.cp = CP.PropsSI("C", "P", self.p, "T", self.T, self.fluid_name)
self.cp_set = True
return self.cp

def set_V_dot(self, volumetric_flow_rate):
self.V_dot = volumetric_flow_rate
self.m_dot = self.V_dot * self.get_rho()
self.c = self.m_dot * self.get_cp()
self.V_dot_set = True

def set_m_dot(self, mass_flow_rate):
self.m_dot = mass_flow_rate
self.V_dot = self.m_dot / self.get_rho()
self.c = self.m_dot * self.get_cp()
self.V_dot_set = True

def add_heat(self, heat):
return FluidState(temperature=self.T + heat / self.c, mass_flow_rate=self.m_dot)

def get_heat(self, other_state):
'''returns the amount of heat difference between this state and "other state"'''
return self.c * self.T - other_state.c * other_state.T
Loading