{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 3 Parallel forces in a plane"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.1 Resultant of Forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The load taken by man P is 400 N\n",
      "The load taken by man Q is 600 N\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#Initilization of variables\n",
    "W=1000 #N\n",
    "Lab=1 #m\n",
    "Lac=0.6 #m\n",
    "theta=60 #degree #angle made by the beam with the horizontal\n",
    "#Calculations\n",
    "Q=(W*Lac*math.cos(theta*180/math.pi))/(Lab*math.cos(theta*180/math.pi)) #N # from eq'n 2\n",
    "P=W-Q #N # from eq'n 1\n",
    "#Results\n",
    "print('The load taken by man P is %d N'%P)\n",
    "print('The load taken by man Q is %d N'%Q)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.2 Resultant of forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction (downwards)at support A is 250 N\n",
      "The reaction (upwards)at support B is 1250 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "F=1000 #N\n",
    "Lab=1 #m\n",
    "Lbc=0.25 #m\n",
    "Lac=1.25 #m\n",
    "#Calculations\n",
    "Rb=(F*Lac)/Lab #N # from eq'n 2\n",
    "Ra=Rb-F #N # fom eq'n 1\n",
    "#Results\n",
    "print('The reaction (downwards)at support A is %d N'%Ra)\n",
    "print('The reaction (upwards)at support B is %d N'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.3 Resultant of Forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The vertical reaction (upwards) at A is 0.833333 kN\n",
      "The horizontal reaction (towards A) is -20.000000 kN\n",
      "The reaction (downwards) at B is -0.833333 kN\n"
     ]
    }
   ],
   "source": [
    "#Inilitization of variables\n",
    "Lab=12 #m\n",
    "Mc=40 #kN-m \n",
    "Md=10 #kN-m\n",
    "Me=20 #kN-m\n",
    "Fe=20 #kN #force acting at point E\n",
    "#Calculations\n",
    "Xa=-(Fe) #kN #take sum Fx=0\n",
    "Rb=(Md+Me-Mc)/Lab #N #take moment at A\n",
    "Ya=-Rb #N #take sum Fy=0\n",
    "#Results\n",
    "print('The vertical reaction (upwards) at A is %f kN'%Ya)\n",
    "print('The horizontal reaction (towards A) is %d kN'%Xa)\n",
    "print('The reaction (downwards) at B is %f kN'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.5 Resultant of Forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at F i.e Rf is 3500.000000 N\n",
      "The reaction at D i.e Rd is 1000.000000 N\n",
      "The reaction at pt E i.e Re is 833.333333 N\n",
      "The reaction at pt A i.e Ra is -333.333333 N\n"
     ]
    }
   ],
   "source": [
    "import numpy\n",
    "#Initilization of variables\n",
    "W=1000 #N\n",
    "Lad=7.5 #m\n",
    "Lae=1.5 #m\n",
    "La1=3.75 #m #distance of 1st 1000N load from pt A\n",
    "La2=5 #m #distance of 2nd 1000N load from pt A\n",
    "La3=6 #m # distance of 3rd 1000N load from pt A\n",
    "# Calculations (part1)\n",
    "#using matrix to solve the given eqn's 1 & 2\n",
    "A=numpy.matrix('1 -2.5;3.5 -5')\n",
    "B=numpy.matrix('1000;7250')\n",
    "C=numpy.linalg.inv(A)*B\n",
    "#Calculations (part 2)\n",
    "#Consider combined F.B.D of beams AB,BC &CD. Take moment at A\n",
    "Re=((W*La1)+(W*La2)+(W*La3)+(C[1]*Lad)-(C[0]*La3))/Lae #N\n",
    "Ra=C[1]-Re-C[0]+(3*W) #N #Taking sum of forces in Y direction\n",
    "#Results\n",
    "print('The reaction at F i.e Rf is %f N'%C[0])\n",
    "print('The reaction at D i.e Rd is %f N'%C[1])\n",
    "print('The reaction at pt E i.e Re is %f N'%Re)\n",
    "print('The reaction at pt A i.e Ra is %f N'%Ra) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.6 Resultant of forces in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The angle theta is 15.945396 degrees\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "W=100 # N #force acting at D\n",
    "AB=50 # N # weight of bar ab\n",
    "CD=50 # N # weight of bar cd\n",
    "# Calculations\n",
    "# From  the derived expression the value of the angle is given as,\n",
    "theta=math.degrees(math.atan(5/17.5)) #degrees\n",
    "# Results\n",
    "print('The angle theta is %f degrees'%theta)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.7 Resultant of forces in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction at wheel A is 0.950000 kN\n",
      "The reaction at wheel B is 0.950000 kN\n",
      "The reaction at wheel C is 0.600000 kN\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "Ws=2 #kN #weight of scooter\n",
    "Wd=0.5 #kN #weight of driver\n",
    "Lab=1 #m\n",
    "Led=0.8 #m\n",
    "Leg=0.1 #m\n",
    "#Calculations\n",
    "Rc=((2*Leg)+(Wd*Led))/Lab #kN #take moment at E\n",
    "Ra=(2+Wd-Rc)/2 # kN # as Ra=Rb,(Ra+Rb=2*Ra)\n",
    "Rb=Ra # kN\n",
    "#Results\n",
    "print('The reaction at wheel A is %f kN'%Ra)\n",
    "print('The reaction at wheel B is %f kN'%Rb)\n",
    "print('The reaction at wheel C is %f kN'%Rc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.8 Resultant of Forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The reaction for single force is -60 N\n",
      "The distance of Ry from A is 0.783333 m\n",
      "The moment at A is -47 N-m\n",
      "The moment at B is 25.020000 N-m\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "W1=15 #N #up\n",
    "W2=60 #N #down\n",
    "W3=10 #N #up\n",
    "W4=25 #N #down\n",
    "Lab=1.2 #m\n",
    "Lac=0.4 #m\n",
    "Lcd=0.3 #m\n",
    "Ldb=0.5 #m\n",
    "Lad=0.7 #m\n",
    "Leb=0.417 #m #Leb=Lab-x\n",
    "#Calculations\n",
    "#(a) A single force\n",
    "Ry=W1-W2+W3-W4 #N #take sum Fy=0\n",
    "x=((-W2*Lac)+(W3*Lad)-(W4*Lab))/(Ry) #m\n",
    "# (b) Single force moment at A\n",
    "Ma=(Ry*x) #N-m\n",
    "# Single force moment at B\n",
    "Mb=W2*Leb #N-m\n",
    "#Results\n",
    "print('The reaction for single force is %d N'%Ry)\n",
    "print('The distance of Ry from A is %f m'%x)\n",
    "print('The moment at A is %d N-m'%Ma)\n",
    "print('The moment at B is %f N-m'%Mb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.9 Resultant of Forces in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tension in wire 1 i.e T1 is 8101.126884 N \n",
      "\n",
      "Tension in wire 2 i.e T2 is 6786.756093 N \n",
      "\n",
      "Tension in wire 3 i.e T3 is 4444.444444 N \n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "Ra=5000 #N\n",
    "Ma=10000 #Nm\n",
    "alpha=60 #degree #angle made by T1 with the pole\n",
    "beta=45 #degree #angle made by T2 with the pole\n",
    "theta=30 #degree #angle made by T3 with the pole\n",
    "Lab=6 #m\n",
    "Lac=1.5 #m\n",
    "Lcb=4.5 #m\n",
    "#Calculations\n",
    "T3=Ma/(4.5*math.sin(theta*math.pi/180)) #N #take moment at B\n",
    "# Now we use matrix to solve eqn's 1 & 2 simultaneously,\n",
    "A=numpy.matrix('-0.707 0.8666;0.707 0.5')\n",
    "B=numpy.matrix('2222.2;8848.8')\n",
    "C=numpy.linalg.inv(A)*B\n",
    "#Results\n",
    "print('Tension in wire 1 i.e T1 is %f N \\n'%C[1])\n",
    "print('Tension in wire 2 i.e T2 is %f N \\n'%C[0])\n",
    "print('Tension in wire 3 i.e T3 is %f N \\n'%T3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.10 Distributed Force in a Plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resultant of the distibuted load lies at 2 m\n",
      "The reaction at support A is 1000 N\n",
      "The reaction at support B is 2000 N\n"
     ]
    }
   ],
   "source": [
    "#Initilization of variables\n",
    "w=2000 #N/m\n",
    "Lab=3 #m\n",
    "#Calculations\n",
    "W=w*Lab/2 #N# Area under the curve\n",
    "Lac=(2/3)*Lab #m#centroid of the triangular load system\n",
    "Rb=(W*Lac)/Lab #N #sum of moment at A\n",
    "Ra=W-Rb #N\n",
    "#Results\n",
    "print('The resultant of the distibuted load lies at %d m'%Lac)\n",
    "print('The reaction at support A is %d N'%Ra)\n",
    "print('The reaction at support B is %d N'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.11 Distributed force in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resultant is 2000 N and the line of action of the force is 3 m\n"
     ]
    }
   ],
   "source": [
    "#Initiization of variables\n",
    "w=1500 #N/m\n",
    "x=4 #m\n",
    "L=4 #m\n",
    "#Calculations\n",
    "k=x**2/w #m**3/N\n",
    "#Solving the intergral we get\n",
    "W=L**3/(3*k) #N\n",
    "x_bar=L**4/(4*k*W) #m\n",
    "#Result\n",
    "print(\"The resultant is %d N and the line of action of the force is %d m\"%(W,x_bar))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.12 Distributed force in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resultant of the distributed load system is 18 kN\n",
      "The line of action of the resulting load is 3.500000 m\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "w1=1.5 #kN/m # intensity of varying load at the starting point of the beam\n",
    "w2=4.5 #kN/m # intensity of varying load at the end of the beam\n",
    "l=6 #m # ength of the beam\n",
    "# Calculations\n",
    "# The varying load distribution is divided into a rectangle and a right angled triangle\n",
    "W1=w1*l #kN # where W1 is the area of the load diagram(rectangle ABED)\n",
    "x1=l/2 #m # centroid of the rectangular load system\n",
    "W2=(w2-w1)*l/2 #kN # where W1 is the area of the load diagram(triangle DCE)\n",
    "x2=2*l/3 #m # centroid of the triangular load system\n",
    "W=W1+W2 #kN # W is the resultant\n",
    "x=((W1*x1)+(W2*x2))/W #m # where x is the distance where the resultant lies\n",
    "#Results\n",
    "print('The resultant of the distributed load system is %d kN'%W)\n",
    "print('The line of action of the resulting load is %f m'%x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.13 Distributed forces in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The horizontal reaction at A i.e Xa is 17.320508 kN\n",
      "The vertical reaction at A i.e Ya is 10 kN\n",
      "The reaction at A i.e Ra is 20 kN\n",
      "The reaction at B i.e Rb is 45 kN\n"
     ]
    }
   ],
   "source": [
    "# Initiization of variables\n",
    "W1=10 #kN #point load acting at D\n",
    "W2=20 #kN # point load acting at C at an angle of 30 degree\n",
    "W3=5 #kN/m # intensity of udl acting on span EB of 4m\n",
    "W4=10 #kN/m # intensity of varying load acting on span BC of 3m\n",
    "M=25 #kN-m # moment acting at E\n",
    "theta=30 #degree # angle made by 20 kN load with the beam\n",
    "Lad=2 #m\n",
    "Leb=4 #m\n",
    "Laf=6 #m #distance between the resultant of W3 & point A\n",
    "Lac=11 #m\n",
    "Lag=9 #m #distance between the resultant of W4 and point A\n",
    "Lbc=3 #m\n",
    "Lab=8 #m\n",
    "# Calculations\n",
    "Xa=20*math.cos(theta*math.pi/180) #kN # sum Fx=0\n",
    "Rb=((W1*Lad)+(-M)+(W3*Leb*Laf)+(W2*math.sin(theta*math.pi/180)*Lac)+((W4*Lbc*Lag)/2))/Lab #kN # taking moment at A\n",
    "Ya=W1+(W2*math.sin(theta*math.pi/180))+(W3*Leb)+(W4*Lbc/2)-Rb #kN # sum Fy=0\n",
    "Ra=math.sqrt(Xa**2+Ya**2) #kN # resultant at A\n",
    "#Results\n",
    "print('The horizontal reaction at A i.e Xa is %f kN'%Xa)\n",
    "print('The vertical reaction at A i.e Ya is %d kN'%Ya)\n",
    "print('The reaction at A i.e Ra is %d kN'%Ra)\n",
    "print('The reaction at B i.e Rb is %d kN'%Rb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 3.14 Distributed forces in a plane"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The minimum width which is to be provided to the dam to prevent overturning about point B is 1.490712 m\n"
     ]
    }
   ],
   "source": [
    "# Initilization of variables\n",
    "h=4 #m #height of the dam wall\n",
    "rho_w=1000 # kg/m**3 # density of water\n",
    "rho_c=2400 # kg/m**3 # density of concrete\n",
    "g=9.81 # m/s**2\n",
    "# Calculations\n",
    "P=(rho_w*g*h**2)/2 # The resultant force due to water pressure per unit length of the dam\n",
    "x=(2/3)*h #m # distance at which the resutant of the triangular load acts \n",
    "b=math.sqrt((2*P*h)/(3*h*rho_c*g)) # m # eq'n required to find the minimum width of the dam\n",
    "# Results\n",
    "print('The minimum width which is to be provided to the dam to prevent overturning about point B is %f m'%b)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  },
  "widgets": {
   "state": {},
   "version": "1.1.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}