# EXPORT CONTROLLED — ITAR USML Category XX  (Ocean Guard M03)
# Code_Aster STAT_NON_LINE nonlinear collapse — 1.5x MAWP elastoplastic large-displacement.
# Auto-generated by gate_codeaster_nonlinear.py. Do not hand-edit.
DEBUT(LANG='EN')

MESH = LIRE_MAILLAGE(FORMAT='MED', UNITE=20)

MODEL = AFFE_MODELE(
    MAILLAGE=MESH,
    AFFE=_F(TOUT='OUI', PHENOMENE='MECANIQUE', MODELISATION='3D'),
)

# Al-5083-H321: elastoplastic (linear kinematic hardening ECRO_LINE).
MAT = DEFI_MATERIAU(
    ELAS=_F(E=7.100000e+10, NU=0.3300),
    ECRO_LINE=_F(D_SIGM_EPSI=7.100000e+08, SY=2.150000e+08),
)

FIELDMAT = AFFE_MATERIAU(MAILLAGE=MESH, AFFE=_F(TOUT='OUI', MATER=MAT))

# NOTE (2026-07-09 fix, MECANONLINE9_4): FWD_FACE/AFT_FACE are NOT flat
# end-cap faces — direct MED inspection confirmed all three surface groups
# (OUTER/FWD_FACE/AFT_FACE) are angular partitions of the SAME outer
# cylindrical wall (radius 146-162mm spanning the full z=0..262mm length).
# DDL_IMPO on FWD_FACE alone left 5 of 6 rigid-body modes unconstrained
# (translation X/Y, rotation about X/Y/Z all free except partial DZ),
# producing a singular tangent stiffness (non-invertible matrix).
#
# Real fix: build proper geometric node groups directly (DEFI_GROUP) —
# the TRUE z=0 end ring (72 nodes, radius 146-162mm, mesh axis confirmed
# centered at x=0,y=0) — and apply a minimal statically-determinate
# 6-DOF removal scheme (verified against exact mesh node coordinates,
# not assumed):
#   END_Z0 (whole z=0 ring): DZ=0 removes axial translation Tz + the two
#     bending rotations (rotation about X/Y would require non-uniform DZ
#     across the ring's real 2D annular extent).
#   PT_FIX = exact node (162, 0, 0) on that ring: DX=DY=0 removes Tx, Ty.
#   PT_ROT = exact node (0, 162, 0) on that ring (90 deg away): DY=0
#     removes the last mode, rotation about Z (torsion about tube axis).
# All 6 rigid-body modes removed; algebraic check: DZ=-theta_x*y+theta_y*x
# forces theta_x=theta_y=0 over the ring; DX=Tx-theta_z*y at y=0 forces
# Tx=0; DY=Ty+theta_z*x at x=0 forces Ty=0; back-substituting DY=0 at
# PT_FIX (y=0, so DY=Ty+theta_z*162=0) forces theta_z=0. No mode left
# unconstrained; no full-face over-constraint (avoids artificial stress
# concentration). Coordinates (162,0,0)/(0,162,0) are EXACT mesh nodes on
# the z=0 ring (confirmed via direct MED HDF5 node-coordinate extraction,
# not merely nearest-node search) — mesh centerline verified at x=0,y=0.
# CORRECTED (2026-07-09, SUPERVIS_4): Aster 17.4's DEFI_GROUP/CREA_GROUP_NO
# catalog has NO 'NOEUD_PROCHE' OPTION (checked catalog source directly,
# defi_group.py — valid OPTION values are ENV_SPHERE/ENV_CYLINDRE/PLAN/
# SEGM_DROI_ORDO/NOEUD_ORDO/TUNNEL/INCLUSION/FISS_XFEM/INTERVALLE_VALE/
# RELA_CINE_BP). Point selection uses OPTION='ENV_SPHERE' (POINT + RAYON +
# PRECISION) instead — RAYON=2mm safely captures only the exact target node
# (verified via direct MED node-coordinate extraction: nodes exist at EXACTLY
# (162,0,0) and (0,162,0), and ring node spacing is ~14mm, so a 2mm sphere
# cannot ambiguously catch a neighboring node).
MESH = DEFI_GROUP(
    reuse=MESH,
    MAILLAGE=MESH,
    CREA_GROUP_NO=(
        _F(NOM='END_Z0', OPTION='PLAN', POINT=(0.0, 0.0, 0.0),
           VECT_NORMALE=(0.0, 0.0, 1.0), PRECISION=0.5),
        _F(NOM='PT_FIX', OPTION='ENV_SPHERE', POINT=(162.0, 0.0, 0.0),
           RAYON=2.0, PRECISION=2.0),
        _F(NOM='PT_ROT', OPTION='ENV_SPHERE', POINT=(0.0, 162.0, 0.0),
           RAYON=2.0, PRECISION=2.0),
    ),
)

