Esempio n. 1
0
    def calculate_pow_cyc(self):

        if (self.press_out == 0 or self.temp_in == 0 or self.temp_out == 0
                or self.mass_fl == 0 or self.work_fl == ''
                or self.amb_work_fl == 0 or self.pr == 0 or self.amb_pr == 0
                or self.amb_temp_in == 0 or self.amb_temp_out == 0
                or self.amb_press_out == 0):

            print(
                "Condenser.calculate_pow_cyc(): There's not enough set attributes "
                "to solve the equation in the TESPy's heat exchanger model\n")

        else:

            if self.approved:
                # With set values of attributes it's possible to solve the TESPy's equation and obtain required results.
                # Solving the TESPy's equation:
                self.nw.solve('design')
                self.nw.save('solved')

                # Saving the results of required attributes:
                self.press_in = self.cycle_cond.p.val
                self.heat_val = abs(self.condenser.Q.val)
                self.enth_in = self.cycle_cond.h.val
                self.enth_out = self.cond_cycle.h.val
                self.entr_out = PropsSI('S', 'H', self.enth_out, 'P',
                                        self.press_out, self.work_fl)
                self.entr_in = PropsSI('S', 'H', self.enth_in, 'P',
                                       self.press_in, self.work_fl)
                self.amb_press_out = self.cond_amb.p.val
                self.amb_press_in = self.amb_cond.p.val
                self.amb_mass_fl = abs(self.cond_amb.m.val)
                self.amb_enth_out = self.cond_amb.h.val
                self.amb_enth_in = self.amb_cond.h.val
            else:
                print(
                    "Condenser.calculate_pow_cyc(): The values of attributes received by the instance of the object"
                    "haven't been approved.\n")
Esempio n. 2
0
    def q_dr_1_2(self):
        #  Heat transferred from the air pipe to the air, W
        average_temperature = (self.st_i.temperature +
                               self.st_o.temperature) / 2
        average_pressure = (self.st_i.pressure + self.st_o.pressure) / 2
        density = PropsSI('D', 'T', average_temperature, 'P', average_pressure,
                          self.st_i.fluid)
        v = 4 * self.st_i.flow_rate[0] / (np.pi * self.airPipe.d_i**2 *
                                          density)
        mu = PropsSI('V', 'T', average_temperature, 'P', average_pressure,
                     self.st_i.fluid)
        re = density * v * self.airPipe.d_i / mu
        cp = PropsSI('C', 'T', average_temperature, 'P', average_pressure,
                     self.st_i.fluid)
        k = PropsSI('L', 'T', average_temperature, 'P', average_pressure,
                    self.st_i.fluid)
        pr = cp * mu / k
        mu_cav = PropsSI('V', 'T', self.airPipe.temperature, 'P',
                         average_pressure, self.st_i.fluid)
        Nu_prime = Const.Nu_in_pipe(re, pr, mu, mu_cav)

        c_r = 1 + 3.5 * self.airPipe.d_i / (self.d_cav - self.airPipe.d_i -
                                            2 * self.airPipe.delta_a)
        Nu = c_r * Nu_prime

        h = Nu * k / self.airPipe.d_i

        H_prime_c = self.airPipe.d_i + 2 * self.airPipe.delta_a
        N = np.floor(self.dep_cav / H_prime_c)
        H_c = self.dep_cav / N
        L_c = N * np.sqrt((np.pi * self.d_cav)**2 + H_c**2)
        A_airPipe = np.pi * self.airPipe.d_i * L_c

        DeltaT1 = self.airPipe.temperature - self.st_i.temperature
        DeltaT2 = self.airPipe.temperature - self.st_o.temperature
        DeltaT = Const.log_mean(DeltaT1, DeltaT2)

        return h * A_airPipe * DeltaT
Esempio n. 3
0
def T_mix_s(gas, s, P, y, Tguess):
    "find the mixture temperature given its specific enthalpy"
    T = [Tguess + 5, Tguess - 5]
    s_check = (PropsSI('S', 'T', T[0], 'P', P * 1000, gas) / 1000 +
               y * s_l(T[0])) / (1 + y)
    f = [abs(s_check - s)]

    i = 0  #array index
    while abs(f[i]) > numTol:
        i = i + 1  #update index
        if T[i] < Tguess / 2:  #ride herd
            T[i] = Tguess / 2 + random() * (Tguess - Tguess / 2)

        s_check = (PropsSI('S', 'T', T[i], 'P', P * 1000, gas) / 1000 +
                   y * s_l(T[i])) / (1 + y)
        f = np.append(f, abs(s_check - s))
        T = np.append(T, T[i] - (f[i] * (T[i] - T[i - 1])) /
                      (f[i] - f[i - 1]))  #secant method

        if i > 100:
            raise Exception("T_mix_s not converging after 100x")

    return T[i]
