Beispiel #1
0
 def __init__(self,P,h_in,mdot,fluid='water'):
     import CoolProp
     
     self.P = P
     self.h_in = h_in
     self.mdot = mdot
     self.fluid = fluid
     f = CoolProp.AbstractState('HEOS',fluid)
     f.update(CoolProp.PQ_INPUTS,self.P,0)
     h_liq = f.hmass()
     f.update(CoolProp.PQ_INPUTS,self.P,1)
     h_vap = f.hmass()
     # Determine what enthalpy to give at saturation temperature, since
     # at saturation temperature, rounding depends whether
     # the user intends heating or cooling.
     if h_in < h_liq:
         self.h_sat = h_liq
     elif h_in > h_vap:
         self.h_sat = h_vap
     else:
         self.h_sat = h_in
     
     #f.update(CoolProp.QT_INPUTS,0,f.Ttriple())
     f.update(CoolProp.PT_INPUTS,P,f.Tmin())
     h_min = f.hmass()
     f.update(CoolProp.PT_INPUTS,P,f.Tmax())
     h_max = f.hmass()
     qlim1,qlim2 = self.mdot * (h_max - self.h_in), self.mdot * (h_min - self.h_in)
     self.qmin = min(qlim1,qlim2)
     self.qmax = max(qlim1,qlim2)
     self.Tmin = K2C(f.Tmin())
     self.Tmax = K2C(f.Tmax())
     self.q = np.vectorize(self._q)
     self.T = np.vectorize(self._T)
Beispiel #2
0
 def _T(self,q):        
     from CoolProp.CoolProp import PropsSI
     if q < self.qmin:
         q = self.qmin
     elif q > self.qmax:
         q = self.qmax
     
     h_out = q / self.mdot + self.h_in
     return K2C(PropsSI('T','P',self.P,'H',h_out,self.fluid))
Beispiel #3
0
 def update(self, P, m_in, T_in, x_in, x_out):
     self.P = P        
     self.m_in = m_in
     self.T_in = T_in
     self.x_in = x_in
     self.x_out = x_out
     
     # Find inlet enthalpy.
     # Find saturation point at inlet concentration.
     # Find ...
     self.T_sat = K2C(libr_props.temperature(self.P * 1e-5, self.x_in))
     self.T_out = K2C(libr_props.temperature(self.P * 1e-5, self.x_out))
     self.h_sat = libr_props.massSpecificEnthalpy(C2K(self.T_sat), self.x_in)
     self.h_out = libr_props.massSpecificEnthalpy(C2K(self.T_out),self.x_out)
     
     self.cp_in = libr_props.massSpecificHeat(C2K(self.T_in),self.x_in)
     # If h_in is an input:
     if False:
         preheat = (self.h_sat - self.h_in)/self.cp_in
         self.T_in = self.T_sat - preheat
     else:
         preheat = self.T_sat - self.T_in
         self.h_in = self.h_sat - preheat * self.cp_in
     
     pwater.update(CP.PT_INPUTS, self.P, C2K(self.T_sat))
     self.h_vapor_out = pwater.hmass() - h_w_ref
     
     # Mass balance on LiBr
     self.m_out = self.m_in * self.x_in / self.x_out
     # Mass balance on Water
     self.m_vapor_out = self.m_in - self.m_out
     self.m_total = self.m_out
     
     self.Q_preheat = self.m_in * (self.h_sat - self.h_in)
     self.Q_desorb = self.m_out * self.h_out \
             + self.m_vapor_out * self.h_vapor_out \
             - self.m_in * self.h_sat
     
     
     # Determine a reasonable limit for extending the domain.
     self.Tmax = K2C(libr_props.temperature(self.P*1e-5,libr_props.xmax))
Beispiel #4
0
 def _qx(self,x_local):
     T = K2C(libr_props.temperature(self.P*1e-5,x_local))
     dx = self.x_in - x_local
     # TODO
     h_local = libr_props.massSpecificEnthalpy(C2K(T),x_local)
     # And calculate
     m_vapor = self.m_in * dx / x_local
     m_out = self.m_in + m_vapor
     # Heat is inbound.
     result = -self.m_in * self.h_in - m_vapor * self.h_vapor_inlet \
         + m_out * h_local
     return T,result
