I'm trying to do dynamic analysis of an electric motor using Ansys Mechanical APDL. The stator has 4 pole pairs and only 1 of them has windings. The rotor has 3 pole pairs with no windings. I want to calculate torque for different rotor positions [limited range of rotations] using a dowhile loop so i won't have to rotate the rotor myself [if i do so, it'll be a static analysis].
In summery in prep7 section: I have defined the materials I need. Then I have defined the shapes of my windings, rotor and stator and airgaps, and finally assigned materials and meshed everything for further steps. my problem is within Dowhile Loop I believe because The command formats are correct as far as I know.
Also, My University professor has debugged my original code and sent me this one and said that it work well on Ansys 9 installed on Windows XP. I use Ansys 15 and windows 10. Just in case.
Here is my source code.
/prep7 emunit,mks csys,1 et,1,plane53,0,,0 et,2,plane53,3,,0 !Coils et,3,circu124,0 !External Resistor et,4,circu124,4,0 !Independent Voltage Source, Piecewise Linear Load et,5,circu124,5 !Stranded Coil (To FEA Domain) /pnum,area,1 N,1 ! CREATE NODES FOR CIRCUIT ELEMENTS *REPEAT,7,1 !Defining Materials mp,murx,1,1 !air and rotor shaft TB,BH,2,,15 !stator and rotor iron tbpt,,146,0.5 tbpt,,157,0.6 tbpt,,168,0.7 tbpt,,180,0.8 tbpt,,194,0.9 tbpt,,212,1 tbpt,,234,1.1 tbpt,,269,1.2 tbpt,,329,1.3 tbpt,,453,1.4 tbpt,,797,1.5 tbpt,,1895,1.6 tbpt,,4476,1.7 tbpt,,8595,1.8 tbpt,,14510,1.9 MP,murx,3,1 !Coil MP,RSVX,3,1e-18 !Resistivity of Coil R,3,0.7 !Resistance Value R,5,1 !Symmetry Factor for Coil Vdc=100 Omega=1500 !RPM turnonang=10 turnoffang=20 aa=0.5 !The Factor Exhibiting the Fraction of 1 Degree for Rotation dt=1/(6*Omega) !Time for 1 Degree Rotation steptime=1000 R,4,Vdc,0 dt=aa*dt timeindex=1e-9 !The Zero Moment *DIM,current_vector1,array,steptime+1,,, *DIM,torque_vector1,array,steptime+1,,, R,1,0.01*0.02,0.5*180,120e-3,-1,, R,2,0.01*0.02,0.5*180,120e-3,1,, *afun,deg Rso=0.095 Rsy=0.08 Rsi=0.0482 Rro=0.0478 Rry=0.035 Rri=0.02 pi=acos(-1) bethas=20 bethar=22.5 airgap=Rsi-Rro !Defining stator and rotor keypoints k,111,Rsy,acos(Rsi*cos((pi/2)+(bethas/2))/Rsy),0 !stator pole keypoints k,112,Rsy,acos(Rsi*cos((pi/2)-(bethas/2))/Rsy),0 k,113,Rsi,90+10,0 k,114,Rsi,90-10,0 k,115,Rro,90+(bethar/2),0 !rotor pole keypoints k,116,Rro,90-(bethar/2),0 k,117,Rry,acos(Rro*cos((pi/2)+(bethar/2))/Rry),0 k,118,Rry,acos(Rro*cos((pi/2)-(bethar/2))/Rry),0 k,100,0,0 !Defining stator and rotor pole lines csys,0 larc,111,112,100,rsy L,111,113 !stator pole lines larc,113,114,100,Rsi L,112,114 larc,115,116,100,Rro !rotor pole lines L,115,117 larc,117,118,100,Rry L,116,118 !defining Stator and rotor pole areas a,111,112,114,113 !stator pole area csys,1 agen,8,1,,,,45,, pcirc,rso,rsy aadd,1,2,3,4,5,6,7,8,9 a,115,116,118,117 !rotor pole area agen,6,1,,,,60,, pcirc,Rry,Rri aadd,1,2,3,4,5,6,7 !Defining winding areas rectng,-0.02,-0.01,0.049,0.069 !winding rectng rectng,-0.02,-0.01,-0.049,-0.069 rectng,0.02,0.01,-0.049,-0.069 rectng,0.02,0.01,0.049,0.069 !creating shaft and airgap areas pcirc,0,Rro pcirc,0,(Rro+Rsi)/2 aovlap,8,5,6 pcirc,(Rro+Rsi)/2,Rso pcirc,Rsi,Rso asel,s,area,,1,6 asel,a,area,,10 aovlap,all NUMCMP,AREA !Compress out unused area numbers ALLSEL,ALL !coil areas 1,2,3,4 !shaft area 10 !stator area 23 !rotor area 14 !Outter airgap areas 6,15,16,17,18,19,20,21 ~ 22 !Inner airgap area 5,7,8,9,11,12 ~ 13 !Assigning materials to stator, rotor, coil, shaft and air ASEL,S,area,,5,13 !assigning shaft and air materials ASEL,A,area,,15,22 AATT,1,1,1, ASEL,S,area,,23 !assigning stator and rotor material ASEL,A,area,,14 AATT,2,1,1, ASEL,S,area,,1,2 !assigning coil materials AATT,3,1,2, ASEL,S,area,,3,4 !assigning coil materials AATT,3,2,2, /PNUM,MAT,1 ALLSEL,ALL APLOT !Meshing different Areas MSHAPE,1,2D !Meshing of Inner Segments Included Shaft, Rotor, and Inner Part of Airgap SMRTSIZE,2 ASEL,S,area,,7,14 ASEL,A,area,,5 AMESH,ALL MSHAPE,1,2D !Meshing of Outer Segments Included Stator and Outer Part of Airgap SMRTSIZE,3 ASEL,S,area,,15,23,1 ASEL,A,area,,1,4 ASEL,A,area,,6 AMESH,ALL !Defining Nodes Inside Coil Areas CSYS,0 ! N,1000001,-0.015,0.059,0 ! N,1000002,-0.015,-0.059,0 ! N,1000003,0.015,0.059,0 ! N,1000004,0.015,-0.059,0 n1=node(-0.015,0.059,0) n2=node(0.015,0.059,0) n3=node(-0.015,-0.059,0) n4=node(0.015,-0.059,0) ASEL,S,AREA,,14 ESLA,S CM,ROTOR,ELEM FMAGBC,'rotor' !Rortating Inner Segments CSYS,1 ASEL,S,area,,7,14 ASEL,A,area,,5 AGEN,,ALL,,,0,30-turnonang,0,,,1 !Generating Constraint Equation at Rotor and Stator Interface ASEL,S,area,,13 NSLA,S NSLA,S,1 NSEL,R,LOC,X,Rro+0.25*airgap,Rro+0.75*airgap ASEL,S,area,,22 ESLA,A,S CEINFT,0.25,,,,,,,0.05 !Designing the external circuit Type,4 Real,4 E,2,1,3 Type,3 Real,3 E,2,4 Type,5 Real,5 E,4,5,n1 Type,5 Real,5 E,5,6,n2 Type,5 Real,5 E,6,7,n3 Type,5 Real,5 E,7,1,n4 ASEL,S,area,,1, ESLA,S NSLE,S CP,1,CURR,ALL CP,2,EMF,ALL ASEL,S,area,,2, ESLA,S NSLE,S CP,3,CURR,ALL CP,4,EMF,ALL ASEL,S,area,,3, ESLA,S NSLE,S CP,5,CURR,ALL CP,6,EMF,ALL ASEL,S,area,,4, ESLA,S NSLE,S CP,7,CURR,ALL CP,8,EMF,ALL FINISH /SOLU ANTYPE,4,new Time,1e-9 CSYS,1 LSEL,S,LOC,X,Rso DL,ALL,,AZ,0 D,1,VOLT,0 CNVTOL,CSG,,0.0000001,2,, ALLSEL,ALL SOLVE cont=1 /post26 NSOL,2,n1,CURR PRVAR,2 *GET,ICUR1,VARI,2,rtime,timeindex current_vector1(cont)=ICUR1 ttt=turnonang torque_vector1(1)=1e-10 ICUR1=1 steps=1 *Dowhile,ICUR1 /Prep7 *if,ttt,gt,turnoffang,then R,4,-Vdc *endif ALLSEL,ALL CEDELE,1,1111111,,ANY !Deletes Contraint Equations ASEL,S,area,,7,14 ASEL,A,area,,5 AGEN,,ALL,,,0,-aa,0,,,1 ASEL,S,area,,13 !Generating Constraint Equation at Rotor and Stator Interface NSLA,S NSLA,S,1 NSEL,R,LOC,X,Rro+0.25*airgap,Rro+0.75*airgap ASEL,S,area,,22 ESLA,A,S CEINFT,0.25,,,,,,,0.05 ttt=ttt+aa cont=cont+1 timeindex=timeindex+dt steps=steps+1 /SOLU ANTYPE,4,REST,steps-1,,1 TRNOPT,full TIME,timeindex TIMINT,ON AUTOTS,off DELTIM,,,,1 KBC,1 TSRES,ERASE OUTRES,ALL,LAST, NEQIT,100 CNVTOL,CSG,,0.0000001,2,, ALLSEL,ALL SOLVE /POST1 TORQSUM,'rotor' torque_vector1(cont)=-0.0873*torqvw /POST26 NSOL,2,n1,CURR PRVAR,2 *GET,iCUR1,VARI,2,rtime,timeindex current_vector1(cont)=iCUR1 ALLSEL,ALL *ENDDO torque_vector1(cont,1,1)=1e-9 *vlen,cont *DIM,rotor_position,table,cont,1,1 *VFILL,rotor_position,ramp,turnonang,aa *DIM,current_vector,table,cont,1,1 *DIM,flux_vector,table,cont,1,1 *DIM,torque_vector,table,cont,1,1 *do,i,1,cont current_vector(i,1,1)=current_vector1(i,1,1) torque_vector(i,1,1)=torque_vector1(i,1,1) *enddo *VPLOT,rotor_position,current_vector ```