{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "language_info": {
   "name": "python"
  },
  "fundamentals": {
   "title": "Where does a circular opening concentrate stress?",
   "lead": "Make a hole in a flat sheet pulled along one direction. Derive the conditions on the empty edge, compute the circumferential stress and check how quickly the disturbance decays as a strain gauge moves into the sheet.",
   "unit_slug": "stress-around-a-circular-opening"
  }
 },
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8ff7c630a3e4",
   "metadata": {},
   "source": [
    "# Where does a circular opening concentrate stress?\n",
    "\n",
    "Make a hole in a flat sheet pulled along one direction. Derive the conditions on the empty edge, compute the circumferential stress and check how quickly the disturbance decays as a strain gauge moves into the sheet."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b932999a89c4",
   "metadata": {
    "fundamentals": {
     "section": "derive-the-model"
    }
   },
   "source": [
    "## Keep the free edge and the distant traction in one solution\n",
    "\n",
    "Take an isotropic linear-elastic sheet, long and wide relative to a circular through-hole of radius $a$. At a large distance apply uniaxial tension $S$ along $x$. The empty edge can carry neither normal nor tangential traction, so $\\sigma_{rr}=\\tau_{r\\theta}=0$ at $r=a$. The circumferential stress $\\sigma_{\\theta\\theta}$ is parallel to this edge and need not vanish. Writing uniaxial tension in polar coordinates introduces only a constant angular sector and a sector in $\\cos(2\\theta)$ and $\\sin(2\\theta)$.\n",
    "\n",
    "In plane elasticity an Airy stress function satisfies equilibrium automatically and must be biharmonic for a homogeneous isotropic solid without body forces. The circular-hole solution can be built by adding decaying terms in those same two angular sectors to the distant uniform stress. One convenient potential is\n",
    "\n",
    "$$\\Phi=\\frac{S}{4}\\left[r^2-2a^2\\log(r/a)-(r^2-2a^2+a^4/r^2)\\cos(2\\theta)\\right].$$\n",
    "\n",
    "Differentiate twice with respect to radius to obtain the hoop stress. Writing $u=(a/r)^2$ gives\n",
    "\n",
    "$$\n",
    "\\sigma_{\\theta\\theta}=\\frac S2[1+u-(1+3u^2)\\cos(2\\theta)].\n",
    "$$\n",
    "\n",
    "The radial and shear stress expressions in the calculation cell follow from $\\sigma_{rr}=\\Phi_r/r+\\Phi_{\\theta\\theta}/r^2$ and $\\tau_{r\\theta}=-\\partial_r(\\Phi_\\theta/r)$. Check both edge tractions explicitly; imposing zero hoop stress instead would erase the stress concentration we aim to measure."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1af267045dd7",
   "metadata": {
    "fundamentals": {
     "section": "worked-prediction"
    }
   },
   "source": [
    "## Locate a gauge and interpret its reading\n",
    "\n",
    "On the edge $u=1$, hence $\\sigma_{\\theta\\theta}=S[1-2\\cos(2\\theta)]$. With $S=40$ MPa, gauges at the top and bottom of the opening align with tensile hoop stress of 120 MPa. At the point facing along the remote pulling direction the hoop stress is compressive at −40 MPa. The nominal far-field stress refers to the gross, undisturbed section. A factor based on a finite specimen’s reduced net section would use a different reference.\n",
    "\n",
    "Along the transverse radius, moving from $r=a$ to $r=2a$ reduces the ratio to $1+u/2+3u^2/2=1.21875$. A gauge whose active length samples a substantial fraction of the hole radius therefore averages a gradient. Failure to read a threefold concentration at a distant or finite-area gauge does not by itself invalidate the elastic solution."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cac42e12a6e0",
   "metadata": {
    "fundamentals": {
     "section": "choose-inputs",
     "notebook_only": true
    }
   },
   "source": [
    "## Set the experimental inputs\n",
    "\n",
    "Edit these values, then run the calculation and both figures again."
   ]
  },
  {
   "cell_type": "code",
   "id": "2e2ccc1127a4",
   "metadata": {},
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "teal, orange, blue = \"#19596a\", \"#aa462a\", \"#3868a0\"\n",
    "def axes(xlabel, ylabel):\n",
    "    fig, ax = plt.subplots(figsize=(7, 4), constrained_layout=True)\n",
    "    ax.set(xlabel=xlabel, ylabel=ylabel)\n",
    "    ax.grid(alpha=0.2)\n",
    "    return fig, ax"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "2c98fe42839c",
   "metadata": {},
   "source": [
    "radius_mm = 8.0\n",
    "remote_mpa = 40.0"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "1424e5e7a3fd",
   "metadata": {},
   "source": [
    "assert radius_mm>0 and remote_mpa>0\n",
    "def stresses(r_over_a,theta):\n",
    "    u = np.asarray(r_over_a,dtype=float)**-2\n",
    "    c,s = np.cos(2*theta),np.sin(2*theta)\n",
    "    rr = .5*remote_mpa*(1-u+(1-4*u+3*u*u)*c)\n",
    "    tt = .5*remote_mpa*(1+u-(1+3*u*u)*c)\n",
    "    rt = -.5*remote_mpa*(1+2*u-3*u*u)*s\n",
    "    return rr,tt,rt\n",
    "ang=np.linspace(0,2*np.pi,181)\n",
    "rr,tt,rt=stresses(1.,ang)\n",
    "assert np.allclose(rr,0) and np.allclose(rt,0)\n",
    "print(f\"Peak hoop stress {tt.max():.2f} MPa; transverse reading at two radii {stresses(2.,np.pi/2)[1]:.2f} MPa\")"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "f42bb9f21bf8",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "engineering-mechanics-engineering-mechanics-methods-1.png",
      "alt": "The hoop-stress field has two tensile lobes above and below an unloaded circular opening.",
      "caption": "The white interior represents removed material. The colour field is one stress component expressed relative to the local circumferential direction."
     }
    }
   },
   "source": [
    "coord=np.linspace(-3,3,301)\n",
    "X,Y=np.meshgrid(coord,coord); rad=np.hypot(X,Y)\n",
    "hoop=np.ma.masked_where(rad<1,stresses(np.maximum(rad,1),np.arctan2(Y,X))[1])\n",
    "fig,ax=axes(\"x (mm)\",\"y (mm)\")\n",
    "im=ax.contourf(radius_mm*X,radius_mm*Y,hoop,levels=24,cmap=\"coolwarm\")\n",
    "fig.colorbar(im,ax=ax,label=\"Hoop stress (MPa)\")\n",
    "ax.set_aspect(\"equal\")\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "b3cdbfa25d50",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "The white interior represents removed material. The colour field is one stress component expressed relative to the local circumferential direction."
   ]
  },
  {
   "cell_type": "code",
   "id": "29af9ae65be4",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "engineering-mechanics-engineering-mechanics-methods-2.png",
      "alt": "Two radial traces give the tensile concentration across the loading direction and the compressive edge value along the loading direction.",
      "caption": "The horizontal coordinate measures actual distance outward from the wall of the hole. Moving the gauge outward changes the inferred peak."
     }
    }
   },
   "source": [
    "fig,ax=axes(\"Distance from hole edge (mm)\",\"Circumferential stress (MPa)\")\n",
    "r=np.linspace(1,5,301)\n",
    "for th,label,col in [(0,\"Along the loading direction\",orange),(np.pi/2,\"Across the loading direction\",teal)]:\n",
    "    ax.plot(radius_mm*(r-1),stresses(r,th)[1],label=label,color=col)\n",
    "ax.axhline(0,color=\"0.5\",lw=.8);ax.legend()\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "62fe6ce92c4c",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "The horizontal coordinate measures actual distance outward from the wall of the hole. Moving the gauge outward changes the inferred peak."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "79774d720590",
   "metadata": {
    "fundamentals": {
     "section": "problem-1"
    }
   },
   "source": [
    "## Exercise · rotate the sensor\n",
    "\n",
    "At what angle between zero and 90 degrees does the edge hoop stress change sign?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adcf2713222d",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "Set $1-2\\cos(2\\theta)=0$. Thus $2\\theta=60^\\circ$ and $\\theta=30^\\circ$. This is a zero of the tangential normal stress on a boundary already free of radial and shear traction."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8cb8840eb585",
   "metadata": {
    "fundamentals": {
     "section": "problem-2"
    }
   },
   "source": [
    "## Exercise · change the radius\n",
    "\n",
    "Double the hole radius at the same remote stress in an effectively infinite sheet. What changes in the peak and the stress gradient in MPa per millimetre?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aba86a33433e",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "The peak remains $3S$ because the stress field depends only on $r/a$ and angle. The physical length scale doubles, hence an otherwise corresponding spatial gradient halves. Finite edge distances, plastic yielding and rounded specimen boundaries can introduce new scales and change these conclusions."
   ]
  }
 ]
}
