!
!   This macro creates a cylindrical slotted mechanical
!   spring based on the parameters calculated by strength
!   of material formula iterations. By capitalizing on
!   symmetry, a quarter coil segment is created and mirrored
!   several times to create the entire spring.
!
!   TITLE:  spring.mac (PART_LIB)
!
*get,prkey_,active,0,prkey
/nopr

mod_assemb_prep
!
/units,bin
!
!*************************** Paramter Values **************************
!
pi=3.1415927    ! constants
rconv=pi/180
!
!
xc=1.00     ! cartesian x coordinate
yc=2.00     ! cartesian y coordinate
zc=3.00     ! cartesian z coordinate
!
!
rotxy=0     ! 1st rotation angle (+x to +y) default 0
rotyz=0     ! 2nd rotation angle (+y to +z) default 0
rotzx=0     ! 3rd rotation angle (+z to +x) default 0
!
!
rout=2.10/2 ! outer radius of coil
rin=.60     ! inner radius of coil
t=0.12      ! coil thickness
tgap=0.064  ! thickness of gap between coils
rfil=0.5*tgap   ! fillet radius
d0=0.27/2   ! 1/2 width of coil connectors
!
!**********************************************************************
!
!
!<<<<<<<<<<<<<<<<<<<<<< Model Coordinate System >>>>>>>>>>>>>>>>>>>>>>>>
!
csn=11          ! initialize local c.s. numbers
ctmcs=csn       ! cartesian model c.s. number
csn=csn+1
cylmcs=csn      ! cylindrical model c.s. number
!
csys,0
clocal,ctmcs,0,xc,yc,zc,rotxy,rotyz,rotzx
!
csys,0
clocal,cylmcs,1,xc,yc,zc,rotxy,rotyz,rotzx
!
!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
!
k,,rin,0
k,,rout,0
k,,rout,90
k,,rin,90
!
*get,km,kp,,num,max
!
lstr,km-3,km-2
l,km-2,km-1
lstr,km-1,km
l,km,km-3
!
a,km-3,km-2,km-1,km
!
*get,am,area,,num,max
!
voffst,am,(tgap+t)
!
!
csys,ctmcs
!
k,,1.1*rout,d0+rfil,-(0.5*tgap)
k,,1.1*rout,1.1*rout,-(0.5*tgap)
k,,1.1*rout,1.1*rout,(0.5*tgap)
k,,1.1*rout,d0+rfil,(0.5*tgap)
k,,1.1*rout,d0,0
!
*get,km,kp,,num,max
!
lstr,km-4,km-3
lstr,km-3,km-2
lstr,km-2,km-1
!
csn=csn+1
clocal,csn,1,1.1*rout,d0+rfil,0,0,0,90
!
l,km-1,km
l,km,km-4
!
a,km,km-1,km-2,km-3,km-4
!
*get,am,area,,num,max
!
voffst,am,1.5*rout
!
*get,vm,volu,,num,max
!
vsbv,vm-1,vm,,delete,delete
!
numcmp,all
!
!
csys,ctmcs
!
k,,d0+rfil,1.1*rout,(t+1.5*tgap)
k,,1.1*rout,1.1*rout,(t+1.5*tgap)
k,,1.1*rout,1.1*rout,(t+0.5*tgap)
k,,d0+rfil,1.1*rout,(t+0.5*tgap)
k,,d0,1.1*rout,(t+tgap)
!
*get,km,kp,,num,max
!
lstr,km-4,km-3
lstr,km-3,km-2
lstr,km-2,km-1
!
csn=csn+1
clocal,csn,1,(d0+rfil),1.1*rout,(t+tgap),-90,0,-90
!
l,km-1,km
l,km,km-4
!
a,km,km-1,km-2,km-3,km-4
!
*get,am,area,,num,max
!
voffst,am,1.5*rout
!
*get,vm,volu,,num,max
!
vsbv,vm-1,vm,,delete,delete
!
numcmp,all
!
/VIEW, 1 ,1,1,1
/auto,1
!
lplot
!
!
!
!<<<<<<<<<<<<<<<<<<<<<<< 1st cut >>>>>>>>>>>>>>>>>>>>>>>>
!
csys,ctmcs
!
k,,d0+rfil,0.8*rin,-(0.5*tgap)
k,,d0+rfil,1.1*rout,-(0.5*tgap)
!
*get,km,kp,,num,max
*get,vm,volu,,num,max
!
phi1=asin((d0+rfil)/rout)
phi2=asin((d0+rfil)/rin)
!
a,km-1,km,kp(d0+rfil,rout*cos(phi1),(t+tgap)),kp(d0+rfil,rin*cos(phi2),(t+tgap))
!
*get,am,area,,num,max
!
vsba,vm,am,,delete,delete
!
numcmp,all
!
!<<<<<<<<<<<<<<<<<<<<<<< 2nd cut >>>>>>>>>>>>>>>>>>>>>>>>
!
csys,ctmcs
!
k,,0.8*rin,d0+rfil,(t+tgap)
k,,1.1*rout,d0+rfil,(t+tgap)
!
*get,km,kp,,num,max
!
csys,cylmcs
vsel,s,loc,y,0,(90-(phi1/rconv))
*get,vm,volu,,num,max
!
csys,ctmcs
a,km-1,km,kp(rout*cos(phi1),d0+rfil,rfil),kp(rin*cos(phi2),d0+rfil,rfil)
!
*get,am,area,,num,max
!
vsba,vm,am,,delete,delete
!
allsel,all
numcmp,all
!
!*go,:flip
csys,ctmcs
vsymm,x,all
vsymm,y,all
vsymm,z,all
!
csn=csn+1
clocal,csn,0,0,0,(t+tgap),0,0,0
vsymm,z,all
!
csn=csn+1
clocal,csn,0,0,0,(t+tgap),0,0,0
vsymm,z,all
!
!:flip
vplot
!
numcmp,all
assemble=1
!name='spring'
!arry_nam='sprng'
finalize_model_data

*if,prkey_,eq,1,then
    /go
*endif