Esempio n. 4
0
 def _q(self,T):
     from CoolProp.CoolProp import PropsSI
     if T < self.Tmin:
         return 0
     elif T > self.Tmax:
         return self._q(self.Tmax)
     else:
         try:
             # CoolProp raises an exception if this is the saturation temp.
             #h_out = CP.PropsSI('H','P',self.P,'T',C2K(T),self.fluid)
             h_out = PropsSI('H','P',self.P,'T',C2K(T),self.fluid)
         except:
             h_out = self.h_sat
     return self.mdot * (h_out - self.h_in)
def leakage(gas, T_pleleak, P_preleak, P_postleak, y_star, A_leak):

    gamma_leak = gamma_mix(gas, T_pleleak, P_preleak, y_star)
    P_leak_crit = P_preleak * pow(
        (2.0 / (gamma_leak + 1)), gamma_leak / (gamma_leak - 1))
    P_leak_thr = max(P_postleak, P_leak_crit)  #choke flow in leakage

    s_preleak = (PropsSI('S', 'T', T_pleleak, 'P', P_preleak * 1000, gas) /
                 1000 + y_star * s_l(T_pleleak)) / (1 + y_star)
    h_preleak = (PropsSI('H', 'T', T_pleleak, 'P', P_preleak * 1000, gas) /
                 1000 + y_star * h_l(T_pleleak, P_preleak)) / (1 + y_star)

    T_leak_thr = PropsSI('T', 'S', s_preleak * 1000, 'P', P_leak_thr * 1000,
                         gas)  #isentropic nozzle leaking
    v_leak_thr = 1.0 / PropsSI('D', 'S', s_preleak * 1000, 'P',
                               P_leak_thr * 1000, gas)
    h_leak_thr = PropsSI('H', 'S', s_preleak * 1000, 'P', P_leak_thr * 1000,
                         gas) / 1000
    vel_leak_thr = math.sqrt(2.0 * (h_preleak - h_leak_thr) *
                             1000)  #kJ/kg --> J/kg
    m_leak = 1.0 / v_leak_thr * vel_leak_thr * A_leak

    return m_leak
def k_mix(gas, T, P, y):
    "find the thermal conductivity of the oil-refrigerant mixture"
    xg = 1.0 / (1 + y)
    xl = y / (1 + y)

    "Reference: Bell, I. PhD Dissertation 2011 p.134"
    vG = vol_g(gas, T, P)
    vL = vol_l(T)
    void = xg * vG / (xl * vL + xg * vG)
    kG = PropsSI('L', 'T', T, 'P', P * 1000, gas)  #[W/m-K]
    kL = k_l(T)
    k = (1.0 - void) * kL + void * kG

    return k
def Re_mix(gas, T, P, vel, D, y):
    "find the Reynolds number of the oil-refrigerant mixture"
    vol = (vol_g(gas, T, P) + y * vol_l(T)) / (1 + y)
    rho = 1.0 / vol

    "McAdams 1942 eqn"
    muG = PropsSI('V', 'T', T, 'P', P * 1000, gas)
    muL = mu_l(T)
    xg = 1.0 / (1.0 + y)
    xl = y / (1.0 + y)
    mu = muG * muL / (muG * xl + muL * xg)
    Re = rho * vel * D / mu

    return Re
Esempio n. 8
0
def get_enthalpy(T, p):
    """Returns SPECIFIC enthalpy for water through CoolProp library
    
    Arguments:
        T {K} -- Temperature
        P {Pa} -- Pressure
    
    Returns:
        h {J/kg}
    """
    # Documentation says "HEOS::Water" is the most accurate, but it is also slow.
    # "IF97::Water" is faster but slightly less accurate
    h = PropsSI('H','T',T,'P',p,"HEOS::Water")
    return h
