








**********************************************************************
 NOTE: This is a copy of "Motor.m" found in directory "../PwmSimulation.
       The Octave commands are removed. This text should be regarded
       as "current information" when referenced to test files like
       "App_Observer.hpp" found in this directory.
**********************************************************************



 

#	Verification of transformation of AC synchronous motor into 2 phase representation.
#     (Refering to Page 1 of "1_Notes.pdf)
#
#
#        L*di1dt - M*di2dt - M*di3dt = v1 - R*i1 + K*w*sin(theta)
#      - M*di1dt + L*di2dt - M*di3dt = v2 - R*i2 + K*w*sin(theta - 2*PI/3)				           (1)
#      - M*di1dt - M*di2dt + L*di3dt = v3 - R*i3 + K*w*sin(theta - 4*PI/3)
#
#        J*dwdt = - K*i1*sin(theta) - K*i2*sin(theta - 2*PI/3) - K*i3*sin(theta - 4*PI/3) - tl             (2)
#
#
#       L  -M  -M    di1dt      1 0 0  v1     R 0 0  i1    K*w   0   0    sin(theta)
#      -M   L  -M    di2dt  =   0 1 0  v2  -  0 R 0  i2  +   0 K*w   0    sin(theta - 2*PI/3)              (3)
#      -M  -M   L    di3dt      0 0 1  v3     0 0 R  i3      0   0 K*w    sin(theta - 4*PI/3)
#
#      The mutual inductance "M", which is equal to ".5*L" for a balanced system, can be visualized by
#      looking at the simplified model of he AC PM motor. Say, referenced to the peak of phase "1", it can be seen
#      that .5 of the phase current is flowing through phase "2" adding .5 PU flux intensity to the flux passing 
#      through passing "1" and that .5 of the phase current is flowing through phase "3" adding another .5 PU flux 
#      intensity to the flux passing through phase "1".
#
#
#      The inverse of the three phase to two phase transform is (applies to current, voltage and derivative of current):
#
#
#
#      i1   =     2/3      0       sqrt(2)/3    ia
#      i2   =    -1/3   1/sqrt(3)  sqrt(2)/3    ib        					                       (4)
#      i3   =    -1/3  -1/sqrt(3)  sqrt(2)/3    ih
#
#
#      Expanding (3) above.
#
#       L  -M  -M      2/3      0       sqrt(2)/3    diadt
#      -M   L  -M     -1/3   1/sqrt(3)  sqrt(2)/3    dibdt    = 
#      -M  -M   L     -1/3  -1/sqrt(3)  sqrt(2)/3    dihdt     
#
#       1 0 0     2/3      0       sqrt(2)/3    va   
#       0 1 0    -1/3   1/sqrt(3)  sqrt(2)/3    vb     -                                                   (5)
#       0 0 1    -1/3  -1/sqrt(3)  sqrt(2)/3    vh         
#
#       R 0 0     2/3      0       sqrt(2)/3    ia   
#       0 R 0    -1/3   1/sqrt(3)  sqrt(2)/3    ib     +
#       0 0 R    -1/3  -1/sqrt(3)  sqrt(2)/3    ih         
#  
#       K*w    0    0   sin(theta) 			  
#         0  K*w    0   sin(theta - 2*PI/3)	 
#         0    0  K*w   sin(theta - 4*PI/3) 	 
#
#
#      First row:
#
#      diadt*((2/3)*L + (1/3)*M + (1/3)*M)  +   0  
#						     +   dihdt*((sqrt(2)/3)*L - (sqrt(2)/3)*M - (sqrt(2)/3)*M)  = 
#      va*(2/3) + 0 +  vh*(sqrt(2)/3) - 
#      (ia*(R*2/3) + 0 + ih*(R*sqrt(2)/3)) + 
#      K*w*sin(theta)
#
#      Second row:
#
#      diadt*(-(2/3)*M - (1/3)*L + (1/3)*M)  +   dibdt*((1/sqrt(3))*L + (1/sqrt(3))*M) 
#							+   dihdt*(-(sqrt(2)/3)*M + (sqrt(2)/3)*L - (sqrt(2)/3)*M)  = 
#      va*(-1/3) + vb*(1/sqrt(3)) + vh*(sqrt(2)/3) - 
#      (ia*(-R*1/3) + ib*(R*1/sqrt(3)) +  ih*(R*sqrt(2)/3)) + 
#      K*w*sin(theta - 2*PI/3)
#
#      Third row:
#
#      diadt*(-(2/3)*M + (1/3)*M - (1/3)*L)  +   dibdt*(-(1/sqrt(3))*M - (1/sqrt(3))*L) 
#							+   dihdt*(-(sqrt(2)/3)*M - (sqrt(2)/3)*M + (sqrt(2)/3)*L)  = 
#      va*(-1/3) + vb*(-1/sqrt(3)) + vh*(sqrt(2)/3) - 
#      (ia*(-R*1/3) + ib*(-R*1/sqrt(3)) +  ih*(R*sqrt(2)/3)) + 
#      K*w*sin(theta - 4*PI/3)
#
#      First row:
#
#      ((2/3)*L + (2/3)*M)  0   ((sqrt(2)/3)*L - (sqrt(2)/3)*M - (sqrt(2)/3)*M)   diadt   
#									         			    dibdt         = 
#													    dihdt
#	 (2/3)   0   (sqrt(2)/3)  va														
#					  vb     -
#                               vh
#                                                                                                         (5a)
#      (R*2/3)   0      (R*sqrt(2)/3)  ia 
#						   ib    +
#                                      ih
#      
#      K*w*(3/2)*sin(theta)  0   0    <- equivilent "sin" in two phase format would have an amplitude of "1.5"
#      
#                      
#
#      Second row "-" Third row:
#
#	 0    ((2/sqrt(3))*L + (2/sqrt(3))*M)    0    diadt
#								    dibdt     =
#								    dihdt
#  
#      0    2/sqrt(3)    0     va
#                              vb    - 
#                              vh
#
#
#      0    R*2/sqrt(3)  0     ia
#                              ib
#                              ih
#                              
#      0  K*w*(-sqrt(3)*cos(theta))  0     <- "sin()'s" reduce to "-sqrt(3)*cos()", 
#                           			  ...this can be readily seen by viewing page 6 of "1_Notes.pdf"
#
#
#
#      We now aggree with Marc's 3-phase/2-phase transformation (electric portion)
#
#      (L + M)*diadt = va - R*ia + (3/2)*K*w*sin(theta)
#      (L + M)*dibdt = vb - R*ib - (3/2)*K*w*cos(theta)                                                            (6)
#
#      The transformation of (2) above is simply
#
#
#
#      			- K*sin(theta)      	'	  2/3      0       sqrt(2)/3    ia   
#      J*dwdt  =		- K*sin(theta - 2*PI/3) '      -1/3   1/sqrt(3)  sqrt(2)/3    ib   - tl                    (7)
#      			- K*sin(theta - 4*PI/3) '      -1/3  -1/sqrt(3)  sqrt(2)/3    ih   
#
#
#              =  (-(2/3)*K*sin(theta) + (1/3)*K*sin(theta - 2*PI/3) + (1/3)*K*sin(theta - 4*PI/3))   '   ia
#			(-(1/sqrt(3))*K*sin(theta - 2*PI/3) + (1/sqrt(3))*K*sin(theta - 4*PI/3))            '   ib   - tl
#                    0                                                                                '   ih
#
#      Again, from page 6,
#
#              =   - (2/3 + 1/6 + 1/6)*sin(theta)    				'      ia
#                  - (1/sqrt(3))*K*(-sqrt(3)*cos(theta))			'      ib   - tl
#                     0                                                 '      ih
#
#      Which agrees with Marc's
#
#      J*dwdt = - K*ia*sin(theta) + K*ib*cos(theta) - tl                                                   (7a)
#
#
#	 From (5a) we have the expression of what Marc terms as the homopolor equation, which again agrees with
#      Marc's equation. (in the case of a Delta connection and unbalanced currents
#      I think this would be a description for "circulating" or harmonic currents).
#
#
#      (L - 2M)*dihdt = vh - R*ih
#
#
#
#	 Now we move on the the analysis of the D/Q transformation.
#
#      A simple derivation was presented on page 9 "1_Notes.pdf". A more formal derivation follows:
#
#
#
#      Given the inverse D/Q (for i or v)
#
#
#      ia/va       cos(theta)    (-sin(theta))      id/vd
#             =                                                                                           (7b)
#      ib/vb       sin(theta)     cos(theta)        iq/vq
#
#
#
#      Since this transformation is itself differencialable in time:
#
#      diadt = -id*sin(theta)*dthetadt + diddt*cos(theta) - iq*cos(theta)*dthetadt - diqdt*sin(theta)
#
#      dibdt =  id*cos(theta)*dthetadt + diddt*sin(theta) - iq*sin(theta)*dthetadt + diqdt*cos(theta)
#
#
#
#      Expanding (6) above:
#
#
#      (L + M)      0        diadt       =
#         0      (L + M)*    dibdt  
#
#            1  0  va    -     R  0  ia   +   (+(3/2)*K*w)      0 	   sin(theta)
#		 0  1  vb          0  R  ib            0        (-(3/2)*K*w)   cos(theta)                                                            
#	  
#	 ... multiplying the top of (6) through by "cos(theta)"
#      (L+M)*(-id*sin(theta)*cos(theta)*dthetadt + diddt*cos**2(theta) - iq*cos**2(theta)*dthetadt - diqdt*sin(theta)*cos(theta))
#
#        = vd*cos**2(theta) - vq*sin(theta)*cos(theta) - R*id*cos**2(theta) + R*iq*sin(theta)*cos(theta) + (3/2)*K*w*sin(theta)*cos(theta)
#
#
#      ... multiplying the bottom of (6) through by "sin(theta)"
#      (L+M)*(id*cos(theta)*sin(theta)*dthetadt + diddt*sin**2(theta) - iq*sin**2(theta)*dthetadt + diqdt*cos(theta)*sin(theta))
#
#        = vd*sin**2(theta) + vq*sin(theta)*cos(theta) - R*id*sin**2(theta) - R*iq*sin(theta)*cos(theta) - (3/2)*K*w*sin(theta)*cos(theta)
#
#
#      ... now, add these together to get the first of the D/Q equations.
#
#
#	 (L+M)*(diddt - iq*dthetadt) = vd - R*id                                             (8)
#
#
#      We repeat the process, except we swap the "sin()" and "cos()" multipliers and "subtract" the equations
#
#	 ... multiplying the top of (6) through by "sin(theta)"
#      (L+M)*(-id*sin**2(theta)*dthetadt + diddt*cos(theta)*sin(theta) - iq*cos(theta)*sin(theta)*dthetadt - diqdt*sin**2(theta))
#
#        = vd*cos(theta)*sin(theta) - vq*sin**2(theta) - R*id*cos(theta)*sin(theta) + R*iq*sin**2(theta) + (3/2)*K*w*sin**2(theta)
#
#
#      ... multiplying the bottom of (6) through by "cos(theta)"
#      (L+M)*(id*cos**2(theta)*dthetadt + diddt*sin(theta)*cos(theta) - iq*sin(theta)*cos(theta)*dthetadt + diqdt*cos**2(theta))
#
#        = vd*sin(theta)*cos(theta) + vq*cos**2(theta) - R*id*sin(theta)*cos(theta) - R*iq*cos**2(theta) - (3/2)*K*w*cos**2(theta)
#
#      ... now, subtract the second equation from the first equation to get the second of the D/Q equations.
#
#      (L+M)*(id*dthetadt + diqdt) = vq - R*iq - (3/2)*K*w                                (9)
#
#
#      (8) and (9) agrees with Marc's equations. (8) and (9) differs with John's equations for the reason of
#      the scale factor he introduced in his version of (4) above.
#
#
#      Finally, we transform (7a) into the equivilent equation in D/Q space.
#
#
#      J*dwdt = (-K*sin(theta)) (+K*cos(theta))  ia               - tl                                                    
#                                                ib
#
#      Combining (7a) and (7b)
#
#      J*dwdt = - K*sin(theta)*cos(theta) + K*cos(theta)*sin(theta) + K*sin**2(theta) + K*cos**2(theta) - tl
#
#
#      J*dwdt = K*iq - tl											(10)
#
#
#
#      The only thing left to analyize is Marc's equation.... 
#
#
#      va1*ia1 + v2*i2 + v3*i3 = (2/3)*(vd*id + vq*iq) + (1/3)*vh*ih
#
#      In reality, homopolar currents and voltages do play a role in performance.
#      In would be interesting to see if cancelation algoryghm could be devised.
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#




