See More

{ "cells": [ { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from modsim import *" ] }, { "cell_type": "code", "execution_count": 194, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 194, "metadata": {}, "output_type": "execute_result" } ], "source": [ "UNITS.Quantity.__init__" ] }, { "cell_type": "code", "execution_count": 362, "metadata": {}, "outputs": [], "source": [ "class _Vector(UNITS.Quantity):\n", " \"\"\"Represented as a Pint Quantity with a NumPy array\n", " \n", " x, y, z, mag, mag2, and angle are accessible as attributes.\n", " \n", " Supports vector operations hat, dot, cross, proj, and comp.\n", " \"\"\"\n", " \n", " @property\n", " def x(self):\n", " \"\"\"Returns the x component with units.\"\"\"\n", " return self[0]\n", "\n", " @property\n", " def y(self):\n", " \"\"\"Returns the y component with units.\"\"\"\n", " return self[1]\n", "\n", " @property\n", " def z(self):\n", " \"\"\"Returns the z component with units.\"\"\"\n", " return self[2]\n", "\n", " @property\n", " def mag(self):\n", " \"\"\"Returns the magnitude with units.\"\"\"\n", " return np.sqrt(np.dot(self, self)) * self.units\n", "\n", " @property\n", " def mag2(self):\n", " \"\"\"Returns the magnitude squared with units.\"\"\"\n", " return np.dot(self, self) * self.units\n", "\n", " @property\n", " def angle(self):\n", " \"\"\"Returns the angle between self and the positive x axis.\"\"\"\n", " return np.arctan2(self.y, self.x)\n", "\n", " def polar(self):\n", " \"\"\"Returns magnitude and angle.\"\"\"\n", " return self.mag, self.angle\n", "\n", " def hat(self):\n", " \"\"\"Returns the unit vector in the direction of self.\"\"\"\n", " \"\"\"\n", " \"\"\"\n", " return self / self.mag * self.units\n", "\n", " def dot(self, other):\n", " \"\"\"Returns the dot product of self and other.\"\"\"\n", " \"\"\"\n", " \"\"\"\n", " return np.dot(self, other) * self.units * other.units\n", "\n", " def cross(self, other):\n", " \"\"\"Returns the cross product of self and other.\"\"\"\n", " \"\"\"\n", " \"\"\"\n", " return np.cross(self, other) * self.units * other.units\n", "\n", " def proj(self, other):\n", " \"\"\"Returns the projection of self onto other.\"\"\"\n", " \"\"\"\n", " \"\"\"\n", " return np.dot(self, other) * other.hat()\n", "\n", " def comp(self, other):\n", " \"\"\"Returns the magnitude of the projection of self onto other.\"\"\"\n", " \"\"\"\n", " \"\"\"\n", " return np.dot(self, other.hat()) * other.units\n", "\n", " def dist(self, other):\n", " \"\"\"Euclidean distance from self to other, with units.\"\"\"\n", " diff = self - other\n", " return diff.mag\n", "\n", " def diff_angle(self, other):\n", " \"\"\"\n", " \"\"\"\n", " #TODO: see http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/\n", " raise NotImplementedError()\n", " \n", " \n", "def Vector(*args, units=None):\n", " # if there's only one argument, it should be iterable\n", " if len(args) == 1:\n", " args = args[0]\n", " \n", " # if it's a series, pull out the values\n", " if isinstance(args, Series):\n", " args = args.values\n", " \n", " # see if any of the arguments have unit; if so, save the first one\n", " for elt in args:\n", " found_units = getattr(elt, 'units', None)\n", " if found_units:\n", " break\n", " \n", " if found_units:\n", " # if there are units, remove them\n", " args = [getattr(elt, 'magnitude', elt) for elt in args]\n", " \n", " # if the units keyword is provided, it overrides the units in args\n", " if units is not None:\n", " found_units = units\n", " \n", " return _Vector(args, found_units)" ] }, { "cell_type": "code", "execution_count": 346, "metadata": {}, "outputs": [], "source": [ "m = UNITS.m\n", "N = UNITS.newton" ] }, { "cell_type": "code", "execution_count": 347, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] dimensionless" ], "text/latex": [ "$[3 4] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 347, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(3, 4)\n", "a" ] }, { "cell_type": "code", "execution_count": 348, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] meter" ], "text/latex": [ "$[3 4] meter$" ], "text/plain": [ "" ] }, "execution_count": 348, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(3, 4, units=m)\n", "a" ] }, { "cell_type": "code", "execution_count": 349, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] dimensionless" ], "text/latex": [ "$[3 4] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 349, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector([3, 4])\n", "a" ] }, { "cell_type": "code", "execution_count": 350, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] meter" ], "text/latex": [ "$[3 4] meter$" ], "text/plain": [ "" ] }, "execution_count": 350, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(3, 4*m)\n", "a" ] }, { "cell_type": "code", "execution_count": 351, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] meter" ], "text/latex": [ "$[3 4] meter$" ], "text/plain": [ "" ] }, "execution_count": 351, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector([3, 4*m])\n", "a" ] }, { "cell_type": "code", "execution_count": 352, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 3. 4.] meter second" ], "text/latex": [ "$[ 3. 4.] meter \\cdot second$" ], "text/plain": [ "" ] }, "execution_count": 352, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(3, 4*m, units=s) * m\n", "a" ] }, { "cell_type": "code", "execution_count": 353, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[3 4]\n" ] }, { "data": { "text/html": [ "[3 4] dimensionless" ], "text/latex": [ "$[3 4] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 353, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(Series([3, 4]))\n", "a" ] }, { "cell_type": "code", "execution_count": 354, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[3 4] dimensionless" ], "text/latex": [ "$[3 4] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 354, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector(3, 4)\n", "a" ] }, { "cell_type": "code", "execution_count": 355, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__._Vector" ] }, "execution_count": 355, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = Vector([3, 4]) * m\n", "type(a)" ] }, { "cell_type": "code", "execution_count": 356, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 3. 4.] meter" ], "text/latex": [ "$[ 3. 4.] meter$" ], "text/plain": [ "" ] }, "execution_count": 356, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a" ] }, { "cell_type": "code", "execution_count": 357, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 3. 4.] meter2" ], "text/latex": [ "$[ 3. 4.] meter^{2}$" ], "text/plain": [ "" ] }, "execution_count": 357, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a * m" ] }, { "cell_type": "code", "execution_count": 358, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 3. 4.] dimensionless" ], "text/latex": [ "$[ 3. 4.] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 358, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a / m" ] }, { "cell_type": "code", "execution_count": 359, "metadata": {}, "outputs": [ { "data": { "text/html": [ "3.0 meter" ], "text/latex": [ "$3.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 359, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a[0]" ] }, { "cell_type": "code", "execution_count": 360, "metadata": {}, "outputs": [ { "data": { "text/html": [ "3.0 meter" ], "text/latex": [ "$3.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 360, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.x" ] }, { "cell_type": "code", "execution_count": 361, "metadata": {}, "outputs": [ { "data": { "text/html": [ "4.0 meter" ], "text/latex": [ "$4.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 361, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.y" ] }, { "cell_type": "code", "execution_count": 216, "metadata": {}, "outputs": [ { "data": { "text/html": [ "5.0 meter" ], "text/latex": [ "$5.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 216, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.mag" ] }, { "cell_type": "code", "execution_count": 217, "metadata": {}, "outputs": [ { "data": { "text/html": [ "25.0 meter" ], "text/latex": [ "$25.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 217, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.mag2" ] }, { "cell_type": "code", "execution_count": 218, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "__main__._Vector" ] }, "execution_count": 218, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(a)" ] }, { "cell_type": "code", "execution_count": 219, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "pint.unit.build_quantity_class..Quantity" ] }, "execution_count": 219, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(a.mag)" ] }, { "cell_type": "code", "execution_count": 220, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 15. 20.] meter2" ], "text/latex": [ "$[ 15. 20.] meter^{2}$" ], "text/plain": [ "" ] }, "execution_count": 220, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c = a * a.mag\n", "c" ] }, { "cell_type": "code", "execution_count": 221, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 0.6 0.8] dimensionless" ], "text/latex": [ "$[ 0.6 0.8] dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 221, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c = a / a.mag\n", "c" ] }, { "cell_type": "code", "execution_count": 222, "metadata": {}, "outputs": [ { "data": { "text/html": [ "0.6 dimensionless" ], "text/latex": [ "$0.6 dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 222, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c.x" ] }, { "cell_type": "code", "execution_count": 223, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 0.6 0.8] meter" ], "text/latex": [ "$[ 0.6 0.8] meter$" ], "text/plain": [ "" ] }, "execution_count": 223, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ah = a.hat()\n", "ah" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 224, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 0.6 0.8] meter\n" ] } ], "source": [ "print(ah)" ] }, { "cell_type": "code", "execution_count": 225, "metadata": {}, "outputs": [ { "data": { "text/html": [ "meter" ], "text/latex": [ "$meter$" ], "text/plain": [ "" ] }, "execution_count": 225, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ah.units" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 226, "metadata": {}, "outputs": [], "source": [ "b = Vector([1, 2])" ] }, { "cell_type": "code", "execution_count": 227, "metadata": {}, "outputs": [ { "data": { "text/html": [ "11.0 meter" ], "text/latex": [ "$11.0 meter$" ], "text/plain": [ "" ] }, "execution_count": 227, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.dot(b)" ] }, { "cell_type": "code", "execution_count": 228, "metadata": {}, "outputs": [], "source": [ "N = UNITS.newton\n", "\n", "b = Vector([1, 2]) * N" ] }, { "cell_type": "code", "execution_count": 229, "metadata": {}, "outputs": [ { "data": { "text/html": [ "11.0 meter newton" ], "text/latex": [ "$11.0 meter \\cdot newton$" ], "text/plain": [ "" ] }, "execution_count": 229, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.dot(b)" ] }, { "cell_type": "code", "execution_count": 230, "metadata": {}, "outputs": [ { "data": { "text/html": [ "2.0 meter newton" ], "text/latex": [ "$2.0 meter \\cdot newton$" ], "text/plain": [ "" ] }, "execution_count": 230, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c = a.cross(b)\n", "c" ] }, { "cell_type": "code", "execution_count": 231, "metadata": {}, "outputs": [], "source": [ "c = a.proj(b)" ] }, { "cell_type": "code", "execution_count": 232, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 4.91934955 9.8386991 ] newton" ], "text/latex": [ "$[ 4.91934955 9.8386991 ] newton$" ], "text/plain": [ "" ] }, "execution_count": 232, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c" ] }, { "cell_type": "code", "execution_count": 233, "metadata": {}, "outputs": [ { "data": { "text/html": [ "4.919349550499537 newton" ], "text/latex": [ "$4.919349550499537 newton$" ], "text/plain": [ "" ] }, "execution_count": 233, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.comp(b)" ] }, { "cell_type": "code", "execution_count": 234, "metadata": {}, "outputs": [], "source": [ "x_hat = Vector([1, 0])\n", "y_hat = Vector([0, 1])" ] }, { "cell_type": "code", "execution_count": 235, "metadata": {}, "outputs": [ { "data": { "text/html": [ "3.0 dimensionless" ], "text/latex": [ "$3.0 dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 235, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.comp(x_hat)" ] }, { "cell_type": "code", "execution_count": 236, "metadata": {}, "outputs": [ { "data": { "text/html": [ "4.0 dimensionless" ], "text/latex": [ "$4.0 dimensionless$" ], "text/plain": [ "" ] }, "execution_count": 236, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.comp(y_hat)" ] }, { "cell_type": "code", "execution_count": 237, "metadata": {}, "outputs": [ { "data": { "text/html": [ "0.9272952180016122 radian" ], "text/latex": [ "$0.9272952180016122 radian$" ], "text/plain": [ "" ] }, "execution_count": 237, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a.angle" ] }, { "cell_type": "code", "execution_count": 238, "metadata": {}, "outputs": [ { "data": { "text/html": [ "1.1071487177940904 radian" ], "text/latex": [ "$1.1071487177940904 radian$" ], "text/plain": [ "" ] }, "execution_count": 238, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b.angle" ] }, { "cell_type": "code", "execution_count": 239, "metadata": {}, "outputs": [ { "data": { "text/html": [ "0.25 radian" ], "text/latex": [ "$0.25 radian$" ], "text/plain": [ "" ] }, "execution_count": 239, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Vector([1, 1]).angle / pi" ] }, { "cell_type": "code", "execution_count": 240, "metadata": {}, "outputs": [ { "data": { "text/html": [ "0.75 radian" ], "text/latex": [ "$0.75 radian$" ], "text/plain": [ "" ] }, "execution_count": 240, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Vector([-1, 1]).angle / pi" ] }, { "cell_type": "code", "execution_count": 241, "metadata": {}, "outputs": [ { "data": { "text/html": [ "-0.75 radian" ], "text/latex": [ "$-0.75 radian$" ], "text/plain": [ "" ] }, "execution_count": 241, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Vector([-1, -1]).angle / pi" ] }, { "cell_type": "code", "execution_count": 242, "metadata": {}, "outputs": [ { "data": { "text/html": [ "-0.25 radian" ], "text/latex": [ "$-0.25 radian$" ], "text/plain": [ "" ] }, "execution_count": 242, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Vector([1, -1]).angle / pi" ] }, { "cell_type": "code", "execution_count": 243, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(,\n", " )" ] }, "execution_count": 243, "metadata": {}, "output_type": "execute_result" } ], "source": [ "Vector([1, -1]).polar()" ] }, { "cell_type": "code", "execution_count": 244, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[5, 3.5355, 0, -10]" ] }, "execution_count": 244, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = [5, 3.5355, 0, -10]\n", "x" ] }, { "cell_type": "code", "execution_count": 245, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[0, 3.5355, 10, 0]" ] }, "execution_count": 245, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y = [0, 3.5355, 10, 0]\n", "y" ] }, { "cell_type": "code", "execution_count": 246, "metadata": { "collapsed": true }, "outputs": [], "source": [ "theta, rho = cart2pol(x,y)" ] }, { "cell_type": "code", "execution_count": 247, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 0. , 0.78539816, 1.57079633, 3.14159265])" ] }, "execution_count": 247, "metadata": {}, "output_type": "execute_result" } ], "source": [ "theta" ] }, { "cell_type": "code", "execution_count": 248, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ 5. , 4.99995205, 10. , 10. ])" ] }, "execution_count": 248, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho" ] }, { "cell_type": "code", "execution_count": 249, "metadata": { "collapsed": true }, "outputs": [], "source": [ "theta = [0, pi/4, pi/2, pi]" ] }, { "cell_type": "code", "execution_count": 250, "metadata": { "collapsed": true }, "outputs": [], "source": [ "rho = [5, 5, 10, 10]" ] }, { "cell_type": "code", "execution_count": 251, "metadata": { "collapsed": true }, "outputs": [], "source": [ "x2, y2 = pol2cart(theta,rho)" ] }, { "cell_type": "code", "execution_count": 252, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 5.00000000e+00 3.53553391e+00 6.12323400e-16 -1.00000000e+01]\n" ] } ], "source": [ "print(x2)" ] }, { "cell_type": "code", "execution_count": 253, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 0.00000000e+00 3.53553391e+00 1.00000000e+01 1.22464680e-15]\n" ] } ], "source": [ "print(y2)" ] }, { "cell_type": "code", "execution_count": 254, "metadata": { "collapsed": true }, "outputs": [], "source": [ "degree = UNITS.degree\n", "kg = UNITS.kg\n", "m = UNITS.m\n", "s = UNITS.s" ] }, { "cell_type": "code", "execution_count": 255, "metadata": { "collapsed": true }, "outputs": [], "source": [ "condition = Condition(x = 0 * m, \n", " y = 0 * m,\n", " g = 9.8 * m/s**2,\n", " mass = 145e-3 * kg,\n", " diameter = 73e-3 * m,\n", " rho = 1.2 * kg/m**3,\n", " C_d = 0.3,\n", " angle = 45 * degree,\n", " velocity = 40 * m / s,\n", " duration = 5 * s)" ] }, { "cell_type": "code", "execution_count": 256, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def make_system(condition):\n", " unpack(condition)\n", " \n", " theta = np.deg2rad(angle)\n", " vx, vy = pol2cart(theta, velocity)\n", " init = State(x=x, y=y, vx=vx, vy=vy)\n", " v = State(vx=vx, vy=vy)\n", " \n", " area = np.pi * (diameter/2)**2\n", " ts = linspace(0, duration, 101)\n", " \n", " return System(init=init, g=g, mass=mass, v=v,\n", " area=area, rho=rho, C_d=C_d, ts=ts)" ] }, { "cell_type": "code", "execution_count": 257, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
value
x0 meter
y0 meter
vx28.284271247461902 meter / second
vy28.2842712474619 meter / second
\n", "
" ], "text/plain": [ "x 0 meter\n", "y 0 meter\n", "vx 28.284271247461902 meter / second\n", "vy 28.2842712474619 meter / second\n", "dtype: object" ] }, "execution_count": 257, "metadata": {}, "output_type": "execute_result" } ], "source": [ "system = make_system(condition)\n", "system.init" ] }, { "cell_type": "code", "execution_count": 258, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([,\n", " ], dtype=object)" ] }, "execution_count": 258, "metadata": {}, "output_type": "execute_result" } ], "source": [ "v = system.v.values\n", "v" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 363, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def slope_func(state, t, system):\n", " x, y, vx, vy = state\n", " unpack(system)\n", " \n", " a_grav = Vector(0, -g)\n", "\n", " v = Vector(vx, vy)\n", " \n", " f_drag = -rho * v.mag * v * C_d * area / 2\n", " a_drag = f_drag / mass\n", "\n", " a = a_grav + a_drag\n", " \n", " return v, a" ] }, { "cell_type": "code", "execution_count": 364, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(,\n", " )" ] }, "execution_count": 364, "metadata": {}, "output_type": "execute_result" } ], "source": [ "slope_func(system.init, 0, system)" ] }, { "cell_type": "code", "execution_count": 261, "metadata": { "collapsed": true }, "outputs": [], "source": [ "a = 5 * m" ] }, { "cell_type": "code", "execution_count": 262, "metadata": { "collapsed": true }, "outputs": [], "source": [ "b = Vector([1, 2]) * s" ] }, { "cell_type": "code", "execution_count": 263, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 5. 10.] meter second" ], "text/latex": [ "$[ 5. 10.] meter \\cdot second$" ], "text/plain": [ "" ] }, "execution_count": 263, "metadata": {}, "output_type": "execute_result" } ], "source": [ "b * a" ] }, { "cell_type": "code", "execution_count": 264, "metadata": {}, "outputs": [ { "data": { "text/html": [ "[ 5. 10.] meter second" ], "text/latex": [ "$[ 5. 10.] meter \\cdot second$" ], "text/plain": [ "" ] }, "execution_count": 264, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a * b" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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.1" } }, "nbformat": 4, "nbformat_minor": 2 }