{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Creating a Nastran Section\n\nCalculate section properties of Nastran HAT1 section.\n\nThe following example demonstrates how to create a cross-section defined in\na Nastran-based finite element analysis program. The following creates a\nHAT1 cross-section and calculates the geometric, warping and plastic properties.\nThe HAT1 cross-section is meshed with a maximum elemental area of 0.005.\n\nThe geometry and mesh are plotted, and the mesh information printed to the terminal\nbefore the analysis is carried out. Detailed time information is printed to the\nterminal during the cross-section analysis stage. Once the analysis is complete,\nthe cross-section properties are printed to the terminal. The centroidal\naxis second moments of area and torsion constant are saved to variables and it\nis shown that, for non-circular sections, the torsion constant is not equal to the\nsum of the second moments of area.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# sphinx_gallery_thumbnail_number = 1\n\nfrom typing import get_origin\nimport sectionproperties.pre.library.nastran_sections as nsections\nfrom sectionproperties.analysis.section import Section"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a HAT1 section\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry = nsections.nastran_hat1(DIM1=4.0, DIM2=2.0, DIM3=1.5, DIM4=0.1875, DIM5=0.375)\ngeometry.plot_geometry()  # plot the geometry\nprint(geometry.geom)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a mesh with a maximum elemental area of 0.005\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry.create_mesh(mesh_sizes=[0.005])\n\nsection = Section(geometry, time_info=True)  # create a Section object\nsection.display_mesh_info()  # display the mesh information\nsection.plot_mesh()  # plot the generated mesh`"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Perform a geometric, warping and plastic analysis, displaying the time info\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "section.calculate_geometric_properties()\nsection.calculate_warping_properties()\nsection.calculate_plastic_properties()\n\nsection.display_results()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Get the second moments of area and the torsion constant\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "(ixx_c, iyy_c, ixy_c) = section.get_ic()\nj = section.get_j()\nprint(\"Ixx + Iyy = {0:.3f}\".format(ixx_c + iyy_c))\nprint(\"J = {0:.3f}\".format(j))"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.9.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}