Beispiel #5
0
def main():
    if True:
        # Example 6.1 in the book
        P1,P2 = 673, 7445
        T1 = K2C(CP.PropsSI('T','P',P1,'Q',1,water))
        T2 = K2C(CP.PropsSI('T','P',P2,'Q',1,water))
        # Trying different inputs
        T1, T2 = 1, 35
        c = ChillerLiBr1(T1,T2,0.5,0.7)
        c.x2=libr_props2.Xsat(89.9,c.P_cond)
        c.x1=libr_props2.Xsat(32.7,c.P_evap)
        # Custom example
        c = ChillerLiBr1(T_evap=5,T_cond=45,x1=0.6026,x2=0.66)
        print("Initializing...")
        print(c)
        print("Iterating...")
        try:
            c.iterate1()
        finally:
            print(c)
        
    if True:
        # Figure 6.3 in the book
        Eff_SHX = np.linspace(0,1)
        COP = np.zeros_like(Eff_SHX)
        for i in range(len(Eff_SHX)):
            c = ChillerLiBr1(Eff_SHX=Eff_SHX[i])
            try:
                c.iterate1()
                COP[i] = c.COP
            except:
                pass
        if False:
            import matplotlib.pyplot as plt
            plt.plot(Eff_SHX, COP)
            plt.show()
    
    return c
Beispiel #6
0
 def myplot(self):
     self.h.set_ydata(self.QQ)
     self.ax1.relim()
     self.ax1.autoscale_view()
     self.h2.set_ydata(self.CC)
     self.ax2.relim()
     self.ax2.autoscale_view()
     #self.ax3.cla()
     x = K2C(self.T_exhaust_range)
     self.ax3.stackplot(x,
                        self.tt_d,
                        self.tt_e,
                        self.tt_a,
                        self.tt_c,
                        colors=['r', 'pink', 'b', 'g'])
     self.ax3.set_ylim([0, max(self.tt_total)])
Beispiel #7
0
    def __init__(self):
        #global t_exhaust T_exhaust_range
        spec = AdsorptionChillerSpec()
        ctrl = AdsorptionChillerControl()
        self.chiller = AdsorptionChiller(spec, ctrl)

        Ni = 20
        #T_exhaust_range = linspace(313,393,Ni);
        self.T_exhaust_range = linspace(313, 423, Ni)
        self.tt_d = zeros(Ni) * nan
        self.tt_e = zeros(Ni) * nan
        self.tt_a = zeros(Ni) * nan
        self.tt_c = zeros(Ni) * nan
        self.QQ = zeros(Ni) * nan
        self.CC = zeros(Ni) * nan
        self.tt_total = zeros(Ni)

        fig = figure(6)
        plt.clf()
        x = K2C(self.T_exhaust_range)
        self.ax1 = subplot(3, 1, 1)
        self.h = plot(x, self.QQ, 'ko')[0]
        self.ax1.relim()
        self.ax1.autoscale_view()
        ylabel('$Q_{\\rm max}$ (kW)')
        self.ax2 = subplot(3, 1, 2, sharex=self.ax1)
        self.h2 = plot(x, self.CC, 'ko')[0]
        self.ax2.relim()
        self.ax2.autoscale_view()
        ylabel('COP')
        self.ax3 = subplot(3, 1, 3, sharex=self.ax1)
        self.ax3.stackplot(x,
                           self.tt_d,
                           self.tt_e,
                           self.tt_a,
                           self.tt_c,
                           colors=['r', 'pink', 'b', 'g'])
        self.ax3.set_xlim([x.min(), x.max()])
        self.ax3.set_ylim([0, 60])
        self.ax3.set_ylabel('Cycle time (s)')
        self.ax3.set_xlabel('Exhaust temperature, $T$ ($^\circ$C)')
        self.ax3.hold(False)
        self.it = iter(enumerate(self.T_exhaust_range))
Beispiel #8
0
T_SHX_concentrate_outlet = T_gen_outlet - DeltaT_SHX_concentrate
h_SHX_concentrate_outlet \
    = CP.PropsSI('H','T',C2K(T_SHX_concentrate_outlet),'P',P_cond,librname(x2))
Q_SHX = m_concentrate * (h_gen_outlet - h_SHX_concentrate_outlet)

# Expansion valve
h_abs_pre = h_SHX_concentrate_outlet
if h_abs_pre > h_abs_inlet:
    # Pre-cooling is required to reach saturation temperature
    Q_abs_pre_cool = m_concentrate * (h_abs_pre - h_abs_inlet)
    T_abs_pre = np.nan
    # Minimum vapor pressure for absorption to occur
    P_abs_pre = np.inf
else:
    Q_abs_pre_cool = 0
    T_abs_pre = K2C(CP.PropsSI('T','H',h_abs_pre,'P',P_evap,librname(x2)))
    # Minimum vapor pressure for absorption to occur
    P_abs_pre = CP.PropsSI('P','T',C2K(T_abs_pre),'Q',0,librname(x2))

# Heat rejection in absorber: energy balance
h_abs_vapor_inlet = CP.PropsSI('H','P',P_evap,'Q',1,water) - h_w_ref
Q_abs_main = m_refrig * h_abs_vapor_inlet + m_concentrate * h_abs_inlet \
    - m_pump * h_abs_outlet
Q_abs_total = Q_abs_main + Q_abs_pre_cool

# Energy balance in SHX, pump side
D_in = CP.PropsSI('D','T',C2K(T_abs_outlet_max),'Q',0,librname(x1))
DeltaH_pump = (P_cond - P_evap) / D_in
W_pump = m_pump * DeltaH_pump
h_pump_outlet = h_abs_outlet + DeltaH_pump
DeltaH_SHX_pumpside = Q_SHX / m_pump
Beispiel #9
0
 def generatorHeatCurveQ(self,T,x_out):
     """Provide process heat canonical curve for generator in various forms.
     Assumes that
     * inlet solution state is obtained from self,
     * generated vapor is flowing in reverse direction and
     * it is everywhere in local equilibrium with solution.
     
     Args
     ----
     T : Temperature (deg C)
         The local temperature
     x_out : Mass fraction (kg/kg)
         The outlet solution LiBr mass fraction
     
     Returns
     -------
     q : Local progress index
         Measured as cumulative heat flux (W).
     Q : Total heat flux (W)
         The total amount of heat transferred into the generator.
     """
     
     # We may need m_concentrate. It depends on Q -- solve from inlet.
     h_solution_inlet = self.h_gen_inlet
     h_vapor_outlet = self.h_gen_vapor_outlet
     T_solution_outlet = K2C(libr_props.temperature(self.P_cond * 1e-5,
                                            x_out))
     h_solution_outlet = libr_props.massSpecificEnthalpy(
         C2K(T_solution_outlet), x_out)
     # Mass balance on LiBr
     m_solution_outlet = self.m_pump * self.x1 / x_out
     # Mass balance on Water
     m_vapor_outlet = self.m_pump - m_solution_outlet
     m_total = m_solution_outlet
     
     hlv0 = h_vapor_outlet - h_solution_inlet
     q0 = m_total * h_vapor_outlet - self.m_pump * hlv0
     
     Q = m_solution_outlet * h_solution_outlet \
         + m_vapor_outlet * h_vapor_outlet \
         - self.m_pump * h_solution_inlet
     
     q = 0
     T0,T1,T2=self.genpoints[0][1],self.genpoints[1][1],self.genpoints[2][1]
     Q0,Q1,Q2=self.genpoints[0][0],self.genpoints[1][0],self.genpoints[2][0]
     if T < T0:
         raise "Generator outlet must be greater than pre-inlet temperature!"
     elif T < T1:
         # The state is either saturated or subcooled.
         # Use linear interpolation.
         q = (T - T0) / (T1 - T0) * (Q1 - Q0)
     else:
         x_local = libr_props.massFraction(C2K(T),self.P_cond * 1e-5)
         pwater.update(CP.PT_INPUTS, self.P_cond, C2K(T))
         h_vapor_local = pwater.hmass() - h_w_ref
         h_solution_local = libr_props.massSpecificEnthalpy(C2K(T), x_local)
         # Mass balance on LiBr
         m_solution_local = self.m_pump * self.x1 / x_local
         
         hlv1 = h_vapor_local - h_solution_local
         q1 = m_total * h_vapor_local - m_solution_local * hlv1
         
         q = (q1 - q0) + (Q1 - Q0)
     # TODO
     # If q > Q (iff T > T_solution_outlet) then result is invalid.
     return q, Q
