Exemplo n.º 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,
    }
Exemplo n.º 2
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]
        }
Exemplo n.º 3
0
def plotSaturationCurve():
    fp = FluidProperties("water")
    p_sat = np.linspace(start=0.01e5, stop=10.0e5, num=100)  # [P] Pressure
    T_sat = fp.get_saturation_temperature(p_sat)  # [K]

    plt.figure()
    plt.plot(T_sat, p_sat * 1e-5)
    plt.xlabel("Saturation temperature - $T_{{sat}}$ [K]")
    plt.ylabel("Saturation pressure - $p_{{sat}}$ [bar]")
    plt.grid()
    plt.title("Saturation curve for water")
    plt.tight_layout()
Exemplo n.º 4
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]
        }
Exemplo n.º 5
0
def two_phase_single_channel(T_wall,
                             w_channel,
                             Nu_func_gas,
                             Nu_func_liquid,
                             T_inlet,
                             T_chamber,
                             p_ref,
                             m_dot,
                             h_channel,
                             fp: FluidProperties,
                             print_info=True):
    """ Function that calculates the total power consumption of a specific chamber, in order to optimize the chamber

    Args:
        T_wall (K): Wall temperature
        w_channel (m): Channel width
        Nu_func_gas (-): Nusselt function for gas phase
        Nu_func_liquid (-) Nusselt function for liquid phase
        T_inlet (K): Chamber inlet temperature
        T_chamber (K): Chamber outlet temperature (same as T_c in IRT)
        p_ref (Pa): Reference pressure for the Nusselt relation and flow similary parameters (same as inlet pressure as no pressure drop is assumed)
        m_dot (kg/s): Mass flow
        h_channel (m): Channel height
        w_channel_margin (m): The amount of margin around the chamber for structural reasons. Important because it also radiates heat
        fp (-  ): [description]
        print_info(Bool): for debugging purposes
    """

    # Calculate saturation temperature, to determine where transition from gas to liquid occurs
    T_sat = fp.get_saturation_temperature(p=p_ref)  # [K]
    # Sanity check on input
    assert (T_chamber > T_sat)
    assert (T_wall > T_chamber)

    # Calculate the two reference temperatures for the separated phases
    T_bulk_gas = (T_sat + T_chamber) / 2  # [K] Bulk temperature gas phase
    T_bulk_liquid_multi = (
        T_inlet +
        T_sat) / 2  # [K] Bulk temperature of liquid and multi-phase flow
    # Calculate the density at these reference points
    rho_bulk_gas = fp.get_density(T=T_bulk_gas, p=p_ref)  # [kg/m^3]
    rho_bulk_liquid_multi = fp.get_density(T=T_bulk_liquid_multi,
                                           p=p_ref)  # [kg/m^3]

    # Channel geometry
    A_channel = w_channel * h_channel  # [m^2] Area through which the fluid flows
    wetted_perimeter = wetted_perimeter_rectangular(
        w_channel=w_channel, h_channel=h_channel
    )  # [m] Distance of channel cross-section in contact with fluid
    D_hydraulic = hydraulic_diameter_rectangular(
        w_channel=w_channel, h_channel=h_channel)  # [m] Hydraulic diameter

    # Flow similarity parameters (for debugging and Nu calculatoin purposes)
    Re_bulk_gas = fp.get_Reynolds_from_mass_flow(
        m_dot=m_dot, p=p_ref, T=T_bulk_gas, L_ref=D_hydraulic,
        A=A_channel)  # [-] Bulk Reynolds number in the gas phase
    Re_bulk_liquid_multi = fp.get_Reynolds_from_mass_flow(
        m_dot=m_dot,
        p=p_ref,
        T=T_bulk_liquid_multi,
        L_ref=D_hydraulic,
        A=A_channel)  # [-] Bulk Reynolds number in the liquid/multi-phase
    Pr_bulk_gas = fp.get_Prandtl(
        T=T_bulk_gas, p=p_ref)  # [-] Prandtl number in the gas phase
    Pr_bulk_liquid_multi = fp.get_Prandtl(
        T=T_bulk_liquid_multi,
        p=p_ref)  # [-] Prandtl number in liquid/multi-phase
    Bo_sat = fp.get_Bond_number(
        p_sat=p_ref, L_ref=D_hydraulic
    )  # [-] Bond number at saturation pressure (assumed to be p_ref)

    # Calculate Nusselt number in both sections
    args_gas = {
        'Re': Re_bulk_gas,  # Arguments for Nusselt function (gas phase) 
        'Pr': Pr_bulk_gas,
        'Bo': Bo_sat,
    }

    args_liquid_multi = { # Arguments for Nusselt function (liquid/multi phase)
        'Re': Re_bulk_liquid_multi,
        'Pr': Pr_bulk_liquid_multi,
        'Bo': Bo_sat,
        }

    Nu_gas = Nu_func_gas(args=args_gas)
    Nu_liquid_multi = Nu_func_liquid(args=args_liquid_multi)
    # Calculate Stanton number in both sections
    St_gas = Stanton_from_Nusselt_and_velocity(
        Nu=Nu_gas,
        T_ref=T_bulk_gas,
        p_ref=p_ref,
        L_ref=D_hydraulic,
        m_dot=m_dot,
        A=A_channel,
        fp=fp)  # [-] Stanton number in gas phase
    St_liquid_multi = Stanton_from_Nusselt_and_velocity(
        Nu_liquid_multi,
        T_ref=T_bulk_liquid_multi,
        p_ref=p_ref,
        L_ref=D_hydraulic,
        m_dot=m_dot,
        A=A_channel,
        fp=fp)  # [-] Stanton number in liquid phase
    # Calculate velocity for convection parameter (bulk temp used as reference for phase)
    u_bulk_gas = velocity_from_mass_flow(
        A=A_channel, m_dot=m_dot,
        rho=rho_bulk_gas)  # [m/s] Velocity at the gas bulk reference state
    u_bulk_liquid_multi = velocity_from_mass_flow(
        A=A_channel, m_dot=m_dot, rho=rho_bulk_liquid_multi
    )  # [m/s] Velocity at the liquid/multi-phase bulk reference state
    # Convective parameter
    h_conv_gas = h_conv_from_Stanton(
        Stanton=St_gas, u=u_bulk_gas, T_ref=T_bulk_gas, p_ref=p_ref, fp=fp
    )  # [W/(m^2*K)] Convective heat transfer coefficient at bulk gas state
    h_conv_liquid_multi = h_conv_from_Stanton(
        Stanton=St_liquid_multi,
        u=u_bulk_liquid_multi,
        T_ref=T_bulk_liquid_multi,
        p_ref=p_ref,
        fp=fp
    )  # [W/(m^2*K)] Convective heat transfer coefficient at bulk liquid/multi-phase state
    # Required specific enthalpy change for heating the separate sections
    h_outlet = fp.get_enthalpy(
        T=T_chamber, p=p_ref)  # [J/kg] Specific enthalpy at the outlet
    h_sat_gas = fp.get_saturation_enthalpy_gas(
        p=p_ref)  # [J/kg] Specific enthalpy of saturated gas
    h_inlet = fp.get_enthalpy(T=T_inlet, p=p_ref)  # [J/kg]
    # Required specific enthalpy increases
    delta_h_gas = h_outlet - h_sat_gas  # [J/kg] Enthalpy increase needed to go from saturated gas to outlet enthalpy
    delta_h_liquid_multi = h_sat_gas - h_inlet  # [J/k] Enthalpy increase needed to go from inlet enthalpy to saturated gas
    # Required power for those enthalpy changes at the given mass flow
    Q_dot_gas = required_power(m_dot=m_dot, delta_h=delta_h_gas)  # [W]
    Q_dot_liquid_multi = required_power(m_dot=m_dot,
                                        delta_h=delta_h_liquid_multi)  # [W]
    # Required heater area to achieve the required power
    A_heater_gas = required_heater_area(Q_dot=Q_dot_gas,
                                        h_conv=h_conv_gas,
                                        T_wall=T_wall,
                                        T_ref=T_bulk_gas)  # [m^2]
    A_heater_liquid_multi = required_heater_area(
        Q_dot=Q_dot_liquid_multi,
        h_conv=h_conv_liquid_multi,
        T_wall=T_wall,
        T_ref=T_bulk_liquid_multi)  # [m^2]
    # Required length to achieve desired area
    L_channel_gas = A_heater_gas / wetted_perimeter  # [m] Length of channel after gas is saturated
    L_channel_liquid_multi = A_heater_liquid_multi / wetted_perimeter  # [m] Length of channel after heater
    L_channel = L_channel_gas + L_channel_liquid_multi  # [m]
    L_hydrodynamic_entrance = D_hydraulic * Re_bulk_liquid_multi * 0.04  # [m] Hydrodynamic entrance to estimate if the flow is fully developed

    assert (h_outlet > h_sat_gas)
    assert (h_sat_gas > h_inlet)

    if (print_info):
        print("\n--- SPECIFIC ENTHALPY AT DIFFERENT STATIONS ---")
        print("h_outlet: {:4.3f} J/kg".format(h_outlet))
        print("h_sat_gas: {:4.3f} J/kg".format(h_sat_gas))
        print("h_inlet: {:4.3f} J/kg".format(h_inlet))

        print("\n --- REQUIRED POWER ---")
        print("Q_dot_gas: {:2.5f} W".format(Q_dot_gas))
        print("Q_dot_liquid_multi: {:2.5f} W".format(Q_dot_liquid_multi))

        print("\n --- BULK GAS PHASE PARAMETERS --- ")
        print("u: {:3.2f} m/s".format(u_bulk_gas))
        print("Nu: {}".format(Nu_gas))
        print("Re: {}".format(Re_bulk_gas))
        print("Pr: {}".format(Pr_bulk_gas))
        print("St: {}".format(St_gas))
        print("Bo_sat: {}".format(Bo_sat))

        print("\n --- BULK LIQUID/MULTI-PHASE PARAMETERS ---")
        print("u: {:3.4f} m/s".format(u_bulk_liquid_multi))
        print("Nu: {}".format(Nu_liquid_multi))
        print("Re: {}".format(Re_bulk_liquid_multi))
        print("Pr: {}".format(Pr_bulk_liquid_multi))
        print("St: {}".format(St_liquid_multi))

        print("\n --- CHARACTERISTIC GEOMETRIC VALUES --- ")
        print("Hydrodynamic entance length: {:3.3f} micron".format(
            L_hydrodynamic_entrance * 1e6))
        print("Hydraulic diameter: {:3.3f} micron".format(D_hydraulic * 1e6))
        print("L/D: {:4.2f} ".format(L_channel / D_hydraulic))
        print("L/X_T {:4.2f}".format(L_channel / L_hydrodynamic_entrance))

        print("\n --- RESULTING GEOMETRY ---")
        print("Total length: {:3.3f} mm".format(L_channel * 1e3))
        print("Length (liquid/multi): {:3.3f} mm".format(
            L_channel_liquid_multi * 1e3))
        print("Length (gas): {:3.4f} mm".format(L_channel_gas * 1e3))
        print("Relative length (gas) {:3.3f} \%".format(L_channel_gas /
                                                        L_channel * 100))

        ## Return a dictionary with results and interesting intermediate values
    res = {
        "L_channel": L_channel,  # [m] Total length of channel
        "D_hydraulic": D_hydraulic,  # [m] Hydraulic diameter of channel
        "Nu_liquid_multi":
        Nu_liquid_multi,  # [-] Nusselt number of liquid/multi-phase flow
        "Pr_bulk_liquid_multi":
        Pr_bulk_liquid_multi,  # [-] Prandlt number of liquid/multi-phase flow
        "Re_bulk_liquid_multi":
        Re_bulk_liquid_multi,  # [-] Reynolds number of liquid/multi-phase flow
        "St_liquid_multi":
        St_liquid_multi,  # [-] Stanton number of liquid/multi-phase flow
        "h_conv_liquid_multi":
        h_conv_liquid_multi,  # [W/(m^2*K)] Heat transfer coefficient
        "A_heater_liquid_multi":
        A_heater_liquid_multi,  # [m^2] Required heater area for liquid/multi-phase flow
        "L_channel_liquid_multi":
        L_channel_liquid_multi,  # [m] Length of channel to get required heater area
        "u_bulk_liquid_multi":
        u_bulk_liquid_multi,  # [m/s] Bulk flow velocity of liquid/multi-phase flow
        "rho_bulk_liquid_multi":
        rho_bulk_liquid_multi,  # [kg/m^3] Bulk density of liquid/multi-phase flow
        "T_bulk_liquid_multi":
        T_bulk_liquid_multi,  # [K] Bulk temperature of liquid/multi-phase flow
        "delta_h_liquid_multi":
        delta_h_liquid_multi,  # [J/kg] Enthalpy change from inlet to saturated gas
        "Q_dot_liquid_multi":
        Q_dot_liquid_multi,  # [W] Power required for enthalpy change
        ## Same thing but for gas values
        "Nu_gas": Nu_gas,  # [-]
        "Pr_bulk_gas": Pr_bulk_gas,  # [-]
        "Re_bulk_gas": Re_bulk_gas,  # [-]
        "St_gas": St_gas,  # [-]
        "h_conv_gas": h_conv_gas,  # [W/(m^2*K)]
        "A_heater_gas": A_heater_gas,  # [m^2]
        "L_channel_gas": L_channel_gas,  # [m]
        "u_bulk_gas": u_bulk_gas,  # [m/s]
        "rho_bulk_gas": rho_bulk_gas,  # [kg/m^3]
        "T_bulk_gas": T_bulk_gas,  # [K]
        "delta_h_gas": delta_h_gas,  # [J/kg]
        "Q_dot_gas": Q_dot_gas,  # [W]
    }
    return res
