{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Simple Example\n\nCalculate section properties of a circle.\n\nThe following example calculates the geometric, warping and plastic properties\nof a 50 mm diameter circle. The circle is discretised with 64 points and a mesh\nsize of 2.5 mm\\ :sup:`2`.\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 a circle, the torsion constant is equal to the sum of the\nsecond moments of area.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# sphinx_gallery_thumbnail_number = 1\n\nimport sectionproperties.pre.library.primitive_sections as sections\nfrom sectionproperties.analysis.section import Section"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a 50 diameter circle discretised by 64 points\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry = sections.circular_section(d=50, n=64)\ngeometry.plot_geometry()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a mesh with a mesh size of 2.5 and display information about it\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry.create_mesh(mesh_sizes=[2.5])\n\nsection = Section(geometry, time_info=True)\nsection.display_mesh_info()\nsection.plot_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()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Print the results to the terminal\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "section.display_results()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Get and print 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
}