{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "language_info": {
   "name": "python"
  },
  "fundamentals": {
   "title": "When does a smooth circular guide lose contact?",
   "lead": "A bead moves inside a vertical circular guide after receiving a known speed at the bottom. Predict whether it turns around, separates from the guide or completes the circle. A normal-force measurement can distinguish these outcomes before a simple top-height energy test can.",
   "unit_slug": "normal-force-in-a-circular-guide"
  }
 },
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7f6577adbaf6",
   "metadata": {},
   "source": [
    "# When does a smooth circular guide lose contact?\n",
    "\n",
    "A bead moves inside a vertical circular guide after receiving a known speed at the bottom. Predict whether it turns around, separates from the guide or completes the circle. A normal-force measurement can distinguish these outcomes before a simple top-height energy test can."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8268dc0ca4b8",
   "metadata": {
    "fundamentals": {
     "section": "derive-the-model"
    }
   },
   "source": [
    "## Check the constraint force after solving for speed\n",
    "\n",
    "Use $\\theta=0$ at the bottom, increasing along the rising side. Let $R$ be the radius of the bead centre's path, $v_0$ its bottom speed and $u=v_0^2/(gR)$. The smooth guide does no work. The rise in gravitational energy $mgR(1-\\cos\\theta)$ therefore gives\n",
    "\n",
    "$$\n",
    "v^2/(gR)=u-2+2\\cos\\theta.\n",
    "$$\n",
    "\n",
    "This relation applies only while the bead follows the circle and the computed speed is real.\n",
    "\n",
    "With inward radial direction positive, force balance is\n",
    "\n",
    "$$\n",
    "N-mg\\cos\\theta=mv^2/R.\n",
    "$$\n",
    "\n",
    "Substitution gives\n",
    "\n",
    "$$\\frac{N}{mg}=u-2+3\\cos\\theta.$$\n",
    "\n",
    "A guide underneath the bead can push but cannot pull. For $u<2$ the speed first reaches zero while the contact force is still positive. For $2<u<5$ the force reaches zero with positive speed at $\\cos\\theta=(2-u)/3$. Above that point circular motion would require a negative normal force. For $u>5$ the bead can remain in contact throughout the circle. At the boundaries $u=2$ gives a zero-speed, zero-normal grazing turn at the side and $u=5$ gives marginal contact at the top. A captive slotted carriage or a bead threaded onto a wire has a different constraint and can transmit force of either sign."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "147122c4378d",
   "metadata": {
    "fundamentals": {
     "section": "worked-prediction"
    }
   },
   "source": [
    "## Distinguish an energetically accessible top from a feasible trajectory\n",
    "\n",
    "Let $R=0.25$ m and choose $v_0=\\sqrt{3gR}=2.71$ m/s. The guide loses contact when $\\cos\\theta=-1/3$, or at 109.5 degrees from the bottom. The remaining speed there is $\\sqrt{gR/3}=0.904$ m/s. Raising the initial energy so that $u=4$ pays the gravitational energy cost to reach the top, but a continuously guided motion still fails the nonnegative force condition earlier. The mechanical-energy and force-balance tests answer different questions."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "920f66ccd2df",
   "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": "d1a0bbe7b3e4",
   "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": "aeeb254aaca3",
   "metadata": {},
   "source": [
    "radius_m=.25\n",
    "speed_parameter=3.0    # v0² / gR\n",
    "gravity=9.81"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "97b605ac6bfa",
   "metadata": {},
   "source": [
    "assert radius_m>0 and gravity>0 and 0<speed_parameter<=8\n",
    "def endpoint(u):\n",
    "    if u<=2: return np.arccos(1-u/2),\"turn\"\n",
    "    if u<5: return np.arccos((2-u)/3),\"detachment\"\n",
    "    return np.pi,\"top reached\"\n",
    "end,outcome=endpoint(speed_parameter)\n",
    "bottom=np.sqrt(speed_parameter*gravity*radius_m)\n",
    "v_end=np.sqrt(gravity*radius_m*max(0,speed_parameter-2+2*np.cos(end)))\n",
    "print(f\"Bottom speed {bottom:.3f} m/s; {outcome} at {np.rad2deg(end):.3f}°, speed {v_end:.3f} m/s\")"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "code",
   "id": "901935acddd6",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "classical-mechanics-mechanics-laboratory-1.png",
      "alt": "Normal force and squared speed are plotted only for the part of the ascent physically reached on the guide.",
      "caption": "The first quantity to reach zero determines which constraint fails. The part after contact loss requires a different trajectory."
     }
    }
   },
   "source": [
    "angle=np.linspace(0,end,170); cs=np.cos(angle)\n",
    "fig,ax=axes(\"Angle from the bottom (degrees)\",\"Dimensionless quantity\")\n",
    "ax.plot(np.rad2deg(angle),speed_parameter-2+3*cs,color=teal,label=\"Normal force / mg\")\n",
    "ax.plot(np.rad2deg(angle),speed_parameter-2+2*cs,color=orange,label=\"Squared speed / gR\")\n",
    "ax.axhline(0,lw=.7,color=\"grey\");ax.set_xlim(0,180);ax.legend()\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "e4c0cce04ccf",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "The first quantity to reach zero determines which constraint fails. The part after contact loss requires a different trajectory."
   ]
  },
  {
   "cell_type": "code",
   "id": "19ae6da67174",
   "metadata": {
    "fundamentals": {
     "figure": {
      "file": "classical-mechanics-mechanics-laboratory-2.png",
      "alt": "The final angle reached on the rising guide changes through three distinct ranges of starting speed.",
      "caption": "The horizontal branch records completion of the ascent, including marginal contact at its threshold. It does not mean that the bead stops at the top."
     }
    }
   },
   "source": [
    "us=np.linspace(.01,7,240); ends=[np.rad2deg(endpoint(val)[0]) for val in us]\n",
    "fig,ax=axes(\"Bottom speed parameter v₀² / gR\",\"Last guided angle on ascent (degrees)\")\n",
    "ax.plot(us,ends,color=teal);ax.axvline(2,color=blue,ls=\"--\",label=\"Grazing turn\")\n",
    "ax.axvline(5,color=orange,ls=\":\",label=\"Marginal top contact\");ax.plot(speed_parameter,np.rad2deg(end),\"o\",color=orange);ax.legend()\n",
    "plt.show()"
   ],
   "execution_count": null,
   "outputs": []
  },
  {
   "cell_type": "markdown",
   "id": "4f025840b0e1",
   "metadata": {
    "fundamentals": {
     "notebook_only": true
    }
   },
   "source": [
    "The horizontal branch records completion of the ascent, including marginal contact at its threshold. It does not mean that the bead stops at the top."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a0bdf3f24a4",
   "metadata": {
    "fundamentals": {
     "section": "problem-1"
    }
   },
   "source": [
    "## Exercise · find the lower turning point\n",
    "\n",
    "For $u=1$, determine the turning angle and force there."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8245428f390",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "Zero speed requires $\\cos\\theta=1-u/2=1/2$, hence $\\theta=60^\\circ$. The contact force then balances the outward radial component of gravity, $N=mg\\cos\\theta=mg/2$. It remains compressive through the turn."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "17e663dd3efd",
   "metadata": {
    "fundamentals": {
     "section": "problem-2"
    }
   },
   "source": [
    "## Exercise · size a classroom loop\n",
    "\n",
    "A bottom speed of 2.0 m/s is available. What is the largest ideal path radius for continuous contact through the top?"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "384a085ba9ac",
   "metadata": {
    "fundamentals": {
     "solution": true
    }
   },
   "source": [
    "The limiting condition is $v_0^2=5gR$, so $R=4/(5\\cdot9.81)=0.0815$ m. This is the radius of the bead centre. Rolling friction, rotational kinetic energy or a different channel radius would alter this calculation."
   ]
  }
 ]
}
