------------------------------------------------------------------------------- -- (C) ESA-ESTEC, Propulsion & Aerothermodynamics Division -- -- FILE NAME: CompJunction.el -- LIBRARY: STEADY -- DESCRIPTION: Definition of concentrated pressure losses (junctions, -- valves, mass flow controllers, injector, split, merge) -- NOTES: -- $LastChangedDate: 2013-11-11 16:37:26 +0100 (lun, 11 nov 2013) $ -- $Rev: 855 $ -- AUTHORS: F.D.M. and M.D.R., TEC-MPC, ESA-ESTEC, J.M., Empresarios Agrupados. -- VERIFIED: M.D.R., TEC-MPC, ESA-ESTEC. -- APPROVED: ------------------------------------------------------------------------------- -- Libraries USE MATH VERSION "3.0" USE PORTS_LIB VERSION "1.0" USE FLUID_PROPERTIES ------------------------------------------------------------------------------- FUNCTION NO_TYPE ori_prop(SET_OF(Chemicals_full) mix, REAL x[mix], ENUM FluidKeys fluid, REAL P, REAL h, OUT REAL Te, OUT REAL rho, OUT REAL cs, OUT REAL G_cr, INTEGER ier) DECLS REAL Cp, MW, Rg, gamma, k BODY rho = FL_prop_vs_ph(mix, x, fluid, P,h, fprop_density, Te,ier) Te = FL_prop_vs_ph(mix, x, fluid, P,h, fprop_temperature, Te, ier) cs = FL_prop_vs_ph(mix, x, fluid, P,h, fprop_vsound, Te,ier) G_cr= FL_Gcrit_fun (fluid, P,rho, Te, 0, 0, cs, ier) END FUNCTION ------------------------------------------------------------------------------- ABSTRACT COMPONENT AbstractJunction "Abstract junction component without mass accumulation" PORTS IN fluid_s f1 "Inlet fluid port number 1" OUT fluid_s f2 "Outlet fluid port number 2" DATA DECLS ENUM FluidKeys fluid "Working fluid" REAL m = 1 "Mass flow - positive from f1 to f2 (kg/s)" INTEGER ier "Error Flag" TOPOLOGY INIT DISCRETE ASSERT (f1.n_fluid > 0) FATAL "AbstractJunction: working fluid not defined" CONTINUOUS f1.x_eq = f2.x_eq f1.fluid = fluid f1.fluid = f2.fluid f1.n_fluid = f2.n_fluid -- Conservation of mass m = f2.m m = f1.m --Conservation of energy f1.h = f2.h END COMPONENT ------------------------------------------------------------------------------- ABSTRACT COMPONENT AbstractJunctionLoss IS_A AbstractJunction( ENUM DeltaP dp_type = FromPorts "Valve DeltaP option", ENUM DesignType type = Design "Design, calculated flow area; OffDesign, fixed flow area") "Calculation of a concentrated load loss including sonic flow limitation" PORTS DATA REAL Ao = 7.e-5 "Junction area [Fixed if Off-Design mode; for iterative calculations if Design] (m^2)" REAL zeta = 1 "Loss coefficient (-)" REAL dP_per = 15 "Relative pressure drop in Design mode (%)" REAL dP_design = 0.1e5 "Absolute pressure drop in Design mode (Pa)" REAL m_o = 1 "Initial mass flow [only to init in case of collection of flows] (kg/s)" REAL T_o = 200 "Initial temperature [only to init in case of collection of flows] (K)" DECLS REAL Te=300 REAL cs REAL A "Junction area (m^2)" REAL G_lam "Max flux corresponding to laminar pressure drop (kg/m^2*s)" REAL G_cr "Critical mass flow per unit area (kg/s m^2)" REAL G_st "Steady unchoked mass flow per unit area (kg/s m^2)" EXPL REAL rho "Throat density (kg/m^3)" REAL dP=1000 "Total pressure drop (Pa)" REAL pos BOOLEAN Init_Flag INIT Init_Flag = TRUE -- m = m_o A = Ao ASSERT (Ao > 0) FATAL "AbstractJunctionLoss: the junction area is null. Use a regulated valve instead" DISCRETE -- This is to initialise when all the port variables (preburner gases properties) are known. WHEN(Init_Flag) THEN Init_Flag = FALSE IF(f1.m == 0) THEN f1.m = m_o END IF -- IF(f1.h == 1e5 AND f1.m > 0) THEN -- f1.h = f1.mh/f1.m -- this is necessary in case of multiple ports -- END IF IF(f1.h == 1e5) THEN f1.h = FL_prop_vs_pT(Chemicals, f1.x_eq, f1.fluid, f1.P, T_o, fprop_enthalpy, ier) END IF END WHEN ASSERT(m > 0) FATAL "mass flow must be possitive in STEADY library " CONTINUOUS -- Density from inlet conditions (dependence on the combusted gases composition) ori_prop(Chemicals, f1.x_eq, f1.fluid, f1.P, f1.h, Te, rho, cs, G_cr, ier) dP = f1.P - f2.P -- Laminar mass flow G_lam = sqrt(max(0., rho) * dp_lam) G_st = ssqrt(2*rho*dP) -- Implicit mass flow calculation (pressure drop given) IF (type == Off_Design) INSERT A = Ao * pos dP/1e5 = 0.5e-5 * max((G_st/G_cr)**2, zeta) * fpow(m/A, G_lam, 2) / rho INVERSE(A) A = m / ssqrt( 2*rho*dP/max((G_st/G_cr)**2, zeta) ) ELSE IF(dp_type == UserGiven) INSERT dP = dP_design ELSEIF(dp_type == Percentage) INSERT dP = dP_per * f2.P / 100 END IF A = m * sqrt( max((G_st/G_cr)**2, zeta) / max(2*dP*rho, 1e-9) ) END IF END COMPONENT ------------------------------------------------------------------------------- COMPONENT Jun_TMD IS_A AbstractJunction \ "Boundary condition in mass flow. The control port signal defines the mass flow law" PORTS IN analog_signal (n=1) s_massflow "Imposed mass flow (kg/s)" DATA DECLS BOOLEAN initial = TRUE INIT m = s_massflow.signal[1] DISCRETE WHEN (initial) THEN initial = FALSE AFTER 0 m = s_massflow.signal[1] END WHEN CONTINUOUS -- Flow & enthalpy are known m = s_massflow.signal[1] f1.P = f2.P END COMPONENT ------------------------------------------------------------------------------- COMPONENT Junction IS_A AbstractJunctionLoss \ "Concentrated load loss with sonic flow limitation" DATA INIT CONTINUOUS pos = 1 END COMPONENT ------------------------------------------------------------------------------- COMPONENT Chamber_inj IS_A AbstractJunctionLoss \ "Injector pressure loss component - sonic flow limitation" DATA DECLS CLOSE dp_type = Percentage CONTINUOUS pos = 1 END COMPONENT ------------------------------------------------------------------------------- COMPONENT Valve IS_A AbstractJunctionLoss \ "Concentrated load loss with variable throat area and sonic flow limitation" PORTS IN analog_signal (n=1) s_pos "Valve position signal" DATA DECLS INIT DISCRETE CONTINUOUS pos = s_pos.signal[1] END COMPONENT ------------------------------------------------------------------------------- COMPONENT Tee_split (ENUM RatioType type = NoRatio "Mass Flow option") PORTS IN fluid_s f1 "Inlet fluid port number 1" OUT fluid_s f2 "Outlet fluid port number 2" OUT fluid_s f3 "Outlet fluid port number 3" DATA REAL m_o = 1 "Initial mass flow [only to init] (kg/s)" REAL mflow_ratio = 0.5 "Mass flow ratio - depending on type (-)" DECLS ENUM FluidKeys fluid "Working fluid" REAL m "Mass flow - positive from f1 to f2 and f3 (kg/s)" INIT m = m_o DISCRETE ASSERT(mflow_ratio >= 0 AND mflow_ratio <=1) FATAL "Tee_split: mass flow ratio must be between 0 and 1" CONTINUOUS EXPAND(i IN Chemicals) f1.x_eq[i] = f2.x_eq[i] f1.fluid = fluid f1.fluid = f2.fluid f1.n_fluid = f2.n_fluid EXPAND(i IN Chemicals) f3.x_eq[i] = f1.x_eq[i] f3.fluid = f1.fluid f3.n_fluid = f1.n_fluid EXPAND_BLOCK(type == NoRatio) -- Conservation of mass f2.m + f3.m = m END EXPAND_BLOCK EXPAND_BLOCK(type == f2_vs_f1) -- Conservation of mass f2.m = m * mflow_ratio f2.m + f3.m = m END EXPAND_BLOCK EXPAND_BLOCK(type == f3_vs_f1) -- Conservation of mass f3.m = m * mflow_ratio f2.m + f3.m = m END EXPAND_BLOCK f1.m = m -- abs(f2.m) + abs(f3.m) = m --Conservation of energy f1.h = f2.h f3.h = f1.h f1.P = f2.P f3.P = f1.P END COMPONENT ------------------------------------------------------------------------------- COMPONENT Tee_merge PORTS OUT fluid_s f1 "Outlet fluid port number 1" IN fluid_s f2 "Inlet fluid port number 2" IN fluid_s f3 "Inlet fluid port number 3" DATA REAL m_o = 1 "Initial mass flow [only to init] (kg/s)" -- REAL m2_m_calc_o = 0.5 "Initial mass flow ratio [guess] (-)" DECLS ENUM FluidKeys fluid "Working fluid" REAL m "Mass flow - positive from f1 to f2 and f3 (kg/s)" -- REAL m2_m_calc "Mass flow ratio - depending on type (-)" INIT -- m2_m_calc = m2_m_calc_o m = m_o DISCRETE CONTINUOUS EXPAND(i IN Chemicals) f1.x_eq[i] = f2.x_eq[i] f1.fluid = fluid f1.fluid = f2.fluid f1.n_fluid = f2.n_fluid EXPAND(i IN Chemicals) f3.x_eq[i] = f1.x_eq[i] f3.fluid = f1.fluid f3.n_fluid = f1.n_fluid -- Conservation of mass f1.m = m -- f3.m = (1 - abs(m2_m_calc))*m -- f2.m = (m2_m_calc)*m -- m2_m_calc = max(1e-9,min(1 - 1e-9,f2.m / m)) f3.m + f2.m = m -- m2_m_calc = 0 --Conservation of energy m * f1.h = f2.mh + f3.mh f2.P = f1.P f3.P = f1.P END COMPONENT