{
 "metadata": {
  "name": "",
  "signature": "sha256:8539e9632363526a1a80f9cc5f76e7021b8f8d8a0160c441e4d39f4cdb32d610"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Principles of Electromechanical Energy Conversion"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1, Page 144"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "A=20*10**-4;#surface area of each  capacitor's plate \n",
      "d=5*10**-3;#separation between the plates\n",
      "e=(10**-9)/(36*math.pi);#permetivity of air\n",
      "V=10*10**3;#potential diff. between the plates\n",
      "\n",
      "#Calculations&Results\n",
      "F_e=(e*A*V**2)/(2*d**2);#electric force\n",
      "g=9.81;#acceleration due to gravity (in meter/second**2)\n",
      "#For condt of balancing electric force=weight of object\n",
      "#F_e=m*g\n",
      "m=F_e/g;\n",
      "print 'mass of object (in grams)=%.2f'%(m*1000)\n",
      "W_f=(e*A*V**2)/(2*d);\n",
      "print 'energy stored in the feild (in micro-joules)=%.f'%(W_f*1000000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass of object (in grams)=3.61\n",
        "energy stored in the feild (in micro-joules)=177\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3, Page 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import scipy\n",
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable declaration\n",
      "#i=current in the ckt (in Amperes)\n",
      "#x=total flux linkage\n",
      "\n",
      "#Calculations\n",
      "def f(x):\n",
      "    return x/(6-(2*x))\n",
      "#Refer to eqn:3.18\n",
      "W_m,err=quad(f,0,2);#Energy stored in magnetic feild\n",
      "\n",
      "#Result\n",
      "print 'Energy stored in magnetic feild (in Joules)=%.3f'%W_m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Energy stored in magnetic feild (in Joules)=0.648\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4, Page 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import scipy\n",
      "from scipy.misc import derivative\n",
      "\n",
      "#Variable declaration\n",
      "N=100;#no. of turns of coil\n",
      "A=10**-4;#area \n",
      "x=1*10**-2;#length of air gap\n",
      "u_o=4*math.pi*10**-7;#permeablity of air\n",
      "u_r=2000;#permeablity of magnetic material\n",
      "D=7.85*10**3;#density of material (in kg/m**3)\n",
      "V=11*10**-6;#volume of material\n",
      "m=D*V;#mass of material\n",
      "g=9.81;#acceleration due to gravity\n",
      "\n",
      "#Calculations&Results\n",
      "#Refer to fig:3.7\n",
      "R_o=(15.5*10**-2)/(u_o*u_r*A);#reluctance of outer legs\n",
      "R_c=(5.5*10**-2)/(u_o*u_r*A);#reluctance of central leg\n",
      "def L( x ):#inductance\n",
      "    return (N**2)/ R ( x );\n",
      "\n",
      "def R( x ):#total reluctance \n",
      "    return R_c+R_g(x)+(0.5*(R_o+R_g(x)));\n",
      "\n",
      "def R_g( x ):#reluctance of air gap\n",
      "    return x/(u_o*A);\n",
      "\n",
      "x = 0.01 ;     # Points of interest\n",
      "t = derivative(L,x)\n",
      "#t=[diag(derivative(L,x))];#t=dL/dx (at x=0.01m)\n",
      "#since t<o,i.e,F_m is acting in opp direction that of weight  \n",
      "#for equilibrium F_m=m*g\n",
      "I=math.sqrt((m*g)/(0.5*t*(1)));#Refer to eqn3.23\n",
      "print 'current in the coil (in Amperes)= %.2f'%(I/100)\n",
      "L_o=L(.01);\n",
      "W_f=0.5*L_o*I**2;\n",
      "print 'energy stored in the magnetic feild  (in mili-Joules)= %.1f'%(W_f*10**3/10000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "current in the coil (in Amperes)= 14.22\n",
        "energy stored in the magnetic feild  (in mili-Joules)= 8.4\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5, Page 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import scipy\n",
      "from scipy.misc import derivative\n",
      "\n",
      "#Variable declaration\n",
      "T=20;#torque exerted by spring (in Newton-meter)\n",
      "r=0.2;#radius of spring (in meter)\n",
      "\n",
      "#Calculations\n",
      "F_s=T/r;#force exerted by spring on magnetic plate\n",
      "N=1000;#no. of turns in coil\n",
      "u_o=4*math.pi*10**-7;#permablityof air\n",
      "A=9*10**-4;#area (in meter**2)\n",
      "def L( x ):#inductance\n",
      "    return (N**2)/ R ( x );\n",
      "\n",
      "def R( x ):#reluctance of air gap\n",
      "    return (2*x)/(u_o*A);\n",
      "\n",
      "x = 0.001;     # Points of interest\n",
      "t = derivative(L,x)\n",
      "#t=[diag(derivative(L,x))];#t=dL/dx (at x=0.001m)\n",
      "#since t<o i.e,F_m is acting in opp direction that of weight  \n",
      "#for equilibrium F_m=F_s\n",
      "I=math.sqrt((2*F_s)/(t*(1)));#Refer to eqn3.23\n",
      "\n",
      "#Result\n",
      "print 'current in the coil (in Amperes)=%.3f'%(I/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "current in the coil (in Amperes)=0.595\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6, Page 168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "N=100;#no. of turns in coil\n",
      "P=4;#number of poles\n",
      "N_m=1800;#rotor speed (in rpm)\n",
      "\n",
      "#Calculations&Results\n",
      "flux_p=4.5*10**-3;#flux per pole (in Wb)\n",
      "f=(P*N_m)/120;#Refer to eqn:3.30a\n",
      "print '(a) frequency of induced emf (in Hertz)=%.f'%f\n",
      "#refer to eqn:3.31\n",
      "E_m=(2*math.pi*P*flux_p*N_m)/120;#max value of induced emf per turn\n",
      "E_mc=N*E_m;\n",
      "print '(b) m/ax value of induced emf in coil (in Volts)= %.2f'%E_mc\n",
      "E_rms=E_mc/math.sqrt(2);\n",
      "print '(c) rms value of induced emf (in Volts)= %.f'%E_rms\n",
      "E_avg=(2*E_mc)/math.pi;\n",
      "print '(d) average value of induced emf (in Volts)= %.f'%E_avg"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) frequency of induced emf (in Hertz)=60\n",
        "(b) m/ax value of induced emf in coil (in Volts)= 169.65\n",
        "(c) rms value of induced emf (in Volts)= 120\n",
        "(d) average value of induced emf (in Volts)= 108\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7, Page 177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P=4;#no. of pole\n",
      "f=50;#frequency (in Hz)\n",
      "N_r=1200.;#speed of rotor(in rpm)\n",
      "\n",
      "#Calculations&Results\n",
      "N_s=(120*f)/P;\n",
      "print 'synchronous speed (in rpm)= %.f'%N_s\n",
      "s=(N_s-N_r)/N_s;#slip\n",
      "s_p=s*100;\n",
      "print 'percent slip of the motor(%%)= %.f'%s_p"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "synchronous speed (in rpm)= 1500\n",
        "percent slip of the motor(%)= 20\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8, Page 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "N=2;#no. of poles\n",
      "f=60;#frequency in Hz\n",
      "I_rms=10;#current intake\n",
      "L_q=1;#min inductance (in H)\n",
      "L_d=2;#max inductance(inH)\n",
      "\n",
      "#Calculations&Results\n",
      "w=2*math.pi*f;\n",
      "print 'rotor speed(in rad/sec)= %f'%w\n",
      "#Refer to eqn:3.52\n",
      "T_avg=(-1)*0.125*(L_d-L_q)*((I_rms*math.sqrt(2))**2)*math.sin(2*45*math.pi/180);\n",
      "if ( T_avg <0 ):\n",
      "    print \"average torque developed by motor (in Newton-meter)= %.f\"%(T_avg*(-1))\n",
      "else:\n",
      "    print \"average torque developed by motor (in Newton-meter)= %f\"%T_avg\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rotor speed(in rad/sec)= 376.991118\n",
        "average torque developed by motor (in Newton-meter)= 25\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9, Page 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "N=500;#no. of turns\n",
      "u_o=4*math.pi*10**-7;#Permeablity of air\n",
      "I=4.2;#main winding current(in A)\n",
      "A=2.25*10**-4;#area of air gap(in m**2)\n",
      "x=0.002;#length of air gap(in m)\n",
      "\n",
      "#Calculations\n",
      "i=I*1.50;#min current needed for activating relay\n",
      "F_m=u_o*A*0.5*((N*i)/x)**2;#Refer to eqn 3.53\n",
      "\n",
      "#Result\n",
      "print 'restraining force of the spring(in Newton)=%.2f'%F_m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "restraining force of the spring(in Newton)=350.69\n"
       ]
      }
     ],
     "prompt_number": 36
    }
   ],
   "metadata": {}
  }
 ]
}