Exemplo n.º 6
0
w_channel = td['w_channel']  # [m] Channel width
T_inlet = td['T_inlet']  # [K] Inlet temperature
T_wall = td['T_wall']  # [K] Wall temperature
p_inlet = td['p_inlet']  # [Pa] Inlet pressure
m_dot = td['m_dot']  # [kg/s] Mass flow (through all channels if multiple)
channel_amount = td['channel_amount']  # [-] Amount of channels
h_channel = td['h_channel']  # [m] Channel height/depth
fp = FluidProperties(
    td['propellant'])  # Object from which fluid properties can be accessed

# Calculate mass flow for one single channel
m_dot_channel = m_dot / channel_amount  # [kg/s] Mass flow through one single channel

## Chamber temperature is unknown, so instead a range is chosen from T_sat + 1 to T_wall-1
T_sat = fp.get_saturation_temperature(p=p_inlet)  # [K]
T_chamber = np.linspace(start=T_sat + 1, stop=T_wall - 1, num=250)  # [K]

it = np.nditer(T_chamber, flags=['c_index'])

L_channel_1 = np.zeros_like(T_chamber)  # [m]
L_channel_2 = np.zeros_like(T_chamber)  # [m]
L_channel_3 = np.zeros_like(T_chamber)  # [m]

