{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1:Singly Reinforced Sections"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.1:pg-27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The depth of neutral axis =  139.969995714  mm\n",
      "Area of steel =  499.892841835  mm**2\n",
      "\n",
      "Percentage of steel =  0.714132631192  percent\n"
     ]
    }
   ],
   "source": [
    " #let the depth of neutral axis be x\n",
    "import math\n",
    "b=200 #width, in mm\n",
    "d=350 #effective depth, in mm\n",
    "m=18.66  #modular ratio\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "x=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    "print \"The depth of neutral axis = \",(x),\" mm\\n\",\n",
    " #to find area of steel\n",
    "Ast=b*x*sigma_cbc/(2*sigma_st) #in sq mm\n",
    "print \"Area of steel = \",(Ast),\" mm**2\\n\"\n",
    " #to find percentage steel\n",
    "pst=Ast*100/(b*d) #in %\n",
    "print \"Percentage of steel = \",(pst),\" percent\\n\", \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.2:pg-27"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The depth of neutral axis =  200.011732416  mm\n"
     ]
    }
   ],
   "source": [
    " #let the depth of neutral axis be x\n",
    "import math\n",
    "b=150.0 #width, in mm\n",
    "d=400 #effective depth, in mm\n",
    "Ast=804 #area of steel, in sq mm\n",
    "m=18.66 #modular ratio\n",
    " #b(x**2)/2=mAst(d-x)-->this becomes a quadratic equation of form px**2+qx+r=0\n",
    "p=b/2.0\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    " #solving the quadratic equation\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    "print \"The depth of neutral axis = \",(x),\" mm\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.3:pg-28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When d is assumed as 400 mm and b as 200 mm\n",
      "(a) Position of neutral axis= 159.965709387  mm\n",
      "(b) Lever arm= 346.678096871  mm\n",
      "(c) Moment of resistance= 27.7283038475  kN-m\n",
      "(d) Percentage of steel= 0.714132631192  percent\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#assume d = 400 mm and b = 200 mm\n",
    "b=200 #in mm\n",
    "d=400 #in mm\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=18.66 #modular ratio\n",
    "Xc=d/(1+sigma_st/m/sigma_cbc) #in mm\n",
    "z=d-Xc/3 #in mm\n",
    "Mr=b*Xc*sigma_cbc/2*z #in N-mm\n",
    "Ast=b*Xc*sigma_cbc/2/sigma_st #in sq mm\n",
    "pt=Ast*100/b/d #in %\n",
    "print \"When d is assumed as 400 mm and b as 200 mm\\n(a) Position of neutral axis=\",(Xc),\" mm\\n(b) Lever arm=\",(z),\" mm\\n(c) Moment of resistance=\",(Mr/10**6),\" kN-m\\n(d) Percentage of steel=\",(pt),\" percent\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.4:pg-28"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam =  54.1568434521  kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=250.0 #width, in mm\n",
    "d=500.0 #effective depth, in mm\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=18.66 #modular ratio\n",
    "#to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    "z=d-Xc/3 #lever arm, in mm\n",
    "Mr=b*Xc*sigma_cbc*z/2 #in N-mm\n",
    "print \"Moment of resistance of the beam = \",(Mr/10**6),\" kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.5:pg-29"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam= 87.5318457534  kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=250 #width, in mm\n",
    "D=550.0 #overall depth, in mm\n",
    "Ast=1521 #area of steel, in sq mm\n",
    "cover=25 #in mm\n",
    "d=D-cover #effective depth, in mm\n",
    "sigma_cbc=7 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=13.33 #modular ratio\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x)--> this will become of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #x>Xc; hence beam is over-reinforced\n",
    "Mr=b*x*sigma_cbc/2*(d-x/3) #in N-mm\n",
    "print \"Moment of resistance of the beam=\",(Mr/10**6),\" kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.6:pg-30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam =  33.0389810897  kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=200 #width, in mm\n",
    "d=450 #effective depth, in mm\n",
    "Ast=3*.785*16**2 #three 16 dia bars, in sq mm\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=18.66 #modular ratio\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #as x<Xc, beam is under-reinforced\n",
    "Mr=Ast*sigma_st*(d-x/3) #in N-mm\n",
    "print \"Moment of resistance of the beam = \",(Mr/10**6),\" kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.7:pg-31"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance= 104.695224175  kN-m\n",
      "Safe uniformly distributed load that the beam can carry= 18.0156053722  kN/m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=300 #width, in mm\n",
    "D=700.0 #overall depth, in mm\n",
    "Ast=3*.785*20**2 #3-20mm dia bars, in sq mm\n",
    "cover=50 #in mm\n",
    "d=D-cover #effective depth, in mm\n",
    "sigma_cbc=7 #in MPa\n",
    "sigma_st=190 #in MPa\n",
    "m=13.33 #modular ratio\n",
    "l=6 #span, in m\n",
    "w=25 #unit weight of concrete, in kN/m**3\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    " #solving quadratic equation\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #x<Xc, hence beam is under-reinforced\n",
    "Mr=sigma_st*Ast*(d-x/3) #in N-mm\n",
    "UDL=(Mr/10.0**6)*8/l**2 #in kN/m\n",
    "self_weight=w*b*D/10**6 #in kN/m\n",
    "net_weight=UDL-self_weight #in kN/m\n",
    "print \"Moment of resistance=\",(Mr/10**6),\" kN-m\\nSafe uniformly distributed load that the beam can carry=\",(net_weight),\" kN/m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.8:pg-32"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The concentrated load the beam can support at centre= 46.4305432264  kN\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "b=250.0 #width, in mm\n",
    "D=500 #overall depth, in mm\n",
    "Ast=4*.785*22**2 #four 22 mm dia bars, in sq mm\n",
    "cover=25 #in mm\n",
    "d=D-cover #effective depth, in mm\n",
    "l=5 #effective span, in m\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=190 #in MPa\n",
    "m=18.66 #modular ratio\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #as x>Xc, beam is over-reinforced\n",
    "Mr=b*sigma_cbc*x/2*(d-x/3) #in N-mm\n",
    "self_weight=25*(b/10**3)*(D/10**3) #in kN/m\n",
    "M=Mr/10**6-self_weight*l**2/8 #moment of resistance available for external load, in kN-m\n",
    "W=4*M/l #in kN\n",
    "print \"The concentrated load the beam can support at centre=\",(W),\" kN\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.9:pg-33"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The safe load for slab= 11.3607587975  kN/m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "d=120.0 #effective depth of slab, in mm\n",
    " #consider 1 m strip of slab\n",
    "b=1000.0 #in mm\n",
    "s=80.0 #spacing of 12mm dia bars centre-to-centre, in mm\n",
    "Ast=1000*.785*12**2/s #in sq mm\n",
    "l=3.2 #span, in m\n",
    "sigma_cbc=7 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=13.33 #modular ratio\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #as x>Xc, the beam is over-reinforced\n",
    "Mr=b*sigma_cbc*x/2*(d-x/3)/10**6 #in kN-m\n",
    "UDL=Mr*8/l**2 #in kN/m\n",
    "self_weight=25*(d/10.0**3)*(b/10**3) #in kN/m\n",
    "W=UDL-self_weight #in kN/m\n",
    "print \"The safe load for slab=\",(W),\" kN/m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.10:pg-34"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stress in steel= 116  N/mm**2\n",
      "Stress in concrete= 5  N/mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=300.0 #width, in mm\n",
    "D=700 #overall depth, in mm\n",
    "Ast=4*.785*25**2 #four 25mm dia bars, in sq mm\n",
    "cover=30 #in mm\n",
    "d=D-cover #effective depth, in mm\n",
    "M=130*10**6 #bending moment, in N-mm\n",
    "m=18.66 #modular ratio\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2.0\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    "z=d-x/3 #lever arm, in mm\n",
    " #assuming under-reinforced section, Mr=Ast*sigma_st(d-x/3) and equating Mr to M\n",
    "sigma_st=M/(Ast*z) #in MPa\n",
    "sigma_st=116 #round-off, in MPa\n",
    "sigma_cbc=(sigma_st/m)*x/(d-x) #in MPa\n",
    "sigma_cbc=5 #round-off, in MPa\n",
    "print \"Stress in steel=\",(sigma_st),\" N/mm**2\\nStress in concrete=\",(sigma_cbc),\" N/mm**2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.11:pg-35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stress in steel= 145.869819292  N/mm**2\n",
      "Stress in concrete= 5.83077431505  N/mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "b=350.0 #width, in mm\n",
    "D=650 #overall depth, in mm\n",
    "Ast=4*.785*22**2 #four 22mm dia bars, in sq mm\n",
    "cover=25 #in mm\n",
    "d=D-cover #effective depth, in mm\n",
    "W=20 #UDL, in kN/m\n",
    "l=7 #span, in m\n",
    "M=W*l**2/8.0*10**6 #bending moment, in N-mm \n",
    "m=13.33 #modular ratio\n",
    " #to find actual depth of neutral axis using b(x**2)/2=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=m*Ast\n",
    "r=-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    "z=d-x/3 #lever arm, in mm\n",
    " #assuming under-reinforced section, Mr=Ast*sigma_st(d-x/3) and equating Mr to M\n",
    "sigma_st=M/(Ast*z) #in MPa\n",
    "sigma_cbc=(sigma_st/m)*x/(d-x) #in MPa\n",
    "print \"Stress in steel=\",(sigma_st),\" N/mm**2\\nStress in concrete=\",(sigma_cbc),\" N/mm**2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.12:pg-35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Effective depth= 640.0  mm\n",
      "Area of steel= 693.498452012  mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "b=250.0 #width, in mm\n",
    "sigma_cbc=5.0 #in MPa\n",
    "sigma_st=190.0 #in MPa\n",
    "m=280.0/(3*sigma_cbc) #modular ratio\n",
    "M=75*10.0**6 #bending moment, in N-mm\n",
    " #critical depth of neutral axis, Xc=d/(1+sigma_st/(m*sigma_cbc))=a*d\n",
    "a=1/(1+sigma_st/(m*sigma_cbc))\n",
    "d=(M/(b*sigma_cbc*a*(1-a/3.0)/2.0))**0.5 #in mm\n",
    "d=640 #round-off, in mm\n",
    "Xc=a*d #in mm\n",
    "Ast=b*Xc*sigma_cbc/(2*sigma_st) #in sq mm\n",
    "print \"Effective depth=\",round(d),\" mm\\nArea of steel=\",(Ast),\" mm**2\",\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex1.13:pg-36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dimensions of section= 265.0  x  530.0  mm\n",
      "Area of steel= 1007.0  mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#b=d/2 (given)\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140.0 #in MPa\n",
    "m=18.66 #modular ratio\n",
    "M=65*10.0**6 #bending moment, in N-mm\n",
    " #critical depth of neutral axis, Xc=d/(1+sigma_st/(m*sigma_cbc))=a*d\n",
    "a=1/(1+sigma_st/(m*sigma_cbc))\n",
    "d=(M/(sigma_cbc*a*(1-a/3.0)/4))**(1/3.0) #in mm\n",
    "d=530.0 #round-off, in mm\n",
    "Xc=a*d #in mm\n",
    "b=d/2.0 #in mm\n",
    "Ast=M/sigma_st/0.87/d #in sq mm\n",
    "Ast=1007.0 #round-off, in sq mm\n",
    "print \"Dimensions of section=\",(b),\" x \",(d),\" mm\\nArea of steel=\",(Ast),\" mm**2\"\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