# External pressure on the outer hull surface group (group_ma='OUTER').
# Full 6-rigid-body-mode removal via END_Z0/PT_FIX/PT_ROT (see note above) —
# replaces the old under-constrained FWD_FACE-only DZ=0.
LOAD = AFFE_CHAR_MECA(
    MODELE=MODEL,
    PRES_REP=_F(GROUP_MA='OUTER', PRES=1.125000e+07),
    DDL_IMPO=(
        _F(GROUP_NO='END_Z0', DZ=0.0),
        _F(GROUP_NO='PT_FIX', DX=0.0, DY=0.0),
        _F(GROUP_NO='PT_ROT', DY=0.0),
    ),
)

# Ramp 0 -> 1.0 (multiplies test pressure). Load factor lambda = ramp value.
RAMP = DEFI_FONCTION(
    NOM_PARA='INST',
    VALE=(0.0, 0.0, 1.0, 1.0),
    PROL_DROITE='CONSTANT', PROL_GAUCHE='CONSTANT',
)

LINST = DEFI_LIST_REEL(DEBUT=0.0, INTERVALLE=_F(JUSQU_A=1.0, NOMBRE=50))

# Automatic sub-stepping so a limit point is captured as non-convergence,
# not a spurious hard stop — the last converged INST = lambda_collapse.
DLIST = DEFI_LIST_INST(
    METHODE='AUTO',
    DEFI_LIST=_F(LIST_INST=LINST),
    ECHEC=_F(ACTION='DECOUPE', SUBD_METHODE='MANUEL', SUBD_PAS=4, SUBD_NIVEAU=5),
)

# STAT_NON_LINE — large displacement + plasticity (VMIS_ISOT_LINE).
# NOTE (2026-07-03 fix, COMPOR5_22): GROT_GDEP is unusable on MECA_TETRA4
# (linear tets — the current mesh, confirmed via MED element-type scan).
# GROT_GDEP requires either quadratic (MECA_TETRA10) elements or a
# different formulation on linear elements. Aster's own exception text
# recommends GREEN_LAGRANGE as the linear-tet-compatible alternative; used
# here so the gate is unblocked without depending on the mesh-order-2
# pipeline bug (generate_aster_med_mesh.py requests `-order 2` but the
# on-disk M02 .med still contains TE4-only cells — separate open defect,
# tracked for a follow-up mesh-pipeline fix so GROT_GDEP can be restored).
RESU = STAT_NON_LINE(
    MODELE=MODEL,
    CHAM_MATER=FIELDMAT,
    EXCIT=_F(CHARGE=LOAD, FONC_MULT=RAMP),
    COMPORTEMENT=_F(RELATION='VMIS_ISOT_LINE', DEFORMATION='GREEN_LAGRANGE', TOUT='OUI'),
    INCREMENT=_F(LIST_INST=DLIST),
    NEWTON=_F(MATRICE='TANGENTE', REAC_ITER=1),
    CONVERGENCE=_F(RESI_GLOB_RELA=1.0e-6, ITER_GLOB_MAXI=25),
)

RESU = CALC_CHAMP(reuse=RESU, RESULTAT=RESU,
                  CRITERES=('SIEQ_ELGA',), DEFORMATION=('EPSP_ELGA',))

# Print the achieved instants (max converged INST = lambda_collapse) to the .mess.
IMPR_RESU(FORMAT='RESULTAT', RESU=_F(RESULTAT=RESU, NOM_CHAM='DEPL'))

FIN()
