Why am i getting the following error?

조회 수: 1 (최근 30일)
Guillermo Herrera Tuñón
Guillermo Herrera Tuñón . 2023년 9월 25일
답변: Sabin . 2023년 9월 26일
Hello!
im currently working on a Simscape alk electrolyzer project, I have the code below, and it is only coded for voltage for now.
component (Propagation = blocks) alk
nodes
% Electrodes
p = foundation.electrical.electrical; % +
n = foundation.electrical.electrical; % -
end
parameters
N_cell = {12, '1' }; % Number of cells in stack
area_cell = {0.01, 'm^2' }; % Cell area
P_stack = {7, 'bar' };%
end
% Parameter checks
equations
assert(N_cell > 0)
assert(area_cell > 0)
end
% Internal parameters
parameters (Access = protected)
% Constants
r1 = {7.3255e-1, 'V*m^2*A^-1'};
r2 = {-4.6800e-6, 'V*K^-1*m^2*A^-1'};%'V*K^-1*m^2*A^-1
d1 = {double(-7.3077e-1), 'V*m^2*A^-1'};
d2 = {double(-1.8500e-5), 'V*bar^-1*m^2*A^-1'};
s = {double(9.3603e-2), 'V'};
t1 = {16.497, 'm^2*A^-1'};
t2 = {-1.1318e4, 'K*m^2*A^-1'};
t3 = {-1.9538e6, 'K^2*m^2*A^-1'};
V_rev = {1.23, 'V'};
uno = {1, '1'};
T_stack = {75, 'K'};
end
variables (ExternalAccess = observe)
i = {0, 'A' }; % Current (positive in)
v = {0, 'V' };
end
branches
i : p.i -> n.i;
end
intermediates
i_cell = if ge(i, 0), i/area_cell else 0 end; % Cell current density
v_cell = V_rev + ((r2*T_stack + r1) + (d1 + d2*P_stack))*i_cell + s*log(((t1 + (t2/T_stack) + (t3/(T_stack)^2))*i_cell) + uno) ; %V_rev + (((r1 + r2*T_stack)) + (d1 + d2*P_stack))*i_cell + s*log((t1 + (t2/T_stack) + (t3/(T_stack)^2))*i_cell + uno);
end
annotations
[v, v_cell] : LoggingUnit = 'V';
i_cell : LoggingUnit = 'A/m^2';
end
equations
% Stack voltage
v == p.v - n.v; % Voltage
v == N_cell * v_cell ;
end
end
This component is modeled with a solar charge profile.But when the simulation runs, this error is presented: "At time 18014.354000, one or more assertions are triggered. See causes for specific information.Argument of log must be positive". I really don't know where my mistake is, and i really dont know why i cant run this empirical model in simscape.
Thanks!!

답변 (1개)

Sabin
Sabin 2023년 9월 26일
This error points out to the log function which is used to compute v_cell,i.e,
s*log(((t1 + (t2/T_stack) + (t3/(T_stack)^2))*i_cell) + uno)
It might be that the argument of log is getting to some small negative values. Probably best to double check if this can be the case with your parameterization. Also, you can try an add some mechanism to protect against negative values. The simulation seems to be running for 5 hours before it errors out. I hope this helps.

카테고리

Help CenterFile Exchange에서 Parameterization Methods에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by