Beispiel #10
0
    def iterate1(self):
        """Update the internal parameters."""
        self.T_gen_inlet = K2C(libr_props.temperature(self.P_cond*1e-5,
                                                      self.x1))
        self.T_gen_outlet = K2C(libr_props.temperature(self.P_cond * 1e-5,
                                                   self.x2))
        self.T_abs_inlet_max = K2C(libr_props.temperature(self.P_evap * 1e-5,
                                                          self.x2))
        self.T_abs_outlet_max = K2C(libr_props.temperature(self.P_evap * 1e-5,
                                                           self.x1))
        
        self.h_gen_inlet = libr_props.massSpecificEnthalpy(
            C2K(self.T_gen_inlet), self.x1)
        self.h_gen_outlet = libr_props.massSpecificEnthalpy(
            C2K(self.T_gen_outlet), self.x2)
        self.h_abs_inlet = libr_props.massSpecificEnthalpy(
            C2K(self.T_abs_inlet_max), self.x2)
        self.h_abs_outlet = libr_props.massSpecificEnthalpy(
            C2K(self.T_abs_outlet_max), self.x1)
        
        # Mass balance on LiBr
        self.m_concentrate = self.m_pump * self.x1 / self.x2
        # Mass balance on Water
        self.m_refrig = self.m_pump - self.m_concentrate
        self.f = self.m_pump / self.m_refrig

        # Compute SHX outlets, assuming concentrate limits heat flow (C_min)
        # Neglect pump work for the present.
        DeltaT_max = self.T_gen_outlet - self.T_abs_outlet_max
        DeltaT_SHX_concentrate = self.Eff_SHX * DeltaT_max
        self.T_SHX_concentrate_outlet = self.T_gen_outlet \
            - DeltaT_SHX_concentrate
        self.h_SHX_concentrate_outlet = libr_props.massSpecificEnthalpy(
            C2K(self.T_SHX_concentrate_outlet), self.x2)
        self.Q_SHX = self.m_concentrate \
            * (self.h_gen_outlet - self.h_SHX_concentrate_outlet)
        
        # Expansion valve
        self.h_abs_pre = self.h_SHX_concentrate_outlet
        if self.h_abs_pre > self.h_abs_inlet:
            # Pre-cooling is required to reach saturation temperature
            self.Q_abs_pre_cool = self.m_concentrate \
                * (self.h_abs_pre - self.h_abs_inlet)
            q,t,xl = libr_props.twoPhaseProps(self.h_abs_pre,
                                              self.P_evap*1e-5,
                                              self.x2)
            self.T_abs_pre = K2C(t)
            self.x_abs_pre = xl
            # ignore vapor quality, q
            # Minimum vapor pressure for absorption to occur
            self.P_abs_pre = np.inf
        else:
            self.Q_abs_pre_cool = 0
            #self.T_abs_pre = K2C(CP.PropsSI('T',
            #    'H', self.h_abs_pre,
            #    'P', self.P_evap,
            #    librname(self.x2)))
            self.T_abs_pre = np.nan
            # Minimum vapor pressure for absorption to occur
#            self.P_abs_pre = CP.PropsSI('P',
#                'T', C2K(self.T_abs_pre),
#                'Q', 0,
#                librname(self.x2))
            self.P_abs_pre = np.nan
                
        # Heat rejection in absorber: energy balance
        pwater.update(CP.PQ_INPUTS, self.P_evap, 1)
        self.h_abs_vapor_inlet = pwater.hmass() - h_w_ref
        self.Q_abs_main = self.m_refrig * self.h_abs_vapor_inlet \
            + self.m_concentrate * self.h_abs_inlet \
            - self.m_pump * self.h_abs_outlet
        self.Q_abs_total = self.Q_abs_main + self.Q_abs_pre_cool
        
        # Energy balance in SHX, pump side
        D_in = CP.PropsSI('D',
            'T',C2K(self.T_abs_outlet_max),
            'Q',0,
            librname(self.x1))
        DeltaH_pump = (self.P_cond - self.P_evap) / D_in
        self.W_pump = self.m_pump * DeltaH_pump
        self.h_pump_outlet = self.h_abs_outlet + DeltaH_pump
        DeltaH_SHX_pumpside = self.Q_SHX / self.m_pump
        self.h_gen_pre = self.h_pump_outlet + DeltaH_SHX_pumpside
        if self.h_gen_pre > self.h_gen_inlet:
            # Flash steam
            self.T_gen_pre = np.nan
        else:
            # The state is either saturated or subcooled.
            # We need to calculate the temperature from specific heat.
            cp = libr_props.massSpecificHeat(C2K(self.T_gen_inlet),self.x1)
            deltaHsub = self.h_gen_inlet - self.h_gen_pre
            deltaT = deltaHsub / cp
            self.T_gen_pre = self.T_gen_inlet - deltaT
        
        self.Q_gen_pre_heat = self.m_pump * (self.h_gen_inlet - self.h_gen_pre)
        
        # Heat input to generator: energy balance
        pwater.update(CP.PT_INPUTS, self.P_cond, C2K(self.T_gen_inlet))
        self.h_gen_vapor_outlet = pwater.hmass() - h_w_ref
        self.vapor_superheat = self.T_gen_inlet - self.T_cond
        self.Q_gen_main = self.m_refrig * self.h_gen_vapor_outlet \
            + self.m_concentrate * self.h_gen_outlet \
            - self.m_pump * self.h_gen_inlet
        self.Q_gen_total = self.Q_gen_main + self.Q_gen_pre_heat
        
        # Condenser
        pwater.update(CP.PQ_INPUTS, self.P_cond, 0)
        self.h_condenser_outlet = pwater.hmass() - h_w_ref
        self.Q_condenser_reject = self.m_refrig * (self.h_gen_vapor_outlet
            - self.h_condenser_outlet)
        
        # Expansion valve
        self.h_evap_inlet = self.h_condenser_outlet
        
        # Evaporator
        self.h_evap_outlet = self.h_abs_vapor_inlet
        self.Q_evap_heat = self.m_refrig * (self.h_evap_outlet
            - self.h_evap_inlet)
        
        self.COP = self.Q_evap_heat / self.Q_gen_total
