{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2:Doubly Reinforced Sections"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.1:pg-47"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Depth of neutral axis= 159.56861799 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=200.0 #width, in mm\n",
    "D=400 #overall depth, in mm\n",
    "m=18.66 #modular ratio\n",
    "Ast=4*0.785*22**2 #four 22 mm dia bars at bottom, in sq mm\n",
    "Asc=3*0.785*20**2 #three 20 mm dia bars at top, in sq mm\n",
    "bottom_cover=30 #in mm\n",
    "top_cover=25 #in mm\n",
    "d=D-bottom_cover #effective depth, in mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    "print \"Depth of neutral axis=\",x,\"mm\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.2:pg-48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam= 120.506005456 kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=280.0 #width, in mm\n",
    "D=540.0 #overall depth, in mm\n",
    "Ast=5*0.785*22**2 #five 22 mm dia bars on tension side, in sq mm\n",
    "Asc=4*0.785*20**2 #four 20 mm dia bars on compression side, in sq mm\n",
    "bottom_cover=40 #in mm\n",
    "top_cover=30.0 #in mm\n",
    "sigma_cbc=5.0#in MPa\n",
    "sigma_st=140.0 #in MPa\n",
    "m=18.66 #modular ratio\n",
    "d=D-bottom_cover #effective depth, in mm\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-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",
    "sigma_cbc=(sigma_st/m)*x/(d-x) #in MPa\n",
    "sigma_cbc_dash=sigma_cbc*(x-top_cover)/x #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #in MPa\n",
    " #stress in compression steel is found to be less than its permissible limit of 130 N/mm**2\n",
    "Mr=b*x*sigma_cbc*(d-x/3)/2+(1.5*m-1)*Asc*sigma_cbc_dash*(d-top_cover) #in N-mm\n",
    "print \"Moment of resistance of the beam=\",Mr/10**6,\"kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.3:pg-48"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam using elastic theory method 132.70169173 kN-m\n",
      "Moment of resistance of the beam using elastic theory method= 136.0248 kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=300.0 #width, in mm\n",
    "d=600.0 #effective depth, in mm\n",
    "Ast=1256 #in sq mm\n",
    "Asc=1256.0 #in sq mm\n",
    "top_cover=30.0 #in mm\n",
    "sigma_cbc=7.0 #in MPa\n",
    "sigma_st=190.0 #in MPa\n",
    "m=13.33 #modular ratio\n",
    "#using elastic theory method\n",
    "#to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2.0*p) #in mm\n",
    " #as x<Xc, beam is under-reinforced\n",
    "sigma_cbc=(sigma_st/m)*x/(d-x) #in MPa\n",
    "sigma_cbc_dash=sigma_cbc*(x-top_cover)/x #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #in MPa\n",
    " #stress in compression steel is found to be less than its permissible limit of 130 N/mm**2\n",
    "Mr1=b*x*sigma_cbc*(d-x/3)/2+(1.5*m-1)*Asc*sigma_cbc_dash*(d-top_cover) #in N-mm\n",
    " #using steel beam theory method\n",
    "Mr2=Ast*sigma_st*(d-top_cover) #in N-mm\n",
    "print \"Moment of resistance of the beam using elastic theory method\",Mr1/10**6,\"kN-m\\nMoment of resistance of the beam using elastic theory method=\",Mr2/10**6,\"kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.4:pg-49"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Moment of resistance of the beam= 117.411305827  kN-m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=250.0 #width, in mm\n",
    "D=550.0 #overall depth, in mm\n",
    "Ast=4*0.785*25**2 #four 25 mm dia bars on tension side, in sq mm\n",
    "Asc=3*0.785*22**2 #three 22 mm dia bars on compression side, in sq mm\n",
    "bottom_cover=50.0 #in mm\n",
    "top_cover=30 #in mm\n",
    "d=D-bottom_cover #effective depth, in mm\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140.0 #in MPa\n",
    "sigma_sc=130 #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 x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-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",
    "sigma_cbc_dash=sigma_cbc*(x-top_cover)/x #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #< 130 MPa, hence OK\n",
    " #stress in compression steel is found to be less than its permissible limit of 130 N/mm**2\n",
    "Mr=b*x*sigma_cbc*(d-x/3)/2+(1.5*m-1)*Asc*sigma_cbc_dash*(d-top_cover) #in N-mm\n",
    "print \"Moment of resistance of the beam=\",Mr/10**6,\" kN-m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.5:pg-50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Uniformly distributed load the beam can carry (including self-weight)= 21.5549707684  kN/m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=250.0 #width, in mm\n",
    "d=450 #effective depth, in mm\n",
    "Ast=4*0.785*22**2 #four 22 mm dia bars on tension side, in sq mm\n",
    "Asc=Ast\n",
    "top_cover=30 #in mm\n",
    "sigma_cbc=7 #in MPa\n",
    "sigma_st=140.0 #in MPa\n",
    "sigma_sc=130 #in MPa\n",
    "m=13.33 #modular ratio\n",
    "l=5.7 #effective span, in m\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-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",
    "sigma_cbc=(sigma_st/m)*x/(d-x) #in MPa\n",
    "sigma_cbc_dash=sigma_cbc*(x-top_cover)/x #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #in MPa\n",
    " #stress in compression steel is found to be less than its permissible limit of 130 N/mm**2\n",
    "Mr=b*x*sigma_cbc*(d-x/3)/2+(1.5*m-1)*Asc*sigma_cbc_dash*(d-top_cover) #in N-mm\n",
    "W=(Mr/10.0**6)*8.0/l**2 #in kN/m\n",
    "print \"Uniformly distributed load the beam can carry (including self-weight)=\",W,\" kN/m\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.6:pg-51"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stress in concrete= 5.37043483737  N/mm**2\n",
      "Stress in tension steel= 126.05367156  N/mm**2\n",
      "Stress in compression steel= 127.691872535  N/mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=200.0 #width, in mm\n",
    "D=480.0 #overall depth, in mm\n",
    "Ast=4*0.785*25**2 #four 25 mm dia bars on tension side, in sq mm\n",
    "Asc=3*0.785*22**2 #three 22 mm dia bars on compression side, in sq mm\n",
    "bottom_cover=30 #in mm\n",
    "top_cover=30 #in mm\n",
    "d=D-bottom_cover #effective depth, in mm\n",
    "m=18.66 #modular ratio\n",
    "M=100*10**6 #in N-mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #sigma_cbc_dash=sigma_cbc*(x-d')/x=a*sigma_cbc\n",
    "a=(x-top_cover)/x\n",
    "sigma_cbc=M/(b*x*(d-x/3.0)/2+(1.5*m-1)*Asc*a*(d-top_cover)) #in MPa\n",
    "sigma_st=m*sigma_cbc*(d-x)/x #in MPa\n",
    "sigma_cbc_dash=a*sigma_cbc #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #in MPa\n",
    "print \"Stress in concrete=\",sigma_cbc,\" N/mm**2\\nStress in tension steel=\",sigma_st,\" N/mm**2\\nStress in compression steel=\",sigma_sc,\" N/mm**2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.7:pg-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stress in concrete= 6.27031395641  N/mm**2\n",
      "Stress in tension steel= 206.375703553  N/mm**2\n",
      "Stress in compression steel= 103.628003414  N/mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=300.0 #width, in mm\n",
    "d=500.0 #effective depth, in mm\n",
    "Ast=4*0.785*20**2 #four 20 mm dia bars on tension and compression side, in sq mm\n",
    "Asc=Ast\n",
    "top_cover=25.0 #in mm\n",
    "m=13.33 #modular ratio\n",
    "M=120*10.0**6 #in N-mm\n",
    " #to find x using b(x**2)/2 + (1.5m-1)Asc(x-d')=mAst(d-x), which becomes of the form px**2+qx+r=0\n",
    "p=b/2\n",
    "q=(1.5*m-1)*Asc+m*Ast\n",
    "r=-(1.5*m-1)*Asc*top_cover-m*Ast*d\n",
    "x=(-q+math.sqrt(q**2-4*p*r))/(2*p) #in mm\n",
    " #sigma_cbc_dash=sigma_cbc*(x-d')/x=a*sigma_cbc\n",
    "a=(x-top_cover)/x\n",
    "sigma_cbc=M/(b*x*(d-x/3)/2+(1.5*m-1)*Asc*a*(d-top_cover)) #in MPa\n",
    "sigma_st=m*sigma_cbc*(d-x)/x #in MPa\n",
    "sigma_cbc_dash=a*sigma_cbc #in MPa\n",
    "sigma_sc=1.5*m*sigma_cbc_dash #in MPa\n",
    "print \"Stress in concrete=\",sigma_cbc,\" N/mm**2\\nStress in tension steel=\",sigma_st,\" N/mm**2\\nStress in compression steel=\",sigma_sc,\" N/mm**2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.8:pg-53"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensile steel required= 1403  mm**2\n",
      "Compression steel required= 565  mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=250 #width, in mm\n",
    "D=600 #overall depth, in mm\n",
    "bottom_cover=50 #in mm\n",
    "top_cover=50 #in mm\n",
    "d=D-bottom_cover #effective depth, in mm\n",
    "sigma_cbc=5 #in MPa\n",
    "sigma_st=140 #in MPa\n",
    "m=18.66 #modular ratio\n",
    "M=95*10**6 #in N-mm\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find Ast1\n",
    "Ast1=b*Xc*sigma_cbc/(2*sigma_st) #in sq mm\n",
    "Ast1=982 #round-off, in sq mm\n",
    "Mr=b*Xc*sigma_cbc/2*(d-Xc/3) #moment of resistance of singly reinforced beam, in N-mm\n",
    "M1=M-Mr #remaining bending moment, in N-mm\n",
    " #to find Ast2\n",
    "Ast2=M1/(sigma_st*(d-top_cover)) #in sq mm\n",
    "Ast2=421 #round-off, in sq mm\n",
    "Ast=Ast1+Ast2 #in sq mm\n",
    " #to find Asc\n",
    "Asc=m*Ast2*(d-Xc)/((1.5*m-1)*(Xc-top_cover)) #in sq mm\n",
    "Asc=565 #round-off, in sq mm\n",
    "print \"Tensile steel required=\",Ast,\" mm**2\\nCompression steel required=\",Asc,\" mm**2\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex2.9:pg-54"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tensile steel required= 2331.20260317  mm**2\n",
      "Compression steel required= 1241.93655457  mm**2\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "b=360 #width, in mm\n",
    "d=750.0 #effective depth, in mm\n",
    "top_cover=50 #in mm\n",
    "sigma_cbc=7 #in MPa\n",
    "sigma_st=190 #in MPa\n",
    "m=13.33 #modular ratio\n",
    "M=300.0*10**6 #in N-mm\n",
    " #to find critical depth of neutral axis\n",
    "Xc=d/(1+sigma_st/(m*sigma_cbc)) #in mm\n",
    " #to find Ast1\n",
    "Ast1=b*Xc*sigma_cbc/(2*sigma_st) #in sq mm\n",
    "Ast1=1638.0 #round-off, in sq mm\n",
    "Mr=b*Xc*sigma_cbc/2*(d-Xc/3) #moment of resistance of singly reinforced beam, in N-mm\n",
    "M1=M-Mr #remaining bending moment, in N-mm\n",
    " #to find Ast2\n",
    "Ast2=M1/(sigma_st*(d-top_cover)) #in sq mm\n",
    "Ast=Ast1+Ast2 #in sq mm\n",
    " #to find Asc\n",
    "Asc=m*Ast2*(d-Xc)/((1.5*m-1)*(Xc-top_cover)) #in sq mm\n",
    "print \"Tensile steel required=\",Ast,\" mm**2\\nCompression steel required=\",Asc,\" 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
}
