Esempio n. 1
0
    def _f(self, T, P):
        P /= 1e6

        vir = self._virial(T)
        Baa = vir["Baa"]
        Bww = vir["Bww"]
        Baw = vir["Baw"]
        Caaa = vir["Caaa"]
        Caaw = vir["Caaw"]
        Caww = vir["Caww"]
        Cwww = vir["Cwww"]

        Pws = self._Pwsat(T)
        if T < 273.15:
            kt = _Ice(T, P)["xkappa"]
            vws = _Ice(T, Pws)["v"]
        else:
            kt = _Region1(T, P)["kt"]
            vws = _Region1(T, Pws)["v"]

        vws *= Mw*1000  # Convert from m³/kg to cm³/mol

        # Henry constant
        H_N2 = _Henry(T, "N2")
        H_O2 = _Henry(T, "O2")
        H_Ar = _Henry(T, "Ar")
        H = 1/1.01325*(0.7812/H_N2+0.2095/H_O2+0.0093/H_Ar)

        if Pws > P:
            kt = 0
            H = 0

        def _f(f):
            ws = f*Pws/P
            lnf = ((1+kt*Pws)*(P-Pws)-kt*(P**2-Pws**2)/2)/R/T*vws \
                + log(1-H*(1-ws)*P) \
                + (1-ws)**2*P/R/T*Baa \
                - 2*(1-ws)**2*P/R/T*Baw \
                - (P-Pws-(1-ws)**2*P)/R/T*Bww \
                + (1-ws)**3*P**2/(R*T)**2*Caaa \
                + 3*(1-ws)**2*(1-2*(1-ws))*P**2/2/(R*T)**2*Caaw \
                - 3*(1-ws)**2*ws*P**2/(R*T)**2*Caww \
                - ((3-2*ws)*ws**2*P**2-Pws**2)/2/(R*T)**2*Cwww \
                - (1-ws)**2*(3*ws-2)*ws*P**2/(R*T)**2*Baa*Bww \
                - 2*(1-ws)**3*(3*ws-1)*P**2/(R*T)**2*Baa*Baw \
                + 6*(1-ws)**2*ws**2*P**2/(R*T)**2*Bww*Baw \
                - 3*(1-ws)**4*P**2/2/(R*T)**2*Baa**2 \
                - 2*(1-ws)**2*ws*(3*ws-2)*P**2/(R*T)**2*Baw**2 \
                - (Pws**2-(4-3*ws)*ws**3*P**2)/2/(R*T)**2*Bww**2
            return log(f) - lnf

        f = fsolve(_f, 1)[0]

        if f < 1:
            f = 1
        return f
Esempio n. 2
0
 def Calculate(self):
     if self.type == 'economiser':
         self.cp['cold'] = 4.2
         self.h['cold in'] = steam._Region1(self.t['cold in'], self.operating_pressure)['h']
         self.h['cold out'] = steam._Region1(self.t['cold out'], self.operating_pressure)['h']
         self.t['hot out'] = self.t['hot in'] - ((self.m['cold']) / (self.m['hot'] * self.cp['hot'])) * (self.h['cold out'] - self.h['cold in'])
     elif self.type == 'superheater':
         self.cp['cold'] = 2.1
         self.h['cold in'] = steam._Region2(self.t['cold in'], self.operating_pressure)['h']
         self.h['cold out'] = steam._Region2(self.t['cold out'], self.operating_pressure)['h']
         self.t['hot out'] = self.t['hot in'] - ((self.m['cold']) / (self.m['hot'] * self.cp['hot'])) * (self.h['cold out'] - self.h['cold in'])
     elif self.type == 'evaporator':  # liquid-vapor mixture then we need to work out enthalpies
         self.h['cold in'] = steam._Region4(self.operating_pressure, self.quality_in)['h']
         self.h['cold out'] = steam._Region4(self.operating_pressure, self.quality_out)['h']
         self.t['hot out'] = self.t['hot in'] - ((self.m['cold']) / (self.m['hot'] * self.cp['hot'])) * (self.h['cold out'] - self.h['cold in'])
     # heat usage
     self.Q = self.m['cold'] * (self.h['cold out'] - self.h['cold in'])
def heat_capacity(P, simplified = False):

    if simplified:

        return simplified_model(P, c=c_dict['heat_capacity'])

    T = calculate_saturation_temperature(P)

    P = P*1e-6
    out = _Region1(T, P)
    cp = 1e3 * out['cp']

    return cp
def enthalpy_vapour(P, simplified = False):

    if simplified:

        return simplified_model(P, c=c_dict['enthalpy_vapour'])

    T = calculate_saturation_temperature(P)

    P = P*1e-6
    out = _Region1(T, P)
    h = 1e3 * out['h']

    return h
