{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n\n# Mirroring and Rotating Geometry\n\nMirror and rotate a cross section.\n\nThe following example demonstrates how geometry objects can be mirrored and\nrotated. A 200PFC and 150PFC are placed back-to-back by using the\n:func:`~sectionproperties.pre.geometry.Geometry.mirror_section` method and are\nrotated counter-clockwise by 30 degrees by using the\n:func:`~sectionproperties.pre.geometry.Geometry.rotate_section` method. The\ngeometry is cleaned to ensure there are no overlapping facets along the junction\nbetween the two PFCs. A geometric, warping and plastic analysis is then carried out.\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 and iteration information printed\nfor the plastic analysis. Once the analysis is complete, a plot of the various\ncalculated centroids is generated.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# sphinx_gallery_thumbnail_number = 1\n\nimport sectionproperties.pre.library.steel_sections as steel_sections\nfrom sectionproperties.analysis.section import Section"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a 200PFC and a 150PFC\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "pfc1 = steel_sections.channel_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8)\npfc2 = steel_sections.channel_section(\n    d=150, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8\n).shift_section(0, 26.5)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Mirror the 200 PFC about the y-axis\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "pfc1 = pfc1.mirror_section(axis=\"y\", mirror_point=[0, 0])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Merge the pfc sections\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry = ((pfc1 - pfc2) | pfc1) + pfc2"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Rotate the geometry counter-clockwise by 30 degrees\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry = geometry.rotate_section(angle=30)\ngeometry.plot_geometry()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Create a mesh and section. For the mesh, use a mesh size of 5 for the 200PFC\nand 4 for the 150PFC\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "geometry.create_mesh(mesh_sizes=[5, 4])\n\nsection = Section(geometry, time_info=True)\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\nand the iteration info for the plastic analysis\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(verbose=True)\n\nsection.plot_centroids()"
      ]
    }
  ],
  "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
}