Esempio n. 9
0
 def vps(self,
         fluid: str,
         fp: str,
         fpv: float,
         sp: str,
         spv: float,
         n: int = 4):
     """ get volume by pressure and entropy"""
     try:
         result = round(PropsSI('D', fp, fpv, sp, spv, fluid), n)
         result = 1 / result
     except:
         result = 'vps does not work'
     return result
Esempio n. 10
0
 def update_temp(self, fissions, decrease=False):
     '''Update temperature of the solution based on energy input'''
     # Assume that the system properties do not diverge greatly from those for water
     spec_heat = PropsSI('O', 'T', self.temp, 'Q', 0.0, 'WATER')  # J/kg-K
     # Assume that 180 MeV is deposited in the solution per fission event
     if not decrease:
         self.delta_temp = (fissions * 180 * 1.6022e-13) / spec_heat / (
             self.mass / 1000)  # K
     else:
         beta_0 = PropsSI('ISOBARIC_EXPANSION_COEFFICIENT', 'T', self.temp,
                          'Q', 0.0, 'WATER')  # 1/K
         kappa_0 = PropsSI('ISOTHERMAL_COMPRESSIBILITY', 'T', self.temp,
                           'Q', 0.0, 'WATER') * 1e6  # 1/MPa
         surf_tens = PropsSI('I', 'T', self.temp, 'Q', 0.0,
                             'WATER') * 1e-6  # MN/m
         self.beta = beta_0 * (1 - self.volfrac_gas) + self.volfrac_gas / self.temp \
                     * (self.av_pressure + 2 * surf_tens / c.RAD_GAS_BUBBLE) \
                     / (self.av_pressure + 4 * surf_tens / 3 / c.RAD_GAS_BUBBLE)  # 1/K
         self.kappa = kappa_0 * (1 - self.volfrac_gas) + self.volfrac_gas \
                     / (self.av_pressure + 4 * surf_tens / 3 / c.RAD_GAS_BUBBLE)  # 1/MPa
         self.delta_temp = -(self.beta * self.temp / (self.kappa * 1e-6) \
                            * (self.delta_vol / 100**3)) / spec_heat / (self.mass / 1000)  # K
     self.temp += self.delta_temp  # K
Esempio n. 11
0
def ShahCondensation_Average(x_min, x_max, Ref, G, D, p, TsatL, TsatV):
    # ********************************
    #        Necessary Properties
    #    Calculated outside the quadrature integration for speed
    # ********************************
    mu_f = PropsSI('V', 'T', TsatL, 'Q', 0, Ref)  #kg/m-s
    cp_f = PropsSI('C', 'T', TsatL, 'Q', 0, Ref)  #*1000 #J/kg-K
    k_f = PropsSI('L', 'T', TsatV, 'Q', 0, Ref)  #*1000 #W/m-K
    Pr_f = cp_f * mu_f / k_f  #[-]
    Pstar = p / PropsSI(Ref, 'pcrit')
    h_L = 0.023 * (G * D / mu_f)**(0.8) * Pr_f**(0.4) * k_f / D  #[W/m^2-K]

    def ShahCondensation(x, Ref, G, D, p):
        return h_L * ((1 - x)**(0.8) + (3.8 * x**(0.76) * (1 - x)**(0.04)) /
                      (Pstar**(0.38)))

    if not x_min == x_max:
        #A proper range is given
        return quad(ShahCondensation, x_min, x_max,
                    args=(Ref, G, D, p))[0] / (x_max - x_min)
    else:
        #A single value is given
        return ShahCondensation(x_min, Ref, G, D, p)
Esempio n. 12
0
 def vpt(self,
         fluid: str,
         fp: str,
         fpv: float,
         sp: str,
         spv: float,
         n: int = 4):
     """ get volume by pressure and temperature"""
     try:
         result = round(PropsSI('D', fp, fpv, sp, spv, fluid), n)
         result = round((1 / result), n)
     except:
         result = 'vpt does not work'
     return result
Esempio n. 13
0
 def get_sound_of_speed(self,
                        fluid: str,
                        fp: str,
                        fpv: float,
                        sp: str,
                        spv: float,
                        n: int = 4):
     """ get value of speed of sound """
     try:
         result = round(PropsSI('speed_of_sound', fp, fpv, sp, spv, fluid),
                        n)
     except:
         result = 'speed of sound does not work'
     return result
