{
 "metadata": {
  "name": "",
  "signature": "sha256:2c442a1cbc28b933d555165b6cb09fa7f45de31e28c837593e3048f115cafdbb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Equilibrium of Floating Bodies"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1 Page No : 26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#initialisation of variables\n",
      "d= 40.   \t#lb/ft**2 density of wood\n",
      "w= 4     \t#ft  wide\n",
      "h= 6     \t#ft  deep\n",
      "l= 12    \t#ft  long \n",
      "\n",
      "#CALCULATIONS\n",
      "W= w*h*d*l\n",
      "V= W/64\n",
      "D= V/(w*l)\n",
      "\n",
      "#RESULTS\n",
      "print  'Volume of water print laced = %.f ft**3'%(V)\n",
      "print  ' Depth of immersion = %.2f ft'%(D)\n",
      "print  ' Centre of buoyancy = %.2f ft from base'%(D)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume of water print laced = 180 ft**3\n",
        " Depth of immersion = 3.75 ft\n",
        " Centre of buoyancy = 3.75 ft from base\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3 Page No : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import Symbol,solve\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "d= 4.    \t#ft diameter\n",
      "h= 7.    \t#ft high\n",
      "W= 2500. \t#lb weighing \n",
      "OG= 3.5\n",
      "OB= 1.55 \t#ft\n",
      "\n",
      "#CALCULATIONS\n",
      "V= W/d**3\n",
      "D= V/(math.pi*(d/2)**2)\n",
      "I= math.pi*d**4/64\n",
      "BM= I/V\n",
      "BG= OG-OB\n",
      "T = Symbol(\"T\")\n",
      "ans = solve( (2500 + T)**2 -(512*math.pi *(8750 - 804)) - 1)\n",
      "T = ans[1]\n",
      "\n",
      "#RESULTS\n",
      "print  'Minimum tension in chain = %d lb'%(T)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum tension in chain = 1075 lb\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4 Page No : 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "W1= 1000. \t#lb weighing\n",
      "W2= 100. \t#lb load\n",
      "h= 4. \t#ft height\n",
      "d= 5. \t#ft  diameter\n",
      "\n",
      "#CALCULATIONS\n",
      "V= (W1+W2)/h**3\n",
      "D= V*h/(d**2*math.pi)\n",
      "I= d**4*math.pi/h**3\n",
      "BM= I/V\n",
      "x= (BM+(D/2)-(W1*(h/2)/(W1+W2)))/(W2/(W1+W2))-0.02\n",
      "C= x-h\n",
      "\n",
      "#RESULTS\n",
      "print  'centre of gravity = %.2f ft'%(x)\n",
      "print  ' Hence the gravity of the weight must not be more than above the top of buoy = %.2f ft'%(C)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "centre of gravity = 4.43 ft\n",
        " Hence the gravity of the weight must not be more than above the top of buoy = 0.43 ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5 Page No : 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "b= 12. \t#ft  breadth\n",
      "h1= 3. \t#ft  draught\n",
      "h2= 1.5 \t#ft\n",
      "h3= 5+(2./3) \t#ft\n",
      "\n",
      "#CALCULATIONS\n",
      "I= b**3/12\n",
      "V= b*h1\n",
      "bm= I/V\n",
      "BG= bm+(h1*2/(3*b))\n",
      "O= math.degrees(math.tan(math.sqrt((h3*2-h1-bm*2)/(bm*2+bm))))\n",
      "\n",
      "\n",
      "#RESULTS\n",
      "print  ' Volume of body immersed = %.f ft**3'%(V)\n",
      "print  ' BM = %.f ft'%(bm)\n",
      "print  ' BG = %.2f ft'%(BG)\n",
      "print  ' angle of heel = %.2f degrees'%(O)\n",
      "\n",
      "#The answer is a bit different due to rounding off error in textbook\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Volume of body immersed = 36 ft**3\n",
        " BM = 4 ft\n",
        " BG = 4.17 ft\n",
        " angle of heel = 9.64 degrees\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}