{ "cells": [ { "cell_type": "markdown", "metadata": { "lang": "en" }, "source": [ "# Point particle on the cone\n", "\n", "Consider the movement of the material point on the surface of the cone.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "var('t')\n", "var('a g')\n", "xy_wsp = [('x','x'),('y','y'),('z','z')]\n", "uv_wsp = [('r','r'),('phi','\\phi'),('z','z')]\n", "\n", "for v,lv in uv_wsp+xy_wsp:\n", " var(\"%s\"%v,latex_name=r'%s'%lv)\n", " vars()[v.capitalize()] = function(v.capitalize())(t)\n", " var(\"%sdd\"%v,latex_name=r'\\ddot %s'%lv)\n", " var(\"%sd\"%v,latex_name=r'\\dot %s'%lv)\n", " var(\"d%s\"%v,latex_name=r'\\delta %s'%lv)\n", "\n", "\n", "xy = [vars()[v] for v,lv in xy_wsp]\n", "uv = [vars()[v] for v,lv in uv_wsp]\n", "\n", "to_fun=dict()\n", "for v,lv in xy_wsp+uv_wsp:\n", " to_fun[vars()[v]]=vars()[v.capitalize()]\n", " to_fun[vars()[v+\"d\"]]=vars()[v.capitalize()].diff()\n", " to_fun[vars()[v+\"dd\"]]=vars()[v.capitalize()].diff(2)\n", "\n", "to_var = dict((v,k) for k,v in to_fun.items())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dAlemb = (X.diff(t,2))*dx +(Y.diff(t,2))*dy+ (Z.diff(t,2)+g)*dz\n", "f = x^2 + y^2 - tan(a)^2*z^2 \n", "\n", "dxy = [vars()['d'+repr(zm)] for zm in xy]\n", "constr =sum([dzm*f.diff(zm) for zm,dzm in zip(xy,dxy)])\n", "show(f)\n", "show(constr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f.solve(z)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dAlemb_xy = dAlemb.subs(constr.solve(dz)[0]).subs(f.solve(z)[1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "show(dAlemb_xy.subs(to_var).coeff(dx))\n", "show(dAlemb_xy.subs(to_var).coeff(dy))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "lang": "en" }, "source": [ "Let's solve the problem in cylindrical coordinates. Because these coordinates are not consistent with constraints, but the cone has a particularly simple form in them. Therefore, we will have to perform the step of removing the dependent virtual offsets after moving to the cylindrical coordinate system." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x2u = {x:r*cos(phi),y:r*sin(phi),z:z}\n", "for w in xy:\n", " vars()['d'+repr(w)+'_polar']=sum([w.subs(x2u).diff(w2)*vars()['d'+repr(w2)] for w2 in uv])\n", "show(dx_polar)\n", "show(dy_polar)\n", "show(dz_polar)" ] }, { "cell_type": "markdown", "metadata": { "lang": "en" }, "source": [ "First, we write the d'Alembert's rule in cylindrical coordinates:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dAlemb = (x.subs(x2u).subs(to_fun).diff(t,2))*dx_polar + \\\n", " (y.subs(x2u).subs(to_fun).diff(t,2))*dy_polar+\\\n", " (z.subs(x2u).subs(to_fun).diff(t,2)+g)*dz_polar \n", "dAlemb = dAlemb.subs(to_var)\n", "show(dAlemb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "f_uv = f.subs(x2u).trig_simplify()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "duv = [vars()['d'+repr(zm)] for zm in uv]\n", "constr =sum([dzm*f_uv.diff(zm) for zm,dzm in zip(uv,duv)])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "show(constr.solve(dz)[0])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dAlemb.subs( constr.solve(dz)[0] )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "zdd_rdd = (f_uv.solve(z)[1]).subs(to_fun).diff(t,2).subs(to_var)\n", "zdd_rdd" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dAlemb_uv = dAlemb.subs( constr.solve(dz)[0] ).subs(f_uv.solve(z)[1]).subs(zdd_rdd)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "r1 = dAlemb_uv.coeff(dr)\n", "r2 = dAlemb_uv.coeff(dphi)\n", "\n", "show(r1)\n", "show( r2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "table([rown.trig_simplify() for rown in solve([r1,r2],[rdd,phidd])[0]])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\\newpage" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "SageMath 8.7", "language": "", "name": "sagemath" }, "language": "python", "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.15" }, "nbTranslate": { "displayLangs": [ "en", "pl" ], "hotkey": "alt-t", "langInMainMenu": true, "sourceLang": "pl", "targetLang": "en", "useGoogleTranslate": true }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }