{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "43d67ad2", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# from __future__ import print_function\n", "from ipywidgets import AppLayout, interact, interactive, fixed, interact_manual\n", "import ipywidgets as widgets\n", "import math" ] }, { "cell_type": "code", "execution_count": 2, "id": "b1c5ff77", "metadata": {}, "outputs": [], "source": [ "def graph (v = widgets.FloatSlider(\n", " value=30,\n", " min=1,\n", " max=1000,\n", " step=0.5,\n", " description='v_0',\n", " orientation='horizontal'\n", "\n", "), alphadeg = widgets.FloatSlider(\n", " value=45,\n", " min=10,\n", " max=80,\n", " step=1,\n", " description='Angle',\n", " orientation='horizontal'\n", "),\n", " rho = widgets.FloatSlider(\n", " value=1.3,\n", " min=0,\n", " max=10.3,\n", " step=1,\n", " description='rho',\n", " orientation='horizontal'\n", "), m = widgets.FloatSlider(\n", " value=1,\n", " min=0.1,\n", " max=10,\n", " step=0.1,\n", " description='m',\n", " orientation='horizontal'\n", ")) :\n", " g = -9.81\n", " R = 0.1\n", " S = math.pi * R**2\n", " alpha = alphadeg * math.pi/360\n", "\n", " v0_x = v * math.cos(alpha)\n", " v0_y = v * math.sin(alpha)\n", " v1_x = v0_x\n", " v1_y = v0_y\n", " v2_x = 0\n", " v2_y = 0\n", "\n", " a_fr = 0\n", "\n", " x0 = 0\n", " y0 = 0\n", " x1 = 0\n", " y1 = 0\n", " x2 = 0\n", " y2 = 0\n", "\n", " x = [x0]\n", " y = [y0]\n", "\n", " t = 0.001\n", " while y2 >= 0:\n", " x1 = x[-1]\n", " y1 = y[-1]\n", " \n", " vcarre = (v1_x**2 + v1_y**2)\n", " a_fr= (- 0.5 * 0.47 * rho * S * vcarre)/m\n", " a_x = a_fr * (v1_x/math.sqrt(vcarre))\n", " a_y = g + a_fr * (v1_y/math.sqrt(vcarre))\n", " \n", " v2_x = a_x * t+ v1_x\n", " v2_y = a_y * t + v1_y\n", " \n", " v1_x = v2_x\n", " v1_y = v2_y\n", " \n", " x2 = v2_x * t + x1\n", " y2 = v2_y * t + y1\n", " x.append(x2)\n", " y.append(y2)\n", " a = plt.plot(x,y)\n", " plt.gca().set_xlim(left=0)\n", " plt.gca().set_ylim(bottom=0)\n", " plt.rcParams['figure.figsize'] = [3, 3]\n", " plt.show()" ] }, { "cell_type": "code", "execution_count": 3, "id": "6b23a5e2", "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "829cf50ab73c48b0bdbeb0e445891a04", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(FloatSlider(value=30.0, description='v_0', max=1000.0, min=1.0, step=0.5), FloatSlider(v…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "interact(graph)" ] }, { "cell_type": "code", "execution_count": null, "id": "533b2541", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "ef99a1ac", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "fa3a35cd", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "4c9580c8", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.2" } }, "nbformat": 4, "nbformat_minor": 5 }