- Change “F_r” from “s^2/m^2 (or implied kg/s per kW)” to “{0.045 / 1000, 'kg/(s*W)'}“ to correctly calculate mass flow rate in “kg/s” when multiplied by “commanded_Phi_flow” in “Watts”.
- Modified the energy balance equation from “Phi_A == Phi_B” to “Phi_B == Phi_A + commanded_Phi_flow” to accurately model the heat (commanded_Phi_flow) being added within the component.
- Updated the temperature calculation to “T_B == T_A + commanded_Phi_flow / (mdot_B * cp_A)“ from “Phi_B/(mdot_B*cp_I)” to use the actual added heat and the dynamic specific heat capacity “(cp_A)”, including an if condition to handle zero mass flow.
what am i doing wrong???
    7 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I'm trying to create a simscape component in which when placing the ernergy flow it calculates the mass flow by multiplying a factor, as well as increasing the temperature of the fluid leaving the component.
component My_HeatLoad
% Mass Flow Rate Source (TL)
% This block represents an ideal mechanical energy source in a thermal
% liquid network that can maintain a constant mass flow rate regardless of
% the pressure differential. There is no flow resistance and no heat
% exchange with the environment. A positive mass flow rate causes liquid to
% flow from port A to port B.
nodes
    A = foundation.thermal_liquid.thermal_liquid; % A:left
    B = foundation.thermal_liquid.thermal_liquid; % B:right
end
parameters
    commanded_Phi_flow  = {10000,    'W'}; % Q_dot_equipment
    area                = {0.01, 'm^2' }; % Cross-sectional area at ports A and B
end
parameters (Access=private)
  F_r    = { 0.045 , 's^2/m^2' }; % Flow rate [kg/s per kW]
    % ControlTemperature = {300, 'K'}; % Temperature
end 
variables
    T_I = {value = {298 , 'K' },       priority = priority.high};      % Temperature initial of liquid
    p_I = {value = {0.101325e6, 'Pa'}, priority = priority.high} % Pressure inicial of liquid 
end
% Parameter checks
equations
    assert(area > 0)
end
variables (Access = protected)
    % Through variables
    mdot_A = {0, 'kg/s'}; % Mass flow rate into port A
    mdot_B = {0, 'kg/s'}; % Mass flow rate into port B
    Phi_A  = {0, 'W'  }; % Energy flow rate into port A
    Phi_B  = {0, 'W'  }; % Energy flow rate into port B
end
branches
    mdot_A : A.mdot -> *;
    mdot_B : B.mdot -> *;
    Phi_A  : A.Phi  -> *;
    Phi_B  : B.Phi  -> *;
end
intermediates (Access = private, ExternalAccess = none)
    % Liquid density
    rho_A   = convection_A.rho;
    rho_B   = convection_B.rho;
    rho_avg = (rho_A + rho_B)/2;
    % Across Variables
    T_A = A.T;
    T_B = B.T;
    % Domain parameters
    T_TLU  = A.T_TLU;
    p_TLU  = A.p_TLU; 
    cp_TLU = A.cp_TLU;
    % liquid properties table lookup
    cp_I = tablelookup (T_TLU, p_TLU, cp_TLU,  T_I, p_I,  interpolation = linear, extrapolation = linear);
end
equations
    let
        Phi_A =  commanded_Phi_flow;
    in
    % Commanded mass flow rate
      mdot_B ==  F_r* Phi_A;
    % Mass balance
    mdot_A + mdot_B == 0;
    % Energy balance
    Phi_A == Phi_B;
    % Temperature in B
    T_B == T_A + Phi_B/(mdot_B*cp_I); 
    end
end
% Internal components that calculate energy convection at ports A and B
components (ExternalAccess = none)
    convection_A = foundation.thermal_liquid.port_convection(flow_area = area, length_scale = sqrt(4*area/pi));
    convection_B = foundation.thermal_liquid.port_convection(flow_area = area, length_scale = sqrt(4*area/pi));
end
connections
    connect(A, convection_A.port)
    connect(B, convection_B.port)
end
% Equate variables for internal components that calculate energy convection at ports A and B
equations
    convection_A.mdot == mdot_A;
    convection_A.Phi  == Phi_A;
    convection_B.mdot == mdot_B;
    convection_B.Phi  == Phi_B;
    convection_B.T    == T_B;
    convection_A.u_I == convection_B.u_I;
end
end
what are missing?
0 Commenti
Risposte (1)
  Prathamesh
 il 30 Lug 2025
        
      Modificato: Prathamesh
 il 30 Lug 2025
  
      I understand that the customer is trying to create a simscape component in which when placing the ernergy flow it calculates the mass flow by multiplying a factor, as well as increasing the temperature of the fluid leaving the component.
Below are required changes:
Hope this helps.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Foundation and Custom Domains in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

