! ============================================================
! M12 - Punto de partida
! Unidades coherentes: m, kg, s, N, Pa.
! ============================================================
/CLEAR,START                        ! Completa los TODO para CERIG, MPC184/BEAM188 y extraccion SMISC.
/FILNAME,m12_start,1
/TITLE,M12 - Punto de partida union atornillada
/UNITS,SI

plate_x=0.08
plate_z=0.04
plate_t=0.012
interface_gap=0.0001
mesh_h=0.004
bolt_x=0.04
bolt_z=0.02
head_absorb_r=0.010
thread_absorb_r=0.008
bolt_d=0.012
young=210E9
nu=0.30
fx_total=4000
fy_total=-3000
select_tol=mesh_h*1E-4

/PREP7
ET,1,SOLID185
KEYOPT,1,2,0
MP,EX,1,young                       ! o ET,2,BEAM188 con SECTYPE,BEAM,CSOLID y SECDATA,bolt_d
MP,PRXY,1,nu
TYPE,1
MAT,1
BLOCK,0,plate_x,0,plate_t,0,plate_z
BLOCK,0,plate_x,plate_t+interface_gap,2*plate_t+interface_gap,0,plate_z

div_x=MAX(1,NINT(plate_x/mesh_h))
div_y=MAX(1,NINT(plate_t/mesh_h))
div_z=MAX(1,NINT(plate_z/mesh_h))
MSHAPE,0,3D
MSHKEY,1
LSEL,S,LENGTH,,plate_x
LESIZE,ALL,,,div_x,,1
LSEL,S,LENGTH,,plate_t
LESIZE,ALL,,,div_y,,1
LSEL,S,LENGTH,,plate_z
LESIZE,ALL,,,div_z,,1
ALLSEL,ALL
VMESH,ALL

SELTOL,select_tol
NSEL,S,LOC,Y,0
CM,bottom_nodes,NODE
ALLSEL,ALL
SELTOL,

! TODO 2: selecciona head_dep en y=2*plate_t+interface_gap y thread_dep en y=plate_t.
! TODO 3: elige head_pilot y thread_pilot; aplica CERIG,piloto,ALL
! CERIG: acopla la region dependiente al nodo piloto (cabecera o rosca).
! TODO 4: crea conector 1D entre pilotos; carga en head_pilot (Fx, Fy).

FINISH

/SOLU
ANTYPE,STATIC
NLGEOM,OFF
CMSEL,S,bottom_nodes
D,ALL,ALL,0
ALLSEL,ALL
! TODO 5: F,head_pilot,FX,fx_total y F,head_pilot,FY,fy_total
OUTRES,ALL,LAST
SOLVE
FINISH

/COM,Completa los TODO y compara con 12_bolt_connector.mac     ! ETABLE con SMISC: almacena esfuerzos internos del conector (N, V, M) para extraccion.
FINISH



