%
% Symbolic code for DFIM with 3-ph stator and 2-ph rotor
%
syms lss lsw msw lrr ld lsr md np th m3to2 cv ...
     l2ss l2sr l2rs is2 isa isb ish ir ird irq tm real
%
% Original model
%
a=2*pi/3;b=pi/2;
lss=[lsw msw msw;msw lsw msw;msw msw lsw];
lrr=[ld 0;0 ld];
lsr=md*[cos(np*th) cos(np*th+b) ; cos(np*th-a) cos(np*th-a+b);
    cos(np*th+a) cos(np*th+a+b)];
%
% 2-phase equivalent model
%
m3to2=cv*[1 -1/2 -1/2;0 sqrt(3)/2 -sqrt(3)/2;1/sqrt(2) ...
    1/sqrt(2) 1/sqrt(2)];
l2ss=simplify(m3to2*lss*inv(m3to2))  
l2sr=simplify(m3to2*lsr)
l2rs=simplify(lsr'*inv(m3to2))
is2=[isa;isb;ish];ir=[ird;irq];
tm=simplify(is2'*inv(m3to2)'*diff(lsr,th)*ir)