def vaporization_enthalpy(P, simplified = False):

    if simplified:

        return simplified_model(P, c=c_dict['vaporization_enthalpy'])


    T = calculate_saturation_temperature(P)

    P = P*1e-6

    v = _Region2(T, P)
    l = _Region1(T, P)

    return 1e3 * (v['h'] - l['h'])
def viscosity(P, simplified = False):

    if simplified:

        return simplified_model(P, c=c_dict['viscosity'])

    T = calculate_saturation_temperature(P)

    P = P*1e-6
    out = _Region1(T, P)
    T = out['T']
    v = out['v']

    rho = 1 / v

    return _Viscosity(rho, T)
def density(P, simplified = False):

    if simplified:

        return simplified_model(P, c=c_dict['density'])


    T = calculate_saturation_temperature(P)

    P = P*1e-6
    out = _Region1(T, P)

    v = out['v']

    rho = 1 / v # kg/m3

    return rho
    def __init__(self, hp, ip, lp, m1, m2, m3, ma, steam_high_temp, water_low_temp):
        # Input Parameters
        self.HP = hp  # Bar
        self.IP = ip   # Bar
        self.LP = lp    # Bar

        mass_flow_1 = m1
        mass_flow_2 = m2
        mass_flow_3 = m3
        mass_flow_amine = ma

        self.massflows = {
            'mass flow 1': mass_flow_1,
            'mass flow 2': mass_flow_2,
            'mass flow 3': mass_flow_3,
            'mass flow to amine': mass_flow_amine
        }

        # total mass flow
        total_mass_flow = mass_flow_1 + mass_flow_2 + mass_flow_3

        # Turbine Mass Flows
        HPT_mass_flow = mass_flow_3
        IPT_mass_flow = HPT_mass_flow + mass_flow_2
        LPT_mass_flow = IPT_mass_flow + mass_flow_1 - mass_flow_amine

        # Pump Mass Flows
        HPP_mass_flow = mass_flow_3
        IPP_mass_flow = mass_flow_2
        LPP_mass_flow = IPP_mass_flow + HPP_mass_flow + mass_flow_1

        # HRSG Mass Flows
        self.economiser_1_mass_flow = total_mass_flow
        self.economiser_2_mass_flow = mass_flow_2
        self.economiser_3_mass_flow = mass_flow_3

        self.evaporator_1_mass_flow = mass_flow_1
        self.evaporator_2_mass_flow = mass_flow_2
        self.evaporator_3_mass_flow = mass_flow_3

        self.superheater_1_mass_flow = mass_flow_1 - mass_flow_amine
        self.superheater_2_mass_flow = mass_flow_2 + mass_flow_3
        self.superheater_3_mass_flow = mass_flow_3

        self.SteamHighTemp = steam_high_temp  # Celcius

        WaterLowTemp = water_low_temp  # Celcius

        quality = 0.9  # at turbine outlet

        self.T = [0]*16

        self.T[1] = ToKelvin(WaterLowTemp)

        # Pressures
        self.P = [0]*16
        self.P[1] = steam._PSat_T(self.T[1])

        # low pressure
        self.P[2] = BarToMP(self.LP)  # bar
        self.P[3] = self.P[2]
        self.P[4] = self.P[2]
        self.P[5] = self.P[2]

        # intermediate pressure
        self.P[7] = BarToMP(self.IP)  # bar
        self.P[8] = self.P[7]
        self.P[9] = self.P[8]
        self.P[10] = self.P[9]
        self.P[15] = self.P[9]

        # High Pressure
        self.P[11] = BarToMP(self.HP)  # bar
        self.P[12] = self.P[11]
        self.P[13] = self.P[12]
        self.P[14] = self.P[13]

        # Temperatures in kelvin

        self.T[3] = steam._TSat_P(self.P[3])
        self.T[4] = self.T[3]

        self.T[6] = self.T[1]

        self.T[8] = steam._TSat_P(self.P[8])
        self.T[9] = self.T[8]

        self.T[12] = steam._TSat_P(self.P[12])
        self.T[13] = self.T[12]
        self.T[14] = ToKelvin(self.SteamHighTemp)

        # Begin going around cycle working out available values
        self.SpecificValues = [0] * 16

        self.SpecificValues[1] = steam._Region1(self.T[1], self.P[1])

        self.T[2] = steam._Backward1_T_Ps(self.P[2], self.SpecificValues[1]['s'])
        self.SpecificValues[2] = steam._Region1(self.T[2], self.P[2])

        self.SpecificValues[3] = steam._Region4(self.P[3], 0)
        self.SpecificValues[4] = steam._Region4(self.P[3], 1)

        self.SpecificValues[6] = steam._Region4(self.P[1], quality)
        self.T[5] = steam._Backward2_T_Ps(self.P[5], self.SpecificValues[6]['s'])
        self.SpecificValues[5] = steam._Region2(self.T[5], self.P[5])

        self.T[7] = steam._Backward1_T_Ps(self.P[7], self.SpecificValues[3]['s'])
        self.SpecificValues[7] = steam._Region1(self.T[7], self.P[7])
        self.SpecificValues[8] = steam._Region4(self.P[8], 0)
        self.SpecificValues[9] = steam._Region4(self.P[8], 1)
        self.T[10] = steam._Backward2_T_Ps(self.P[10], self.SpecificValues[5]['s'])
        self.SpecificValues[10] = steam._Region2(self.T[10], self.P[10])
        self.T[11] = steam._Backward1_T_Ps(self.P[11], self.SpecificValues[3]['s'])
        self.SpecificValues[11] = steam._Region1(self.T[11], self.P[11])
        self.SpecificValues[12] = steam._Region4(self.P[12], 0)
        self.SpecificValues[13] = steam._Region4(self.P[13], 1)
        self.SpecificValues[14] = steam._Region2(self.T[14], self.P[14])
        self.T[15] = steam._Backward2_T_Ps(self.P[15], self.SpecificValues[14]['s'])
        self.SpecificValues[15] = steam._Region2(self.T[15], self.P[15])

        self.s = [0] * 16
        self.h = [0] * 16

        for i in range(0, len(self.SpecificValues)):
            if i == 0:
                continue
            self.s[i] = self.SpecificValues[i]['s']
            self.h[i] = self.SpecificValues[i]['h']

        #Printing T-P conditions at each point
        print("-------------------------------------------------------")
        print("\nCycle Conditions:")
        for i in range(1, 16):
            print("\n\tT"+str(+i)+" = "+str(ToCelcius(self.T[i]))+" C")
            print("\tP"+str(+i)+" = "+str(MPToBar(self.P[i]))+" bar")

        #Finding specific work of turbines and pump
        self.total_works = {
            'Work Type': 'Work [kW]',
            'LP Pump work': LPP_mass_flow * (self.h[2] - self.h[1]),
            'IP Pump work': IPP_mass_flow * (self.h[7] - self.h[3]),
            'HP Pump work': HPP_mass_flow * (self.h[11] - self.h[3]),
            'HP Turbine work': HPT_mass_flow * (self.h[14] - self.h[15]),
            'IP Turbine work': IPT_mass_flow * (self.h[10] - self.h[5]),
            'LP Turbine work': LPT_mass_flow * (self.h[5] - self.h[6]),
            'LP Superheater Heat Input': self.superheater_1_mass_flow * (self.h[5] - self.h[4]),
            'LP Evaporator Heat Input': self.evaporator_1_mass_flow * (self.h[4] - self.h[3]),
            'LP Economiser Heat Input':  self.economiser_1_mass_flow * (self.h[3] - self.h[2]),
            'IP Superheater Heat Input': self.superheater_2_mass_flow * (self.h[10] - self.h[15]),
            'IP Superheater 2 Heat Input': self.evaporator_2_mass_flow * (self.h[15] - self.h[9]),
            'IP Evaporator Heat Input': self.evaporator_2_mass_flow * (self.h[9] - self.h[8]),
            'IP Economiser Heat Input':  self.economiser_2_mass_flow * (self.h[8] - self.h[7]),
            'HP Superheater Heat Input': self.superheater_3_mass_flow * (self.h[14] - self.h[13]),
            'HP Evaporator Heat Input': self.evaporator_3_mass_flow * (self.h[13] - self.h[12]),
            'HP Economiser Heat Input':  self.economiser_3_mass_flow * (self.h[12] - self.h[11])
        }

        print("\nCycle Specific Works:")
        for work, value in self.total_works.items():
            print("\n\t"+work+" = "+str(value))

        #Finding Total Heat into Cycle from HRSG
        self.q_in = self.total_works['LP Economiser Heat Input'] + self.total_works['LP Evaporator Heat Input'] + self.total_works['LP Superheater Heat Input'] + self.total_works['IP Economiser Heat Input'] + \
            self.total_works['IP Evaporator Heat Input'] + self.total_works['IP Superheater Heat Input'] + self.total_works['HP Economiser Heat Input'] + self.total_works['HP Evaporator Heat Input'] + self.total_works['HP Superheater Heat Input']

        #FInding Net Work
        self.w_net = self.total_works['HP Turbine work'] + self.total_works['IP Turbine work'] + self.total_works['LP Turbine work'] - self.total_works['HP Pump work'] - self.total_works['IP Pump work'] - self.total_works['LP Pump work']
        self.total_works['Net Work'] = self.w_net
        #Finding Thermal Efficiency fo Steam Cycle
        self.efficiency = self.w_net / self.q_in
        self.total_works['Efficiency'] = self.efficiency

        print("\nCycle Efficiency:")
        print("\n\tefficiency = "+str(self.efficiency*100)+"%")
        print("\n\tWith a Net Work of : "+str(np.round(self.w_net))+"kW")
        print("\n\tand a Total Heat Input of: "+str(np.round(self.q_in))+"kW\n")
