{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Dynamics of Electric Drives"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.1,Page no:34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "MoI=0.3              #Moment of inertia of motor[Kg-m**2]\n",
      "T=20                 #Torque developed[N-m]\n",
      "MoIshaft=10          #Shaft load moment of inertia in Kg-m**2\n",
      "LostT=10             #Torque lost [%]\n",
      "\n",
      "#Calculation\n",
      "MoItotal=MoI+MoIshaft            #Total moment of inertia in Kg-m**2\n",
      "LoadTorque=T-T*LostT/100         # Load torque in N-m\n",
      "\n",
      "#Result\n",
      "print\"Total Moment of Inertia: \",MoItotal,\"Kg-m**2\"\n",
      "print\"Load Torque is:\",LoadTorque,\"N-m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Moment of Inertia:  10.3 Kg-m**2\n",
        "Load Torque is: 18 N-m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.2,Page no:34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from fractions import Fraction\n",
      "from decimal import Decimal\n",
      "#Variable declaration\n",
      "n=0.1                #teeth ratio\n",
      "ETAg=90/100.0        #efficiency\n",
      "J0=0.4               #Inertia of motor Kg-m**2\n",
      "J1=10                #Load moment of inertia Kg-m**2\n",
      "TL=50                #Torque N-m\n",
      "N=1400               #speed in rpm\n",
      "\n",
      "#Calculation\n",
      "J=J0+n**2*J1         #Kg-m**2\n",
      "T=n*TL/ETAg          #Load torque referred to motor side in [N-m]\n",
      "MotorSpeed=2*math.pi*N/60     #Speed of motor [rad/sec]\n",
      "Pdev=MotorSpeed*T             #Power developed by motor [Watt]\n",
      "\n",
      "#Result\n",
      "print\"Equivalent Inertia: \",J,\"Kg-m^2\"\n",
      "print\"Load Torque refered to motor side : \",round(T,3),\"N-m,(which is equal to 50/9 N in fraction)\"\n",
      "print\"Power developed by motor: \",round(Pdev,3),\"W\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equivalent Inertia:  0.5 Kg-m^2\n",
        "Load Torque refered to motor side :  5.556 N-m,(which is equal to 50/9 N in fraction)\n",
        "Power developed by motor:  814.487 W\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.3,Page no:35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "v=60.0                 #Velocity of train Km/hr\n",
      "w=400.0                #Total weight of train in KN\n",
      "friction=5.0           #frictional resistance  N/KN weight\n",
      "tan_theta=1/100.0      #inclination\n",
      "g=9.81                 # gravity constant\n",
      "\n",
      "#Calculation\n",
      "\n",
      "#Part(a):\n",
      "sin_theta=tan_theta \n",
      "W_sin_theta=w*1000*sin_theta           #N\n",
      "R=friction*W_sin_theta/10.0            #frictional resistance in N\n",
      "P=W_sin_theta+R                        #Total force opposing motion[N]\n",
      "v=60*1000/60.0/60.0                    #Speed of traing[m/s]\n",
      "Power=P*v                              #Power[Watt]\n",
      "Force=P                                #down the inclined force in N\n",
      "\n",
      "#Part(b):\n",
      "u=v #initial velocity in m/s\n",
      "v=0 #final velocity in m/s\n",
      "m=w*1000/g #in Kg\n",
      "KE=1.0/2.0*m*u**2 #in Joule\n",
      "d=KE/P #distance in meter\n",
      "\n",
      "#Result\n",
      "print\"(a).Final KW rating of the motor of train : \",Power/1000.0,\"KW\"\n",
      "print\"(b).Distance covered : \",d,\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Final KW rating of the motor of train :  100.0 KW\n",
        "(b).Distance covered :  943.859251708 m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.4,Page no:35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "MotorOutput=200.0                        #Increased output of motor in KW\n",
      "v=60.0                                   #Velocity of train in Km/hr\n",
      "w=400.0                                  #Total weight of train in KN\n",
      "friction=5.0                             #frictional resistance in N/KN weight\n",
      "tan_theta=1/100.0                        #inclination\n",
      "g=9.81                                   # gravity constant\n",
      "\n",
      "#Calculation\n",
      "sin_theta=tan_theta \n",
      "W_sin_theta=w*1000*sin_theta             #N\n",
      "R=friction*W_sin_theta/10                #frictional resistance in N\n",
      "P=W_sin_theta+R                          #N\n",
      "v=60*1000.0/60.0/60.0                    #Velocity of train[m/s]\n",
      "Power=P*v                                #Power[Watt]\n",
      "Pdash=MotorOutput*1000-Power             #Power causes acceleration in watt or N-m/s\n",
      "m=w*1000.0/g                             #Mass in Kg\n",
      "a=Pdash/m                                #Acceleration of train in m/s**2\n",
      "\n",
      "#Result\n",
      "print\"Acceleration is: \",round(a,3),\"m/s**2\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Acceleration is:  2.453 m/s**2\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.5,Page no:36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "MotorSpeed=200                        #Speed of motor [rpm]\n",
      "d1=50                                 #diameter of motor pulley in cm\n",
      "MachineSpeed=100                      #Speed of machine [rpm]\n",
      "\n",
      "#Calculation\n",
      "d2=MotorSpeed/MachineSpeed*d1         #diameter of machine pulley in cm\n",
      "\n",
      "#Result\n",
      "print\"Diameter of machine pulley : \",d2,\"cm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of machine pulley :  100 cm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.6,Page no:36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "v=1.2                    #belt conveyer speed in m/s\n",
      "TransRate=100            #rate of transportation of material in tons/hour\n",
      "l=200                    #length of belt in meter\n",
      "MotorSpeed=1200          #Speed of motor in rpm\n",
      "MoI=0.1                  #Moment of Inertia in Kg-m**2\n",
      "\n",
      "\n",
      "#Calculation\n",
      "#Part A\n",
      "TransRate=TransRate*1000/60.0/60.0 #rate of transportation of material in Kg/sec\n",
      "TransTime=l/v #Time of transportation [sec]\n",
      "omega=MotorSpeed*2*math.pi/60.0 #Angular velocity [rad/sec]\n",
      "M=TransRate*TransTime #Mass of material carried[Kg]\n",
      "J=M*(v/omega)**2 #Total inertia[Kg-m**2]\n",
      "#Part B\n",
      "t=8 #Time [sec]\n",
      "a=v/t #Acceleration [m/s**2]\n",
      "TorqueInertai=MoI*omega/t #Torque required for inertia [N-m]\n",
      "F=M*a #Force[N]\n",
      "Tload=F*v/omega #Totruq to accelerate load [N-m]\n",
      "TotalTorque=Tload+TorqueInertai #Total torque[N-m]\n",
      "\n",
      "#Result\n",
      "print\"(a).Load Inertia  : \",round(J,4),\"Kg-m**2\"\n",
      "print\"(b).Total Torque is: \",round(TotalTorque,2),\"N-m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Load Inertia  :  0.4222 Kg-m**2\n",
        "(b).Total Torque is:  8.2 N-m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.7,Page no:37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "w=400                  #Weight to be lifted Kg\n",
      "v=1                    #Uniform velocity m/s\n",
      "MotorSpeed=1000        #Motor speed rpm\n",
      "MoI=0.5                #Moment of Inertia in Kg-m**2\n",
      "winch=0.3              #Moment of inertia of winch Kg-m**2\n",
      "Tnl=80                 #Torque in absence of wt in N-m\n",
      "Speed_nl=1000          #speed of motor in rpm\n",
      "g=9.81                 #gravity constant\n",
      "\n",
      "#Calculation\n",
      "mass=w*g #N\n",
      "omega=MotorSpeed*2*math.pi/60 #rad/sec\n",
      "TotTorque=Tnl+mass*v/omega #Total torque [N-m]\n",
      "J=MoI+winch+w*(v/omega)**2 #Kg-m**2\n",
      "\n",
      "#Result\n",
      "print\"Total Motor Torque  :  \",round(TotTorque,2),\"N-m\"\n",
      "print\"Moment of Inertia refered to motor shaft : \",round(J,4),\"Kg-m**2\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Motor Torque  :   117.47 N-m\n",
        "Moment of Inertia refered to motor shaft :  0.8365 Kg-m**2\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.9,Page no:38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "Jmotor=0.3                 #Inertia of motor in Kg-m**2\n",
      "Jgd_load=15.0              #Kg-m**2(Inertia gear driven load)\n",
      "GSRratio=0.1               #gear speed reduction ratio\n",
      "Jbd_load=0.6               #Kg-m**2(Inertia belt driven load)\n",
      "d1=10.0                    #cm(diameter of driver pulley)\n",
      "d2=30.0                    #cm(diameter of driven pulley)\n",
      "MotorSpeed=1440.0          #Speed of motor in rpm\n",
      "Tload1=100.0               #Troque on load 1 N-m\n",
      "Tload2=35.0                #Torque on load 2 in N-m\n",
      "\n",
      "\n",
      "#Calculation\n",
      "MotorSpeed=MotorSpeed*2*math.pi/60.0 #Speed of motor [rad/sec]\n",
      "Speed_gd=GSRratio*MotorSpeed #Speed of load driven gear[rad/sec]\n",
      "Speed_bd=MotorSpeed*d1/d2 #Speed of belt driven load[rad/sec]\n",
      "\n",
      "#Equating Kinetic Energies\n",
      "#1/2*J*MotorSpeed**2=1/2*Jmotor*MotorSpeed**2+1/2*Jgd_load*speed_gd**2+1/2*Jbd_load*speed_bd**2\n",
      "J=(1/2.0*Jmotor*MotorSpeed**2+1/2.0*Jgd_load*Speed_gd**2+1/2.0*Jbd_load*Speed_bd**2)*2.0/MotorSpeed**2.0   #Equivalent inertia \n",
      "\n",
      "#Equating power of motor\n",
      "#T*(MotorSpeed)=Tload1*Speed_gd+Tload2*Speed_bd\n",
      "T=(Tload1*Speed_gd+Tload2*Speed_bd)/MotorSpeed #Torque at motor shaft[N-m]\n",
      "Pdev=T*MotorSpeed #Power developed by motor [watt]\n",
      "\n",
      "\n",
      "#Result\n",
      "print\"Moment of Inertia refered to motor shaft : \",round(J,4),\"Kg-m^2\"\n",
      "print\"Torque is: \",round(T,3),\"N-m\"\n",
      "print\"Power developed by the motor: \",round(Pdev,1),\"W\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Moment of Inertia refered to motor shaft :  0.5167 Kg-m^2\n",
        "Torque is:  21.667 N-m\n",
        "Power developed by the motor:  3267.3 W\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.10,Page no:39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Variable declaration\n",
      "MotorSpeed=1440                #Motor speed rpm\n",
      "Jmotor=0.4                     # Moment of inertia of motor Kg-m**2\n",
      "Jdc_load=0.6                   #Kg-m**2(Inertia directly coupled load)\n",
      "w_tl=100                       #kg(weight of transratioonal load)\n",
      "F_res=1.2                      #N/Kg(Friction resistance for translational load)\n",
      "v=10                           #Velocity of translational load in m/s\n",
      "T_RotLoad=1.5                  #Torque of rotational load in N-m\n",
      "g=9.81                         #gravity constant\n",
      "\n",
      "#Calculation\n",
      "MotorSpeed=MotorSpeed*2*math.pi/60 #Motor speed [rad/sec]\n",
      "F_horz=w_tl*F_res #N(horizontal force of translational load)\n",
      "mass=w_tl*g #Mass of load[N]\n",
      "J=Jmotor+Jdc_load+mass*(v/MotorSpeed)**2 #Inertia [Kg-m**2]\n",
      "T=T_RotLoad+F_horz*v/MotorSpeed #Torque at motor shaft[N-m]\n",
      "\n",
      "#Result\n",
      "print\"Moment of Inertia at motor shaft is:\",round(J,3),\"Kg-m^2\"\n",
      "print\"Torque at motor shaft: \",round(T,2),\"N-m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Moment of Inertia at motor shaft is: 5.314 Kg-m^2\n",
        "Torque at motor shaft:  9.46 N-m\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.11,Page no:41"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "import numpy as np\n",
      "from scipy import misc\n",
      "#Variable declaration\n",
      "#T=0.6+1.9*omega_m\n",
      "#TL=2.8*math.sqrt(omega_m)\n",
      "def T(w):\n",
      "    return(0.6+1.9*w)\n",
      "def Tl(w):\n",
      "     return(2.8*w**0.5)\n",
      "    \n",
      "#Calculation\n",
      "coeff = [3.61,-5.56,0.36]\n",
      "W=np.roots(coeff)\n",
      "dT_dw=range(2)\n",
      "dTl_dw=range(2)\n",
      "for i in range(0,2):\n",
      "    dT_dw[i]=scipy.misc.derivative(T,W[i],dx=1e-6)\n",
      "    dTl_dw[i]=scipy.misc.derivative(Tl,W[i], dx=1e-6)\n",
      "\n",
      "#Result    \n",
      "print\"w=\",round(W[0],2),\"or\",round(W[1],3),\"rad/sec\"\n",
      "for i in range(0,2):  \n",
      "    print\"At,w=\",round(W[i],3),\"rad/s\"\n",
      "    if dTl_dw[i] < dT_dw[i]:\n",
      "        print \"This operating point does not have steady state stability\"\n",
      "    elif dTl_dw[i] > dT_dw[i]:\n",
      "        print \"This operating point has steady state stability\"  \n",
      "        print\"\\nANSWER: Thus,wm=\",round(W[i],3),\"rad/sec\"\n",
      "   \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "w= 1.47 or 0.068 rad/sec\n",
        "At,w= 1.472 rad/s\n",
        "This operating point does not have steady state stability\n",
        "At,w= 0.068 rad/s\n",
        "This operating point has steady state stability\n",
        "\n",
        "ANSWER: Thus,wm= 0.068 rad/sec\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example no:3.12,Page no:42"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "from scipy.optimize import fsolve\n",
      "\n",
      "\n",
      "#Variable declaration\n",
      "#T=15-0.5*omega_m\n",
      "#TL=0.5*omega_m**2\n",
      "def T(w):\n",
      "    return(15-0.5*w)\n",
      "def Tl(w):\n",
      "     return(0.5*w**2)\n",
      "\n",
      "    \n",
      "#Calculation\n",
      "P=[1,1,-30] #Polynomial for omega_m calculated by equating T=TL\n",
      "omega_m=np.roots(P) #Angular velctiy rad/sec\n",
      "coeff = [1,1,-30]\n",
      "W=np.roots(coeff)\n",
      "dT_dw=range(2)\n",
      "dTl_dw=range(2)\n",
      "for i in range(0,2):\n",
      "    dT_dw[i]=scipy.misc.derivative(T,W[i],dx=1e-6)\n",
      "    dTl_dw[i]=scipy.misc.derivative(Tl,W[i], dx=1e-6)\n",
      "\n",
      "#Result    \n",
      "print\"w=\",round(W[0],2),\"or\",round(W[1],3),\"rad/sec\"\n",
      "for i in range(0,2):  \n",
      "    print\"At,w=\",round(W[i],3),\"rad/s\"\n",
      "    if dTl_dw[i] < dT_dw[i]:\n",
      "        print \"This operating point does not have steady state stability\"\n",
      "    elif dTl_dw[i] > dT_dw[i]:\n",
      "        print \"This operating point has steady state stability\"  \n",
      "        print\"\\nANSWER: Thus,wm=\",round(W[i],3),\"rad/sec\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "w= -6.0 or 5.0 rad/sec\n",
        "At,w= -6.0 rad/s\n",
        "This operating point does not have steady state stability\n",
        "At,w= 5.0 rad/s\n",
        "This operating point has steady state stability\n",
        "\n",
        "ANSWER: Thus,wm= 5.0 rad/sec\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}