Solving the equations of Simscape's Ejector with vsolve
10 views (last 30 days)
Show older comments
Dear Everyone,
I have written a Matlab script based on the equations of the Ejector in Simscape (https://www.mathworks.com/help/hydro/ref/ejectorg.html). I am not good at using Simscape and I am having difficulties running the Ejector in Simscape.
My script calculates Pm (pressure after mixing ) using fsolve. I have modified the equations a bit as I think γ should be different for the two streams, therefore I have kp (γ of the primary stream) and ks (γ of the secondary stream). I also included an iteration to calculate the stagnation temperatures of the two streams since the documentation of the Ejector states that the block assumes that Tp and Ts (temperatures of primary and secondary streams) are equal to their primary flow stagnation temperature. These temperatures are needed for the calculation of Tm (temperature of mixing). The stagnation temperature depends on Mm (Mach number of mixing) which depends on Tm which in turn depends on the stagnation temperatures.
I am considering a case where the primary stream is CO2 at 1MPa and 20°C and the secondary stream is air at 0.1 MPa and 20°C, and I calculate Pm = 0.0012 MPa and Mm = 0.033. I think these results are wrong, could someone please confirm this? It seems that my solver calculates the same Pm regardless of Pp (primary pressure) and a Pm always close to Ps (secondary pressure).
I am attaching the m files needed to run the script below. "ejector_solver.m". "Ejector_equations_star" uses the same equations as in "Ejector_equations" but replaces Pm with Pm_star to calculate the critical diffuser outlet pressure.
Also, does anyone know how the cross-sectional areas of the three ports are used? They need to be specified for the Ejector in Simscape but I am not sure where they appear in the equations.
I am grateful for any help you can provide.
Best regards,
clearvars; close all; clc;
% Primary stream
Primary_fluid = 'CO2';
Pp = 1; % [MPa] Pressure of primary stream
Tp = 20 + 273.15; % [K] Temperature of primary stream
kp = 1.3589; % Primary stream's ratio of heat capacities
rhop = 19.098; % [kg/m^3] Density of primary stream
% Secondary stream
Secondary_fluid = 'Air.ppf';
Ps = 0.1; % [MPa] Pressure of secondary stream
Ts = 20 + 273.15; % [K] Temperature of secondary stream
ks = 1.402; % Secondary stream's ratio of heat capacities
rhos = 1.189; % [kg/m^3] Density of secondary stream
% Gas constant
R = 0.2871; % [kJ/(kg K)]
% Parameters of ejector (same as in Simscape)
Spt = 1e-4; % [m^2] Throat area
Spn_to_Spt = 3; % Area ratio of nozzle exit to throat
Sm_to_Spt = 8; % Area ratio of mixing chamber exit to throat
eta_p = 0.95; % Efficiency of primary flow through nozzle
eta_s = 0.85; % Efficiency of secondary suction flow
eta_e = 0.88; % Efficiency for primary flow expansion
eta_m = 0.84; % Efficiency for mixing
% Initial guess for Pm
Pm_initial_guess = 0.001; % [MPa]
% Use fsolve to find Pm
options = optimoptions('fsolve', 'Display', 'iter');
Pm = fsolve(@(Pm) ejector_solver(Pm, Pp, Tp, kp, rhop, Ps, Ts, ks, rhos, R, Spt, Spn_to_Spt, Sm_to_Spt, eta_p, eta_s, eta_e, eta_m), Pm_initial_guess, options);
disp(['Pm is: ', num2str(Pm), ' MPa']);
% Calculate equations with Pm
Ejector_equations
% Critical mode operation
Pm_star = min(Pp,Ps) * (2 / (km+1))^(km / (km-1)); % Threshold that causes choking in both primary and secondary flow
Ejector_equations_star % Same equations to calculate the critical diffuser outlet pressure by replacing Pm with Pm_star
% Evaluate if critical mode operation
if Pd < Pd_star
Pm = Pm_star;
else
Ejector_equations % Repeat equations to save the correct values
end
disp(['Mm is: ', num2str(Mm), '']);
3 Comments
Yifeng Tang
on 14 Jun 2024
For the "cross-sectional areas of the three ports", are you talking about these ones in the red box? Not the throat area on the first row, right?
Please kindly clarify and I can provide an answer in the Answer section.
Answers (1)
Paris
on 16 Jun 2024
3 Comments
Yifeng Tang
on 17 Jun 2024
Regarding your observation on the value of the results from Results Explorer vs. Scope, I suggest that you look in these places:
(1) PS-Simulink Converter: did you set a unit? Default unit of "1" will be interpreted as SI unit.
(2) in Simscape Results Explorer, the y-axis also contains a unit. You can click on the drop down arrow and change that.
Make sure the two units are consistent. I suspect you have g/s somewhere but kg/s at another place.
See Also
Categories
Find more on Thermal Liquid Library in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!