!   TITLE:  ground_load.mac (MMA WBDDS)
!
!-----------------------------------------------------------------------
!       Rev -   08/19/2006      D. Edwards
!-----------------------------------------------------------------------
!
!   Kinematics & Kinetics model of MMA Weapons Bay Doors and Linakges.
!   
!   Usage:  ground_load,Adoor
!
!       Adoor: Angle [0, 95] of outboard door from the closed position
!
!   If no argument is supplied, the model will be solved with a zero deg
!   door angle.
!
!
!   CS_0:       Cartesian aircraft reference point Coordinate System
!   CS_1:       Cylindrical aircraft reference point Coordinate System
!   CS_2:       Spherical aircraft reference point Coordinate System
!
!   Ref: Boeing_model-2006-07-18.drw
!
!************************** TABLE OF CONTENTS **************************
!
!       Model Assembly Preparation
!
!   1.  Parameter List
!   2.  Model Coordinate System
!   3.  Elements
!   4.  Constraints
!   5.  Solution
!   6.  Post Processing
!
!********************* Model Assembly Preparation **********************
!
mod_assemb_prep     !,arg1,arg2,arg3    ! prepare database for assembly
!
Adoor=arg1          ! Initial door angle (Adoor=0 @ fully closed)
!
!<<<<<<<<<<<<<<<<<<<<<<<< 1.  Parameter List >>>>>>>>>>>>>>>>>>>>>>>>>>
!
ground_load.parm
!
!<<<<<<<<<<<<<<<<<<<< 2.  Model Coordinate System >>>>>>>>>>>>>>>>>>>>>
!
mod_coord_system,acs,xc,yc,zc,rotxyc,rotyzc,rotzxc

! Turn on KP and line numbers & switch to front view.
/pnum,node,1
/pnum,elem,1
/view,1,,,1
/ang, 1
/rep,fast

!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 3.  Elements >>>>>>>>>>>>>>>>>>>>>>>>
!

!
! Create KPs at aircraft mount points (fixed pivots)
!
csys,0
k,1,y1,z1
nkpt,1,1

k,4,y4,z4
nkpt,4,4

k,26,y26,z26
nkpt,26,26

!
! Create the Gooseneck Link
!
create_cs,2,'CS1_1',1,y1,z1
!
k,2,Lgoose,Adoor0+Adoor
nkpt,2,2
!
e,1,2                                   ! Gooseneck link

!
! Create the Load Link and RGA output link
!
csys,CS1_1
create_cs,0,'CS2_1',1,Lgoose,Adoor0+Adoor,0,180 ! Cylindrical CS @ node 2

k,100,Llink,((29-96)/95*Adoor+90)-20    ! Construct an arc @ 2
k,101,Llink,((29-96)/95*Adoor+90)+20
larc,100,101,2,Llink

create_cs,2,'CS4_1',1,y4,z4             ! Construct an arc @ 4
k,102,Lrga,((230-75)/95*Adoor+75)-20
k,103,Lrga,((230-75)/95*Adoor+75)+20
larc,102,103,4,Lrga

! Joint 3 is at the intersection of the two arcs
linl,1,2                                ! Create KP 3 at joint 3

nkpt,3,3
nkpt,20,2                               ! Create node at KP 2
nkpt,30,3                               ! Create node at KP 3  

e,20,30                                 ! Load link
e,4,3                                   ! RGA output

!
! Create the outer door
!
csys,CS1_1
k,31,Ldo1,Adoor0+Adoor+Ado+Ado1         ! Location of outer door CG
nkpt,31,31
e,1,31

k,24,Ldo,Adoor0+Adoor+Ado
nkpt,24,24
e,31,24

!
! Create Strut and Inner Door
!
nkpt,240,24                             ! Node for inner door @ KP 24

create_cs,2,'CS26_1',1,y26,z26          ! Swing an arc for strut
k,104,Lstrut,((132-56)/95*Adoor-132)-20
k,105,Lstrut,((132-56)/95*Adoor-132)+20
larc,104,105,26,Lstrut

csys,0
create_cs,2,'CS24_1',1,kx(24),ky(24)
k,106,Ldi,135
k,107,Ldi,225
larc,106,107,24,Ldi

!lplot

linl,1,2                                !KP=5
nkpt,25,5
e,26,25                                 ! Strut

nkpt,250,5

csys,CS24_1                             ! Define location of inner door CG
create_cs,0,'CS240_1',1,0,0,0,ky(5)
k,32,Ldi1,Adi1
nkpt,32,32

e,240,32                                ! Create the inner door
e,32,250



! Compute moment arm for load link about RGA driveline (d1)
csys,0
l,2,3
ln_dist_kp,'d1',1,4

! Compute moment arm for load link about hingeline (d2)
csys,0
ln_dist_kp,'d2',1,1


!
! Create the bottom skin of the inner door for use in calculating
! the projected height for the wind load calculation
!
csys,CS240_1
k,110,Ldisc,Adisc                       ! Inner door skin center
k,111,Ldis1,Adis1                       ! Outboard corner
k,112,Ldis2,Adis2                       ! Inboard corner
larc,111,112,110,Rdis

!
! Mass elements
!

! Outer door
type,2
mat,2
real,2
e,31

! Inner Door
real,3
e,32

!
!<<<<<<<<<<<<<<<<<<<<<<<<<<< 4.  Constraints >>>>>>>>>>>>>>>>>>>>>>>>>>
!
! Aircraft structure constraints
nsel,s,node,,1
nsel,a,node,,26
d,all,ux,0,,,,uy

! Completely fix the RGA output
allsel
d,4,all

!
! Constrain all the links together
!
cpintf,ux
cpintf,uy

/pbc,all,,1
eplot

!
!<<<<<<<<<<<<<<<<<<<< 5. Solution >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
fini

/solu

acel,0,g_bin

antype,static

outres,all,all

solve

fini

!
!<<<<<<<<<<<<<<<<<<<< 6. Post Processing >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
!
/post1

!
! Process text results
!


! Strut angle from horizontal
csys,CS26_1
Astrut=ny(25)

! RGA out angle from door closed position
csys,CS4_1
Arga=ky(3)-Arga0
*if,Arga,lt,0,then
    Arga=360+Arga
*endif

! Calculate projected height for wind load calculation
csys,0
*if,ky(111),lt,ky(112),then
    Height=ny(1)-ky(111)
*else
    Height=ny(1)-ky(112)
*endif

! Reaction moment on RGA output due to door weight
*get,Mrga,NODE,4,RF,Mz

! Record position of CGs
csys,0
CGoy=nx(31)
CGoz=ny(31)
CGiy=nx(32)
CGiz=ny(32)


!
! Process graphics results
!
round_num,Mrga,0
a1=num_
round_num,Arga,1
a2=num_
/title,MMA RGA torque due to ground loads: Mrga = %a1% (Adoor = %Adoor% Arga = %a2%)

/pbc,rfor,,1

!/dscale,,1
!plnsol,rot,z,2,1.0  

!/out,mma,out
!prnsol,dof
!prnld,,,all
!presol,elem
!/out