{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 : Electrical Measurements"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 : pg 81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "required resistance is,(ohm)= 15000.0\n"
     ]
    }
   ],
   "source": [
    "# Example 5.1 : resistance\n",
    "#calculate the resistance \n",
    "# given :\n",
    "n=50.;#number of turns\n",
    "B=1.;#magnetic field in tesla\n",
    "I=1.;#current in amperes\n",
    "L=4.;#length in cm\n",
    "d=3.;#dia in cm\n",
    "#calculations\n",
    "Td=n*B*I*L*d*10**-4;#torque in N-m\n",
    "cd1=2.4*10**-4;#controlling torque\n",
    "id=cd1/Td;#current in amperes\n",
    "fsv=100;#full scale voltage\n",
    "trv=fsv/id;#ohms\n",
    "adr=10000;#ohms\n",
    "r=trv-adr;#ohms\n",
    "#results\n",
    "print \"required resistance is,(ohm)=\",r\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 : pg 82"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total resistance of the voltmeter is,(ohm)= 49990.0\n"
     ]
    }
   ],
   "source": [
    "# Example 5.2 : resistance\n",
    "#calculate the total resistance \n",
    "# given :\n",
    "fsf=20.;#full scale deflection current in mA\n",
    "v=200.;#voltage in mV\n",
    "#calculations\n",
    "ri=v/fsf;#resistance in ohms\n",
    "x=199.98;#current in amperes\n",
    "rsh=(v*10**-3)/x;#ohms\n",
    "fs2=1000;#volts\n",
    "trv=fs2/(fsf*10**-3);#ohms\n",
    "rse=trv-ri;#reqquired resistance in ohms\n",
    "#results\n",
    "print \"total resistance of the voltmeter is,(ohm)=\",rse\n",
    "#in the text book approximately value of resistance is taken as 50000 ohm\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 : pg 82"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "power factor is ,= 0.693\n",
      "part (b)\n",
      "power factor is ,= 0.327\n"
     ]
    }
   ],
   "source": [
    "# Example 5.3 : power factor\n",
    "#calculate the power factor\n",
    "from math import sqrt, atan, cos\n",
    "# given :\n",
    "w1=2000.;#power in watts\n",
    "w2=500.;#power in watts\n",
    "#calculations and results\n",
    "an=atan(sqrt(3)*(((w1-w2)/(w1+w2))));#angle in radians\n",
    "print \"part (a)\"\n",
    "pf=cos(an);#power factor\n",
    "print \"power factor is ,=\",round(pf,3)\n",
    "print \"part (b)\"\n",
    "w1=2000.;#power in watts\n",
    "w2=-500.;#power in watts\n",
    "an=atan(sqrt(3)*(((w1-w2)/(w1+w2))));#angle in degree\n",
    "pf=cos(an);#power factor\n",
    "print \"power factor is ,=\",round(pf,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 : pg 83"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (i)\n",
      "indication of moving iron instrument is,(A)= 5.64\n",
      "part (ii)\n",
      "indication of moving coil instrument is,(A)= 3.18\n"
     ]
    }
   ],
   "source": [
    "# Example 5.4;reading\n",
    "#calculate the reading of the instrument\n",
    "from math import sqrt, pi, sin\n",
    "from scipy import integrate\n",
    "import numpy\n",
    "print \"part (i)\"\n",
    "# given :\n",
    "vm=100.;#volts\n",
    "rc=10.;#ohms\n",
    "#calculations and results\n",
    "im=vm/rc;#amperes\n",
    "t= numpy.linspace(0,2*pi, num =3);#time rane\n",
    "#x=intsplin(t,(sin(t))**2);#variable\n",
    "x=2.0;\n",
    "Irms=sqrt((1/(2*pi))*im**2*x);#current in amperes\n",
    "print \"indication of moving iron instrument is,(A)=\",round(Irms,2)\n",
    "print \"part (ii)\"\n",
    "t1=0;#time interval\n",
    "t2=pi;#time inerval\n",
    "def function(t):\n",
    "    return sin(t)\n",
    "    \n",
    "x=integrate.quad(function,t1,t2)[0];#variable\n",
    "Iav=(1/pi)*x*(im/2);#current in amperes\n",
    "print \"indication of moving coil instrument is,(A)=\",round(Iav,2)\n",
    "#answer of part a is calculated wrong in the textbook\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 : pg 86"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current read by meter 1 is,(A)= 55.56\n",
      "current read by meter 2 is,(A)= 44.44\n"
     ]
    }
   ],
   "source": [
    "# Example 5.5;reading\n",
    "#calculate the current reading\n",
    "# given :\n",
    "fsd=100.;#full scale division in amperes\n",
    "fsd1=100.;#full scale division in mA\n",
    "#calculations\n",
    "csh=fsd-(fsd*10**-3);#difference in currents in amperes\n",
    "rx=0.8;#resistance in ohms\n",
    "r1=((fsd1*10**-3*rx)/csh);#resistance in ohms\n",
    "rx1=1;#resistance in ohms\n",
    "r2=((fsd1*10**-3*rx1)/csh);#resistance in ohms\n",
    "em1=((rx*r1)/(rx+r1));#resistance in ohms\n",
    "em2=((rx1*r2)/(rx1+r2));#resistance in ohms\n",
    "crm1=((em2*10**4*fsd)/((em2*10**4)+(em1*10**4)));#current in amperes\n",
    "crm2=((em1*10**4*fsd)/((em1*10**4)+(em2*10**4)));#current in amperes\n",
    "#results\n",
    "print \"current read by meter 1 is,(A)=\",round(crm1,2)\n",
    "print \"current read by meter 2 is,(A)=\",round(crm2,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 : pg 90"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "multiplier resistance Rs is,(Ohm)= 1825.0\n",
      "part (b)\n",
      "sensivity is,(Ohm/V)= 225.0\n"
     ]
    }
   ],
   "source": [
    "# Example 5.6;\n",
    "#calculate the multiplier resistance and sensivity\n",
    "# given :\n",
    "rm=50.;#resistance in ohms\n",
    "rsh=rm;#shunt resistance in ohms\n",
    "it=2.;#current in mA\n",
    "erms=10.;#rms voltage in volts\n",
    "#calculations\n",
    "ede=0.45*erms;#voltage in volts\n",
    "rd1=400.;#resistance in ohms\n",
    "x=(rm*rsh)/(rm+rsh);#resistance in ohms\n",
    "r1=ede/(it*10**-3);#resistance in ohms\n",
    "rs=r1-x-rd1;#resistance in ohms\n",
    "S=r1/erms;#sensivity in ohms/V\n",
    "#results\n",
    "print \"part (a)\"\n",
    "print \"multiplier resistance Rs is,(Ohm)=\",rs\n",
    "print \"part (b)\"\n",
    "print \"sensivity is,(Ohm/V)=\",S\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 : pg 91"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "apparent resistance of unknown resistor is,(kilo-Ohm)= 40.0\n",
      "part (b)\n",
      "actual resistance of unknown resistor is,(kilo-Ohm)= 47.619\n",
      "part (c)\n",
      "percentage error is,(%)= 16.0\n"
     ]
    }
   ],
   "source": [
    "# Example 5.7;\n",
    "#calculate the apparent resistance of the unknown resistor,actual resistance of the unknown resistor and percentage error\n",
    "# given :\n",
    "v=200.;#voltage in volts\n",
    "i=5.;#current in mA\n",
    "#calculations and results\n",
    "tr=v/i;#resistance in kilo ohms\n",
    "print \"part (a)\"\n",
    "print \"apparent resistance of unknown resistor is,(kilo-Ohm)=\",tr\n",
    "S=1000.;#sensivity in ohms/V\n",
    "V1=250.;#voltage in volts\n",
    "rv=V1*S*10**-3;#resistance in kilo ohms\n",
    "rx=(V1*tr)/(V1-tr);#resistance in kilo ohms\n",
    "print \"part (b)\"\n",
    "print \"actual resistance of unknown resistor is,(kilo-Ohm)=\",round(rx,3)\n",
    "per=(rx-tr)/rx;#percentage error\n",
    "print \"part (c)\"\n",
    "print \"percentage error is,(%)=\",per*100\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 : pg 92"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resolution is, (V)= 0.2\n"
     ]
    }
   ],
   "source": [
    "# Example 5.8;resolution\n",
    "#calculate the resolution\n",
    "# given :\n",
    "fsr=200.;#full scale reading in volts\n",
    "d=100.;#number of divisions\n",
    "sc=1/10.;#scale\n",
    "#calculations\n",
    "sd1=fsr/d;#one sccale divisions\n",
    "R=sc*sd1;#resolution\n",
    "#results\n",
    "print \"resolution is, (V)=\",R\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9 : pg 93"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "resolution is ,(mV)= 1.0\n"
     ]
    }
   ],
   "source": [
    "# Example 5.9;resolution\n",
    "#calculate the resolution\n",
    "# given :\n",
    "fsr=9.999;#full scale reading in volts\n",
    "d=9999.;#number of divisions\n",
    "#calculations\n",
    "R=(1/d)*fsr*10**3;#resolution\n",
    "#results\n",
    "print \"resolution is ,(mV)=\",R\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10 : pg 95"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (i)\n",
      "true value of resistance is,(Ohm)= 91.65\n",
      "part (ii)\n",
      "percentage error is,(%)= 1.8\n",
      "part (iii)\n",
      "reading of voltmeter is,(V)= 18.35\n"
     ]
    }
   ],
   "source": [
    "# Example 5.10;\n",
    "#calculate the true resistance of the unknown resistor  , percentage error and reading voltmeter\n",
    "# given :\n",
    "print \"part (i)\"\n",
    "ra=0.1;#ohms\n",
    "vr=18.;#voltage in volts\n",
    "am=0.2;#current in amperes\n",
    "#calculations and results\n",
    "apr=vr/am;#in ohms\n",
    "rv=5000.;#ohms\n",
    "im=vr/rv;#amperes\n",
    "rxi=am-(im);#in amperes\n",
    "rx=vr/rxi;#ohms\n",
    "print \"true value of resistance is,(Ohm)=\",round(rx,3)\n",
    "per=((rx-apr)/rx)*100;#percentage error\n",
    "print \"part (ii)\"\n",
    "print \"percentage error is,(%)=\",per\n",
    "rvv=am*(ra+rx);#reading of voltmeter\n",
    "print \"part (iii)\"\n",
    "print \"reading of voltmeter is,(V)=\",round(rvv,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 11 : pg 96"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (i)\n",
      "resistance of shunt (range 0-100mA) Rsh1 is,(Ohm)= 5.556\n",
      "part (ii)\n",
      "resistance of shunt (range 0-500mA) Rsh2 is,(Ohm)= 1.02\n",
      "part (iii)\n",
      "resistance of shunt (range 0-1A) Rsh2 is,(Ohm)= 0.505\n",
      "part (iv)\n",
      "resistance of shunt (range 0-5A) Rsh2 is,(Ohm)= 0.1\n"
     ]
    }
   ],
   "source": [
    "# Example 5.11;resistance\n",
    "#calculate the resistance in all cases\n",
    "# given :\n",
    "im=10.;#mA\n",
    "i=100.;#mA\n",
    "#calculations and results\n",
    "m=i/im;#multiplying factor\n",
    "rm=50;#ohms\n",
    "rsh=rm/(m-1);#in ohms\n",
    "print \"part (i)\"\n",
    "print \"resistance of shunt (range 0-100mA) Rsh1 is,(Ohm)=\",round(rsh,3)\n",
    "i1=500.;#mA\n",
    "m1=i1/im;#multiplying factor\n",
    "rm1=50.;#ohms\n",
    "rsh1=rm1/(m1-1);#in ohms\n",
    "print \"part (ii)\"\n",
    "print \"resistance of shunt (range 0-500mA) Rsh2 is,(Ohm)=\",round(rsh1,3)\n",
    "im2=1;#A\n",
    "i2=100.;#A\n",
    "m2=i2/im2;#multiplying factor\n",
    "rm2=50.;#ohms\n",
    "rsh2=rm2/(m2-1);#in ohms\n",
    "print \"part (iii)\"\n",
    "print \"resistance of shunt (range 0-1A) Rsh2 is,(Ohm)=\",round(rsh2,3)\n",
    "im3=1;#A\n",
    "i3=500.;#A\n",
    "m3=i3/im3;#multiplying factor\n",
    "rm3=50.;#ohms\n",
    "rsh3=rm3/(m3-1);#in ohms\n",
    "print \"part (iv)\"\n",
    "print \"resistance of shunt (range 0-5A) Rsh2 is,(Ohm)=\",round(rsh3,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 12 : pg 98"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load power is,(kW)= 1.5\n"
     ]
    }
   ],
   "source": [
    "# Example 5.12;load power\n",
    "#calculate the load power\n",
    "# given :\n",
    "k=600.;#in rev./kwh.\n",
    "nr=5.;#number of revolutions\n",
    "t=20.;#time in seconds\n",
    "#calculations\n",
    "lp=(1/k)*nr*((60*60)/t);#power in kW\n",
    "#results\n",
    "print \"load power is,(kW)=\",lp\n"
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}