Simcape two phase fluid custom component

14 views (last 30 days)
I am trying to write a custom component for a non-isentropic compressor in Simscape. However, I saw a convection term that I don't understand. A snippet of the source code from the controlled_mass_flow_rate_source is shown below:
% Specific total enthalpy for outflow
ht_out_A == convection_A.ht_I;
ht_out_B == convection_B.ht_I;
% Equate variables for internal components that calculate energy convection at ports A and B
convection_A.mdot == mdot_A;
convection_A.Phi == Phi_A;
convection_B.mdot == mdot_B;
convection_B.Phi == Phi_B;
convection_A.ht_I == convection_B.ht_I;
What is the convection_A, convection_B, and the ht_I term?
Thank you!
  1 Comment
Tech Logg Ding
Tech Logg Ding on 19 Apr 2021
I will also include a snippet of my code:
% 1 is the input and 2 is the output of the block
% NI is the isentropic efficiency
% _isen indicates the case for the isentropic efficiency
% isentropic relationship
s_1 == s_2_isen;
% isentropic efficiency balance
NI*(ht_2-ht_1) == (ht_2_isen-ht_1);
% power calculation
power == mdot_A*(ht_2-ht_1);
% Specific total enthalpy for outflow
% not sure which one to use to balance the equations
(ht_2+ht_1)/2 == convection_B.ht_I;
%ht_2 == convection_B.ht_I;
%ht_1 == convection_A.ht_I;
% Equate variables for internal components that calculate energy convection at ports A and B
convection_A.mdot == mdot_A;
convection_A.Phi == Phi_A;
convection_B.mdot == mdot_B;
convection_B.Phi == Phi_B;
convection_A.ht_I == convection_B.ht_I;
As shown above, I am not sure what the ht_I, convection_A, and convection_B terms do.

Sign in to comment.

Accepted Answer

Yifeng Tang
Yifeng Tang on 26 Apr 2021
The convection_A & convection_B are two components that defines the behavior at the "port" or boundary of this block. If you look further down the source code, you should find something like:
% Internal components that calculate energy convection at ports A and B
components (ExternalAccess=none)
convection_A = foundation.two_phase_fluid.port_convection(flow_area = area_A, length_scale = sqrt(4*area_A/pi));
convection_B = foundation.two_phase_fluid.port_convection(flow_area = area_B, length_scale = sqrt(4*area_B/pi));
end
That "foundation.two_phase_fluid.port_convection" is a 2P module that defines the upwind scheme at the ports. All fluids domains have a similar component. You can select "foundation.two_phase_fluid.port_convection" and do a Ctrl+D to read its source code. The idea behind the upwind scheme maybe found on this Documentation page:

More Answers (0)

Categories

Find more on Gas Models in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!