Esempio n. 9
0
    def __step(self, time=0.0):

        # Check for valid intervals
        p_in_min = 6.1121e-4 * unit.mega * unit.pascal
        p_in_max = 22.064 * unit.mega * unit.pascal
        assert p_in_min <= self.inflow_pressure <= p_in_max

        assert 19 + 273.15 <= self.inflow_temp <= 800 + 273.15, 'inflow temp = %r' % self.inflow_temp

        # Get state values
        p_in_MPa = self.inflow_pressure / unit.mega / unit.pascal
        p_out_MPa = self.vent_pressure / unit.mega / unit.pascal

        # If entering stream is not steam (valve closed scenario)
        if self.inflow_temp < steam_table._TSat_P(p_in_MPa):
            t_runoff = self.inflow_temp
            turbine_power = 0
            quality = 0

        else:
            s_out_prime = steam_table._Region2(self.inflow_temp, p_in_MPa)['s']
            h_in = steam_table._Region2(self.inflow_temp, p_in_MPa)['h']
            bubl = steam_table._Region4(p_out_MPa, 0)
            dew = steam_table._Region4(p_out_MPa, 1)
            bubl_entropy = bubl['s']
            dew_entropy = dew['s']
            bubl_enthalpy = bubl['h']
            dew_enthalpy = dew['h']

            # If the ideal runoff is two-phase mixture:
            if bubl_entropy < s_out_prime < dew_entropy:
                quality = (s_out_prime - bubl_entropy) / (dew_entropy -
                                                          bubl_entropy)
                h_out_prime = bubl_enthalpy + quality * (dew_enthalpy -
                                                         bubl_enthalpy)

            # If ideal run off is superheated
            elif s_out_prime > dew_entropy:
                t_ideal = steam_table._Backward2_T_Ps(p_out_MPa, s_out_prime)
                h_out_prime = steam_table._Region2(t_ideal, p_out_MPa)['h']
                quality = 1

            # Else ideal run off is subcooled
            else:
                t_ideal = steam_table._Backward1_T_Ps(p_out_MPa, s_out_prime)
                h_out_prime = steam_table._Region1(t_ideal, p_out_MPa)['h']
                quality = 0

            # Calculate the real runoff enthalpy
            w_ideal = h_in - h_out_prime  #on a per mass basis
            assert w_ideal > 0
            w_real = w_ideal * self.turbine_efficiency
            h_out_real = h_in - w_ideal
            assert h_out_real > 0
            if w_real < 0:
                w_real = 0

            # If run off is actually subcooled
            if h_out_real < bubl_enthalpy:
                t_runoff = steam_table._Backward1_T_Ph(p_out_MPa, h_out_real)
                quality = 0  # subcooled liquid

            # If run off is actually superheated
            elif h_out_real > dew_enthalpy:
                t_runoff = steam_table._Backward2_T_Ph(p_out_MPa, h_out_real)
                quality = 1  # superheated steam

            # Else run off is actually in two phase region
            else:
                quality = (h_out_real - bubl_enthalpy) / (dew_enthalpy -
                                                          bubl_enthalpy)
                t_runoff = steam_table._Region4(p_out_MPa, quality)['T']

            turbine_power = self.inflow_mass_flowrate * w_real * unit.kilo * unit.watt

        # Update state variables
        turbine_outflow = self.outflow_phase.get_row(time)
        turbine = self.state_phase.get_row(time)

        time += self.time_step

        self.outflow_phase.add_row(time, turbine_outflow)

        self.outflow_phase.set_value('temp', t_runoff, time)
        self.outflow_phase.set_value('flowrate', self.inflow_mass_flowrate,
                                     time)
        self.outflow_phase.set_value('quality', quality, time)
        self.outflow_phase.set_value('pressure', self.vent_pressure, time)

        self.state_phase.add_row(time, turbine)

        self.state_phase.set_value('power', turbine_power, time)
        self.rejected_heat_pwr = self.inflow_total_heat_pwr - turbine_power
        self.state_phase.set_value('rejected-heat', self.rejected_heat_pwr,
                                   time)

        return time