def calc_props(T, fluid):
    Pv = PropsSI('P', 'T', T, 'Q', 1, fluid)
    rhov = PropsSI('D', 'T', T, 'Q', 1, fluid)
    rhol = PropsSI('D', 'T', T, 'Q', 0, fluid)
    dHv = PropsSI("H", "T", T, "Q", 1, fluid)
    dHl = PropsSI("H", "T", T, "Q", 0, fluid)
    if fluid == 'NitrousOxide':
        Vv = visc_sat_vap(T) / rhov
        Vl = visc_sat_liq(T) / rhol
        sigma = surface_tension(T)
    else:
        Vv = PropsSI('V', 'T', T, 'Q', 1, fluid) / rhov
        Vl = PropsSI('V', 'T', T, 'Q', 0, fluid) / rhol
        sigma = PropsSI("surface_tension", "T", T, "Q", 0, fluid)
    update_disp(Pv, rhov, rhol, Vv, Vl, sigma, dHv, dHl)
    return
Esempio n. 15
0
 def vtx(self,
         fluid: str,
         fp: str,
         fpv: float,
         sp: str,
         spv: float,
         n: int = 4):
     """ get volume by temperature and vapor quality """
     try:
         result = round(PropsSI('D', fp, fpv, sp, spv, fluid), n)
         result = 1 / result
     except:
         result = 'vtx does not work'
     return result
Esempio n. 16
0
 def UDproblem(self, U, rho, Pguess, Tguess):
     """
     Defining a constant UV problem i.e. constant internal energy and density/volume 
     problem relevant for the 1. law of thermodynamics. 
     For multicomponent mixture the final temperature/pressure is changed/optimised until the 
     residual U/rho is near zero. For single component fluid the coolprop 
     built in methods are used for speed. 
     
     Parameters
     ----------
     U : float 
         Internal energy at final conditions
     rho : float
         Density at final conditions. 
     Pguess : float 
         Initial guess for the final pressure at U, rho
     Tguess : float 
         Initial guess for the final temperature at U, rho
     """
     if "&" in self.species:
         x0 = [Pguess, Tguess]
         res = minimize(self.UDres,
                        x0,
                        args=(U, rho),
                        method='Nelder-Mead',
                        options={
                            'xatol': 0.1,
                            'fatol': 0.001
                        })
         P1 = res.x[0]
         T1 = res.x[1]
         Ures = U - self.fluid.umass()
     else:
         P1 = PropsSI("P", "D", rho, "U", U, self.species)
         T1 = PropsSI("T", "D", rho, "U", U, self.species)
         Ures = 0
     return P1, T1, Ures
Esempio n. 17
0
    def charge(self, m_dot_in, fluid_in, T_in, p_in, m_dot_out, dt):

        # Subscripts
        # i - inlet
        # 0 - previous time step, time 0
        # 1 - current time step, time 1

        # Tank current state
        T0 = self.T
        p0 = self.p
        Cv0 = PropsSI('CVMASS', 'T', T0, 'P', p0,
                      fluid)  # Assume small differences in Cv
        MW = PropsSI('MOLEMASS', fluid)  # kg/mol
        R = PropsSI('GAS_CONSTANT', fluid)  # J/mol-K

        # Inlet state
        Ti = state_i['T']
        pi = state_i['p']

        # Mass Balance
        mi = m_dot * dt  # mass inflow
        m0 = self.m  # tank mass at t-1 (t0)
        m1 = mi + m0  # tank mass at t (t1)

        # Energy Balance
        ui = PropsSI('U', 'T', Ti, 'P', pi, fluid)
        u0 = PropsSI('U', 'T', T0, 'P', p0, fluid)
        u1 = (mi * ui + m0 * u0) / m1

        # Ideal Gas Law
        T1 = u1 / Cv
        n = m1 / MW  # moles
        p1 = n * R * T1 / V

        # Store results
        self.m = m1
        self.state = def_state_tp(fluid, T1, p1)
