/out,g_3dcoil,out
fini
/prep7
*if,ar12,eq,0,then
esel,,ename,,36
nsle
edel,all,
ndel,all
numc,node
numc,elem
edel,_etyp
numc,type
*endif
_no_arc=0
*if,gen_arc,eq,0,then
*if,skew_ang,gt,0,then
*if,skew_stk,eq,'stator',then
_no_arc=1
*endif
*endif
*endif
_aof=ar10
_deltht=360/arg5
_thtout=(arg1-1)*_deltht+_aof
_thtin=(arg2-1)*_deltht+_aof
_n_turn=arg3
_r_in=arg6*ggeom
_r_out=arg7*ggeom
_ww=arg8*ggeom
_wh=arg9*ggeom
nsel,all
*get,ndmx,node,,num,max
cmsel,,stator
esel,u,mat,,1
nsle
*get,zmax,node,,mxloc,z
*get,_zmin,node,,mnloc,z
_z_f=zmax+ggeom*arg4+_ww/2
*if,ar13,eq,0,then
_z_b=-_z_f
*else
_z_b=_zmin-(ggeom*arg4+_ww/2)
*endif
cm,c_e,elem
esel,all
*get,_elmx,elem,,num,max
*set,_mskg
*dim,_mskg,,_elmx
*set,_el_rl
*dim,_el_rl,,_elmx
*vget,_mskg(1),elem,1,esel
*voper,_mskg(1),_mskg(1),gt,0
*vmask,_mskg(1)
*vget,_el_rl(1),elem,1,attr,real
*vmask,_mskg(1)
*vscfun,_rl_mx,max,_el_rl(1)
_rl_mx=_rl_mx+1
*if,ar11,le,0,then
*get,_etyp,etyp,,num,max
_etyp=_etyp+1
*else
_etyp=ar11
*endif
et,_etyp,36
type,_etyp
*set,_c_a36
*dim,_c_a36,,3,4
*afun,deg
csys
esel,none
ndmx=ndmx+1
n,ndmx,_r_out*cos(_thtout),_r_out*sin(_thtout),_z_b+_ww/2
_c_a36(1,1)=ndmx
ndmx=ndmx+1
n,ndmx,_r_out*cos(_thtout),_r_out*sin(_thtout),_z_f-_ww/2
_c_a36(2,1)=ndmx
ndmx=ndmx+1
n,ndmx,_r_out*cos(_thtout-2),_r_out*sin(_thtout-2),0
_c_a36(3,1)=ndmx
r,_rl_mx,2,_n_turn,_wh,_ww
real,_rl_mx
e,_c_a36(1,1),_c_a36(2,1),_c_a36(3,1)
*if,_no_arc,eq,0,then
ndmx=ndmx+1
_rddg=180/3.141593
_a_fac=1
*if,_thtout,lt,_thtin,then
_a_fac=-1
*endif
_th_omx=_thtout+_a_fac*_rddg*_ww/2/_r_out
n,ndmx,_r_out*cos(_th_omx),_r_out*sin(_th_omx),_z_f
_c_a36(1,2)=ndmx
ndmx=ndmx+1
_th_imn=_thtin-_a_fac*_rddg*_ww/2/_r_in
n,ndmx,_r_in*cos(_th_imn),_r_in*sin(_th_imn),_z_f
_c_a36(2,2)=ndmx
ndmx=ndmx+1
n,ndmx,,,_z_f
_c_a36(3,2)=ndmx
_rl_mx=_rl_mx+1
r,_rl_mx,3,_n_turn,_wh,_ww
real,_rl_mx
e,_c_a36(1,2),_c_a36(2,2),_c_a36(3,2)
*endif
ndmx=ndmx+1
n,ndmx,_r_in*cos(_thtin),_r_in*sin(_thtin),_z_f-_ww/2
_c_a36(1,3)=ndmx
ndmx=ndmx+1
n,ndmx,_r_in*cos(_thtin),_r_in*sin(_thtin),_z_b+_ww/2
_c_a36(2,3)=ndmx
ndmx=ndmx+1
n,ndmx,_r_in*cos(_thtin+2),_r_in*sin(_thtin+2),0
_c_a36(3,3)=ndmx
*if,_no_arc,eq,0,then
real,_rl_mx-1
*else
real,_rl_mx
*endif
e,_c_a36(1,3),_c_a36(2,3),_c_a36(3,3)
*if,_no_arc,eq,0,then
ndmx=ndmx+1
n,ndmx,_r_out*cos(_th_omx),_r_out*sin(_th_omx),_z_b
_c_a36(2,4)=ndmx
ndmx=ndmx+1
n,ndmx,_r_in*cos(_th_imn),_r_in*sin(_th_imn),_z_b
_c_a36(1,4)=ndmx
ndmx=ndmx+1
n,ndmx,,,_z_b
_c_a36(3,4)=ndmx
real,_rl_mx
e,_c_a36(1,4),_c_a36(2,4),_c_a36(3,4)
*endif
*if,_plot,eq,1,then
esel,,ename,,36
nsle
/pbc,real,1
/auto
eplo
*endif
*set,_mskg
*set,_el_rl
:end
/out