Beispiel #11
0
    def __init__(self,P,m_in,h_in,x_in,h_vapor_inlet,debug=False):
        self.P=P
        self.m_in=m_in
        self.h_in=h_in
        self.x_in=x_in
        self.h_vapor_inlet = h_vapor_inlet
        
        self.T_sat = K2C(libr_props.temperature(self.P * 1e-5,
                                                          self.x_in))
        self.h_sat = libr_props.massSpecificEnthalpy(C2K(self.T_sat),self.x_in)
        
        if self.h_in > self.h_sat:
            q,t,xl = libr_props.twoPhaseProps(self.h_in,self.P*1e-5,self.x_in)
            # Pre-cooling is required to reach saturation temperature
            self.Q_pre_cool = self.m_in * (self.h_sat - self.h_in)
            self.T_in = K2C(t)
            prepoints_x = np.linspace(xl,self.x_in,20,endpoint=False)
            prepoints_T = np.zeros_like(prepoints_x)
            prepoints_q = np.zeros_like(prepoints_x)
            
            for i,x in enumerate(prepoints_x):
                #q,t,xl = libr_props.twoPhaseProps(h,self.P*1e-5,self.x_in)
                t = libr_props.temperature(self.P * 1e-5, x)
                h = libr_props.massSpecificEnthalpy(t,x)
                prepoints_T[i] = K2C(t)
                prepoints_q[i] = self.m_in * (h - self.h_in)
                prepoints_x[i] = x
        else:
            self.Q_pre_cool = 0
            self.T_in = K2C(libr_props.temperature(self.P * 1e-5, self.x_in))
            prepoints_T = []
            prepoints_q = []
            prepoints_x = []
        
        # Set up bounds and points for interpolation.
        # Absorber limit is liquid water.
        pwater.update(CP.PQ_INPUTS,P,0)
        self.Tmin = pwater.T()
        x_points = np.linspace(x_in,0.1,100)
        T_points = np.zeros_like(x_points)
        q_points = np.zeros_like(x_points)
        #q_func = np.vectorize(self._q)
        #q_points = q_func(T_points)
        for i,x in enumerate(x_points):
            T_points[i],q_points[i] = self._qx(x)

        x_points = np.concatenate([prepoints_x,x_points])
        T_points = np.concatenate([prepoints_T,T_points])
        q_points = np.concatenate([prepoints_q,q_points])
        
        # Forward function
        T_points1 = np.resize(T_points,len(T_points)+1)
        q_points1 = np.resize(q_points,len(T_points)+1)
        T_points1[-1] = T_points[-1] - 5
        q_points1[-1] = q_points[-1]
        
        # Inverse function
        T_points2 = np.resize(T_points,len(T_points)+1)
        q_points2 = np.resize(q_points,len(T_points)+1)
        T_points2[-1] = T_points[-1]
        q_points2[-1] = q_points[-1] * 1.05
        
        if debug:        
            import matplotlib.pyplot as plt
            import tabulate
            xmod = np.resize(x_points,len(x_points)+1)
            print(tabulate.tabulate(zip(xmod,T_points1,q_points1,
                                    T_points2,q_points2),
                                    headers=['x','T1','q1','T2','q2']))
            plt.figure(); plt.plot(T_points1,q_points1); plt.title("q(T)")
            plt.figure(); plt.plot(q_points2,T_points2); plt.title("T(q)")
        # Interpolate data must be in increasing order, so we reverse it
        # compared to reaction direction.
        self.q = PchipInterpolator(T_points1[::-1], q_points1[::-1])
        self.T = PchipInterpolator(q_points2[::-1], T_points2[::-1])
