예제 #1
0
def prepare_single_phase_liquid(T_inlet, steps, p_ref, m_dot, fp: FluidProperties):
    """ Prepare numpy arrays for calculating channel length in a liquid single-phase section of a channel.
    NOTE: This is done to avoid recalculating arrays that are not dependent on channel geometry, therefore speeding up optimizations.\
        After all, during optimization the geometry is what varies.\
        Also it also ensure that temperature endpoint and enthalpy cleanly match with saturation temperature in the correct phase

    Args:
        T_inlet (K): Inlet temperature
        steps (-): Amount steps of dT taken to reach saturation temperature T_sat (dT = (T_sat-T_inlet)/2)
        p_ref (Pa): Pressure assumed constant along channel, equal to inlet pressure
        m_dot (kg/s): Mass flow
        fp (FluidProperties): Object to access propellant properties with
    """
    T_sat = fp.get_saturation_temperature(p=p_ref) # [K] Saturation temperature
    assert ( T_inlet < T_sat) # Check input
    assert (steps > 1)

    # Temperature and other intermediate variable in channel section i=0...n
    T, dT = np.linspace(start=T_inlet, stop=T_sat, num=steps,retstep=True) # [K] Temperature T_i (also returns steps between sections)
    # The reference temperature for heat transfer calculations
    # The first value [0] should not be important. The heat transfer calculated at i is between i-1 and i
    #  So, from T[i-1] to T[i]. So, if there reference temperature is the average dT/2 must SUBTRACTED
    #T_ref = T - dT/2 # [K] Reference temperature for heat transfer calculations

    ## Get all thermodynamic values that can be precalculated
    # NOTE: all last values must be replaced with the correct values for the saturated liquid state
    # Before the values are replaced, sometimes an error is thrown because the values are close to the saturation point
    # That, or NaNs and infinites show up. This shouldn't be a problem, unless the second-to-last points also start getting close to the saturation point
    
    # Enthalpy 
    h = fp.get_enthalpy(T=T, p=p_ref) # [J/kg] Enthalpy
    h[-1] = fp.get_saturation_enthalpy_liquid(p=p_ref) # [J/kg] Saturation enthalpy at T_n = T_sat
    # Heating power required in section to increase temp by dT. Use enthalpy difference
    delta_h = delta_enthalpy_per_section(h=h) # [J/kg] Enthalpy difference per section
    Q_dot = required_power(m_dot=m_dot, delta_h=delta_h) # [W]

    # Density
    rho = fp.get_density(T=T, p=p_ref) # [kg/m^3] Density
    rho[-1] = fp.get_liquid_density_at_psat(p_sat=p_ref) # [kg/m^3] Saturation density
    # Prandtl number
    Pr = fp.get_Prandtl(T=T, p=p_ref) # [-] Prandtl number
    Pr[-1] = fp.get_saturation_Prandtl_liquid(p_sat=p_ref) # [-] Saturation Prandtl
    # Thermal conductivity 
    kappa = fp.get_thermal_conductivity(T=T, p=p_ref) # [W/(m*K)] Conductivity
    kappa[-1] = fp.get_liquid_saturation_conductivity(p_sat=p_ref) # [W/(m*K)] Saturation conductivity
    # Viscosity
    mu = fp.get_viscosity(T=T, p=p_ref) # [Pa*s] Viscosity
    mu[-1] = fp.get_liquid_saturation_viscosity(p_sat=p_ref) # [Pa*s] Saturation viscosity
    return {\
        "T":T, # [K]
        "dT": dT, # [K]
        "rho": rho, # [kg/m^3]
        "h": h, # [J/kg]
        "Q_dot": Q_dot, # [W]
        "Pr": Pr, # [-]
        "kappa": kappa, # [W/(m*K)]
        "mu": mu, # [Pa*s]
        }
예제 #2
0
    def test_table(self):
        # Table V from Lemmon2004 has density as inputs, which is not interesting for our purposes, so first the pressure must be obtained

        fp = FluidProperties("nitrogen")

        # T in, Density in mol/dm^3, thermal conductivity in W/(m*K)
        in_out = ((100, 25.0, 103.834e-3, 6), (200, 10.0, 36.0099e-3, 7),
                  (300, 5.0, 32.7694e-3, 7))

        molar_mass = 0.02801348  # [kg/mol] also from Span2000

        for T, rho, kappa, places in in_out:
            p = fp.get_pressure(T=T, rho=rho * molar_mass * 1e3)
            res_kappa = fp.get_thermal_conductivity(T=T, p=p)
            self.assertAlmostEqual(res_kappa, kappa, places=places)