Esempio n. 18
0
def heat_room(Q_dot, T_amb, i, T_int, Pot):

    ii = i

    A_sala, h_sala, V_sala, P_int = room_conditions()

    # Caudal Volumico de ar renovado - [m^3 / min]
    V_dot_renov = 0.7 * (10 ^ (-3)) / 60

    # CP do ar renovado
    cp_renov = PropsSI('CPMASS','T', T_amb[i] + 273.15,'P',P_int, 'Air')

    # Caudal Massico de ar Renovado - [kg^3 / min]
    m_dot_renov = V_dot_renov * PropsSI('D','T', T_amb[i] + 273.15,'P',P_int, 'Air')

    # Caudal Massico da Sala - [kg^3 / min]
    m_dot_int = V_sala * PropsSI('D','T', T_amb[i] + 273.15,'P',P_int, 'Air') * 60

    Pot[ii] = pump(T_int[i-1], Pot[ii-1])

    C_1 = m_dot_int * PropsSI('CPMASS','T', (T_int[ii-1]) + 273.15,'P',P_int, 'Air')
    C_2 = - (A_sala * h_sala + m_dot_renov * cp_renov)
    C_3 = Pot[ii]
    C_4 = T_int[ii-1]
    C_5 = T_amb[i]

    a = np.array([[(C_2 / C_1), 1, 0],
                  [0, 1, -1],
                  [1, 0, -1]])

    b = np.array([C_3/C_1, -C_4, -C_5])

    x = np.linalg.solve(a, b)

    T_int[ii] = x[2]

    return T_int, Pot
Esempio n. 19
0
    def p_v_plot(self):
        Press = np.linspace(self.p + self.p_under, self.p + self.p_over, 200)
        fig = plt.figure()
        # plotting the isotherm in P_v diagram
        plt.semilogx(1 / PropsSI("D", "P", Press, "T", self.T, "HEOS::Water"),
                     Press / 1e5,
                     label='Temperature = ' + str(self.T) + ' K, ')
        if self.saturated == 'False':
            plt.semilogx(1/PropsSI("D","P",self.p,"T",self.T,"HEOS::Water"), self.p/1e5, 'ro', \
                     label = 'P = '+ str(self.p/1e5)+ ' bar, ' + 'T = '+ str(self.T)+ ' K')
        else:
            v = float(
                input(
                    'The state is saturated. Enter the speoific volume in m^3/kg '
                ))
            plt.semilogx(v,
                         self.p / 1e5,
                         'ro',
                         label='P = ' + str(self.p / 1e5) + ' bar, ' + 'T = ' +
                         str(self.T) + ' K')

        # plotting the saturation states
        P_range = np.logspace(
            np.log10(611), np.log10(Pc),
            1000)  # 611 is just above the triple point pressure
        V_liquid = 1 / PropsSI("D", "P", P_range, "Q", 0, "HEOS::Water")
        V_vapor = 1 / PropsSI("D", "P", P_range, "Q", 1, "HEOS::Water")
        plt.semilogx(V_liquid, P_range / 1e5)
        plt.semilogx(V_vapor, P_range / 1e5)
        plt.gca().set_ylim(
            bottom=0
        )  # had problems with neg. pressures when above critical pt

        plt.xlabel('specific Volume (v) in m^3/kg')
        plt.ylabel('Pressure [bar]')
        plt.legend(loc='best')
        plt.show(block=False)
Esempio n. 20
0
    def cal_design_params(self):

        #  0 = hot, 1 = cold, following Enum PipeType
        A_fx = np.zeros(len(StreamType))

        (self.A_c, self.d_h, peri_c) = self.cal_geo_params()

        for i in StreamType:
            self.mu[i] = PropsSI('V', 'P', self.p[i], 'T', self.T[i], "CO2")

        A_fx = np.divide(self.mdot, self.mu) * (self.d_h / self.Re)

        self.A_f = max(A_fx)
        self.N_ch = math.ceil(self.A_f / self.A_c)
        self.G = self.mdot / self.A_f
Esempio n. 21
0
def Pr(T, P, species):
    """
    Calculation of Prandtl number, eq. 4.5-6 in
    C. J. Geankoplis Transport Processes and Unit Operations, International Edition,
    Prentice-Hall, 1993

    Parameters
    ----------
    T : float
        Temperature of the fluid film interface 
    P : float 
        Pressure of fluid inventory

    Returns
    ----------
    Pr : float
        Prantdl number
    """
    C = PropsSI("C", "T|gas", T, "P", P, species)
    V = PropsSI("V", "T|gas", T, "P", P, 'HEOS::'+species.split('::')[1])
    L = PropsSI("L", "T|gas", T, "P", P, 'HEOS::'+species.split('::')[1])
    Pr = C * V / L

    return Pr
