Modified mutual inductance with error due to mod command
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I want to build a custom made simscape block with variing self and mutual inductances. These are part of a rotating system, which angel changes over time and repeats after 360°.
I built the following code:
component mutual_inductance_angle
%Mutual inductance with lookup table and product rule; small example
nodes
ps1 = foundation.electrical.electrical; % s1+:left
ns1 = foundation.electrical.electrical; % s1-:left
ps2 = foundation.electrical.electrical; % s2+:right
ns2 = foundation.electrical.electrical; % s2-:right
end
parameters
angle_ref = {[0 90 180 270 360], 'deg'}; % Array with reference angle
frequency = {50, 'Hz'}; % Frequency of fundamental harmonic in stator
L_s1_ref = { [10, 10, 10, 100, 10], 'H' }; % Selfinductance stator phase 1
L_s2_ref = { [0.1, 0.1, 0.1, 0.1, 0.1], 'H' }; % Selfinductance stator phase 2
M_s1_s2_ref = { [0.9, 1, 0.7, 1.2, 1], 'H' }; % Mutual inductance stator phase 1 and stator phase 2
end
variables
angle = { 0, 'deg' }; %angle
i_s1 = {value = { 0, 'A' }, priority = priority.high}; % Current stator phase 1
i_s2 = {value = { 0, 'A' }, priority = priority.high}; % Current stator phase 2
v_s1 = { 0, 'V' }; % Voltage inductance stator phase 1
v_s2 = { 0, 'V' }; % Voltage inductance stator phase 2
v_s11 = { 0, 'V' }; % Voltage inductance stator phase 1
v_s12 = { 0, 'V' }; % Voltage inductance stator phase 1
v_s21 = { 0, 'V' }; % Voltage inductance stator phase 1
v_s22 = { 0, 'V' }; % Voltage inductance stator phase 1
L_s1 = {0, 'H'}; % Self Inductance
L_s2 = {0, 'H'}; % Self Inductance
M_s1_s2 = {0, 'H'}; % Mutual Inductance
end
branches
i_s1 : ps1.i -> ns1.i;
i_s2 : ps2.i -> ns2.i;
end
equations
v_s1 == ps1.v - ns1.v;
v_s2 == ps2.v - ns2.v;
angle == mod(360*frequency*time, 360);
L_s1 == tablelookup(angle_ref, L_s1_ref ,angle,interpolation=linear,extrapolation=nearest);
L_s2 == tablelookup(angle_ref, L_s2_ref ,angle,interpolation=linear,extrapolation=nearest);
M_s1_s2 == tablelookup(angle_ref, M_s1_s2_ref ,angle,interpolation=linear,extrapolation=nearest);
v_s11 == L_s1 * i_s1.der + i_s1 * L_s1.der;
v_s12 == M_s1_s2 * i_s2.der + i_s2 * M_s1_s2.der;
v_s21 == L_s2 * i_s2.der + i_s2 * L_s2.der;
v_s22 == M_s1_s2 * i_s1.der + i_s1 * M_s1_s2.der;
v_s1 == v_s11 + v_s12;
v_s2 == v_s21 + v_s22;
end
end
and tested it in a simple circuit shown here:
When running the simscape simulation, I get the following error:
"Total size of differential equations does not match the total size of differential variables."
When I leave out the "mod" command in the calculation of the angle, the error does not occure. But then the angle would exceed 360 degree. So I could implement a huhgh reference for the angle with more than 360° where the information just repeats but this does not make sense to me.
Does somebody know, how I could implement the time depending angle and avoid the error?
Thank you and best regards
Andreas
0 个评论
回答(1 个)
Yash
2023-9-7
The size of differential equations means the number of equations containing "der" and the size of differential variables means the number of different variables containing "der". To resolve the error the code must be modified to match these two sizes. Refer to this answer by MathWorks Support Team on how to resolve this kind of error here (https://www.mathworks.com/matlabcentral/answers/458270-why-do-i-get-total-size-of-differential-equations-does-not-match-the-total-size-of-differential-var).
I hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simscape Electrical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!