예제 #3
0
def prepare_single_phase_gas(T_outlet, steps, p_ref, m_dot, fp: FluidProperties):

    T_sat = fp.get_saturation_temperature(p=p_ref) # [K] Saturation temperature
    assert (T_outlet > T_sat)
    assert (steps > 1)

    # Temperature and other intermediate variable in channel section i=0...n
    T, dT = np.linspace(start=T_sat, stop=T_outlet, num=steps, retstep=True) # [K] Temperature T_i
    # The reference temperature for heat transfer calculations
    # The first value [0] should not be important. The heat transfer calculated at i is between i-1 and i
    #  So, from T[i-1] to T[i]. So, if there reference temperature is the average dT/2 must SUBTRACTED
    #T_ref = T - dT/2 # [K] Reference temperature for heat transfer calculations

    ## Get all thermodynamic values that can be precalculated
    # NOTE: all first values must be replaced with the correct values for the saturated gas state
    # Before the values are replaced, sometimes an error is thrown because the values are close to the saturation point
    # That, or NaNs and infinites show up. This shouldn't be a problem, unless the second-to-last points also start getting close to the saturation point
    
    # Enthalpy 
    h = fp.get_enthalpy(T=T, p=p_ref) # [J/kg] Enthalpy
    h[0] = fp.get_saturation_enthalpy_gas(p=p_ref) # [J/kg] Saturation enthalpy at T_n = T_sat
    # Heating power required in section to increase temp by dT. Use enthalpy difference
    delta_h = delta_enthalpy_per_section(h=h) # [J/kg] Enthalpy difference per section
    Q_dot = required_power(m_dot=m_dot, delta_h=delta_h) # [W]

    # Density
    rho = fp.get_density(T=T, p=p_ref) # [kg/m^3] Density
    rho[0] = fp.get_vapour_density_at_psat(p_sat=p_ref) # [kg/m^3] Saturation density
    # Prandtl number
    Pr = fp.get_Prandtl(T=T, p=p_ref) # [-] Prandtl number
    Pr[0] = fp.get_saturation_Prandtl_gas(p_sat=p_ref) # [-] Saturation Prandtl
    # Thermal conductivity 
    kappa = fp.get_thermal_conductivity(T=T, p=p_ref) # [W/(m*K)] Conductivity
    kappa[0] = fp.get_gas_saturation_conductivity(p_sat=p_ref) # [W/(m*K)] Saturation conductivity
    # Viscosity
    mu = fp.get_viscosity(T=T, p=p_ref) # [Pa*s] Viscosity
    mu[0] = fp.get_gas_saturation_viscosity(p_sat=p_ref) # [Pa*s] Saturation viscosity
    return {\
        "T":T, # [K]
        "dT": dT, # [K]
        "rho": rho, # [kg/m^3]
        "h": h, # [J/kg]
        "Q_dot": Q_dot, # [W]
        "Pr": Pr, # [-]
        "kappa": kappa, # [W/(m*K)]
        "mu": mu, # [Pa*s]
        }
예제 #4
0
                                            p=p,
                                            L_ref=D_hydraulic,
                                            m_dot=m_dot,
                                            A=A_channel)
# Range of hydraulic diameter that fit this Reynolds number
#w_channel = 2*m_dot/( Reynolds_100 * mu_liquid ) - h_c # [m]
#A_channel = h_c * w_channel # [m^2]
#D_hydraulic = basic.chamber.hydraulic_diameter_rectangular(w_channel=w_channel,h_channel=h_c) # [m]

#Reynolds_check = fp.get_Reynolds_from_mass_flow(T=T_liquid, p=p, L_ref=D_hydraulic, m_dot=m_dot, A=A_channel) # [-]
Bond = fp.get_Bond_number(p_sat=p, L_ref=D_hydraulic)  # [m]
# Prandtl number in both reference states
Pr_liquid = fp.get_Prandtl(T=T_liquid, p=p)  # [-]
Pr_gas = fp.get_Prandtl(T=T_gas, p=p)  # [-]
# Conductivity in reference state
conductivity_liquid = fp.get_thermal_conductivity(T=T_liquid, p=p)

Nu_DB_liquid = np.zeros_like(Reynolds)
Nu_DB_gas = np.zeros_like(Reynolds)
Nu_Kandlikar_liquid = np.zeros_like(Reynolds)
#Nu_Kandlikar_gas = np.zeros_like(Reynolds)
# Calculate Nusselt number for different relations

# Iterare over Reynolds numbers
# print(Reynolds)
# iter_Re = np.nditer(Reynolds, flags=['c_index'])
# for Re in Reynolds:

args_liquid = {'Re': Reynolds, 'Pr': Pr_liquid}
args_gas = {'Re': Reynolds, 'Pr': Pr_gas}
args_Kandlikar = {