Beispiel #12
0
def Tsat(x, P, T_guess=25):
    # CP.PropsSI('T','P',P_evap,'Q',0,libr(x1)) # unsupported inputs
    P_err = lambda T: CP.PropsSI('P', 'T', T, 'Q', 0, librname(x)) - P
    f = fsolve(P_err, C2K(T_guess))
    return K2C(f[0])
Beispiel #13
0
    def iterate1(self):
        """Update the internal parameters."""
        self.T_gen_inlet = libr_props2.Tsat(self.x1, self.P_cond, 80)
        self.T_gen_outlet = libr_props2.Tsat(self.x2, self.P_cond,
                                             self.T_gen_inlet)
        self.T_abs_inlet_max = libr_props2.Tsat(self.x2, self.P_evap,
                                                self.T_gen_outlet)
        self.T_abs_outlet_max = libr_props2.Tsat(self.x1, self.P_evap,
                                                 self.T_abs_inlet_max)
        
        self.h_gen_inlet = libr_props2.Hsat(self.x1, self.T_gen_inlet)
        self.h_gen_outlet = libr_props2.Hsat(self.x2, self.T_gen_outlet)
        self.h_abs_inlet = libr_props2.Hsat(self.x2, self.T_abs_inlet_max)
        self.h_abs_outlet = libr_props2.Hsat(self.x1, self.T_abs_outlet_max)
        
        # Mass balance on LiBr
        self.m_concentrate = self.m_pump * self.x1 / self.x2
        # Mass balance on Water
        self.m_refrig = self.m_pump - self.m_concentrate
        self.f = self.m_pump / self.m_refrig

        # Compute SHX outlets, assuming concentrate limits heat flow (C_min)
        # Neglect pump work for the present.
        DeltaT_max = self.T_gen_outlet - self.T_abs_outlet_max
        DeltaT_SHX_concentrate = self.Eff_SHX * DeltaT_max
        self.T_SHX_concentrate_outlet = self.T_gen_outlet \
            - DeltaT_SHX_concentrate
        self.h_SHX_concentrate_outlet = CP.PropsSI('H',
            'T', C2K(self.T_SHX_concentrate_outlet),
            'P', self.P_cond,
            librname(self.x2))
        self.Q_SHX = self.m_concentrate \
            * (self.h_gen_outlet - self.h_SHX_concentrate_outlet)
        
        # Expansion valve
        self.h_abs_pre = self.h_SHX_concentrate_outlet
        if self.h_abs_pre > self.h_abs_inlet:
            # Pre-cooling is required to reach saturation temperature
            self.Q_abs_pre_cool = self.m_concentrate \
                * (self.h_abs_pre - self.h_abs_inlet)
            self.T_abs_pre = np.nan
            # Minimum vapor pressure for absorption to occur
            self.P_abs_pre = np.inf
        else:
            self.Q_abs_pre_cool = 0
            self.T_abs_pre = K2C(CP.PropsSI('T',
                'H', self.h_abs_pre,
                'P', self.P_evap,
                librname(self.x2)))
            # Minimum vapor pressure for absorption to occur
            self.P_abs_pre = CP.PropsSI('P',
                'T', C2K(self.T_abs_pre),
                'Q', 0,
                librname(self.x2))
                
        # Heat rejection in absorber: energy balance
        self.h_abs_vapor_inlet = CP.PropsSI('H',
            'P',self.P_evap,
            'Q',1,
            water) - h_w_ref
        self.Q_abs_main = self.m_refrig * self.h_abs_vapor_inlet \
            + self.m_concentrate * self.h_abs_inlet \
            - self.m_pump * self.h_abs_outlet
        self.Q_abs_total = self.Q_abs_main + self.Q_abs_pre_cool
        
        # Energy balance in SHX, pump side
        D_in = CP.PropsSI('D',
            'T',C2K(self.T_abs_outlet_max),
            'Q',0,
            librname(self.x1))
        DeltaH_pump = (self.P_cond - self.P_evap) / D_in
        self.W_pump = self.m_pump * DeltaH_pump
        self.h_pump_outlet = self.h_abs_outlet + DeltaH_pump
        DeltaH_SHX_pumpside = self.Q_SHX / self.m_pump
        self.h_gen_pre = self.h_pump_outlet + DeltaH_SHX_pumpside
        if self.h_gen_pre > self.h_gen_inlet:
            # Flash steam
            self.T_gen_pre = np.nan
        else:
            self.T_gen_pre = K2C(CP.PropsSI('T',
                'P', self.P_cond,
                'H', self.h_gen_pre,
                librname(self.x1)))
        
        self.Q_gen_pre_heat = self.m_pump * (self.h_gen_inlet - self.h_gen_pre)
        
        # Heat input to generator: energy balance
        self.h_gen_vapor_outlet = CP.PropsSI('H',
            'P', self.P_cond,
            'T', C2K(self.T_gen_inlet), water) - h_w_ref
        self.vapor_superheat = self.T_gen_inlet - self.T_cond
        self.Q_gen_main = self.m_refrig * self.h_gen_vapor_outlet \
            + self.m_concentrate * self.h_gen_outlet \
            - self.m_pump * self.h_gen_inlet
        self.Q_gen_total = self.Q_gen_main + self.Q_gen_pre_heat
        
        # Condenser
        self.h_condenser_outlet = CP.PropsSI('H',
            'P',self.P_cond,
            'Q', 0, water) - h_w_ref
        self.Q_condenser_reject = self.m_refrig * (self.h_gen_vapor_outlet
            - self.h_condenser_outlet)
        
        # Expansion valve
        self.h_evap_inlet = self.h_condenser_outlet
        
        # Evaporator
        self.h_evap_outlet = self.h_abs_vapor_inlet
        self.Q_evap_heat = self.m_refrig * (self.h_evap_outlet
            - self.h_evap_inlet)
        
        self.COP = self.Q_evap_heat / self.Q_gen_total
