cmsel,s,kstator
allsel,below,area
NUMMRG,NODE,1e-6 , , ,LOW 
NUMCMP,NODE 
nummrg,kp

cmsel,s,krotor
allsel,below,area
NUMMRG,NODE,1e-6 , , ,LOW 
NUMCMP,NODE 
nummrg,kp

allsel

csys,1
nsel,s,loc,x,raussen
d,all,az,0
nsel,s,loc,x,rinnen
cp,2,az,all

!!
!!Stator
!!
csys,1

*Do,ileit,1,2*p
asel,s,mat,,3
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,ileit*4+1,curr,all
cp,ileit*4+2,emf,all
*GET,wicknode1%ileit%, NODE, 0,num,min

asel,s,mat,,4
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,ileit*4+3,curr,all
cp,ileit*4+4,emf,all
*GET,wicknode2%ileit%, NODE, 0,num,min

*EndDo

*If,kompound,eq,1,then
*Do,ileit,1,2*p
asel,s,mat,,33
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknode1ko%ileit%, NODE, 0,num,min

asel,s,mat,,34
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknode2ko%ileit%, NODE, 0,num,min

*EndDo
*EndIf

*If,wende,eq,1,then
*Do,ileit,1,2*p
asel,s,mat,,43
allsel,below,area
ASEL,r,LOC,Y,(ileit-1)*360/(2*p),360/(2*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknode1we%ileit%, NODE, 0,num,min

asel,s,mat,,44
allsel,below,area
ASEL,r,LOC,Y,(ileit-1)*360/(2*p),360/(2*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknode2we%ileit%, NODE, 0,num,min

*EndDo
*EndIf

*If,kompen,eq,1,then
*Do,ileit,2,2*p,2
asel,s,mat,,23
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
aclear,all
aatt,24,24,24
amesh,all
allsel
*EndDo
*EndIf

*If,kompen,eq,1,then
*Do,ileit,1,2*p,2
asel,s,mat,,23
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknodek%ileit%, NODE, 0,num,min

*EndDo

*Do,ileit,2,2*p,2

asel,s,mat,,24
allsel,below,area
ASEL,r,LOC,Y,-360/(4*p)+(ileit-1)*360/(2*p),360/(4*p)+(ileit-1)*360/(2*p) 
allsel,below,area

cp,next,curr,all
cp,next,emf,all
*GET,wicknodek%ileit%, NODE, 0,num,min

*EndDo
*EndIf