for T in it:
    ## First set of Nusselt relations
    res_1 = zD.two_phase_single_channel( T_wall=T_wall, w_channel=w_channel, Nu_func_gas=Nu_func_gas_1, Nu_func_liquid=Nu_func_liquid_1,\
    T_inlet=T_inlet, T_chamber=float(T), p_ref=p_inlet, m_dot=m_dot_channel,\
        h_channel=h_channel, fp=fp,print_info=False)
    # Store results
    L_channel_1[it.index] = res_1['L_channel']
Exemplo n.º 7
0
def calc_and_plot_thruster(td, axs_to_plot):
    # For Cen the chamber temperature is unknown, so  a range is taken instead
    # seem inconsitent with saturation temperatures and/or reported wall temperatures
    T_wall = td['T_wall']                   # [K] Wall temperature
    w_channel = td['w_channel']             # [m] Channel width
    T_inlet = td['T_inlet']                 # [K] Inlet temperature
    p_inlet = td['p_inlet']                 # [Pa] Inlet pressure
    m_dot = td['m_dot']                     # [kg/s] Mass flow (through all channels if multiple)
    channel_amount = td['channel_amount']   # [-] Amount of channels
    h_channel = td['h_channel']             # [m] Channel height/depth
    fp = FluidProperties(td['propellant'])  # Object from which fluid properties can be accessed

    # Calculate mass flow for one single channel
    m_dot_channel = m_dot/channel_amount    # [kg/s] Mass flow through one single channel

    # Chamber temperature is unknown, so a range is taken
    T_sat = fp.get_saturation_temperature(p=p_inlet) # [K]
    T_chamber = np.linspace(start=T_sat+1, stop=T_wall-1, num=250) # [K] 

    # Geometric values
    wetted_perimeter = basic.chamber.wetted_perimeter_rectangular(w_channel=w_channel, h_channel=h_channel) # [m] Wetted perimeter of channel
    A_channel = w_channel*h_channel # [m^2] Cross-sectional through which fluid flows
    D_hydraulic = basic.chamber.hydraulic_diameter_rectangular(w_channel=w_channel, h_channel=h_channel) # [m] Hydraulic diameter
    # Preparation functions calculations many intermediate values that are known before geometry is known


    
    # Storing the length results in here, one for each set of Nusselt relations
    L_1 = np.zeros_like(T_chamber) # [m] Total channel length
    L_2 = np.zeros_like(L_1)

    # Loop to calculate the channel length with each wall temperature
    it_T = np.nditer(T_chamber, flags=['c_index']) # [K] Wall temperature
    T_chamber_guess = None # [K] Stores chamber temperature when actual length is first reached (in laminar case).
    for T in it_T:


        prepared_values = oneD.full_homogenous_preparation(
        T_inlet=T_inlet,
        T_outlet=T, # <---- Iterated variable
        m_dot=m_dot_channel,
        p_ref=p_inlet,
        steps_l=steps_l,
        steps_tp=steps_tp,
        steps_g=steps_g,
        fp=fp)

        # results_1 = oneD.full_homogenous_calculation(
        #     prepared_values=prepared_values,
        #     Nusselt_relations=Nusselt_relations_1,
        #     A_channel=A_channel,
        #     wetted_perimeter=wetted_perimeter,
        #     D_hydraulic=D_hydraulic,
        #     m_dot=m_dot,
        #     T_wall=T_wall,
        #     p_ref=p_inlet,
        #     fp=fp
        #     )
        
        results_2 = oneD.full_homogenous_calculation(
            prepared_values=prepared_values,
            Nusselt_relations=Nusselt_relations_2,
            A_channel=A_channel,
            wetted_perimeter=wetted_perimeter,
            D_hydraulic=D_hydraulic,
            m_dot=m_dot_channel,
            T_wall=T_wall, # <--- Iterated variable
            p_ref=p_inlet,
            fp=fp
            )
        
        # First time the length crosses the actual length, store the value
        if (T_chamber_guess == None) and (results_2['L_total'] > td['L_channel']): # results_2 stores laminar results
            T_chamber_guess = T # [K]
        # L_1[it_T.index] = results_1['L_total']
        L_2[it_T.index] = results_2['L_total']

    ## Print info about thruster, including, estimated chamber temperature for laminar relations
    print("Thruster name: {}".format(td['name']))
    print("Estimated chamber temperature: {:3.2f} K".format(T_chamber_guess))
    

    axs_to_plot.set_title("$\\dot{{m}}={:1.2f}$ mg/s, $p={:1.2f}$ bar".format(m_dot*1e6,p_inlet*1e-5))
    # axs_to_plot.plot(T_chamber,L_1*1e3, label="Turbulent")
    axs_to_plot.plot(T_chamber,L_2*1e3, label="Laminar")
    axs_to_plot.hlines(td['L_channel']*1e3, xmin=T_chamber[0], xmax=T_chamber[-1], linestyle='dashed', color='red', label="Real length")
    axs_to_plot.grid()
