Why does my simscape component have an error?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to model a customized non-linear capacitor with simulink's simscape component. However, I am constantly getting errors, so I would appreciate it if you could advise me on the problem with my code.
"component CAP
parameters
L_1 = {561800,'cm^-1'};
L_2 = {3246100,'cm^-1'};
L_3 = {6336900,'cm^-1'};
CAP3_1 = {1.09E-17,'F'};
CAP3_2 = {1.14E-19,'F'};
CAP3_3 = {1.57E-20,'F'};
Length = {3.0e-6, 'cm'};
end
nodes
p = foundation.electrical.electrical; % +:top
n = foundation.electrical.electrical; % -:bottom
end
annotations
p : Side = left;
n : Side = right;
end
branches
i : p.i -> n.i; % Current through from node p to node n
end
variables
v = {value = { 0, 'V' }, priority = priority.high}; % Voltage
i = { 0, 'A' }; % Current
CAP = { 0, 'F' };
CAP1 = { 0, 'F' };
CAP2 = { 0, 'F' };
CAP3 = { 0, 'F' };
PD1 = { 0, 'cm/cm' };
PD2 = { 0, 'cm/cm' };
PD3 = { 0, 'cm/cm' };
PD0 = { 0, 'cm/cm' };
Delta_Length = { 0, 'cm' };
CAP1_1 = {0,'F/F'};
CAP1_2 = {0,'F/F'};
CAP1_3 = {0,'F/F'};
end
equations
assert(Length > 0);
assert(L_1 > 0);
assert(L_2 > 0);
assert(L_3 > 0);
assert(CAP3_1 > 0);
assert(CAP3_2 > 0);
assert(CAP3_3 > 0);
Delta_Length == (log((p.v/n.v) + sqrt((p.v/n.v)^2 - 1)))/L_1; % an alternative expression of acosh
if Delta_Length > Length %(Line: 66) Error section
Delta_Length == Length;
else
Delta_Length == Delta_Length;
end
PD0 == L_1 * Delta_Length;
PD1 == L_1 * Delta_Length;
PD2 == L_2 * Delta_Length;
PD3 == L_3 * Delta_Length;
if Delta_Length == Length
CAP1_1 == 0;
CAP1_2 == 0;
CAP1_3 == 0;
else
CAP1_1 == L_1 * (cosh(PD1) - cosh(PD0)) / (L_1 * tanh(PD0) * power(sinh(PD1), 2));
CAP1_2 == L_2 * (cosh(PD2) - cosh(PD0)) / (L_1 * tanh(PD0) * power(sinh(PD2), 2));
CAP1_3 == L_3 * (cosh(PD3) - cosh(PD0)) / (L_1 * tanh(PD0) * power(sinh(PD3), 2));
end
CAP1 == CAP + CAP3_1 / sinh(PD1) + (CAP1_1 * CAP3_1);
CAP2 == CAP1 + CAP3_2 / sinh(PD2) + (CAP1_2 * CAP3_2);
CAP3 == CAP2 + CAP3_3 / sinh(PD3) + (CAP1_3 * CAP3_3);
v == p.v - n.v;
i == CAP3*v.der;
end
end"
The section where the error occurs is "if Delta_Length > Length", and the contents are as follows.
"Cause: The model may not give enough information to make it possible to solve for values of some of its variables. Specific advice is given below.
all components and nodal across variables involved
Cannot solve for one or more variables:
'Simscape_Component4.CAP' (CAP)
'Simscape_Component4.CAP1' (CAP1)
'Simscape_Component4.CAP2' (CAP2)
'Simscape_Component4.CAP3' (CAP3)
Equations (including nonlinear equations) of one or more components may be dependent or inconsistent. This can cause problems in transient initialization. Here is the set of components involved:
all components involved
'CAP_Simulation/Simscape Component4'
Equation location is:
'C:\Users\KIMSUNGJU\Matlab\CAP.ssc' (line 66)
Component:Simulink | Category:BlockError"
And the suspected code interval is "Delta_Length == (log((p.v/n.v) + sqrt((p.v/n.v)^2-1))/L_1;" which is used as an alternative expression because acosh is not supported by simscape.
Delta_Length == acosh(p.v/n.v)/L_1; originally.
The slx file for the circuit is uploaded, but the capacitor file is an ssc file, so it is not uploaded separately, so I think you can paste the code presented above and save it as ssc.
I'd appreciate it if you could answer.
0 comentarios
Respuestas (1)
Adeline
el 8 de Sept. de 2023
Hi,
I understand you are trying to execute a Simulink model which includes a customized non-linear capacitor. The model attached seems to be encountering an error during transient initialization.
This failure can be caused by the switching behaviour of the capacitor. It can be avoided by either smoothing the dynamics, simplifying the equations, or adjusting the solver settings.
In the given model, the non-linear solver fails to converge at the first time step due to the issue in transient initialization. Hence, the error can be avoided by increasing the sample time in the “Solver Configuration” block.
Note: The given model works by assigning a sample time value greater than or equal to 0.004 seconds in the ”Solver Configuration” block.
I hope this helps you address the issue.
0 comentarios
Ver también
Categorías
Más información sobre Discrete Events and Mode Charts en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!