{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 16 Kinetics of a Particle Work and Energy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.1 Work of the Force of Spring"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The work of the spring force is -5.000000 N-m\n",
      "The work required to stretch the spring by 20 cm is -15.000000 N-m\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "k=1000 # N/m # stiffness of spring\n",
    "x_1=0.1 # m # distance upto which the spring is stretched\n",
    "x_2=0.2 # m \n",
    "x_0=0 # initial position of spring\n",
    "# Calculations\n",
    "# Work required to stretch the spring by 10 cm from undeformed position is given as,\n",
    "U_10=-(k/2)*(x_1**2-x_0**2) # N-m \n",
    "# Work required to stretch from 10 cm to 20 cm is,\n",
    "U=-(1/2)*k*(x_2**2-x_1**2) # N-m\n",
    "# Results\n",
    "print('The work of the spring force is %f N-m'%U_10)\n",
    "print('The work required to stretch the spring by 20 cm is %f N-m'%U)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.3 Work and energy principle for a system of particles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The velocity of block A is 3.194120 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "M_A=100 # kg # mass of block A\n",
    "M_B=150 # kg # mass of block B\n",
    "mu=0.2 # coefficient of friction between the blocks and the surface\n",
    "x=1 # m # distance by which block A moves\n",
    "g=9.81 # m/s^2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the respective F.B.D\n",
    "# Applying the principle of work and energy to the system of blocks A&B and on simplifying we get the value of v as,\n",
    "v=math.sqrt(((-mu*M_A*g)+(M_B*g))/(125)) # m/s \n",
    "# Results\n",
    "print('The velocity of block A is %f m/s'%v)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.4 Power"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) The maximum power required is 6.625000 MW\n",
      "(b) The power required to maintain a speed of 90 km/hr is 375.000000 kW\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "M=500*10**3 # kg # mass of the train\n",
    "u=0 # m/s # initial speed\n",
    "v=90*(1000/3600) # m/s # final speed\n",
    "t=50 # seconds\n",
    "F_r=15*10**3 # N # Frictioal resistance to motion\n",
    "# Calculations\n",
    "# Acceleration is given as,\n",
    "a=v/t # m/s**2\n",
    "# The total force required to accelerate the train is,\n",
    "F=M*a # N\n",
    "# The maximum power required is at, t=50s & v=25 m/s\n",
    "P=(F+F_r)*v*(10**-6) # MW\n",
    "# At any time after 50 seconds, the force required only to overcome the frictional resistance of 15*10**3 N is,\n",
    "P_req=F_r*v*(10**-3) # kW\n",
    "# Results\n",
    "print('(a) The maximum power required is %f MW'%P)\n",
    "print('(b) The power required to maintain a speed of 90 km/hr is %f kW'%P_req)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.5 Principle of conservation of energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The potential energy of the system is 500.000000 N-cm\n",
      "The maximum height above the floor that the weight W will attain after release is 10.000000 cm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "W=50 # N # Weight suspended on spring\n",
    "k=10 # N/cm # stiffness of the spring\n",
    "x_2=15 # cm # measured extensions\n",
    "h=10 # cm # height for position 2\n",
    "# Calculations\n",
    "# Consider the required F.B.D.\n",
    "# POSITION 1: The force exerted by the spring is,\n",
    "F_1=W # N\n",
    "# Extension of spring from undeformed position is x_1,\n",
    "x_1=F_1/k # cm\n",
    "# POSITION 2: When pulled by 10 cm to the floor. PE of weight is,\n",
    "PE_g=-W*h # N-cm # (PE_g= PE_gravity)\n",
    "# PE of the spring with respect to position 1\n",
    "PE_s=(1/2)*k*(x_2**2-x_1**2) # N-cm  # (PE_s= PE_ spring)\n",
    "# Total PE of the system with respect to position 1\n",
    "PE_t=PE_g+PE_s # N-cm # (PE_t= PE_total)\n",
    "# Total energy of the system,\n",
    "E_2=PE_t # N-cm\n",
    "# Total energy of the system in position 3 w.r.t position 1 is:\n",
    "x=-math.sqrt(100) # cm\n",
    "x=+math.sqrt(100) # cm\n",
    "# Results\n",
    "print('The potential energy of the system is %f N-cm'%E_2)\n",
    "print('The maximum height above the floor that the weight W will attain after release is %f cm'%x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.6 Principle of conservation of energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum deflection of the spring is 26.910763 cm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "m=5 # kg # mass of the ball\n",
    "k=500 # N/m # stiffness of the spring\n",
    "h=10 # cm # height of drop\n",
    "g=9.81 # m/s**2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the respective F.B.D.\n",
    "# In eq'n 1 substitute the respective values and simplify it further. In this eq'n of 2nd degree a=1 b=-0.1962 & c=-0.01962. Thus the roots of the eq'n is given as,\n",
    "a=1 \n",
    "b=-0.1962\n",
    "c=-0.01962\n",
    "delta=((-b+(math.sqrt((b**2)-(4*a*c))))/(2*a))*(10**2) # cm # We consider the +ve value of delta\n",
    "# Results\n",
    "print('The maximum deflection of the spring is %f cm'%delta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.7 Principle of conservation of energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum compression of the spring is 0.140071 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "m=5 # kg # mass of the ball\n",
    "k=500 # N/m # stiffness of the spring\n",
    "h=0.1 # m # height of vertical fall\n",
    "g=9.81 # m/s**2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the respective F.B.D\n",
    "# On equating the total energies at position 1 & 2 we get eq'n of delta as,\n",
    "delta=math.sqrt((2*m*g*h)/(k)) # m \n",
    "# Results\n",
    "print('The maximum compression of the spring is %f m'%delta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.9 Principle of conservation of energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The velocity of the collar will be 1.641036 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "m=5 # kg # mass of the collar\n",
    "k=500 # N/m # stiffness of the spring\n",
    "AB=0.15 # m # Refer the F.B.D for AB\n",
    "AC=0.2 # m # Refer the F.B.D for AC\n",
    "g=9.81 # m/s**2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the respective F.B.D\n",
    "# POSITION 1: \n",
    "PE_1=m*g*(AB)+0 \n",
    "KE_1=0\n",
    "E_1=PE_1+KE_1 #\n",
    "# POSITION 2 : Length of the spring in position 2\n",
    "CB=math.sqrt(AB**2+AC**2) # m \n",
    "# x is the extension in the spring\n",
    "x=CB-AC # m\n",
    "# On substuting and Equating equations of total energies for position1 & position 2 we get the value of v as,\n",
    "v=math.sqrt(((E_1-((1/2)*k*x**2))*2)/m) # m/s\n",
    "# Results\n",
    "print('The velocity of the collar will be %f m/s'%v)\n",
    "# The answer given in the text book (v=16.4 m/s) is wrong"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.10 Principle of work and energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum compression of the spring is 0.114614 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "m=5 # kg # mass of the block\n",
    "theta=30 # degree # inclination of the plane\n",
    "x=0.5 # m # distance travelled by the block\n",
    "k=1500 # N/m # stiffness of the spring\n",
    "mu=0.2 # coefficient of friction between the block and the surface\n",
    "g=9.81 # m/s**2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the F.B.D of the block\n",
    "# Applying the principle of work and energy between the positions 1 & 2 and on further simplification we get the generic eq'n for delta as, 750*delta^2-16.03*delta-8.015=0. From this eq'n e have values of a.b & c as,\n",
    "a=750\n",
    "b=-16.03\n",
    "c=-8.015\n",
    "# Thus the roots of the eq'n are given as,\n",
    "delta=(-b+(math.sqrt(b**2-(4*a*c))))/(2*a) # m\n",
    "# Results\n",
    "print('The maximum compression of the spring is %f m'%delta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 16.11 Principle of conservation of energy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The velocity of mass M_2 is 3.961818 m/s\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "# Initilization of variables\n",
    "M=10 # kg # Here M=M_1=M_2\n",
    "g=9.81 # m/s^2 # acc due to gravity\n",
    "# Calculations\n",
    "# Consider the respective F.B.D\n",
    "# Applying the principle of conservation of energy and by equating the total energies at position 1 & position 2 we get v as,\n",
    "v=math.sqrt((M*g*4)/(25)) # m/s\n",
    "# Results\n",
    "print('The velocity of mass M_2 is %f m/s'%v)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "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.12"
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
