Exemple #1
0
def prepare_homogenous_transition(p, m_dot, steps, fp: FluidProperties):
    x = np.linspace(start=0, stop=1, num=steps) # [-] Vapour quality range
    ## NOTE: subscript sat for sat has been dropped for readability
    # Calculate saturation parameters at edges
    T_sat = fp.get_saturation_temperature(p=p) # [K] Saturation temperature
    rho_l = fp.get_liquid_density_at_psat(p_sat=p) # [kg/m^3]
    rho_g = fp.get_vapour_density_at_psat(p_sat=p) # [kg/m^3] Gas saturation density

    # Void fraction is precalculated because it allow for simple evaluation of velocity when geometry changes
    alpha = tp.homogenous_void_fraction(x=x, rho_g=rho_g, rho_l=rho_l) # [-] Void fraction
    rho = tp.mixture_density(alpha=alpha, rho_g=rho_g, rho_l=rho_l) # [kg/m^3] Mixture density of two-phase flow

    # Mean viscosity has no obvious way to be calculated and as such, a relation must simply be chosen [10.42] from Carey2008 is used.
    mu_l = fp.get_liquid_saturation_viscosity(p_sat=p) # [Pa*s]
    mu_g = fp.get_gas_saturation_viscosity(p_sat=p) # [Pa*s]
    mu = tp.mean_viscosity(mu_g=mu_g, mu_l=mu_l, rho_l=rho_l, rho_g=rho_g, x=x) # [Pa*s]

    # Thermal conductivity at saturation
    kappa_l = fp.get_liquid_saturation_conductivity(p_sat=p) # [W/(m*K)]
    kappa_g = fp.get_gas_saturation_conductivity(p_sat=p) # [W/(m*K)]
    # Mean conductivity
    kappa = tp.mean_conductivity(kappa_g=kappa_g, kappa_l=kappa_l, rho_l=rho_l, rho_g=rho_g, x=x) # [W/(m^2*K)]
    # Prandtl numbers at saturation,
    Pr_l = fp.get_saturation_Prandtl_liquid(p_sat=p) # [-]
    Pr_g = fp.get_saturation_Prandtl_gas(p_sat=p) # [-]
    # Mean Prandtl
    Pr = tp.mean_Prandtl(Pr_g=Pr_g, Pr_l=Pr_l, rho_l=rho_l, rho_g=rho_g, x=x) # [-]



       


    # Saturation enthalpies
    h_sat_liquid = fp.get_saturation_enthalpy_liquid(p=p) # [J/kg]
    h_sat_gas = fp.get_saturation_enthalpy_gas(p=p) # [J/kg]
    # Enthalpy as function of vapour quality x
    h = h_sat_liquid + (h_sat_gas-h_sat_liquid) * x # [J/kg] Saturation enthalpy as flow quality increases
    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] Heating power required to increase enthalpy in each sections

    return {
        'x': x,
        'alpha': alpha,
        'T_sat': T_sat,
        'rho': rho,
        'rho_l': rho_l,
        'rho_g': rho_g,
        'mu': mu,
        'mu_l': mu_l,
        'mu_g': mu_g,
        'Pr_l': Pr_l,
        'Pr_g': Pr_g,
        'Pr': Pr,
        'kappa_l': kappa_l,
        'kappa_g': kappa_g,
        'kappa': kappa,
        'h': h,
        'Q_dot': Q_dot,
    }
Exemple #2
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]
        }