{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 - DC machines"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.1 Pg No: 174"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Current delievered in 50kw generator = 62.50 amperes\n",
      "    Current delievered in 100kw generator = 187.50 amperes\n",
      "(b) Terminal voltage = 481.25 volts\n"
     ]
    }
   ],
   "source": [
    "#for 50kw generator\n",
    "I_1=50*1000/500 #  full load current in ampere\n",
    "V_1=0.06*500 #  full load voltage drop in volts\n",
    "V_1pi=V_1/I_1 #  voltage drop per ampere of current supply in volts/ampere\n",
    "#for 100kw generator\n",
    "I_2=100*1000/500 #  full load current in ampere\n",
    "V_2=0.04*500 #  full load voltage drop in volts\n",
    "V_2pi=V_2/I_2 #  voltage drop per ampere of current supply in volts/ampere\n",
    "i_1=250/(1+(V_1pi/V_2pi)) #  amperes\n",
    "i_2=250/(1+(V_2pi/V_1pi)) #  amperes\n",
    "print '(a) Current delievered in 50kw generator = %.2f amperes'%i_1\n",
    "print '    Current delievered in 100kw generator = %.2f amperes'%i_2\n",
    "V_t=500-V_1pi*i_1 #  volts\n",
    "print '(b) Terminal voltage = %.2f volts'%V_t"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.2 Pg No: 174"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power shared by generator-1 = 17.21 kilo Watts\n",
      "Power shared by generator-2 = 7.79 kilo Watts\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "E_g1=120 #  volts\n",
    "E_g2=115 #  volts\n",
    "R_a1=0.05 #  armature winding resistance of first generator = %.2f ohms)\n",
    "R_a2=0.04 #  armature winding resistance of second generator = %.2f ohms)\n",
    "R_f1=20 #  feild winding resistance of first generator = %.2f ohms)\n",
    "R_f2=25 #  feild winding resistance of seccond generator = %.2f ohms)\n",
    "P=25000 #  watts\n",
    "V_t=(5275+sqrt((5275**2)-(4*45.09*25000)))/(2*45.09) #  terminal voltage in volts\n",
    "I_1=(E_g1-(V_t*(1+(R_a1/R_f1))))/R_a1 #  amperes\n",
    "I_2=(E_g2-(V_t*(1+(R_a2/R_f2))))/R_a2 #  amperes\n",
    "P_1=V_t*I_1/1000 #  kilo watts\n",
    "P_2=V_t*I_2/1000 #  kilo watts\n",
    "print 'Power shared by generator-1 = %.2f kilo Watts'%P_1\n",
    "print 'Power shared by generator-2 = %.2f kilo Watts'%P_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.3 Pg No: 175"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of conductors= 750.0\n"
     ]
    }
   ],
   "source": [
    "P=8 #  no. of poles\n",
    "A=8\n",
    "Phy=40*10**-3 #  flux in weber\n",
    "N=500 #  speed in rpm\n",
    "E_g=250 #  no-load voltage in volts\n",
    "Z=(E_g*60*A)/(P*N*Phy)\n",
    "print 'Number of conductors=',Z"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.4 Pg No: 175"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of generated voltage = 320.09 volts\n",
      "Value of armature current = 201.00 Ampers\n"
     ]
    }
   ],
   "source": [
    "V_t=300 #  volts\n",
    "V_b=1 #  voltage drop per brush in volts\n",
    "I=200 #  amperes\n",
    "R_f=200 #  shunt feild winding resistance in ohms\n",
    "R_a=0.05 #  armature winding resistance in ohms\n",
    "R_se=0.04 #  Series feild winding resistance in ohms\n",
    "I_f=V_t/R_f #  amperes\n",
    "I_a=I+I_f #  amperes\n",
    "E_g=V_t+(R_a+R_se)*I_a+(2*V_b)\n",
    "print 'Value of generated voltage = %.2f volts'%E_g\n",
    "print 'Value of armature current = %.2f Ampers'%I_a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.5 Pg No: 175"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Value of shunt feild current = 5.00 Amperes\n",
      "(b) Value of armature current = 200.00 Amperes\n",
      "(c) Value of generated voltage = 260.00 volts\n",
      "(d) Value of load resistance = 1.00 ohms\n"
     ]
    }
   ],
   "source": [
    "V_t=250 #  volts\n",
    "I=195 #  amperes\n",
    "R_f=50 #  shunt feild winding resistance in ohms\n",
    "R_a=0.05 #  armature winding resistance in ohms\n",
    "I_f=V_t/R_f #  amperes\n",
    "I_a=I+I_f #  amperes\n",
    "E_g=V_t+(R_a*I_a)\n",
    "R_L=V_t/I\n",
    "print '(a) Value of shunt feild current = %.2f Amperes'%I_f\n",
    "print '(b) Value of armature current = %.2f Amperes'%I_a\n",
    "print '(c) Value of generated voltage = %.2f volts'%E_g\n",
    "print '(d) Value of load resistance = %.2f ohms'%R_L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.6 Pg No: 176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Value of armature current = 42.52 Amperes\n",
      " Value of generated voltage = 255.85 volts\n"
     ]
    }
   ],
   "source": [
    "V_t=250 #  volts\n",
    "V_AC=V_t\n",
    "V_b=1 #  voltage drop per brush in volts\n",
    "I=40 #  amperes\n",
    "R_f=100 #  shunt feild winding resistance in ohms\n",
    "R_a=0.05 #  armature winding resistance in ohms\n",
    "R_se=0.04 #  series feild winding resistance in ohms\n",
    "V_BC=V_AC+I*R_se #  volts\n",
    "I_f=V_BC/R_f #  amperes\n",
    "I_a=I+I_f #  amperes\n",
    "E_g=V_BC+(R_a*I_a)*(2*V_b)\n",
    "print ' Value of armature current = %.2f Amperes'%I_a\n",
    "print ' Value of generated voltage = %.2f volts'%E_g"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.7 Pg No: 177"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of generated emf = 221.67 volts\n"
     ]
    }
   ],
   "source": [
    "P=8 #  no. of poles\n",
    "A=8\n",
    "Z=760 #  no.of conductors\n",
    "Phy=35*10**-3 #  flux in weber\n",
    "N=500 #  speed in rpm\n",
    "E_g=(P*N*Phy*Z)/(60*A)\n",
    "print 'Value of generated emf = %.2f volts'%E_g"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.8 Pg No: 178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed of generator = 1441.79 rpm\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "P=8 #  no. of poles\n",
    "S=70 #  no. of slots\n",
    "C=22 #  conductors per slot\n",
    "A=8\n",
    "D=0.48 #  meter\n",
    "Z=S*C #  no.of conductors\n",
    "r=0.64 #  ratio of pole arc to pole pitch \n",
    "l=0.28 #  length of pole shoe in meter\n",
    "B=0.32 #  air gap flux density in weber/meter**2\n",
    "E_g=400 #  volts\n",
    "Pole_arc=r*pi*D/P #  meter\n",
    "Ao=Pole_arc*l #  Area of pole shoe in meter\n",
    "Phy=Ao*B #  weber\n",
    "N=E_g*60*A/(Phy*Z*P)\n",
    "print 'Speed of generator = %.2f rpm'%N"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.9 Pg No: 179"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Armature current = 22.00 amperes\n",
      "(b) Generated emf = 207.48 volts\n",
      "(c) flux/pole = 15.35 mili weber\n"
     ]
    }
   ],
   "source": [
    "V_t=200 #  volts\n",
    "P=4 #  no. of poles\n",
    "A=2\n",
    "Z=676 #  no.of conductors\n",
    "R_L=10 #  load resistance in ohms\n",
    "R_a=0.34 #  armature winding resistance in ohms\n",
    "R_f=100 #  feild winding resistance in ohms\n",
    "N=600 #  speed in rpm\n",
    "I_f=V_t/R_f #  amperes\n",
    "I=V_t/R_L #  amperes\n",
    "I_a=I+I_f\n",
    "E_g=V_t+I_a*R_a\n",
    "Phy=E_g*60*A/(P*N*Z)\n",
    "print '(a) Armature current = %.2f amperes'%I_a\n",
    "print '(b) Generated emf = %.2f volts'%E_g\n",
    "print '(c) flux/pole = %.2f mili weber'%(Phy*1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.10 Pg No: 180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Load current = 178.00 amperes\n",
      "(b) Generated emf = 257.20 volts\n",
      "(c) flux/pole = 22.05 mili weber\n"
     ]
    }
   ],
   "source": [
    "V_t=250 #  volts\n",
    "P=6 #  no. of poles\n",
    "A=P\n",
    "Z=700 #  no.of conductors\n",
    "R_a=0.04 #  armature winding resistance in ohms\n",
    "R_f=100 #  feild winding resistance in ohms\n",
    "N=1000 #  speed in rpm\n",
    "I_f=V_t/R_f #  amperes\n",
    "I_a=7.2/R_a #  amperes\n",
    "I=I_a-I_f #  amperes\n",
    "E_g=V_t+I_a*R_a\n",
    "Phy=E_g*60*A/(P*N*Z)\n",
    "print '(a) Load current = %.2f amperes'%I\n",
    "print '(b) Generated emf = %.2f volts'%E_g\n",
    "print '(c) flux/pole = %.2f mili weber'%(Phy*1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.11 Pg No: 182"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Armature current = 102.00 amperes\n",
      "(b) Generated emf = 231.18 volts\n",
      "(c) No. of conductors of armature= 889.15\n"
     ]
    }
   ],
   "source": [
    "P_o=22000 #  power in watts\n",
    "V_t=220 #  volts\n",
    "V_b=1 #  per brush drop in volts\n",
    "P=4 #  no. of poles\n",
    "A=2\n",
    "R_se=0.04 #  series resistance in ohms\n",
    "R_a=0.05 #  armature winding resistance in ohms\n",
    "R_f=110 #  feild winding resistance in ohms\n",
    "Phy=7.8*10**-3 #  weber\n",
    "N=1000 #  speed in rpm\n",
    "I=P_o/V_t #  amperes\n",
    "I_f=V_t/R_f #  amperes\n",
    "I_a=I+I_f\n",
    "E_g=V_t+I_a*(R_a+R_se)+2*V_b\n",
    "Z=E_g*60*A/(Phy*N*P)\n",
    "print '(a) Armature current = %.2f amperes'%I_a\n",
    "print '(b) Generated emf = %.2f volts'%E_g\n",
    "print '(c) No. of conductors of armature= %.2f'%Z"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.12 Pg No: 182"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power absorbed by the load = 10208.33 watts\n"
     ]
    }
   ],
   "source": [
    "P=6 #  no. of poles\n",
    "A=2\n",
    "Z=350 #  no. of conductors\n",
    "R_a=0.8 #  armature winding resistance in ohms\n",
    "R_f=120 #  feild winding resistance in ohms\n",
    "Phy=0.02 #  weber\n",
    "N=1000 #  speed in rpm\n",
    "R_L=12 #  load resistance in ohms\n",
    "E_g=Phy*N*Z*P/(60*A) #  emf induced in volts\n",
    "V_t=E_g/(1+((1/R_f)+(1/R_L))*R_a)\n",
    "I_L=V_t/R_L #  amperes\n",
    "P_o=V_t*I_L #  watts\n",
    "print 'Power absorbed by the load = %.2f watts'%P_o"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.13 Pg No: 182"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percentage reduction in speed = 1.70 %\n"
     ]
    }
   ],
   "source": [
    "P1=200*10**3 #  initial load in watts\n",
    "P2=125*10**3 #  final load in watts\n",
    "V_t=250 #  volts\n",
    "V_b=2 #  total brush drop in volts\n",
    "P=6 #  no. of poles\n",
    "R_a=0.015 #  armature winding resistance in ohms\n",
    "I_g1=P1/V_t #  amperes\n",
    "I_a1=I_g1 #  amperes\n",
    "E_g1=V_t+I_a1*R_a+V_b #  volts\n",
    "I_g2=P2/V_t #  amperes\n",
    "I_a2=I_g2 #  amperes\n",
    "E_g2=V_t+I_a2*R_a+V_b #  volts\n",
    "#since E_g is directly proportional to N\n",
    "#therefore,E_g1/E_g2=N_1/N_2\n",
    "r=E_g2/E_g1\n",
    "reduction=(1-r)*100\n",
    "print 'Percentage reduction in speed = %.2f %%'%reduction "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.14 Pg No: 183"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed = 510.00 rpm\n"
     ]
    }
   ],
   "source": [
    "from math import ceil\n",
    "V_t=400 #  volts\n",
    "V_b=2 #  total brush drop in volts\n",
    "R_a=0.12 #  armature winding resistance in ohms\n",
    "N1=1000 #  speed in rpm\n",
    "I_a1=150 #  amperes\n",
    "I_a2=100 #  amperes\n",
    "R_L=V_t/I_a1 #  load resistance in ohms\n",
    "E_g1=V_t+I_a1*R_a+V_b #  volts\n",
    "V_to=R_L*I_a2 #  volts\n",
    "E_g2=ceil (V_to+I_a2*R_a+V_b) #  volts\n",
    "#Since E_g is directly proportional to N\n",
    "#therefore,E_g1/E_g2=N1/N2\n",
    "N2= N1*E_g2/E_g1 #  rpm\n",
    "print 'Speed = %.2f rpm'%(ceil(N2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.15 Pg No: 184"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Cu-loss = 2242.25 watts\n",
      "(b) Iron and friction loss = 847.64 watts\n",
      "(c) Torque = 268.24 N-m\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "P_o=25000 #  output power in watts\n",
    "V_t=250 #  volts\n",
    "R_se=0.05 #  series resistance in ohms\n",
    "R_a=0.04 #  armature winding resistance in ohms\n",
    "R_f=50 #  shunt feild winding resistance in ohms\n",
    "Eff=0.89 #  efficiency\n",
    "N=1000 #  speed in rpm\n",
    "I=P_o/V_t #  amperes\n",
    "I_f=V_t/R_f #  amperes\n",
    "I_a=I+I_f\n",
    "P_cu=R_a*I_a**2+R_se*I_a**2+R_f*I_f**2 #  copper loss in watts\n",
    "print '(a) Cu-loss = %.2f watts'%P_cu\n",
    "P_i=P_o/Eff #  input power in watts\n",
    "P_L=P_i-P_o #  total losses in watts\n",
    "P_fric=P_L-P_cu\n",
    "print '(b) Iron and friction loss = %.2f watts'%P_fric\n",
    "T=P_i*60/(2*pi*N)\n",
    "print '(c) Torque = %.2f N-m'%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.16 Pg No: 184"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Flux per pole = 0.02 Weber\n",
      "(b) Total no. of conductors=340.00\n",
      "(c) Torque = 63.67 Newton-meter\n"
     ]
    }
   ],
   "source": [
    "from math import pi,ceil\n",
    "I_a=50 #  amperes\n",
    "P=6 #  no.of poles\n",
    "E_g=200 #  volts\n",
    "N=1500 #  speed in rpm\n",
    "A=6\n",
    "L=0.25 #  meter\n",
    "d=0.2 #  meter\n",
    "B=0.9 #  tesla\n",
    "Theta=360/P #  angle subtended by pole shoe in degrees\n",
    "l=pi*L*Theta/360 #  arc length of pole shoe in meter\n",
    "area=l*d #  meter**2\n",
    "Phy=B*area\n",
    "print '(a) Flux per pole = %.2f Weber'%Phy\n",
    "Z=ceil(E_g*60/(Phy*N))\n",
    "print '(b) Total no. of conductors=%.2f'%Z\n",
    "T=9.55*E_g*I_a/N\n",
    "print '(c) Torque = %.2f Newton-meter'%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.17 Pg No: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Demagnetizing Ampere Turns per pole=500.00\n",
      "(b) Cross magnetizing Ampere Turns per pole=0.00\n",
      "(c) Number of turns per pole=18.00\n"
     ]
    }
   ],
   "source": [
    "P=40000 #  watts\n",
    "E_g=400 #  volts\n",
    "A=4\n",
    "Pole=4\n",
    "Z=2*30*12 #  no. of conductors\n",
    "theta_m=10 #  degrees\n",
    "I_a=P/E_g #  armature current in amperes\n",
    "I=I_a/A #  current in each conductor in amperes\n",
    "AT_d=Z*I*theta_m/360\n",
    "print '(a) Demagnetizing Ampere Turns per pole=%.2f'%AT_d\n",
    "AT_cm=Z*I*((1/(2*Pole))-(theta_m/360))\n",
    "print '(b) Cross magnetizing Ampere Turns per pole=%.2f'%AT_cm\n",
    "n=Z*I*0.8/(2*Pole*100)\n",
    "print '(c) Number of turns per pole=%.2f'%n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.18 Pg No: 185"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Current supplied by generator-1 = 20.00 amperes\n",
      "    Current supplied by generator-2 = 40.00 amperes\n",
      "(b) Output voltage of generator-1 = 260.00 volts\n",
      "(b) Output voltage of generator-2 = 260.00 volts\n",
      "(c) Output KW of generator-1 = 5.00 kilo watts\n",
      "(c) Output KW of generator-2 = 10.00 kilo watts\n"
     ]
    }
   ],
   "source": [
    "V_t1=280 #  terminal voltage of generator-1 in volts\n",
    "V_nl1=240 #  no-load voltage of generator-1 in volts\n",
    "V_t2=300 #  terminal voltage of generator-2 in volts\n",
    "V_nl2=240 #  no-load voltage of generator-2 in volts\n",
    "I_s1=40 #  supply current to generator-1 in amperes\n",
    "I_s2=50 #  supply current to generator-2 in amperes\n",
    "V_d1=V_t1-V_nl1 #  voltage drop for generator-1 in volts\n",
    "V_d2=V_t2-V_nl2 #  voltage drop for generator-2 in volts\n",
    "V_d1_pa=V_d1/I_s1 #  voltage drop per ampere for generator-1 in volts/ampere\n",
    "V_d2_pa=V_d2/I_s2 #  voltage drop per ampere for generator-2 in volts/ampere\n",
    "I_2=(20+60)/(V_d1_pa+V_d2_pa) #  amperes\n",
    "I_1=60-I_2 #  amperes\n",
    "print '(a) Current supplied by generator-1 = %.2f amperes'%I_1\n",
    "print '    Current supplied by generator-2 = %.2f amperes'%I_2\n",
    "V_1=V_t1-(V_d1_pa*I_1) #  volts\n",
    "V_2=V_t2-(V_d2_pa*I_2) #  volts\n",
    "print '(b) Output voltage of generator-1 = %.2f volts'%V_1\n",
    "print '(b) Output voltage of generator-2 = %.2f volts'%V_2\n",
    "P_1=V_1*I_1/1000 #  kilo watts\n",
    "P_2=V_2*I_2/1000 #  kilo watts\n",
    "print '(c) Output KW of generator-1 = %.2f kilo watts'%P_1\n",
    "print '(c) Output KW of generator-2 = %.2f kilo watts'%P_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.19 Pg No: 186"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ratio of speed as a generator to speed as motor=1.08\n"
     ]
    }
   ],
   "source": [
    "V=250 #  volts\n",
    "I_L=80 #  amperes\n",
    "R_a=0.12 #  ohms\n",
    "R=100 #  ohms\n",
    "I_f=V/R #  amperes\n",
    "I_a1=I_L+I_f #  amperes (generator)\n",
    "E_1=V+(I_a1*R_a) #  volts (generator)\n",
    "I_a2=I_L-I_f #  amperes (motor)\n",
    "E_2=V-(I_a2*R_a) #  volts (motor)\n",
    "Ratio=E_1/E_2\n",
    "print 'Ratio of speed as a generator to speed as motor=%.2f'%Ratio"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.20 Pg No: 186"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No-load speed = 1328.00 rpm\n"
     ]
    }
   ],
   "source": [
    "V=200 #  volts\n",
    "I_a0=2 #  amperes\n",
    "R_a=0.4 #  ohms\n",
    "I_a1=50 #  amperes\n",
    "N_1=1200 #  rpm\n",
    "E_0=V-(I_a0*R_a) #  volts \n",
    "E_1=V-(I_a1*R_a) #  volts \n",
    "N_0=N_1*(E_0/E_1) #  rpm\n",
    "print 'No-load speed = %.2f rpm'%N_0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.21 Pg No: 187"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "speed of motor = 963.88 rpm\n"
     ]
    }
   ],
   "source": [
    "V=250 #  volts\n",
    "I_L1=5 #  amperes\n",
    "R_a=0.2 #  ohms\n",
    "R_f=250 #  ohms\n",
    "I_f=V/R_f #  amperes\n",
    "I_a1=I_L1-I_f #  amperes\n",
    "I_L2=50 #  amperes\n",
    "I_a2=I_L2-I_f #  amperes\n",
    "N_1=1000 #  rpm\n",
    "E_2=V-(I_a2*R_a) #  volts \n",
    "E_1=V-(I_a1*R_a) #  volts \n",
    "N_2=N_1*(E_2/E_1) #  rpm\n",
    "print 'speed of motor = %.2f rpm'%N_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.22 Pg No: 187"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "speed of motor = 381.00 rpm\n"
     ]
    }
   ],
   "source": [
    "V=250 #  volts\n",
    "P_i=50*10**3 #  watts\n",
    "I_L1=P_i/V #  amperes\n",
    "R_a=0.02 #  ohms\n",
    "R_f=50 #  ohms\n",
    "I_f=V/R_f #  amperes\n",
    "I_a1=I_L1+I_f #  amperes\n",
    "I_L2=P_i/V #  amperes\n",
    "I_a2=I_L2-I_f #  amperes\n",
    "N_1=400 #  rpm\n",
    "E_2=V-(I_a2*R_a)-(2*1) #  volts \n",
    "E_1=V+(I_a1*R_a)+(2*1) #  volts \n",
    "N_2=int(N_1*(E_2/E_1)) #  rpm\n",
    "print 'speed of motor = %.2f rpm'%N_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.23 Pg No: 188"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Total torque = 135.22 Newton-meter\n",
      "(b) Useful torque = 95.49 Newton-meter\n",
      "(c) Useful flux per pole = 0.01 Weber\n",
      "(d) Rotational losses = 4160.00 Watts\n",
      "(e) Efficiency = 65.00 %\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "P=4 #  no of poles\n",
    "Z=560 #  no of conductors\n",
    "A=2\n",
    "V=250 #  volts\n",
    "P_o=10*10**3 #  watts\n",
    "R_a=0.2 #  ohms\n",
    "I_f=1 #  amperes\n",
    "I_a=60 #  amperes\n",
    "N=1000 #  rpm\n",
    "V_b=1*2#in volts\n",
    "E=V-(I_a*R_a)-V_b #  volts\n",
    "T=60*E*I_a/(2*pi*N) #  Newton-meter\n",
    "print '(a) Total torque = %.2f Newton-meter'%T\n",
    "T_useful=P_o*60/(2*pi*N)\n",
    "print '(b) Useful torque = %.2f Newton-meter'%T_useful\n",
    "Phy=60*E*A/(N*P*Z)\n",
    "print '(c) Useful flux per pole = %.2f Weber'%Phy\n",
    "P_d=(V*I_a)-((I_a**2)*R_a)-(V_b*I_a) #  Watts\n",
    "P_rot=P_d-P_o\n",
    "print '(d) Rotational losses = %.2f Watts'%P_rot\n",
    "P_i=V*(I_a+I_f) #  Watts\n",
    "Eff=P_o*100/P_i\n",
    "print '(e) Efficiency = %.2f %%'%Eff"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.24 Pg No: 189"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed = 679.00 rpm\n",
      "Percentage change in torque=100.00\n"
     ]
    }
   ],
   "source": [
    "V=460 #  volts\n",
    "R_a=0.8 #  ohms\n",
    "I_a1=40 #  amperes\n",
    "I_a2=30 #  amperes\n",
    "N_1=500 #  rpm\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "E_2=V-(I_a2*R_a) #  volts\n",
    "N_2=int(E_2*I_a1*N_1/(E_1*I_a2))\n",
    "print 'Speed = %.2f rpm'%N_2\n",
    "ratio=(I_a2/I_a1)**2\n",
    "T_c=(1-ratio)*100\n",
    "print 'Percentage change in torque=%.2f'%T_c"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.25 Pg No: 190"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed = 1147.00 rpm\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=220 #  volts\n",
    "R_a=0.1 #  ohms\n",
    "I_a1=100 #  amperes\n",
    "I_a2=sqrt(I_a1**2/2) #  amperes\n",
    "N_1=800 #  rpm\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "E_2=V-(I_a2*R_a) #  volts\n",
    "N_2=int(E_2*I_a1*N_1/(E_1*I_a2))\n",
    "print 'Speed = %.2f rpm'%N_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.26 Pg No: 192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed = 828.00 rpm\n"
     ]
    }
   ],
   "source": [
    "V=250 #  volts\n",
    "R_a=0.25 #  ohms\n",
    "I_a1=50 #  amperes\n",
    "I_a2=I_a1/0.9 #  amperes\n",
    "N_1=750 #  rpm\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "E_2=V-(I_a2*R_a) #  volts\n",
    "N_2=int(E_2*N_1/(E_1*0.9))\n",
    "print 'Speed = %.2f rpm'%N_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.27 Pg No: 192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Speed at half load = 1865 rpm\n",
      "(b) Speed at 125% load = 1767 rpm\n"
     ]
    }
   ],
   "source": [
    "V=120 #  volts\n",
    "V_b=3 #  volts\n",
    "R_a=0.2 #  ohms\n",
    "R_f=60 #  ohms\n",
    "I_L1=40 #  amperes\n",
    "I_f=V/R_f #  inn amperes\n",
    "I_a1=I_L1-I_f #  amperes\n",
    "N_1=1800 #  rpm\n",
    "E_1=V-(I_a1*R_a)-V_b #  volts\n",
    "I_L2=I_L1/2\n",
    "I_a2=I_L2-I_f\n",
    "E_2=V-(I_a2*R_a)-V_b #  volts\n",
    "N_2=int(E_2*N_1/E_1)\n",
    "print '(a) Speed at half load = %d rpm'%N_2\n",
    "I_L3=I_L1*1.25\n",
    "I_a3=I_L3-I_f\n",
    "E_3=V-(I_a3*R_a)-V_b #  volts\n",
    "N_3=int(E_3*N_1/E_1)\n",
    "print '(b) Speed at 125%% load = %d rpm'%N_3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.28 Pg No: 192"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Additional resistance = 3.82 ohms\n"
     ]
    }
   ],
   "source": [
    "V=220 #  volts\n",
    "R_a=0.1 #  ohms\n",
    "N_1=800 #  rpm\n",
    "N_2=520 #  rpm\n",
    "I_a1=20 #  ampers\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "E_2=N_2*E_1/N_1 #  volts\n",
    "R_A=-(E_2-V+I_a1*R_a)/20\n",
    "print 'Additional resistance = %.2f ohms'%R_A"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.29 Pg No: 193"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Additional resistance at starting = 5.70 ohms\n",
      "(b) Additional resistance at 1000 rpm = 1.90 ohms\n"
     ]
    }
   ],
   "source": [
    "V=240 #  volts\n",
    "R_a=0.3 #  ohms\n",
    "N_1=1500 #  rpm\n",
    "I_a=40 #  ampers\n",
    "E=V-(I_a*R_a) #  volts\n",
    "R_1=(V-I_a*R_a)/I_a\n",
    "print '(a) Additional resistance at starting = %.2f ohms'%R_1\n",
    "N_2=1000 #  rpm\n",
    "E_2=N_2*E/N_1 #  volts\n",
    "R_2=-(E_2-V+I_a*R_a)/I_a\n",
    "print '(b) Additional resistance at 1000 rpm = %.2f ohms'%R_2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.30 Pg No: 194"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Speed at full load = 535.54 rpm\n",
      "(b) Speed at double full load = 244.63 rpm\n",
      "(c) stalling torque is 2.84 times full load torque\n"
     ]
    }
   ],
   "source": [
    "V=250 #  volts\n",
    "R_a=0.2 #  ohms\n",
    "N_1=800 #  rpm\n",
    "R_f=250 #  ohms\n",
    "I_f=V/R_f #  amperes\n",
    "I=41 #  ampers\n",
    "I_a1=I-I_f #  amperes\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "E_2=V-(I_a1*(R_a+2)) #  volts\n",
    "N_2=E_2*N_1/E_1\n",
    "print '(a) Speed at full load = %.2f rpm'%N_2\n",
    "I_a2=I_a1*2 #  amperes\n",
    "E_3=V-I_a2*(R_a+2) #  volts\n",
    "N_3=E_3*N_1/E_1 #  rpm\n",
    "print '(b) Speed at double full load = %.2f rpm'%N_3\n",
    "I_ao=V/(R_a+2)\n",
    "r=I_ao/I_a1\n",
    "print '(c) stalling torque is %.2f times full load torque'%r"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.31 Pg No: 194"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the resistance to be inserted in series = 4.42 ohms\n"
     ]
    }
   ],
   "source": [
    "V=200 #  volts\n",
    "R_a=0.4 #  ohms\n",
    "N_1=1000 #  rpm\n",
    "N_2=800 #  rpm\n",
    "I_a1=20 #  amperes\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "I_a2=0.8*I_a1 #  amperes\n",
    "E_2=N_2*I_a2*E_1/(N_1*I_a1) #  volts\n",
    "R=-(E_2-193.6)/16\n",
    "print 'the resistance to be inserted in series = %.2f ohms'%R"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.32 Pg No: 195"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the resistance to be inserted in series = 6.45 ohms\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=500 #  volts\n",
    "R_a=0.5 #  ohms\n",
    "I_a1=60 #  amperes\n",
    "E_1=V-(I_a1*R_a) #  volts\n",
    "I_a2=sqrt(((0.75)**3)*I_a1**2) #  amperes\n",
    "E_2=0.75*E_1*I_a2/I_a1 #  volts\n",
    "R=-(E_2-480.5)/38.97\n",
    "print 'the resistance to be inserted in series = %.2f ohms'%R"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.33 Pg No: 196"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a) Output = 7929.60 watts\n",
      "  Efficiency = 79.30 %\n",
      "(b) Output = 46041.60 watts\n",
      "  Efficiency = 92.08 %\n"
     ]
    }
   ],
   "source": [
    "V=500 #  volts\n",
    "R_a=0.2 #  ohms\n",
    "I_o=4 #  amperes\n",
    "I_f=1 #  amperes\n",
    "P_c=V*I_o-(((I_o-I_f)**2)*R_a) #  watts\n",
    "I_1=20 #  /in amperes\n",
    "P_i1=V*I_1 #  watts\n",
    "P_a1=((I_1-I_f)**2)*R_a #  watts\n",
    "P_L1=P_c+P_a1 #  watts\n",
    "P_o1=P_i1-P_L1 #  watts\n",
    "print '(a) Output = %.2f watts'%P_o1\n",
    "print '  Efficiency = %.2f %%'%(P_o1/P_i1*100)\n",
    "I_2=100 #  /in amperes\n",
    "P_i2=V*I_2 #  watts\n",
    "P_a2=((I_2-I_f)**2)*R_a #  watts\n",
    "P_L2=P_c+P_a2 #  watts\n",
    "P_o2=P_i2-P_L2 #  watts\n",
    "print '(b) Output = %.2f watts'%P_o2\n",
    "print '  Efficiency = %.2f %%'%(P_o2/P_i2*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.34 Pg No: 196"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)no load speed = 338.93 rpm\n",
      "(b)Full load speed = 327.70 rpm\n",
      "(c)Speed Regulation = 3.43 %\n"
     ]
    }
   ],
   "source": [
    "V=240 #  volts\n",
    "V_b=2 #  volts\n",
    "R_a=0.15 #  ohms\n",
    "P=4\n",
    "Z=700\n",
    "Phy=0.06 #  Webers\n",
    "A=P\n",
    "I_o=7 #  amperes\n",
    "I_f=2 #  amperes\n",
    "I=90 #  amperes\n",
    "I_ao=I_o-I_f #  amperes\n",
    "E_bo=V-I_ao*R_a-V_b #  volts\n",
    "N_o=E_bo*60*A/(P*Phy*Z) #  rpm\n",
    "print '(a)no load speed = %.2f rpm'%N_o\n",
    "I_a=I-I_f #  amperes\n",
    "E_b1=V-I_a*R_a-V_b #  volts\n",
    "N=E_b1*N_o/(E_bo*0.98)\n",
    "print '(b)Full load speed = %.2f rpm'%N\n",
    "SR=100*(N_o-N)/N\n",
    "print '(c)Speed Regulation = %.2f %%'%SR"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.35 Pg No: 197"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)no load speed = 722.23 rpm\n",
      "(b)Percentage reduction in flux per pole = 21.30 %\n"
     ]
    }
   ],
   "source": [
    "V=220 #  volts\n",
    "V_b=1 #  volts\n",
    "R_f=110 #  ohms\n",
    "R_a=0.14 #  ohms\n",
    "I_o=7 #  amperes\n",
    "I_f=2 #  amperes\n",
    "I=90 #  amperes\n",
    "N_1=700 #  rpm\n",
    "I_ao=I_o-I_f #  amperes\n",
    "E_bo=V-I_ao*R_a-V_b #  volts\n",
    "I=55 #  amperes\n",
    "I_a1=I-I_f #  amperes\n",
    "E_b1=V-I_a1*R_a-V_b #  volts\n",
    "N_o=E_bo*N_1/E_b1\n",
    "print '(a)no load speed = %.2f rpm'%N_o\n",
    "I_a2=35 #  amperes\n",
    "N_2=900 #  rpm\n",
    "E_b2=V-I_a2*R_a-V_b #  volts\n",
    "Phy_r=E_b2*N_1/(E_b1*N_2)\n",
    "R=(1-Phy_r)*100\n",
    "print '(b)Percentage reduction in flux per pole = %.2f %%'%R"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.36 Pg No: 198"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Full load speed = 943.51 rpm\n",
      "(b)Speed regulation = 5.65 %\n",
      "(c)HP rating = 16.25 HP\n",
      "(d)Efficiency = 84.19 %\n"
     ]
    }
   ],
   "source": [
    "V=240 #  volts\n",
    "R_f=120 #  ohms\n",
    "R_a=0.25 #  ohms\n",
    "I_1=60 #  amperes\n",
    "I_f=V/R_f #  amperes\n",
    "I_a1=I_1-I_f #  amperes\n",
    "E_b1=V-I_a1*R_a #  volts\n",
    "N_o=1000 #  rpm\n",
    "I=6 #  amperes\n",
    "I_ao=I-I_f #  amperes\n",
    "E_bo=V-I_ao*R_a #  volts\n",
    "N_1=N_o*E_b1/E_bo\n",
    "print '(a)Full load speed = %.2f rpm'%N_1\n",
    "SR=100*(N_o-N_1)/N_o\n",
    "print '(b)Speed regulation = %.2f %%'%SR\n",
    "P_o=E_b1*I_a1-(E_bo*I_ao)\n",
    "HP=P_o/746\n",
    "print '(c)HP rating = %.2f HP'%HP\n",
    "P_i=V*I_1\n",
    "Eff=P_o*100/P_i\n",
    "print '(d)Efficiency = %.2f %%'%Eff"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.37 Pg No: 199"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)speed = 864.00 rpm\n",
      "(b)Torque = 61.12 N-m\n",
      "(c)Efficiency = 78.83 %\n"
     ]
    }
   ],
   "source": [
    "V=240 #  volts\n",
    "P=4\n",
    "Phy=0.008 #  webers\n",
    "Z=1000\n",
    "A=2\n",
    "R_f=240 #  ohms\n",
    "R_a=0.4 #  ohms\n",
    "I_1=25 #  amperes\n",
    "I_f=V/R_f #  amperes\n",
    "I_a1=I_1-I_f #  amperes\n",
    "E_b=V-I_a1*R_a #  volts\n",
    "N=E_b*60*A/(P*Z*Phy)\n",
    "print '(a)speed = %.2f rpm'%N\n",
    "P_m=E_b*I_a1\n",
    "T_g=(9.55*P_m)/N\n",
    "print '(b)Torque = %.2f N-m'%T_g\n",
    "P_f=P_m-800\n",
    "P_i=V*I_1\n",
    "Eff=P_f*100/P_i\n",
    "print '(c)Efficiency = %.2f %%'%Eff"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.38 Pg No: 201"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Power input = 13709.96 watts\n",
      "Efficiency = 87.53 %\n"
     ]
    }
   ],
   "source": [
    "P_out=20000 #  watts\n",
    "P_in=23000 #  watts\n",
    "V=250 #  volts\n",
    "R_f=125 #  ohms\n",
    "R_a=0.2 #  ohms\n",
    "I_L=P_in/V #  amperes\n",
    "I_f=V/R_f #  amperes\n",
    "I_a1=I_L-I_f #  amperes\n",
    "P_cu=(I_a1**2)*R_a\n",
    "P_fcu=V*I_f\n",
    "P_tcu=P_cu+P_fcu\n",
    "P_fric=P_in-P_out-P_tcu\n",
    "P_o=12000 #  watts\n",
    "P_m=P_o+P_fric\n",
    "I_a2=53.85\n",
    "P_tcu2=((I_a2**2)*R_a)+250\n",
    "P_in_2=P_m+P_tcu2\n",
    "print 'Power input = %.2f watts'%P_in_2\n",
    "Eff=P_o*100/P_in_2\n",
    "print 'Efficiency = %.2f %%'%Eff"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.39 Pg No: 202"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Efficiency = 68.43 %\n",
      "(b)Armature current = 44.54 Amperes\n",
      "(c)Max Efficiency = 79.97 %\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=240 #  volts\n",
    "R_f=240 #  ohms\n",
    "R_a=0.6 #  ohms\n",
    "I_o=5 #  amperes\n",
    "I=18 #  amperes\n",
    "I_f=V/R_f #  amperes\n",
    "I_ao=I_o-I_f\n",
    "I_a1=I-I_f\n",
    "E_bo=V-I_ao*R_a #  volts\n",
    "E_b1=V-I_a1*R_a #  volts\n",
    "P_dnL=E_bo*I_ao #  watts\n",
    "P_m=E_b1*I_a1 #  watts\n",
    "P_o=P_m-P_dnL\n",
    "P_i=V*I #  watts\n",
    "Eff=P_o/P_i\n",
    "print '(a)Efficiency = %.2f %%'%(Eff*100)\n",
    "I_a=sqrt((P_dnL+V*1)/R_a)\n",
    "print '(b)Armature current = %.2f Amperes'%I_a\n",
    "E_b=V-I_a*R_a\n",
    "P_m2=E_b*I_a #  watts\n",
    "P_out=P_m2-P_dnL #  watts\n",
    "P_in=V*I_a #  watts\n",
    "Eff_m=P_out/P_in\n",
    "print '(c)Max Efficiency = %.2f %%'%(Eff_m*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.40 Pg No: 202"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Speed at full load = 975.61 rpm\n",
      "Torque Developed = 83.85 N-m\n",
      "(b)Shaft Power = 7788.30 watts\n",
      "(c)Efficiency = 82.59 %\n"
     ]
    }
   ],
   "source": [
    "V=230 #  volts\n",
    "R_a=0.4 #  ohms\n",
    "I_a1=3.4 #  amperes\n",
    "R_f=170 #  ohms\n",
    "E_b1=V-I_a1*R_a\n",
    "I_f=V/R_f\n",
    "I_L=41 #  amperes\n",
    "I_a2=I_L-I_f\n",
    "E_b2=214.142 #  volts\n",
    "N_1=1000 #  rpm\n",
    "N_2=N_1*E_b2/(E_b1*0.96) #  rpm\n",
    "print '(a)Speed at full load = %.2f rpm'%N_2\n",
    "T_a=9.55*E_b2*I_a2/N_2\n",
    "print 'Torque Developed = %.2f N-m'%T_a\n",
    "P_r=E_b1*I_a1\n",
    "P_m=E_b2*I_a2\n",
    "P_f=P_m-P_r\n",
    "print '(b)Shaft Power = %.2f watts'%P_f\n",
    "P_in=V*I_L\n",
    "Eff=P_f/P_in\n",
    "print '(c)Efficiency = %.2f %%'%(Eff*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.41 Pg No: 203"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(a)Value of external resistance when the load torque is independent of speed = 0.98 ohms\n",
      "(b)Value of external resistance when the load torque is proportional to speed = 1.08 ohms\n",
      "(a)Value of external resistance when the load torque is independent of speed = 1.20 ohms\n"
     ]
    }
   ],
   "source": [
    "V=240 #  volts\n",
    "R_a=0.25 #  ohms\n",
    "R_f=120 #  ohms\n",
    "I_f=V/R_f\n",
    "I_L=26.0 #  amperes\n",
    "I_a=I_L-I_f\n",
    "N_1=1000.0 #  rpm\n",
    "N_2=900.0 #  rpm\n",
    "E_b1=V-I_a*R_a\n",
    "r=N_1/N_2\n",
    "R=(E_b1-(E_b1/r))/I_a\n",
    "print '(a)Value of external resistance when the load torque is independent of speed = %.2f ohms'%R\n",
    "I_a2=I_a/r\n",
    "R1=(E_b1-(E_b1/r))/I_a2\n",
    "print '(b)Value of external resistance when the load torque is proportional to speed = %.2f ohms'%R1\n",
    "I_a2_n=I_a/r**2\n",
    "R2=(E_b1-(E_b1/r))/I_a2_n\n",
    "print '(a)Value of external resistance when the load torque is independent of speed = %.2f ohms'%R2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.43 Pg No: 204"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Efficiency of the motor = 85.13 %\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=240 #  volts\n",
    "P=10000 #  watts\n",
    "R_a=0.25 #  ohms\n",
    "R_f=160 #  ohms\n",
    "I_f=V/R_f\n",
    "I_L=5.2 #  amperes\n",
    "I_ao=I_L-I_f\n",
    "W=V*I_ao-I_ao**2*R_a\n",
    "I_a=(V-sqrt(V**2-4*R_a*(P+W)))/(2*R_a)\n",
    "P_in=P+W+I_a**2*R_a+I_f**2*R_f\n",
    "Eff=P/P_in\n",
    "print 'Efficiency of the motor = %.2f %%'%(Eff*100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.44 Pg No: 205"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Armature voltage drop = 880.00 volts\n"
     ]
    }
   ],
   "source": [
    "V=440 #  volts\n",
    "N_1=1000 #  rpm\n",
    "N_2=1050 #  rpm\n",
    "r=N_1/N_2\n",
    "V_drop=2*(V-V*r)\n",
    "print 'Armature voltage drop = %.2f volts'%V_drop"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.45 Pg No: 205"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No Load Speed = 944.90 RPM\n"
     ]
    }
   ],
   "source": [
    "V=220 #  volts\n",
    "R_a=2.5 #  ohms\n",
    "N_1=859 #  rpm\n",
    "I_ao=0\n",
    "I_a=8 #  amperes\n",
    "E_b1=V-I_a*R_a\n",
    "E_bo=V-I_ao*R_a\n",
    "N_o=N_1*E_bo/E_b1\n",
    "print 'No Load Speed = %.2f RPM'%N_o"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.46 Pg No: 206"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "percentage reduction in feild flux = 22.36 %\n",
      "Value of additional resistance = 31.67 ohms\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=220 #  volts\n",
    "R_a=0.2 #  ohms\n",
    "R_f=110 #  ohms\n",
    "N_1=700 #  rpm\n",
    "N_2=900 #  rpm\n",
    "T_a1=90 #  N-m\n",
    "T_a2=70 #  N-m\n",
    "I_1=27 #  amperes\n",
    "I_f=V/R_f\n",
    "I_a1=I_1-I_f\n",
    "E_b1=V-I_a1*R_a\n",
    "x=(V+sqrt(V**2-4*276.43*4.168))/(2*276.43)\n",
    "print 'percentage reduction in feild flux = %.2f %%'%((1-x)*100)\n",
    "I_f2=x*I_f\n",
    "R=(V-I_f2*R_f)/I_f2\n",
    "print 'Value of additional resistance = %.2f ohms'%R"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exa:2.47 Pg No: 207"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "New Speed is= 64.32\n",
      "percent of original speed\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "V=400 #  volts\n",
    "R_f=200 #  ohms\n",
    "I_1=25 #  amperes\n",
    "I_f=V/R_f\n",
    "I_a1=I_1-I_f\n",
    "x=(-V+sqrt(V**2+4*345*400))/(2*345)\n",
    "print 'New Speed is= %.2f'%(x*100)\n",
    "print 'percent of original speed'"
   ]
  }
 ],
 "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
