/out
/nopr
_ok3=0
_status=0
_esav=1
_emat=1
_tri=1
_db=1
_rmg=1
_rst=1
*get,_cpu1,active,,time,cpu
_qq=arg5
*get,_ptyp,parm,_qq,type
*if,_ptyp,ne,0,then
*msg,error
LMATRIX 5th argument must be numeric
_ok3=1
*endif
*dim,_jname,char,2
*get,_jname(1),active,,jobnam,,start,1
*get,_jname(2),active,,jobnam,,start,9
*if,_jname(2),ne,' ',then
*msg,error
LMATRIX is restricted to jobnames up to 8 characters.
_ok3=1
*endif
_qq=arg1
*get,_ptyp,parm,_qq,type
*if,_ptyp,ne,0,then
*msg,error
Input value for symmetry factor must be numeric
_ok3=1
*endif
*if,arg1,le,0,then
_symm = 1.0
*else
_symm = arg1
*endif
_qq=
_qq=arg2
*get,_ptyp,parm,_qq,type
*if,_ptyp,eq,0,then
*msg,error
Component name prefix must be alphanumeric string enclosed in single quotes
_ok3=1
*else
*if,_ptyp,eq,3,then
_pre=_qq
*else
*msg,error
Component name prefix must be an alphanumeric string
_ok3=1
*endif
*endif
_qq=
_qq=arg3
*get,_ptyp,parm,_qq,type
*if,_ptyp,eq,3,then
*get,_ztyp,parm,arg3,type
*if,_ztyp,ne,1,then
*msg,error,_qq
Coil current array %c must be defined before LMATRIX command
_ok3=1
*else
_cur=arg3
*endif
*elseif,_ptyp,eq,0,then
*msg,error
Coil current array name must be alphanumeric string enclosed in single quotes
_ok3=1
*else
*msg,error
Coil current array name must be an alphanumeric string
_ok3=1
*endif
_qq=
_qq=arg4
*get,_ptyp,parm,_qq,type
*if,_ptyp,eq,3,then
*if,arg4,eq,' ',then
arg4='lmatrix'
*msg,note,arg4
Inductance matrix array parameter name defaults to: %c
*endif
*endif
*if,_ptyp,eq,0,then
*if,_qq*1.0e+30,eq,0,then
arg4='lmatrix'
*msg,note,arg4
Inductance matrix array parameter name defaults to: %c
*else
*msg,error
Inductance matrix name must be alphnumeric string enclosed in single quotes
_ok3=1
*endif
*endif
cm,_elem,elem
*if,_ok3,ne,1,then
*get,_antyp,active,,anty
*if,_antyp,ge,1,then
*msg,error
LMATRIX macro is available only for static analysis
_ok3=1
*endif
*get,_nrows,parm,_cur,dim,x
*if,_status,gt,2,then
*msg,error
Non-existent or improperly dimensioned 1D-array
_ok3=1
*endif
esel,u,ename,,53
esel,u,ename,,96
esel,u,ename,,97
esel,u,ename,,117
esel,u,ename,,36
esel,u,ename,,115
*get,_mxvld,elem,,count
*if,_mxvld,gt,0,then
*msg,error
Some of the selected element types are not supported by LMATRIX
_ok3=1
*endif
cmsel,s,_elem
*endif
*dim,_ind,array,_nrows,_nrows
*dim,_ene,array,_nrows,_nrows
*dim,_nami,char,_nrows
*do,_i,1,_nrows
_nami(_i)='%_pre%%chrval(_i)%'
*enddo
*get,_mnu3,active,,menu
*get,_level,active,,rout
*get,_neqit,active,,solu,eqit
/out,scratch
finish
/out
*if,_ok3,ne,1,then
/gopr
/out,data
_noelm=0
*do,_i,1,_nrows
cmsel,s,_nami(_i)
*stat,_nami
*if,_status,gt,2,then
*msg,error
Coil element components are not properly defined; check 2nd argument
_ok3=1
*exit
*endif
*get,_ecount,elem,,count
*if,_ecount,lt,1,then
_noelm=1
*endif
*enddo
*if,_noelm,eq,1,then
*msg,error
Coil component contains no elements
_ok3=1
*endif
*endif
cmsel,s,_elem
*if,_ok3,ne,1,then
save
/rename,%_jname(1)%,esav,,oper,esav
_esav=
*if,_status,gt,2,then
_esav=1
*msg,error,_jname(1)
File %c.esav is required for LMATRIX command
_ok3=1
*endif
/rename,%_jname(1)%,emat,,oper,emat
_emat=
*if,_status,gt,2,then
_emat=1
*msg,error,_jname(1)
File %c.emat is required for LMATRIX command
_ok3=1
*endif
/rename,%_jname(1)%,tri,,oper,tri
_tri=
*if,_status,gt,2,then
_tri=1
*msg,error,_jname(1)
File %c.tri is required for LMATRIX command
_ok3=1
*endif
/rename,%_jname(1)%,db,,oper,db
_db=
*if,_status,gt,2,then
_db=1
*msg,error,_jname(1)
File %c.db is required for LMATRIX command
_ok3=1
*endif
/out,scratch
/uis,msgpop,3
/nerr,,,-1
/uis,msgpop
/out
/copy,%_jname(1)%,rmg,,oper,rmg
_rmg=
_rst=1
*if,_status,gt,2,then
_rmg=1
_rst=0
/copy,%_jname(1)%,rst,,oper,rst
*if,_status,gt,2,then
_rst=1
/nerr
*msg,error
Results file for Operating point solution is missing
_ok3=1
*endif
*endif
*endif
*if,_ok3,ne,1,then
_curmax=0.0
*do,_i,1,_nrows
*if,abs(_cur(_i)),gt,_curmax,then
_curmax=abs(_cur(_i))
*endif
*enddo
*if,_curmax,lt,1.0e-6,then
*msg,error
Nominal applied currents from operating point solution are zero
_ok3=1
*endif
_tinycur=1.0e-6*_curmax
*do,_i,1,_nrows
*if,abs(_cur(_i)),lt,_tinycur,then
*msg,error
Current in one of the coils is zero, nonzero current required
_ok3=1
*endif
*enddo
*endif
*if,_ok3,ne,1,then
*do,_ii,1,_nrows
*do,_jj,_ii,_nrows
parsav,all
/copy,oper,esav,,%_jname(1)%,esav
/copy,oper,emat,,%_jname(1)%,emat
/copy,oper,tri,,%_jname(1)%,tri
/copy,oper,db,,%_jname(1)%,db
resume
parres
/solu
magopt,4,,1
antype,static,rest
kuse,1
neqit,1
eqslv,front
autots,off
nlgeom,off
nsubs,1
_scale=1.0e-12
bfescal,JS,_scale
*get,_nele,elem,,count
*do,_iele,1,_nele
*get,_e1,elem,,num,max
*if,_e1,eq,0,exit
*get,_ityp,elem,_e1,attr,type
*get,_rcon,elem,_e1,attr,real
*get,_jtyp,etyp,_ityp,attr,enam
*if,_jtyp,eq,36,then
*get,_rcur,rcon,_rcon,const,2
rmodif,_rcon,2,_scale*_rcur
esel,u,real,,_rcon
*else
esel,u,type,,_ityp
*endif
*enddo
*do,_kkk,1,_nrows
cmsel,s,_nami(_kkk)
*if,_kkk,eq,_ii,then
*if,_kkk,eq,_jj,then
_scale=1.0e+12
*else
_scale=1.0e+12
*endif
*else
*if,_kkk,eq,_jj,then
_scale=1.0e+12
*else
_scale=1.0
*endif
*endif
_scale=_scale*_curmax/_cur(_kkk)
bfescal,JS,_scale
*get,_nele,elem,,count
*do,_iele,1,_nele
*get,_e1,elem,,num,max
*if,_e1,eq,0,exit
*get,_ityp,elem,_e1,attr,type
*get,_rcon,elem,_e1,attr,real
*get,_jtyp,etyp,_ityp,attr,enam
*if,_jtyp,eq,36,then
*get,_rcur,rcon,_rcon,const,2
rmodif,_rcon,2,_scale*_rcur
esel,u,real,,_rcon
*else
esel,u,type,,_ityp
*endif
*enddo
*enddo
cmsel,s,_elem
biot,new
outres,esol,all
/uis,msgpop,4
solve
/uis,msgpop
*if,_status,gt,2,then,exit
*msg,error
LMATRIX incremental solution encountered an error condition
_ok3=1
*endif
/out,scratch
finish
/out
/solu
outres
neqit,_neqit
kuse
/out,scratch
fini
/out
/post1
etab,_ene,IENE
/out,scratch
ssum
/out
*get,_ene(_ii,_jj),SSUM,,ITEM,_ene
_ene(_jj,_ii)=_ene(_ii,_jj)
_eneiijj=_ene(_ii,_jj)
*if,arg5,ge,1,then
/out
*if,_ii,eq,_jj,then
*vwrite,_jj,_curmax
('current incremented in coil',f3.0,' by',e15.6)
*else
*vwrite,_ii,_jj,_curmax
('current incremented in coils',f3.0,' and',f3.0,' by',e15.6)
*endif
*if,arg5,ge,2,then
etab,_x,cent,x
etab,_y,cent,y
etab,_z,cent,z
etab,_hsum,h,sum
etab,_bsum,b,sum
pretab,_x,_y,_z,_hsum,_bsum,_ene
*endif
*vwrite,_eneiijj
(' total energy increment=',e15.6)
*endif
/out,scratch
fini
/out
*enddo
*enddo
*do,_ii,1,_nrows
*do,_jj,_ii,_nrows
*if,_ii,eq,_jj,then
_ind(_ii,_jj)=_ene(_ii,_ii)*2.0/_curmax**2*_symm
*else
_ind(_ii,_jj)=(_ene(_ii,_jj)-_ene(_ii,_ii)-_ene(_jj,_jj))/_curmax**2*_symm
_ind(_jj,_ii)=_ind(_ii,_jj)
*endif
*enddo
*enddo
*get,_cpu2,active,,time,cpu
_dcpu=_cpu2-_cpu1
/nopr
/out,lmatrix,out
*msg,info
%/____________ INDUCTANCE CALCULATION SUMMARY ___________________
*do,_ii,1,_nrows
_indii=_ind(_ii,_ii)
*vwrite,_ii,_indii
('Self inductance of coil ',f3.0,' = ',e15.5,' (H)')
*enddo
*do,_ii,1,_nrows
*do,_jj,_ii+1,_nrows
_indij=_ind(_ii,_jj)
*vwrite,_ii,_jj,_indij
('Mutual inductance between coils ',f3.0,' and ',f3.0,' = ',e15.5,' (H)')
*enddo
*enddo
*vwrite,arg4,_nrows,_nrows
(/'Inductance matrix is stored in array parameter ',a,'(',f3.0,',',f3.0,')')
*vwrite,arg4
('Inductance matrix is stored in file ',a,'.txt'/)
*msg,info
%/_____________________________________________________________
*vwrite,_dcpu
('Time (cpu): ',f6.1,'Sec')
/out
/gopr
*set,%arg4%
*dim,%arg4%,array,_nrows,_nrows
*do,_ii,1,_nrows
*do,_jj,1,_nrows
%arg4%(_ii,_jj,1)=_ind(_ii,_jj,1)
*enddo
*enddo
*if,_mnu3,ne,1,then
*list,lmatrix,out
*else
*list,lmatrix,out
*if,_mg1,eq,0,then
*uilist,lmatrix,out
*endif
*endif
/nopr
/out,%arg4%,txt
*do,_ii,1,_nrows
*do,_jj,_ii,_nrows
_indij=_ind(_ii,_jj)
*vwrite,_ii,_jj,_indij
(5X,2(F5.0,3X),E13.5)
*enddo
*enddo
/out
*endif
parsav,all
/out,scratch
/solu
magopt,4
fini
*if,_esav,ne,1,then
/rename,oper,esav,,%_jname(1)%,esav
*endif
*if,_emat,ne,1,then
/rename,oper,emat,,%_jname(1)%,emat
*endif
*if,_tri,ne,1,then
/rename,oper,tri,,%_jname(1)%,tri
*endif
*if,_db,ne,1,then
/rename,oper,db,,%_jname(1)%,db
*endif
*if,_rmg,ne,1,then
/rename,oper,rmg,,%_jname(1)%,rmg
*endif
*if,_rst,ne,1,then
/rename,oper,rst,,%_jname(1)%,rst
*endif
/out
*if,_ok3,ne,1,then
resume
*endif
parres
cmdele,_elem
_ind =
_nrows= $_mnu3= $_ok3= $_symm= $_cchk3= $_jname=
_status= $_ene= $_curmax= $_tinycur= $_absi= $_scale=
_indii= $_indij= $_nami= $_ecount= $_cur= $_noelm= $_ztyp=
_antyp= $_level= $_neqit= $_ityp= $_jtyp= $_rcon= $_rcur= $_e1=
_ptyp= $_qq= $_pre= $_mxvld= $_ind= $_eneiijj= $_nami=
_nele= $_iele= $_esav= $_emat= $_tri= $_rmg= $_rst= $_db=
_x= $_y= $_z= $_hsum= $_bsum= $_ii= $_jj= $_kkk= $_i=
/out