An error: Undefined function 'mrdivide' for input arguments of type 'NetworkEngine.ComponentVariableCompileData'.
1 view (last 30 days)
Show older comments
I'm trying to build an engine model in simscape. Here is my code;*
component engine_cylinders
% ine :0.1
% Provides an interface between the pneumatic, liquid and mechanical rotational
% domains.
%
% Eta is the conversion efficiency.
%
% If the pneumatic pressure drops from Port A to port B, then the
% resulting torque is positive acting from the mechanical C to S ports.
% Copyright 2014 SK.
nodes
A = foundation.pneumatic.pneumatic; % A:right
B = foundation.pneumatic.pneumatic; % B:right
F = foundation.thermal_liquid.thermal_liquid; % F:left
S = foundation.mechanical.rotational.rotational; % S:left
C = foundation.mechanical.rotational.rotational; % C:left
end
parameters
H_L = { 1, 'J/kg' }; % Fuel lower heating value
rev_cy = { 1, '1'}; % 1 for two stroke and 2 for four stroke engines
V_d = { 1, 'm^3' }; % Displacement volume
R_AF_high = { 27, '1'}; % Higher R_AF limit (typically 20-27 for HFO)
R_AF_low = { 5, '1'}; % Lower R_AF limit (typically 5-8)
end
parameters(Access = private)
gam = { 1.4, '1' }; % Ratio of specific heats
c_p = { 1005 , 'J/kg/K' }; % Specific heat at constant pressure
c_v = { 717.86 , 'J/kg/K' }; % Specific heat at constant volume
R = { 287.05, 'J/kg/K' }; % Specific gas constant
viscosity = { 18.21e-6, 'Pa*s' }; % Dynamic viscosity
kin_viscosity = { 15.11e-6, 'm^2/s'}; % Kinematic viscosity
Pa = { 101325, 'Pa' }; % Ambient pressure
Ta = { 293.15, 'K' }; % Ambient temperature
range_error = {2, '1' }; % Pressure or temperature below absolute zero
K_z1 = {0.0105e-5, '1'}; % Const. for fuel chem. energy prop. in exh gas
K_z0 = {0.3120, '1' }; % Const. for fuel chem. energy prop. in exh gas
end
variables
mdot_F = { 1, 'kg/s' }; % Fuel mass flow
mdot_A = { 1, 'kg/s' }; % Air mass flow
R_AF = {1, '1'}; % Air to fuel ratio
eta_c = { 1, '1' }; % Combustion Efficiency
p_i = {1, 'N/m^2' }; % Indicated mean effective pressure (IMEP)
x_r = {1, '1' }; % Fuel index position
p_imax = {1, 'N/m^2' }; % Maximum IMEP
p_b = {1, 'N/m^2' }; % Brake mean effective pressure (BMEP)
p_f = {1, 'N/m^2' }; % Friction mean effective pressure (FMEP)
zeta_a = {1, '1' }; % Fuel chemical energy proportion in exh gas
% Pneumatic through variables
G = { 0, 'kg/s' }; % Mass flow rate
Q_A = { 0, 'J/s' }; % Heat flow into port A
Q_B = { 0, 'J/s' }; % Heat flow into port B
% Mechanical through and across variables
t = { 0, 'N*m' }; % Torque
w = { 0, 'rad/s' }; % Angular velocity
BSFC = {0, 'kg/W' }; % Brake specific fuel consumption
pr_t = {0, '1'}; % Pressure ratio P_B/P_A
lambda_e = {0, '1'}; % Specific heat ratio
eta_b = {0, '1' }; % Brake efficiency
mdot = {0, 'kg/s'}; % Fuel mass flow
end
function setup
mdot_F == F.mdot;
mdot_A == A.G;
R_AF == mdot_A/mdot_F;
if R_AF>=R_AF_high
eta_c == 1;
elseif R_AF<=R_AF_low
eta_c == 0;
else
eta_c == (R_AF-R_AF_low)/(R_AF_high-R_AF_low);
end
if eta <= 0
pm_error( 'simscape:GreaterThanZero', 'Efficiency' )
end
if eta > 1
pm_error( 'simscape:LessThan', '1' )
end
end
branches
G : A.G -> B.G;
Q_A : A.Q -> *;
Q_B : B.Q -> *;
t : S.t -> C.t;
mdot: F.mdot -> *;
end
equations
let
% Logs of absolute pressures and temperatures. Extrapolate
% linearly for pressures below p_min.
P_A = if A.p < p_min, p_unit*exp(p_offset_min + p_gradient_min*(A.p - p_min)) else A.p end;
P_B = if B.p < p_min, p_unit*exp(p_offset_min + p_gradient_min*(B.p - p_min)) else B.p end;
% Efficiency from pneumatic to mechanical domains. Will be greater than one if pumping, and
% less than one if motoring.
in
w == S.w - C.w;
p_i == eta_c*p_imax*x_r;
p_b == p_i - p_f;
p_b == (p_imax - K_f3)*x_r-K_f0;
zeta_a == K_z1 * p_b + K_z0;
t == p_b*V_d/(2*pi*rev_cy);
p_b == pi*N_E*t/30;
BSFC == mdot_F/p_b;
eta_b == p_b/mdot_F/H_L;
if G>=0
Q_A == G*A.c_p*A.T;
else
Q_B == -G*A.c_p*B.T;
end
end
end
end
But I'm getting an error:
Failed to generate 'MySimscape_lib'
Caused by: Error using MySimscape.pneumatic/engine_cylinders>setup (line 73) Undefined function 'mrdivide' for input arguments of type 'NetworkEngine.ComponentVariableCompileData'.
What does this mean, and how can I get over that problem.
I'll appreciate if anyone can help?
0 Comments
Answers (1)
Steve Miller
on 9 May 2023
The documentation page for equations in Simscape tells you which equations you can use and what the requirements are. mrdivide is permitted, but the second element must be a scalar.
--Steve
0 Comments
See Also
Categories
Find more on Foundation and Custom Domains 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!