{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Graphical analysis of stresses: Mohr's circle" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*From [Wikipedia](https://en.wikipedia.org/wiki/Mohr%27s_circle)*\n", "\n", "\n", "Mohr's circle, named after Christian Otto Mohr, is a two-dimensional graphical representation of the transformation law for the Cauchy stress tensor.\n", "\n", "After performing a stress analysis on a material body assumed as a continuum, the components of the Cauchy stress tensor at a particular material point are known with respect to a coordinate system. The Mohr circle is then used to determine graphically the stress components acting on a rotated coordinate system, i.e., acting on a differently oriented plane passing through that point.\n", "\n", "The abscissa, $\\sigma_\\mathrm{n}$, and ordinate, $\\tau_\\mathrm{n}$, of each point on the circle, are the magnitudes of the normal stress and shear stress components, respectively, acting on the rotated coordinate system. In other words, the circle is the locus of points that represent the state of stress on individual planes at all their orientations, where the axes represent the principal axes of the stress element.\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from scipy.linalg import eigvalsh\n", "from ipywidgets import interact\n", "from IPython.display import display\n", "from matplotlib import rcParams" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook\n", "rcParams['font.family'] = 'serif'\n", "rcParams['font.size'] = 16" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Mohr circle for 2D stresses" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def mohr2d(S11=10, S12=0, S22=-5):\n", " \"\"\"Plot Mohr circle for a 2D tensor\"\"\"\n", " center = [(S11 + S22)/2.0, 0.0]\n", " radius = np.sqrt((S11 - S22)**2/4.0 + S12**2)\n", " Smin = center[0] - radius\n", " Smax = center[0] + radius\n", " \n", " \n", " print(\"Minimum Normal Stress: \", np.round(Smin,6))\n", " print(\"Maximum Normal Stress: \", np.round(Smax, 6))\n", " print(\"Average Normal Stress: \", np.round(center[0], 6))\n", " print(\"Minimum Shear Stress: \", np.round(-radius, 6))\n", " print(\"Maximum Shear Stress: \", np.round(radius, 6))\n", " \n", " plt.figure()\n", " circ = plt.Circle((center[0],0), radius, facecolor='#cce885', lw=3,\n", " edgecolor='#5c8037') \n", " plt.axis('image')\n", " ax = plt.gca() \n", " ax.add_artist(circ)\n", " ax.set_xlim(Smin - .1*radius, Smax + .1*radius)\n", " ax.set_ylim(-1.1*radius, 1.1*radius)\n", " plt.plot([S22, S11], [S12, -S12], 'ko')\n", " plt.plot([S22, S11], [S12, -S12], 'k')\n", " plt.plot(center[0], center[1], 'o', mfc='w')\n", " plt.text(S22 + 0.1*radius, S12, 'A')\n", " plt.text(S11 + 0.1*radius, -S12, 'B')\n", " plt.xlabel(r\"$\\sigma$\", size=18)\n", " plt.ylabel(r\"$\\tau$\", size=18) \n", " " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6e8772041d4743728ffb92c82c1fe9f4", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(FloatSlider(value=10.0, description='S11', min=-100.0), FloatSlider(value=0.0, descripti…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "w = interact(mohr2d,\n", " S11=(-100.,100.),\n", " S12=(-100.,100.),\n", " S22=(-100.,100.))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Mohr circle for 3D stresses" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "def mohr3d(S11=90, S12=0, S13=95, S22=96, S23=0, S33=-50):\n", " r\"\"\"Plot 3D Mohr circles.\"\"\"\n", " \n", " S = np.array([[S11, S12, S13],\n", " [S12, S22, S23],\n", " [S13, S23, S33]])\n", " \n", " S3, S2, S1 = eigvalsh(S)\n", "\n", " R_maj = 0.5*(S1 - S3)\n", " cent_maj = 0.5*(S1+S3)\n", " \n", " R_min = 0.5*(S2 - S3)\n", " cent_min = 0.5*(S2 + S3)\n", " \n", " R_mid = 0.5*(S1 - S2)\n", " cent_mid = 0.5*(S1 + S2)\n", " \n", " plt.figure()\n", " circ1 = plt.Circle((cent_maj,0), R_maj, facecolor='#cce885', lw=3,\n", " edgecolor='#5c8037')\n", " circ2 = plt.Circle((cent_min,0), R_min, facecolor='w', lw=3,\n", " edgecolor='#15a1bd')\n", " circ3 = plt.Circle((cent_mid,0), R_mid, facecolor='w', lw=3,\n", " edgecolor='#e4612d')\n", " plt.axis('image')\n", " ax = plt.gca()\n", " ax.add_artist(circ1)\n", " ax.add_artist(circ2)\n", " ax.add_artist(circ3)\n", " ax.set_xlim(S3 - .1*R_maj, S1 + .1*R_maj)\n", " ax.set_ylim(-1.1*R_maj, 1.1*R_maj)\n", " plt.xlabel(r\"$\\sigma$\", size=18)\n", " plt.ylabel(r\"$\\tau$\", size=18)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "a832faf9bb1d4f7fb9e6e6df0f9bf844", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(FloatSlider(value=90.0, description='S11', min=-100.0), FloatSlider(value=0.0, descripti…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "w = interact(mohr3d,\n", " S11=(-100.,100.),\n", " S12=(-100.,100.),\n", " S13=(-100.,100.),\n", " S22=(-100.,100.),\n", " S23=(-100.,100.),\n", " S33=(-100.,100.))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.core.display import HTML\n", "def css_styling():\n", " styles = open('./styles/custom_barba.css', 'r').read()\n", " return HTML(styles)\n", "css_styling()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.6.9" }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 1 }