/out,pm_rotor,out
fini
/prep7
/uis,msgpop,3
_err=0
_error=0
/nerr,1,1e6
*get,_mod_id,parm,rotor_id,type
*if,_mod_id,eq,3,then
*if,rotor_id,ne,'pmrotor',then
/out
*msg,error,rotor_id
The model type ( %c ) does not correspond to a permanent magnet rotor
/out,pm_rotor,out,,append
_error=1
*endif
*else
/out
_error=1
*msg,error
The model type identifier specified is not a "character" type parameter&
or it was not specified
/out,pm_rotor,out,,append
*endif
*if,_error,eq,1,:err
_error=0
_nm_vn=3
*set,_nm_vv
*dim,_nm_vv,,_nm_vn
_nm_vv(1)=rr1,nrp,gap
*set,_nm_v
*dim,_nm_v,char,_nm_vn
_nm_v(1)='rr1','nrp','gap'
/out
*do,_i,1,_nm_vn
*if,_nm_vv(_i),le,0,then
/nerr,1,1e6
*msg,error,_nm_v(_i)
Parameter { %c } is negative or zero.
_error=_error+1
*endif
*enddo
/out,pm_rotor,out,,append
*if,loaf,eq,1,then
m_flat=1
*endif
*get,_tmagtop,parm,magtop,type
*if,_tmagtop,ne,3,then
_magflat=0
*else
*if,magtop,eq,'flat',then
_magflat=1
*if,magh,le,0,then
/nerr
/out
*msg,error
The top of the magnet is flat, but the magnet thickness&
has not been specified-no action.
/out,pm_rotor,out,,append
_err=1
/nerr,0,1e5
*endif
*endif
esel,none
*get,_ck_st,comp,stator,type
_ec_s=0
*if,_ck_st,gt,0,then
cmsel,,stator
*get,_ec_s,elem,,count
*endif
*if,_ec_s,gt,0,then
/nerr
/out
*msg,error
The option for the square magnet is being used. For this option&
the rotor must be constructed first, since the boundary between&
the rotor and the stator models has to be readjusted. Please clear the&
database and construct the rotor first, then construct the stator.
/out,pm_rotor,out,,append
_error=1
/nerr,0,1e5
*endif
*endif
*if,_error,eq,1,:err
*if,(1-_magflat)*m_flat,eq,1,then
*if,(rc1+rc2),eq,0,then
/out
*msg,error
The flat bottom for the magnet option has been selected, but the&
parameters {rc1} and {rc2} have not been specified. The {magh} parameter&
cannot be used with the flat bottom magnet option
_error=_error+1
/out,pm_rotor,out,,append
*endif
*endif
*if,rbc,le,0,then
*if,rc1+rc2,le,0,then
rbc=rr2+magh+gap/2
*else
rbc=rc1+rc2+gap/2
*endif
*endif
*if,_magflat,eq,1,then
*if,magh,ne,0,then
*elseif,rc1+rc2,ne,0,then
rbc=rc1+rc2+gap/2
*else
_err=1
*endif
*if,magw,gt,0,then
_y4=rr2*tan(magw/nrp)
*else
_y4=magl/2
*endif
_r4=sqrt((rr2+magh)**2+_y4**2)
rbc=(_r4+r3)/2
gap=r3-_r4
*if,gap,le,0,then
/nerr
/out
*msg,error
For the top of magnet option, the edge of the magnet crosses over&
into the stator. Check the magnet height and magnet width.
/out,pm_rotor,out,,append
_error=1
/nerr,0,1e5
*endif
*endif
*if,rc2+rc1,le,0,then
*if,rr2*magh,le,0,then
*msg,error
Parameter {rr2} OR {magh} are negative or zero.
_error=_error+1
*endif
*endif
*if,magl+magw,le,0,then
*msg,error
Parameter {magl} and {magw} are negative or zero.
_error=_error+1
*endif
*if,magw,gt,180,then
*msg,error
The magnet angle width cannot be greater than 180
_error=_error+1
*endif
/nerr,0,1e6
*if,_error,ge,1,:err
*if,arg1,eq,0,then
arg1=2
*endif
_cd1=1
*get,_elmtyp,etyp,,num,max
*if,_elmtyp,eq,0,then
_elmtyp=1
*endif
_elmtyp=_elmtyp+1
_elctyp=_elmtyp+1
*if,arg2,eq,0,then
et,_elmtyp,13
*else
et,_elmtyp,53
*endif
*if,arg4,eq,0,then
et,_elctyp,13
*else
et,_elctyp,53
*endif
*if,arg6,eq,1,then
et,_elctyp,53,3
*endif
*if,arg5,eq,0,then
arg5=1
*endif
f_2=arg5
immed
esel,none
nsel,none
asel,none
ksel,none
lsel,none
cmsel,,rotor
cpdel,all,,,any
cedel,all,,,any
acle,all
adel,all,,,1
ldel,all,,,1
kdel,all
edel,all
ndel,all
numc,elem
numc,node
numc,cp
numc,ce
alls
cm,_ckp,kp
cm,_cls,line
cm,_car,area
cmgrp,_cmp,_ckp,_cls,_car
esel,all
*get,_elmx,elem,,num,max
_rl_strt=0
*if,_elmx,ne,0,then
*set,_mskv
*dim,_mskv,,_elmx
*vget,_mskv(1),elem,1,esel
*set,_r_e
*dim,_r_e,,_elmx
*vmask,_mskv(1)
*vget,_r_e(1),elem,1,attr,real
*vmask,_mskv(1)
*vscfun,_rl_strt,max,_r_e(1)
_zz=100*nint(_rl_strt/100)
*if,_zz,lt,_rl_strt,then
_rl_strt=_zz+51
*else
_rl_strt=_zz
*endif
_zz=
*set,_mskv
*set,_r_e
esel,none
*endif
_mxkp=11
*set,_kp_n_
*dim,_kp_n,,_mxkp
_60=180
*set,_x
*dim,_x,,_mxkp
*set,_y
*dim,_y,,_mxkp
*afun,deg
*if,nrp,eq,0,then
_err=2
nrp=1
*endif
_x(1)=rbc
_y(1)=0
_x(2)=rbc*cos(180/nrp)
_y(2)=rbc*sin(180/nrp)
*if,magh,ne,0,then
_x(3)=rr2+magh
_y(3)=0
*else
_x(3)=rc1+rc2
_y(3)=0
*endif
*if,(1-_magflat)*(rc1+rc2),ne,0,then
*if,magw,ne,0,then
t_b=tan(magw/nrp)
_x(4)=rc1+sqrt(rc1**2-(1+t_b**2)*(rc1**2-rc2**2))
_x(4)=_x(4)/(1+t_b**2)
_y(4)=_x(4)*t_b
*elseif,magl,ne,0,then
_x(4)=rc1+sqrt(rc2**2-(magl/2)**2)
_y(4)=magl/2
*else
_err=3
_x(4)=0
_y(4)=0
*endif
*elseif,magh,ne,0,then
*if,_magflat,eq,0,then
*if,magw,ne,0,then
_x(4)=(rr2+magh)*cos(magw/nrp)
_y(4)=(rr2+magh)*sin(magw/nrp)
*elseif,magl,ne,0,then
_x(4)=sqrt((rr2+magh)**2-(magl/2)**2)
_y(4)=magl/2
*else
_err=3
_x(4)=0
_y(4)=0
*endif
*endif
*if,_magflat,eq,1,then
*if,magw,ne,0,then
_x(4)=_x(3)
_y(4)=rr2*tan(magw/nrp)
*elseif,magl,ne,0,then
_x(4)=_x(3)
_y(4)=magl/2
*else
_err=3
_x(4)=0
_y(4)=0
*endif
*endif
*else
_err=3
_x(4)=0
_y(4)=0
*endif
_x(5)=rr2
_y(5)=0
*if,loaf,eq,1,then
_x(6)=sqrt(rr2**2-_y(4)**2)
_y(6)=_y(4)
*else
_x(6)=rr2*cos(magw/nrp)
_y(6)=rr2*sin(magw/nrp)
*endif
*if,m_flat,eq,1,then
*if,magh,ne,0,then
_x(6)=_x(4)-magh
*else
_x(6)=rr2
*endif
_x(5)=_x(6)
_r7=sqrt(_x(6)**2+_y(6)**2)
_x(7)=(_r7)*cos(_60/nrp)
_y(7)=(_r7)*sin(_60/nrp)
_x(8)=rr1
_y(8)=0
*else
_x(7)=(rr2)*cos(_60/nrp)
_y(7)=(rr2)*sin(_60/nrp)
_x(8)=rr1
_y(8)=0
*endif
_x(9)=(rr1)*cos(_60/nrp)
_y(9)=(rr1)*sin(_60/nrp)
*if,rc1+rc2,ne,0,then
_x(10)=rc1
_y(10)=0
*else
_x(10)=0
_y(10)=0
*endif
_r_1=sqrt(_x(4)**2+_y(4)**2)
_x(11)=_r_1*cos(_60/nrp)
_y(11)=_r_1*sin(_60/nrp)
csys
ksel,none
*do,_ikp,1,_mxkp
/gopr
k,,_x(_ikp),_y(_ikp)
_kp_n(_ikp)=kp(_x(_ikp),_y(_ikp),0)
*enddo
cm,rot_k,kp
asel,none
lsel,none
csys,1
l,_kp_n(1),_kp_n(2)
l,_kp_n(2),_kp_n(11)
l,_kp_n(11),_kp_n(4)
_done=0
*if,rc1+rc2,ne,0,then
*if,_magflat,eq,0,then
larc,_kp_n(4),_kp_n(3),_kp_n(10),rc2
_done=1
*endif
*endif
*if,_magflat,eq,1,then
csys
l,_kp_n(4),_kp_n(3)
*elseif,_done,eq,0,then
csys,1
l,_kp_n(4),_kp_n(3)
csys
*endif
l,_kp_n(3),_kp_n(1)
a,_kp_n(1),_kp_n(2),_kp_n(11),_kp_n(4),_kp_n(3),
*get,_ar_1,area,,num,max
aatt,1,5,_elctyp
ksel,,,,_kp_n(3)
ksel,a,,,_kp_n(4)
ksel,a,,,_kp_n(11)
lslk,,1
*get,_lsmx,line,,num,max
*get,_lsmn,line,,num,min
lccat,_lsmn,_lsmx
cm,rot_a,area
ksel,all
asel,none
lsel,none
csys,1
l,_kp_n(11),_kp_n(7)
l,_kp_n(7),_kp_n(6)
csys
l,_kp_n(6),_kp_n(4)
a,_kp_n(4),_kp_n(11),_kp_n(7),_kp_n(6),
*if,embed,eq,0,then
aatt,1,5,_elmtyp
*else
aatt,2,2,_elmtyp
*endif
cmsel,a,rot_a
cm,rot_a,area
*get,_mag_esy,cdsy,,num,max
*if,_mag_esy,lt,50,then
_mag_esy=50
*else
_mag_esy=_mag_esy+1
*endif
*if,rad_mag,eq,0,then
local,_mag_esy,0
*else
rad_mag=1
local,_mag_esy,rad_mag
*endif
asel,none
lsel,none
ksel,,,,_kp_n(6)
ksel,a,,,_kp_n(4)
ksel,a,,,_kp_n(3)
lslk,,1
ksel,all
l,_kp_n(3),_kp_n(5)
csys,1
*if,m_flat,eq,1,then
csys
*endif
l,_kp_n(5),_kp_n(6)
al,all
aatt,3,3,_elctyp,_mag_esy
cmsel,a,rot_a
cm,rot_a,area
asel,none
lsel,none
ksel,,,,_kp_n(5)
ksel,a,,,_kp_n(6)
ksel,a,,,_kp_n(7)
lslk,,1
ksel,all
csys,1
l,_kp_n(5),_kp_n(8)
l,_kp_n(8),_kp_n(9)
l,_kp_n(9),_kp_n(7)
al,all
aatt,2,2,_elmtyp
cmsel,a,rot_a
cm,rot_a,area
*set,_gapd
*dim,_gapd,,5
_gapd(1)=1,2,3,4,5
*set,_asprg
*dim,_asprg,,5
_asprg(1)=2,2,1,1,1
*set,_kpz1
*dim,_kpz1,,5
_kpz1(1)=4,3,2,1,1
*set,_kpz2
*dim,_kpz2,,5
_kpz2(1)=17,15,9,6,1
*voper,_kpz2(1),_kpz2(1),mult,f_2
*set,_kpz3
*dim,_kpz3,,5
_kpz3(1)=24,20,18,6,4
*voper,_kpz3(1),_kpz3(1),mult,f_2
ksel,,,,_kp_n(1)
ksel,a,,,_kp_n(3)
lslk,,1
lesi,all,,,_gapd(arg1)
ksel,,,,_kp_n(11)
ksel,a,,,_kp_n(2)
lslk,,1
lesi,all,,,_gapd(arg1)
ksel,,,,_kp_n(1)
ksel,a,,,_kp_n(3)
ksel,a,,,_kp_n(2)
ksel,a,,,_kp_n(4)
ksel,a,,,_kp_n(11)
lslk,,1
lesi,all,_asprg(arg1)*(gap)/_gapd(arg1)/2
_gap_d=gap/_gapd(arg1)/2
ksel,all
kesi,_kp_n(3),_kpz1(arg1)*_gap_d
kesi,_kp_n(4),_kpz1(arg1)*_gap_d
kesi,_kp_n(11),_kpz1(arg1)*_gap_d
kesi,_kp_n(5),_kpz2(arg1)*_gap_d
kesi,_kp_n(6),_kpz2(arg1)*_gap_d
kesi,_kp_n(7),_kpz2(arg1)*_gap_d
kesi,_kp_n(8),_kpz3(arg1)*_gap_d
kesi,_kp_n(9),_kpz3(arg1)*_gap_d
cmsel,,rot_a
esha
*if,m_tri,eq,1,then
esha,1
*endif
cmsel,,rot_a
*if,arg2,eq,0,then
asel,r,type,,_elmtyp
ames,all
*endif
cmsel,,rot_a
*if,arg4,eq,0,then
esha,2
*if,m_tri,eq,1,then
esha,1
*endif
ames,_ar_1
esha
*if,m_tri,eq,1,then
esha,1
*endif
asel,r,type,,_elctyp
ames,all
*else
esha,2
mshkey,1
*if,m_tri,eq,1,then
esha,1
*endif
ames,_ar_1
esha
mshkey
*if,m_tri,eq,1,then
esha,1
*endif
*endif
cmsel,,rot_a
alis
ames,all
cmsel,,rot_a
esla
nsle
lsla
ksll
cm,rot_l,line
cm,rot_e,elem
cm,rot_n,node
cmgrp,rotor,rot_a,rot_l,rot_k,rot_e,rot_n
dsys
esel,r,mat,,6
cmsel,,rotor
*if,arg3,ne,0,then
polegen,arg3,0,0,0,0,'rotor',0,ggeom
/out,pm_rotor,out,,append
csys,0
mrk_nod=node(_x(3)*ggeom,_y(3)*ggeom,0)
*endif
*if,rad_mag,eq,1,then
*get,_zz,mgxx,3
mp,mgxx,4,_zz*(-1)
*get,_zz,murx,3
mp,murx,4,_zz
_zz=
_iflip=1
*do,_i1,1,nrp
/gopr
*if,_iflip,eq,-1,then
cmsel,,rotor
esel,r,mat,,3
nsle
csys,1
nsel,r,loc,y,360/nrp*((2*_i1-1)/2-1)-.00001,360/nrp*((2*_i1-1)/2)+.0001
esln,,1
emod,all,mat,4
_iflip=_iflip*(-1)
*else
_iflip=_iflip*(-1)
*endif
*enddo
*endif
_iflip= $ _zz= $ _i1=
esel,,mat,,2,3
cm,r_iron,elem
r_iron_c='r_iron'
cmsel,,rotor
/pnum,mat,1
csys
*get,_xmn,node,,mnloc,x
*get,_xmx,node,,mxloc,x
*get,_ymn,node,,mnloc,y
*get,_ymx,node,,mxloc,y
_dify=_ymx-_ymn
_difx=_xmx-_xmn
_eify=_ymx+_ymn
_eifx=_xmx+_xmn
_rmx=_dify
*if,_difx,gt,_dify,then
_rmx=_difx
*endif
alls
cmsel,u,_cmp
/auto
/num,1
eplo
immed,1
:err
/out