Exemplo n.º 8
0
    axs[1][0].plot(T_chamber, w_throat[it_AR.index, :] * 1e6)
    axs[2][0].plot(T_chamber, Isp[it_AR.index, :])
    axs[3][0].plot(T_chamber, Pt_ideal[it_AR.index, :])
    axs[4][0].plot(T_throat[it_AR.index, :], mu_throat[it_AR.index, :])

    # Right side of plot
    axs[0][1].plot(T_chamber, D_hydraulic_throat[it_AR.index, :] * 1e6)
    axs[1][1].plot(T_chamber, Re_throat[it_AR.index, :])
    axs[2][1].plot(T_chamber, Pr_throat[it_AR.index, :])
    axs[3][1].plot(T_throat[it_AR.index, :], p_throat[it_AR.index, :] * 1e-5)
    axs[4][1].plot(T_exit[it_AR.index, :], p_exit[it_AR.index, :] * 1e-5)

# Plot saturation curve on the throat pressure plot to check for condensation
# Some calculations in here are to put proper bound on the plot
T_sat_max = fp.get_saturation_temperature(
    p=1.1 * np.max(p_throat)
)  #fp.get_critical_temperature() # [K] Get saturation temperature at 1.1 times p_throat
T_sat = np.linspace(
    start=np.min(T_throat), stop=T_sat_max,
    num=50)  # [K] Evenly spaced temperature from inlet temp to critical temp
p_sat = fp.get_saturation_pressure(
    T=T_sat)  # [Pa] Saturation pressures matching the temps
# Plot it on the throat pressure curve
axs[3][1].plot(T_sat, p_sat * 1e-5, label="Saturation curve")

# Again, but with bounds for exit pressures and temperature, to keep plot nice
T_sat_max_2 = fp.get_saturation_temperature(
    p=1.1 * np.max(p_exit)
)  #fp.get_critical_temperature() # [K] Get saturation temperature at 1 bar
T_sat_2 = np.linspace(
    start=np.min(T_exit), stop=T_sat_max_2,