Beispiel #14
0
        W W
        C
        W W W
        W W W/W
        W
        kg/kg
        W
        none""".split()
        return tabulate.tabulate(zip(names,vals,units))
        

if __name__ == "__main__":
    if True:
        # Example 6.1 in the book
        P1,P2 = 673, 7445
        T1 = K2C(CP.PropsSI('T','P',P1,'Q',1,water))
        T2 = K2C(CP.PropsSI('T','P',P2,'Q',1,water))
        c = ChillerLiBr1(T_evap=T1,T_cond=T2)
        c.x2=libr_props2.Xsat(89.9,c.P_cond)
        c.x1=libr_props2.Xsat(32.7,c.P_evap)
        print "Initializing..."
        print c
        print "Iterating..."
        c.iterate1()    
        print c
    if False:
        # Figure 6.3 in the book
        Eff_SHX = np.linspace(0,1)
        COP = np.zeros_like(Eff_SHX)
        for i in range(len(Eff_SHX)):
            c = ChillerLiBr1(Eff_SHX=Eff_SHX[i])
def main():
    spec = AdsorptionChillerSpec()
    ctrl = AdsorptionChillerControl()
    chiller = AdsorptionChiller(spec, ctrl)

    Ni, Nj = 2, 3
    T_exhaust_range = linspace(313, 393, Ni)
    end_t_range = logspace(2, 3, Nj)
    #end_t_range = [240];

    #Ni = length(T_exhaust_range);
    #Nj = length(end_t_range);
    q_ref = zeros((Ni, Nj))
    q_in = zeros((Ni, Nj))
    cop = zeros((Ni, Nj))
    T = []
    ##
    T_d0 = 311
    #T_d0 = 325.6137

    for i, t_exhaust in enumerate(T_exhaust_range):
        ctrl.t_exhaust = t_exhaust
        #for j = Nj:-1:1
        for j, end_t in enumerate(end_t_range):
            ctrl.end_t = end_t
            t = linspace(ctrl.start_t, ctrl.end_t, endpoint=True)
            #[T_d0,fval,exitflag,output,jacobian] = fsolve(@(T)(loopOnce(T,t)),T_d0);
            x, infodict, ier, mesg = fsolve(chiller.loopOnce,
                                            T_d0,
                                            args=(t, t),
                                            full_output=True)
            print(mesg)
            T_d0 = x

            if 'qad' in vars():
                del qad
            print('T={}, '.format(t_exhaust))
            fig3 = figure(3)
            fig3.clear()
            xlabel('Time(sec)')
            ylabel('Temperature($^\circ$C)')
            ax3 = fig3.gca()
            ax3.cla()
            #hold on
            fig4 = figure(4)  # cla
            fig4.clear()
            xlabel('$T$ / $^\circ$C')
            ylabel('$q$ / (kg/kg)')
            ax4 = fig4.gca()
            ax4.cla()
            ax4.grid(True)
            #hold on

            #       for t_evap = [283:1:295]
            #       for m_water = [0.1:0.01:0.6]

            dta = 1
            myt = 0
            for k in range(5):
                #while dta>=1:
                #while dta>=1e-3:
                dTa, dt, q_d1, q_a1 = chiller.loopOnce(T_d0, t, t, ax3, ax4,
                                                       [fig3, fig4], myt)
                myt += dt
                # Don't need to see this for every case.
                # Run adsorption.main to view time series of individual cases.
                """
                ty, qy = chiller.desorption9(t, T_d0)
                fig=figure(3)
                plot(myt + t,ty-273.15,'r')
                draw()
                fig.canvas.flush_events()
                figure(4);
                if 'qad' in vars():
                    # There was a compression step
                    # Continue plot from previous adsorption step
                    plot(K2C(array([tad[-1],ty[0]])),[qad[-1],qy[0]],'o-');
                plot(ty-273.15,qy,'r'); draw()
                myt = myt + end_t
                T_d1 = ty[-1]
                q_d1 = chiller.f.Q(ctrl.t_cond, T_d1)
                P_a0 = wsr4t2p(ctrl.t_evap) / ((q_d1 / spec.xo) ** spec.n)
                T_a0 = wsr4p2t(P_a0)
                q_a0 = q_d1
    
                tad, qad = chiller.adsorption9(t, T_a0)
                T_a1 = tad[-1]
                q_a1 = chiller.f.Q(ctrl.t_evap, T_a1);
                P_d0 = wsr4t2p(ctrl.t_cond) / ((q_a1 / spec.xo) ** spec.n)
                T_d0_new = wsr4p2t(P_d0)
    
                figure(3); plot(myt + t,K2C(tad),'b'); draw()
                figure(4); plot(K2C(array([T_d1,T_a0])),[q_d1,q_a0],'o-')
                plot(K2C(tad),qad,'b'); draw()
                myt = myt + end_t
    
                dta = abs(T_d0 - T_d0_new)
                T_d0 = T_d0_new
                fig.canvas.flush_events()
                """

            x_dil = q_d1
            x_conc = q_a1
            q_ref_this, q_in_this, cop_this, m_ref = chiller.afterSolve(
                x_dil, x_conc, 0.5 * end_t)
            pe = wsr4t2p(ctrl.t_evap)

            q_ref[i, j] = q_ref_this
            q_in[i, j] = q_in_this
            cop[i, j] = cop_this
            print('{}, {}\n'.format(cop[i, j], q_ref[i, j]))
            #raw_input("Please press [Enter] to proceed")
            #plt.draw()
            #plt.show()

    # <codecell>
    fig = figure(7)
    ax = fig.add_subplot(111, projection='3d')
    T = K2C(T_exhaust_range)
    [X, Y] = meshgrid(T, end_t_range, indexing='ij')
    surf = ax.plot_surface(X, Y, q_ref, cmap=cm.viridis, rstride=1, cstride=1)
    xlabel('Hot Water Temperature, $T$ ($^\circ$C)')
    ylabel('Half cycle time, $t/2$')
    ax.set_zlabel('Cooling capacity, kW')
    fig.colorbar(surf, shrink=0.5, aspect=5)
    # Not necessary in matplotlib

    figure(1)
    plot(T, q_ref, 'k-'), xlabel('Hot Water Temperature ($^\circ$C)'), ylabel(
        'Refrigeration Capacity(kW)')
    figure(2)
    plot(T, cop,
         'k-'), xlabel('Hot Water Temperature ($^\circ$C)'), ylabel('COP')

    fig, ax1 = plt.subplots()
    ax2 = ax1.twinx()
    ax1.plot(T, q_ref, 'o:')
    ax2.plot(T, cop, 's:')
    ax1.set_xlabel('Hot Water Temperature ($^\circ$C)')
    ax1.set_ylabel('Refrigeration Capacity (kW)')  # left y-axis
    ax2.set_ylabel('COP')  # right y-axis

    ax1.set_ylim([0, 21])
    ax2.set_ylim([0, 1.4])

    plt.show()