Esempio n. 22
0
def compute_mu_from_TP_gas(temp, press, gas_name):
    """Computes the chemical potential from temperature, pressure for a gas

    :param temp: The temperature in Kelvin
    :param press: The pressure in Pa
    :param str: The name of the gas
    :returns: The chemical potential
    """

    # Compute the fugacity coefficient
    fug_coeff = _compute_fug_coeff(
        lambda p: PropsSI('Z', 'T', temp, 'P', p, gas_name),
        press
        )

    # Compute the molecular weight, a little bit hack, obtained by taking the
    # ratio of the mass density and the molar density.

    call_seq = ('T', temp, 'P', press, gas_name)
    # The call sequence to get properties of the current gas
    mol_wgt = PropsSI('DMASS', *call_seq) / PropsSI('DMOLAR', *call_seq)

    # Return the chemical potential
    return _compute_mu(mol_wgt, fug_coeff, temp, press)
Esempio n. 23
0
    def get_Mach_number(self, T, p, u):
        """Returns the Mach number by dividing provided velocity with speed of sound

        Args:
            T (K): Temperature
            p (Pa): Pressure
            u (m/s): Velocity

        Returns:
            M (-): Mach number
        """

        speed_of_sound = PropsSI("speed_of_sound", 'T', T, 'P', p, self.fluid)

        return u / speed_of_sound  # [-] Return the mach number based on given velocity u
Esempio n. 24
0
    def __init__(self,
                 comp,
                 flow,
                 temperature=None,
                 pressure=None,
                 quality=None):
        self.comp = comp
        self.flow = flow

        assert (temperature,pressure,quality).count(None) == 1, \
            "Must specify exactly two properties for a pure fluid."

        if temperature is not None and quality is not None:
            self.t = temperature
            self.q = quality
            self.p = PropsSI('P', 'T', temperature, 'Q', quality, comp)
        elif pressure is not None and quality is not None:
            self.p = pressure
            self.q = quality
            self.t = PropsSI('T', 'P', pressure, 'Q', quality, comp)
        elif temperature is not None and pressure is not None:
            self.t = temperature
            self.p = pressure
            self.q = -1
Esempio n. 25
0
    def calculate(self, event):
        #
        GoOn = True
        #
        self.Text_1.delete(1.0, END)
        self.ref = self.Caller.get_ref()
        #

        for k in self.symbols:
            try:
                self.OutVal[k] = SI_TO(
                    k,
                    PropsSI(cpcode[k], cpcode[self.Quantity1], self.Value1,
                            cpcode[self.Quantity2], self.Value2, self.ref))
            except ValueError:
                self.Text_1.insert(END,
                                   _('Calculation error, check your inputs!'))
                GoOn = False
                break
        #
        if GoOn:
            Phase = CoolProp.CoolProp.PhaseSI(cpcode[self.Quantity1],
                                              self.Value1,
                                              cpcode[self.Quantity2],
                                              self.Value2, self.ref)
            #
            self.var_ref = _('Statepoint calculation for %12s \n\n')
            self.lines = []
            myline = self.var_ref % self.ref
            self.lines.append(myline)
            #
            for sy in self.symbols:
                one = '{:<27}'.format(label[sy])
                two = '{:16.4f}'.format(self.OutVal[sy])
                if sy == 'Q':
                    three = '{:>10} {:<}\n'.format(GUI_UNIT(sy), Phase)
                else:
                    three = '{:>10}\n'.format(GUI_UNIT(sy))
                myline = one + two + three
                self.lines.append(myline)
            #
            for l in self.lines:
                self.Text_1.insert(END, l)

        def Update(self):
            #
            pass
