Skip to content

Commit

Permalink
Use black formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
nealkruis committed Feb 22, 2024
1 parent ca47c71 commit 44a3f53
Show file tree
Hide file tree
Showing 10 changed files with 1,304 additions and 710 deletions.
584 changes: 324 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

0 comments on commit 44a3f53

Please sign in to comment.