{
 "metadata": {
  "name": "",
  "signature": "sha256:3976133032282813954f4ef27a856985c5b926684fb73e20db088ec999943de6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# Test case: pivot irrigation kinematics\n",
      "\n",
      "Consider a pivot irrigation system with following points:\n",
      "\n",
      "* A: pivot\n",
      "* B: attachment of pipe to rolling support\n",
      "* C: wheel center\n",
      "* D: wheel-ground contact point\n",
      "\n",
      "The pivot rotates at an angular rate of $\\omega_z$,\n",
      "the wheel center is a distance $R$ from the pivot,\n",
      "the wheel has a radius $r$,\n",
      "and the wheel rolls without slip with angular rate $\\omega_x$,\n",
      "which implies the following relationship:\n",
      "\n",
      "$ R \\omega_z = r \\omega_x $\n",
      "\n",
      "The linear acceleration at points B and C is purely centripetal, pointing towards the pivot.\n",
      "The linear acceleration at point D is a bit more complicated, so an analytical solution is derived here.\n",
      "\n",
      "The position of point C:\n",
      "\n",
      "$C = \\\\\n",
      "R [\\cos \\omega_z t \\\\\n",
      "   \\sin \\omega_z t\\\\\n",
      "   0]^T$\n",
      " \n",
      "and has linear acceleration:\n",
      " \n",
      "$\\ddot{C} = \\\\\n",
      "-R \\omega_z^2 [\\cos \\omega_z t \\\\\n",
      "               \\sin \\omega_z t\\\\\n",
      "               0]^T$\n",
      "   \n",
      "$\\ddot{C} = -R \\omega_z^2 C$\n",
      "\n",
      "The position of point D relative to C:\n",
      "\n",
      "$D - C= \\\\\n",
      "r[ \\sin \\omega_x t \\sin \\omega_z t \\\\\n",
      "  -\\sin \\omega_x t \\cos \\omega_z t \\\\\n",
      "  -\\cos \\omega_z t]^T$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import *\n",
      "R = Symbol('R')\n",
      "r = Symbol('r')\n",
      "t = Symbol('t')\n",
      "wx = Symbol('wx')\n",
      "wz = Symbol('wz')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Position of D relative to C\n",
      "Dx =  r * sin(wx*t) * sin(wz*t)\n",
      "Dy = -r * sin(wx*t) * cos(wz*t)\n",
      "Dz = -r * cos(wx*t)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Acceleration of D relative to C\n",
      "print(simplify(diff(diff(Dx, t), t)))\n",
      "print(simplify(diff(diff(Dy, t), t)))\n",
      "print(simplify(diff(diff(Dz, t), t)))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "r*(-wx**2*sin(t*wx)*sin(t*wz) + 2*wx*wz*cos(t*wx)*cos(t*wz) - wz**2*sin(t*wx)*sin(t*wz))\n",
        "r*(wx**2*sin(t*wx)*cos(t*wz) + 2*wx*wz*sin(t*wz)*cos(t*wx) + wz**2*sin(t*wx)*cos(t*wz))"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "r*wx**2*cos(t*wx)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "and has linear acceleration:\n",
      "\n",
      "$\\ddot{D} - \\ddot{C} = \\\\\n",
      "r [-(\\omega_x^2 + \\omega_z^2) \\sin \\omega_x t \\sin \\omega_z t + 2 \\omega_x \\omega_z \\cos \\omega_x t \\cos \\omega_z t \\\\\n",
      "   (\\omega_x^2 + \\omega_z^2) \\sin \\omega_x t \\cos \\omega_z t + 2 \\omega_x \\omega_z \\cos \\omega_x t \\sin \\omega_z t \\\\\n",
      "   \\omega_x^2 \\cos \\omega_x t]^T$\n",
      "\n",
      "$\\ddot{D} - \\ddot{C} = \\\\\n",
      "r [-(\\omega_x^2 + \\omega_z^2) \\sin \\omega_x t \\sin \\omega_z t \\\\\n",
      "   (\\omega_x^2 + \\omega_z^2) \\sin \\omega_x t \\cos \\omega_z t \\\\\n",
      "   \\omega_x^2 \\cos \\omega_x t]^T \\\\\n",
      "+ 2r \\omega_x \\omega_z \\cos \\omega_x t\n",
      "[\\cos \\omega_z t \\\\\n",
      " \\sin \\omega_z t \\\\\n",
      " 0]^T$\n",
      "\n",
      "which has a relative centripetal acceleration of $2r \\omega_x \\omega_z t$\n",
      "when point D is at the contact point ($cos \\omega_x t = 1$).\n",
      "Using the no-slip condition, this is equivalent to $2R \\omega_z^2 t$.\n",
      "The xy centripetal acceleration components of D towards the pivot are then\n",
      "\n",
      "$\\ddot{D}_{xy} = R \\omega_z^2 C_{xy}$\n",
      "\n",
      "which is the exact opposite of the centripetal acceleration at $C$."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}