Esempio n. 26
0
    def generate_temperature_data(self, accuracy=10):

        # The parameter of "accuracy" indicates number of temperature points, which will be generated for particular
        # zones - liquid and saturation

        # The matrices below are going to be filled with both values of working fluid and ambient temperatures.
        temp_vap = [[0 for x in range(accuracy + 1)] for y in range(2)]
        temp_sat = [[0 for x in range(accuracy + 1)] for y in range(2)]
        temp_liq = []
        # It may happen that the evaporator is used to heat the working fluid in power cycle:
        used_in_power_cyc = False
        saturation_temp = PropsSI("T", "P", self.press_in, "Q", 0,
                                  self.work_fl)
        if self.temp_in < saturation_temp:
            temp_liq = [[0 for x in range(accuracy + 1)] for y in range(2)]
            used_in_power_cyc = True

        enth_results = self.generate_enthalpies_data(accuracy=accuracy)
        enth_sat = enth_results[0]
        enth_vap = enth_results[1]
        # For power cycle the function "generate_enthalpies_data()" will automatically generate an additional
        # list with data of enthalpies in the liquid zone.
        if used_in_power_cyc:
            enth_liq = enth_results[0]
            enth_sat = enth_results[1]
            enth_vap = enth_results[2]

        # basing on the enthalpy points from above, temperatures of working fluid and ambient fluid will be generated:
        for a in range(accuracy + 1):
            # working fluid:
            temp_sat[0][a] = PropsSI("T", "P", self.press_in, "H",
                                     enth_sat[0][a], self.work_fl)
            temp_vap[0][a] = PropsSI("T", "P", self.press_out, "H",
                                     enth_vap[0][a], self.work_fl)
            if used_in_power_cyc:
                temp_liq[0][a] = PropsSI("T", "P", self.press_in, "H",
                                         enth_liq[0][a], self.work_fl)
            # ambient:
            temp_sat[1][a] = PropsSI("T", "P", self.amb_press_out, "H",
                                     enth_sat[1][a], self.amb_work_fl)
            temp_vap[1][a] = PropsSI("T", "P", self.amb_press_in, "H",
                                     enth_vap[1][a], self.amb_work_fl)
            if used_in_power_cyc:
                temp_liq[1][a] = PropsSI("T", "P", self.amb_press_in, "H",
                                         enth_liq[1][a], self.amb_work_fl)
        if used_in_power_cyc:
            return [temp_liq, temp_sat, temp_vap]
        else:
            return [temp_sat, temp_vap]
Esempio n. 27
0
def test_input_types():
    for Fluid in ['Water']:
        for Tvals in [
                0.5 * PropsSI(Fluid, 'Tmin') + 0.5 * PropsSI(Fluid, 'Tcrit'),
            [PropsSI(Fluid, 'Tmin') + 1e-5,
             PropsSI(Fluid, 'Tcrit') - 1e-5],
                np.linspace(
                    PropsSI(Fluid, 'Tmin') + 1e-5,
                    PropsSI(Fluid, 'Tcrit') - 1e-5, 30)
        ]:
            yield check_type, Fluid, Tvals
Esempio n. 28
0
    def getEnthalpy(self, T):

        if self.useConstantProperties:
            if self.constantEnthalpyIsSet == False:
                print(
                    "FATAL ERROR setConstantEnthalpy must be defined if constant properties are used"
                )
                sys.exit(0)
            else:
                return self.constantEnthalpy
        else:
            if newVersion == True:
                return PropsSI("H", "T", T + 273.15, "P", self.pressure,
                               self.name) * 1000.0
            else:
                return Props("H", "T", T + 273.15, "P", self.pressure,
                             self.name) * 1000.0
Esempio n. 29
0
    def getEnthalpy(self, T):

        if (self.useConstantProperties):
            if (self.constantEnthalpyIsSet == False):
                print(
                    "FATAL ERROR setConstantEnthalpy must be defined if constant properties are used"
                )
                sys.exit(0)
            else:
                return self.constantEnthalpy
        else:
            if (newVersion == True):
                return (PropsSI('H', 'T', T + 273.15, 'P', self.pressure,
                                self.name) * 1000.)
            else:
                return (Props('H', 'T', T + 273.15, 'P', self.pressure,
                              self.name) * 1000.)
Esempio n. 30
0
    def getMu(self, T):

        if (self.useConstantProperties):
            if (self.constantMuIsSet == False):
                print(
                    "FATAL ERROR setConstartMu must be defined if constant properties are used"
                )
                sys.exit(0)
            else:
                return self.constantMu
        else:
            if (newVersion == True):
                return PropsSI('V', 'T', T + 273.15, 'P', self.pressure,
                               self.name)
            else:
                return Props('V', 'T', T + 273.15, 'P', self.pressure,
                             self.name)