{
 "metadata": {
  "name": "",
  "signature": "sha256:3a0360df3c22e5e4c6f88ae6f9ab32945c496822bb8898446d53149d9f1116ec"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 8: Magnetic Forces, Materials and Devices<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8.1, Page number: 308<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "m=2                     #mass in kg\n",
      "q=3                     #charge in C\n",
      "v=array([4,0,3])        #initial velocity in m/s\n",
      "E=array([12,10,0])      #electric field in V/m\n",
      "t=1                     #time in sec\n",
      "\n",
      "#Calculations\n",
      "\n",
      "a=q*E/m                                 #acceleration in m/s^2 after 1 sec\n",
      "u=array([18*t+4,15*t,3])                #velocity in m/s after 1 sec\n",
      "modofu=scipy.sqrt(dot(u,u))\n",
      "KE=0.5*m*(modofu)**2                    #kinetic energy in J at t=1 sec\n",
      "s=array([9*t**2+4*t+1,7.5*t**2-2,3*t])  #position after 1 sec in m\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'At time t=1 sec,'\n",
      "print' The acceleration of the particle =',a,'m/s^2'\n",
      "print 'Its velocity =',u,'m/s' \n",
      "print 'Its kinetic energy =',KE,'J'\n",
      "print 'Its position =',s,'m'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At time t=1 sec,\n",
        " The acceleration of the particle = [18 15  0] m/s^2\n",
        "Its velocity = [22 15  3] m/s\n",
        "Its kinetic energy = 718.0 J\n",
        "Its position = [ 14.    5.5   3. ] m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.6, Page number: 322"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "ar=array([1,0,0])                    #Unit vector along radial direction\n",
      "ath=array([0,1,0])                   #Unit vector along theta direction\n",
      "aph=array([0,0,1])                   #Unit vector along phi direction \n",
      "x=4\n",
      "y=-3\n",
      "z=10\n",
      "muo=4*scipy.pi*10**-7                #permeability of free space\n",
      "m1=5                                 #magnetic moment in A/m^2\n",
      "\n",
      "#Calculations\n",
      "\n",
      "r=scipy.sqrt(x**2+y**2+z**2)\n",
      "p=scipy.sqrt(x**2+y**2)\n",
      "sinphi=y/p\n",
      "cosphi=x/p\n",
      "sintheta=1/scipy.sqrt(5)\n",
      "costheta=2/scipy.sqrt(5)\n",
      "B1=muo*m1*(2*costheta*ar+sintheta*ath)/(4*scipy.pi*r**3)\n",
      "m2=3*(sintheta*sinphi*ar+costheta*sinphi*ath+cosphi*aph)\n",
      "T2=cross(m2,B1)*10**9\n",
      "T2x=round(dot(T2,ar),3)\n",
      "T2y=round(dot(T2,ath),3)\n",
      "T2z=round(dot(T2,aph),3)\n",
      "T2r=array([T2x,T2y,T2z])      #torque in nNm\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'Torque T2 =',T2r,'nNm'\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Torque T2 = [-0.384  1.536  0.902]\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 8.7, Page number: 330"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import scipy\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "muo=4*scipy.pi*10**-7               #permeability of free space\n",
      "mur=2                               #relative permeability\n",
      "ax=array([1,0,0])                   #Unit vector along x direction\n",
      "ay=array([0,1,0])                   #Unit vector along y direction\n",
      "az=array([0,0,1])                   #Unit vector along z direction\n",
      "\n",
      "\n",
      "#Calculations\n",
      "\n",
      "J=(-5-10)*10**-6/(4*scipy.pi*10**-7*2.5)          #in kA/m^2\n",
      "Jb=1.5*J                                          #in kA/m^2\n",
      "MbyB=(1.5)*10**4/(4*scipy.pi*2.5)       \n",
      "Mv=MbyB*10*10**-3*ax+MbyB*5*10**-3*ay\n",
      "Kb=cross(az,Mv)\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'J =',round(J,3),'kA/m^2'\n",
      "print 'Jb =',round(Jb,3),'kA/m^2'\n",
      "print 'M =(',round(dot(Mv,ax),3),'y,',round(dot(Mv,ay),3),'x, 0) kA/m'\n",
      "print 'Kb =(',round(dot(Kb,ax),3),'x,',round(dot(Kb,ay),3),'y, 0) kA/m' \n",
      "         \n",
      "\n",
      " \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "J = -4.775 kA/m^2\n",
        "Jb = -7.162 kA/m^2\n",
        "M =( 4.775 y, 2.387 x, 0) kA/m\n",
        "Kb =( -2.387 x, 4.775 y, 0) kA/m\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8.8, Page number: 332<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "ax=array([1,0,0])                   #Unit vector along x direction\n",
      "ay=array([0,1,0])                   #Unit vector along y direction\n",
      "az=array([0,0,1])                   #Unit vector along z direction \n",
      "H1=array([-2,6,4])                  #in A/m\n",
      "mu0=4*scipy.pi*10**-7               #permeability of free space\n",
      "mur1=5                              #relative permeabililty in region 1\n",
      "mur2=2                              #relative permeabililty in region 2\n",
      "an=array([-1,1,0])/scipy.sqrt(2)\n",
      "\n",
      "#Calculatios\n",
      "\n",
      "mu1=mu0*mur1\n",
      "mu2=mu0*mur2\n",
      "M1=(mur1-1)*H1                      # magnetisation in region 1 in A/m\n",
      "B1=mu1*H1*10**6                     # field in micro Wb/m^2\n",
      "B1x=round(dot(B1,ax),2)             # x component of B1\n",
      "B1y=round(dot(B1,ay),1)             # y component of B1\n",
      "B1z=round(dot(B1,az),2)             # z component of B1\n",
      "B1r=array([B1x,B1y,B1z])            # B1 rounded to 2 decimal places\n",
      "H1n=dot(H1,an)*an                   \n",
      "H1t=H1-H1n\n",
      "H2t=H1t                             # using transverse boundary condition\n",
      "H2n=(mu1/mu2)*H1n                   # using normal boundary condition\n",
      "H2=H2t+H2n                          # in A/m\n",
      "B2=mu2*H2*10**6                     # field in micro Wb/m^2\n",
      "B2x=round(dot(B2,ax),2)             # x component of B2\n",
      "B2y=round(dot(B2,ay),2)             # y component of B2\n",
      "B2z=round(dot(B2,az),2)             # z component of B2\n",
      "B2r=array([B2x,B2y,B2z])            # B2 rounded to 2 decimal places\n",
      "\n",
      "#Results\n",
      "\n",
      "print 'M1= ',M1,'A/m'\n",
      "print 'B1= ',B1r,'micro Wb/m^2'\n",
      "print 'H2= ',H2,'A/m'\n",
      "print 'B2= ',B2r,'micro Wb/m^2'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "M1=  [-8 24 16] A/m\n",
        "B1=  [-12.57  37.7   25.13] micro Wb/m^2\n",
        "H2=  [ -8.  12.   4.] A/m\n",
        "B2=  [-20.11  30.16  10.05] micro Wb/m^2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8.14, Page number: 350<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "#Variable declaration\n",
      "\n",
      "p=10*10**-2             #in m\n",
      "a=1*10**-2              #in m\n",
      "Ur=1000                 #relative permeability\n",
      "Uo=4*scipy.pi*10**-7    #permeability of free space\n",
      "n=200                   #number of turns\n",
      "phi=0.5*10**-3          #flux in the core in Wb\n",
      "U=Uo*Ur                 #permeability of steel core\n",
      "\n",
      "#Calculation\n",
      "\n",
      "I=phi*2*scipy.pi*p/(U*n*scipy.pi*a*a)   #current in A\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'The current that will produce a flux of 0.5 mWb =',round(I,3),'A'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current that will produce a flux of 0.5 mWb = 3.979 A\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8.15, Page number: 351<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "Uo=4*scipy.pi*10**-7    #permeability of free space\n",
      "Ur=50                   #relative permeability of coil\n",
      "l1=30*10**-2\n",
      "s=10*10**-4 \n",
      "l3=9*10**-2\n",
      "la=1*10**-2 \n",
      "B=1.5                   #flux density in Wb/m^2\n",
      "N=400                   #number of turns\n",
      "\n",
      "#Calculations\n",
      "\n",
      "R1=l1/(Uo*Ur*s)\n",
      "R2=R1\n",
      "R3=l3/(Uo*Ur*s)\n",
      "Ra=la/(Uo*s)\n",
      "R=R1*R2/(R1+R2)\n",
      "Req=R3+Ra+R\n",
      "I=B*s*Req/N     #current in A\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'The current required =',round(I,3),'A'\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current required = 44.165 A\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 8.16, Page number: 353<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "\n",
      "import scipy\n",
      "from numpy import *\n",
      "\n",
      "#Variable Declaration\n",
      "\n",
      "m=400                       #mass in kg\n",
      "g=9.8                       #acceleration due to gravity in m/s^2\n",
      "Ur=3000                     #relative permeability of the iron yoke\n",
      "Uo=4*scipy.pi*10**-7        #permeability of free space\n",
      "S=40*10**-4                 #cross sectional area of iron yoke in m^2\n",
      "la=1*10**-4                 #air gaps in m\n",
      "li=50*10**-2                #mean length of yoke in m\n",
      "I=1                         #excitation current in A \n",
      "\n",
      "#Calculations\n",
      "\n",
      "B=scipy.sqrt(m*g*Uo/S)      #field in Wb/m^2\n",
      "Ra=2*la/(Uo*S) \n",
      "Ri=li/(Uo*Ur*S) \n",
      "N=(Ra+Ri)/(Ra*Uo)*B*la      #number of turns\n",
      "\n",
      "#Result\n",
      "\n",
      "print 'The nmber of turns in the coil when the excitation current is 1 A ='\n",
      "print round(N,0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The nmber of turns in the coil when the excitation current is 1 A =\n",
        "162.0\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}