{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Dynamics Example Problems\n",
"\n",
"Selected example problems are illustrated below, including\n",
"\n",
"- [Using Jupyter as a calculator](#Using-Jupyter-as-a-calculator)\n",
"- [Vectors and the cross product](#Vectors-and-the-cross-product)\n",
"- [Solving several simultaneous equations](#Solving-several-simultaneous-equations)\n",
"\n",
"For more information on how to use the Jupyter notebook, see \n",
"[Archie's Intro](https://madisoncollegephysics.net/comp/intro-to-jupyter.html) document.\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"# The following statements are required for the work below\n",
"from numpy import *\n",
"dtr = pi/180\n",
"g = 9.81 # m/s2\n",
"gfps = 32.2 # ft/s2"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"----------------------------------------------------\n",
"\n",
"## Using Jupyter as a calculator\n",
"\n",
"The problem below illustrates the use of Jupyter as a calculator. \n",
"\n",
"The solution to the problem is first developed by hand on paper, using\n",
"variables for all quantities, then scanned and posted with the problem. When\n",
"the final solution equation is derived, it is put into code.\n",
"\n",
"![textbook problem 15-78](images/15-78.png)\n",
"\n",
"Here is the \n",
"[hand-written solution](images/15-78-sol.png).\n",
"The variables used are defined at the top (note that we don't need $W$ or $h$\n",
"for the solution). The bottom line is what we need to calculate, but it is\n",
"based on a few intermediate results.\n",
"\n",
"We put this solution into code as follows:\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"# symbol definitions:\n",
"e = 0.5\n",
"d = 100 # ft\n",
"vA = 75 # ft/s\n",
"phi = 60*dtr # rad\n",
"Q0 = 45*dtr # rad\n",
"\n",
"# intermediate results:\n",
"vfx = vA*cos(Q0)\n",
"tf = d/vfx\n",
"vfy = vA*sin(Q0) - gfps*tf\n",
"v1 = sqrt( vfx**2 + vfy**2 )\n",
"Q1 = arctan(-vfy/vfx)\n",
"alpha = pi/2 - (phi+Q1)\n",
"v2x = e*v1*cos(alpha)\n",
"v2y = v1*sin(alpha)\n",
"\n",
"# final result:\n",
"v2 = sqrt(v2x**2+v2y**2)\n",
"print('speed after bounce = {:.3f} ft/s'.format(v2))"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"----------------------------------------------------\n",
"\n",
"## Vectors and the cross product\n",
"\n",
"Doing cross products is much easier with some computational help. In this case\n",
"the whole problem is done in code (no hand written component).\n",
"\n",
"![textbook problem 15-99](images/15-99.png)\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"rOP = array((-1, 1.5, 2)) # m\n",
"rOA = array(( 2,-1.5, 2)) # m\n",
"rOB = array(( 3, 3, 0)) # m\n",
"m = 3.0 # kg\n",
"rPA = rOA - rOP\n",
"rAB = rOB - rOA\n",
"uAB = rAB / sqrt(sum(rAB**2))\n",
"v = 6*uAB # m/s\n",
"H = cross( rPA, m*v )\n",
"print('H = ({:.2f} i {:+.2f} j {:+.2f} k) kg.m\u00b2/s'.format(*H))"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"----------------------------------------------------\n",
"\n",
"## Solving several simultaneous equations\n",
"\n",
"Solving several equations simultaneouly is best done by computer.\n",
"\n",
"### General theory\n",
"\n",
"The tools of linear algebra make linear equations easy to handle. If you have\n",
"not yet studied linear algebra this material might not be intelligible. But\n",
"don't worry, you don't need to understand it to use it.\n",
"\n",
"To solve a series of coupled linear equations such as\n",
"\n",
"$$ C_{11} x + C_{12} y + C_{13} z = S_1 $$\n",
"\n",
"$$ C_{21} x +C_{22} y + C_{23} z = S_2 $$\n",
"\n",
"$$ C_{31} x +C_{32} y + C_{33} z = S_3 $$\n",
"\n",
"they must first be written in matrix form:\n",
"\n",
"$$\\begin{bmatrix}\n",
"C_{11} & C_{12} & C_{13} \\\\ \n",
"C_{21} & C_{22} & C_{23} \\\\ \n",
"C_{31} & C_{32} & C_{33} \\\\ \n",
"\\end{bmatrix}\n",
"\\begin{bmatrix} x \\\\ y \\\\ z \\end{bmatrix}=\n",
"\\begin{bmatrix} S_1\\\\S_2\\\\S_3 \\end{bmatrix}\n",
"$$\n",
"\n",
"or more compactly as:\n",
"\n",
"$$ \\mathbb{C} \\vec{x} = \\vec{s} $$\n",
"\n",
"This is solved by inverting matrix $\\mathbb{C}$:\n",
"\n",
"$$ \\mathbb{C}^{-1} \\mathbb{C} \\vec{x} = \\mathbb{C}^{-1} \\vec{s} $$\n",
"\n",
"$$\\vec{x} = \\mathbb{C}^{-1} \\vec{s} $$\n",
"\n",
"### Theory Applied\n",
"\n",
"We will now use this theory to solve the following problem that requires \n",
"seven equations with seven unknowns.\n",
"\n",
"![textbook problem 17-93](images/17-93.png)\n",
"\n",
"First, the [hand written\n",
"solution](http://madisoncollegephysics.net/dynamics/extras/images/17-93-sol.png). At\n",
"the bottom of that development are the seven equations with seven unknowns\n",
"($N_A$, $N_B$, $\\alpha$, $a_A$, $a_B$, and $\\vec{a}_G$ with two components). We\n",
"can solve these with a little linear algebra, as follows.\n",
"\n",
"In Python we use the\n",
"[linalg](http://docs.scipy.org/doc/numpy/reference/routines.linalg.html)\n",
"routine to perform the matrix inversion.\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"m = 12 # kg\n",
"L = 3 # m\n",
"Q = 60*dtr # rad\n",
"w = 2 # rad/s\n",
"IG = m*L**2/12\n",
"c,s = cos(Q),sin(Q)\n",
"\n",
" # NA NB alpha aA aB aGx aGy\n",
"CC = array((( 0, -1, 0, 0, 0, -m, 0 ), # Fx = 0\n",
" ( 1, 0, 0, 0, 0, 0, -m ), # Fy = mg\n",
" ( -L*c/2, L*s/2, IG, 0, 0, 0, 0 ), # MG = 0\n",
" ( 0, 0, L*s, -1, 0, 0, 0 ), # B/A x = L w^2 cosQ\n",
" ( 0, 0, -L*c, 0, 1, 0, 0 ), # B/A y = L w^2 sinQ\n",
" ( 0, 0, 0, .5, 0, 1, 0 ), # G=(A+B)/2 x = 0\n",
" ( 0, 0, 0, 0, .5, 0, 1 ) )) # G=(A+B)/2 y = 0\n",
"\n",
"print(' check if coefficient matrix is invertable (nonzero determinant):')\n",
"print(' det(CC)={:.3f}'.format(linalg.det(CC)))\n",
"\n",
"SS = array(( 0, m*g, 0, L*w**2*c, L*w**2*s, 0, 0 ))\n",
"NA,NB,alpha,aA,aB,aGx,aGy = linalg.solve(CC,SS)\n",
"\n",
"print('Solution:')\n",
"print(' reactions are NA={:.2f} N, NB={:.2f} N '.format(NA,NB))\n",
"print(' angular acceleration is {:.2f} rad/s2'.format(alpha))\n",
"print('We also now know:')\n",
"print(' acceleration of ends are: aA={:.2f} m/s2, aB={:.2f} m/s2'.format(aA,aB))\n",
"print(' aG is ({:.3f} i {:+.3f} j) m/s2'.format(aGx,aGy))"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Anticipating Problems\n",
"\n",
"If all of the equations are not independant, there is no solution ([more\n",
"here](http://mathworld.wolfram.com/LinearlyIndependent.html)). You can easily\n",
"check if this will be a problem by finding the determinant of the coefficient\n",
"matrix: if it is zero (or very near zero) you will have a problem.\n",
"\n",
"This is demonstrated here, using the same solution but with extra equations\n",
"derived from taking moments about other points ($\\sum M_A$ and $\\sum M_B$). In\n",
"this case the determinant of the coefficient matrix is pretty much zero, but\n",
"the `linalg.solve()` routine gives an answer anyway -- a wrong answer!\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"m = 12 # kg\n",
"L = 3 # m\n",
"Q = 60*dtr # rad\n",
"w = 2 # rad/s\n",
"IA = m*L**2/3 # = IB\n",
"IG = IA/4\n",
"c,s = cos(Q),sin(Q)\n",
"zs = -m*s*L/2\n",
"zc = -m*c*L/2\n",
" # NA NB alp aA aB aGx aGy\n",
"CC = array((( 0, -1, 0, 0, 0, -m, 0 ), # Fx = 0\n",
" ( 1, 0, 0, 0, 0, 0, -m ), # Fy = mg\n",
" ( -L*c/2,L*s/2,IG, 0, 0, 0, 0 ), # MG = 0\n",
" ( 0, L*s, IA, zs, 0, 0, 0 ), # MA = mgLcosQ/2\n",
" (-L*c, 0, IA, 0, zc, 0, 0 ), # MB = -mgLcosQ/2\n",
" ( 0, 0,L*s, -1, 0, 0, 0 ), # B/A x = L w^2 cosQ\n",
" ( 0, 0,-L*c, 0, 1, 0, 0 ), ))# B/A y = L w^2 sinQ\n",
"\n",
"print(' check if coefficient matrix is invertable (nonzero determinant):')\n",
"det = linalg.det(CC) # find determinant of CC\n",
"print(' det(CC)={:.3e}'.format(det))\n",
"if abs(det)<1e-5: \n",
" print(' WARNING: Coefficient matrix is not invertable...!')\n",
" \n",
"SS = array(( 0, m*g, 0, m*g*L*c/2, -m*g*L*c/2, L*w**2*c, L*w**2*s ))\n",
"NA,NB,alpha,aA,aB,aGx,aGy = linalg.solve(CC,SS)\n",
"\n",
"print('Incorrect Solution:')\n",
"print(' reactions are NA={:.2f} N, NB={:.2f} N '.format(NA,NB))\n",
"print(' angular acceleration is {:.2f} rad/s2'.format(alpha))"
],
"metadata": {},
"execution_count": null,
"outputs": []
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}