{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter : Transformers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 : pg 66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of primary winding turns are 1720.0\n",
      "number of secondary winding turns are 172.0\n"
     ]
    }
   ],
   "source": [
    "# Example 4.1;NUMBER OF TURNS\n",
    "#calculate the number of turns\n",
    "# given :\n",
    "e1=2200.;#voltage in volts\n",
    "f=50.;#frequency in Hz\n",
    "e2=220.;#voltage in volts\n",
    "fd=1.6;#magnetic field in Tesla\n",
    "a=3600.;#area in mm**2\n",
    "#calculations\n",
    "n1=(e1/(4.44*f*fd*a*10**-6));#number  of turns\n",
    "n2=(e2/(4.44*f*fd*a*10**-6));#number of turns\n",
    "#results\n",
    "print \"number of primary winding turns are\",round(n1)\n",
    "print \"number of secondary winding turns are\",round(n2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2 : pg 68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "iron loss current is, (A)= 0.182\n",
      "magnetising component is, (A)= 0.572\n",
      " part (b)\n",
      "iron loss current is, (A)= 0.1\n",
      "magnetising component  is, (A)= 0.49\n"
     ]
    }
   ],
   "source": [
    "# Example 4.2;\n",
    "#calculate the components of no load currents,magnetising and working components of exciting current \n",
    "from math import sqrt\n",
    "# given \n",
    "print \"part (a)\"\n",
    "nlw=2000.;#no load input watts\n",
    "pv=11000.;#primary voltage\n",
    "#calculations and results\n",
    "Iw=nlw/pv;#current in amperes\n",
    "Io=0.6;#current in amperes\n",
    "Imu=sqrt(Io**2-Iw**2);#current in amperes\n",
    "print \"iron loss current is, (A)=\",round(Iw,3)\n",
    "print \"magnetising component is, (A)=\",round(Imu,3)\n",
    "pf=0.2;#power factpr\n",
    "Io=0.5;#current in amperes\n",
    "Iw=Io*(pf);#current in amperes\n",
    "Imu=Io*sqrt(1-pf**2);#magnetising component in amperes\n",
    "print \" part (b)\"\n",
    "print \"iron loss current is, (A)=\",Iw\n",
    "print \"magnetising component  is, (A)=\",round(Imu,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 : pg 68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "current is, (A)= 33.43\n"
     ]
    }
   ],
   "source": [
    "# Example 4.3;current\n",
    "#calculate the current\n",
    "from math import sqrt, acos, cos\n",
    "# given \n",
    "pf1=0.866;#power factor\n",
    "pf2=0.1736;#power factor\n",
    "#calculations\n",
    "ph1=acos(pf1);#phase angle in radians\n",
    "ph2=acos(pf2);#phase angle in radians\n",
    "ir=120.;#current in amperes\n",
    "n2=110;#number of turns\n",
    "n1=440.;#number of turns\n",
    "i2d=(n2/n1)*ir;#current in amperes\n",
    "io=5.;#current in amperes\n",
    "aioi2=ph2-ph1;#change in angle in degree\n",
    "i1=sqrt(io**2+i2d**2+(2*io*i2d*cos(aioi2)));#current in amperes\n",
    "#results\n",
    "print \"current is, (A)=\",round(i1,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 4 : pg 69"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total core losses is,(W) =  2900.0\n"
     ]
    }
   ],
   "source": [
    "# Example 4.4;core losses\n",
    "#calculate the core losses\n",
    "# given \n",
    "f=50.;#frquency in Hz\n",
    "hl=650.;#hystresis loss\n",
    "edl=400.;#eddy current loss\n",
    "#calculations\n",
    "A=hl/f;#parameter\n",
    "B=edl/f**2;#parameter\n",
    "Ph=A*2*f;#loss in watts\n",
    "Pe=B*(2*f)**2;#loss in watts\n",
    "pt=Ph+Pe;#total loss in watts\n",
    "#results\n",
    "print \"total core losses is,(W) = \",pt\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5 : pg 71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a)\n",
      "full load efficiency at 0.8 pf is,(%)= 96.165\n",
      "part (b)\n",
      "percentage of full load on which efficiency will be maximum is,(%)= 95.603\n"
     ]
    }
   ],
   "source": [
    "# Example 4.5;\n",
    "#calculate the efficiency and load for maximum efficiency \n",
    "from math import sqrt\n",
    "# given \n",
    "cl=125.;#copper losses\n",
    "fcl=2**2*cl;#full load copper losses\n",
    "il=457.;#iron losses\n",
    "pf=0.8;#power factor\n",
    "kba=30.;#loss\n",
    "#calculations and results\n",
    "print \"part (a)\"\n",
    "fle=((kba*pf)/((kba*pf)+(fcl+il)*10**-3))*100;#full load efficiency  in %\n",
    "print \"full load efficiency at 0.8 pf is,(%)=\",round(fle,3)\n",
    "lme=kba*sqrt(il/fcl);#variable\n",
    "pfl=(lme/kba)*100;#percentage of full load on which efficiency will be maximum \n",
    "print \"part (b)\"\n",
    "print \"percentage of full load on which efficiency will be maximum is,(%)=\",round(pfl,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6 : pg 73"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "all day efficiency is,(%)= 95.31\n"
     ]
    }
   ],
   "source": [
    "# Example 4.6;\n",
    "#calculate the all day efficiency \n",
    "#given\n",
    "ef=0.98;#efficiency in %\n",
    "kva=15;#kVA\n",
    "pf=1;#power factor\n",
    "#calculations\n",
    "op=kva*pf;#output power in kW\n",
    "ip=op/ef;#input power in kW\n",
    "loss=ip-op;#loss in kW\n",
    "cl=(loss*10**3)/2;#copper loss in W\n",
    "il=cl;#iron loss in W\n",
    "t1=12;#time in hours\n",
    "p1=2;#power in kW\n",
    "pf1=0.5;#power factor\n",
    "y1=(p1)/pf1;#kVA\n",
    "il1=il*t1;#loss in Wh\n",
    "cl1=cl*((y1)/kva)**2*t1;#copper loss in Wh\n",
    "top1=p1*t1;#kWht1=12;#time in hours\n",
    "t2=6;#time in hours\n",
    "p2=12;#power in kW\n",
    "pf2=0.8;#power factor\n",
    "y2=(p2)/pf2;#kVA\n",
    "il2=il*t2;#iron loss in Wh\n",
    "cl2=cl*((y2/kva)**2)*t2;#copper loss in Wh\n",
    "top2=p2*t2;#kWh\n",
    "t3=6;#time in hours\n",
    "il3=il*t3;#iron loss Wh\n",
    "tol=top1+top2;#iron loss kWh\n",
    "til=(il1+il2+il3)*10**-3;#total iron loss in kWh\n",
    "tcl=(cl1+cl2)*10**-3;#total copper loss in kWh\n",
    "ade=((tol)/(tol+til+tcl))*100;#efficiency in %\n",
    "#results\n",
    "print \"all day efficiency is,(%)=\",round(ade,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 : pg 75"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iron losses is,(kW)= 2.32\n"
     ]
    }
   ],
   "source": [
    "# Example 4.7;iron losses\n",
    "#calculate the iron losses\n",
    "from math import sqrt\n",
    "#given\n",
    "kva=200;#kVA\n",
    "pf=0.8;#power factor\n",
    "rflo=kva*pf;#kW\n",
    "ef=0.96;#efficiency\n",
    "#calculations\n",
    "ip=rflo/ef;#kW\n",
    "tl=ip-rflo;#kW\n",
    "e2=800;#volts\n",
    "e1=6600;#volts\n",
    "n21=((e2/sqrt(3))/e1);#turn ratiom\n",
    "r1=4;#ohms\n",
    "r2=0.05;#ohms\n",
    "roe=(r1)*n21**2+r2;#ohms\n",
    "fli=((kva*10**3)/(sqrt(3)*e2));#amperes\n",
    "fcl=3*fli**2*roe;#kW\n",
    "il=tl-(fcl)*10**-3;#kW\n",
    "#results\n",
    "print \"iron losses is,(kW)=\",round(il,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 : pg 78"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part (a) \n",
      "equivalent resistance referred to the primary is,(Ohm)= 7.05\n",
      "equivalent reactance referred to the primary is,(Ohm)= 11.2\n",
      "equivalent resistance referred to the secondary is,(Ohm)= 0.017625\n",
      "equivalent reactance referred to the secondary is,(Ohm)= 0.028\n",
      "equivalent impedance referred to the primary is,(Ohm)= 13.234\n",
      "equivalent impedance referred to the secondary is,(Ohm)= 0.033\n",
      "part (b) \n",
      "total copper losses considering individual resistance is,(W)= 910.382\n",
      "total copper losses consdering equivalent resistance (for primary) is,(W)= 910.382\n",
      "total copper losses consdering equivalent resistance (for secondary) is,(W)= 910.382\n"
     ]
    }
   ],
   "source": [
    "# Example 4.8;\n",
    "#calculate the resistance,reactances and impedances and copper losses\n",
    "from math import sqrt \n",
    "#given\n",
    "r1=3.45;#ohms\n",
    "r2=0.009;#ohms\n",
    "x1=5.2;#ohms\n",
    "x2=0.015;#ohms\n",
    "kva=100.;#kVA\n",
    "e1=8800.;#volts\n",
    "e2=440.;#volts\n",
    "#calculations\n",
    "i1=(kva*10**3)/e1;#in amperes\n",
    "i2=(kva*10**3)/e2;#in amperes\n",
    "k=e2/e1;#transformation ratio\n",
    "ro1=r1+(r2/k**2);#ohms\n",
    "xo1=x1+(x2/k**2);#ohms\n",
    "ro2=r2+(k**2*r1);#ohms\n",
    "xo2=k**2*xo1;#ohms\n",
    "zo1=sqrt(ro1**2+xo1**2);#ohms\n",
    "zo2=sqrt(ro2**2+xo2**2);#ohms\n",
    "tcl=i1**2*r1+i2**2*r2;#in watts\n",
    "tcl1=i1**2*ro1;#in watts\n",
    "tcl2=i2**2*ro2;#in watts\n",
    "#results\n",
    "print \"part (a) \"\n",
    "print \"equivalent resistance referred to the primary is,(Ohm)=\",ro1\n",
    "print \"equivalent reactance referred to the primary is,(Ohm)=\",xo1\n",
    "print \"equivalent resistance referred to the secondary is,(Ohm)=\",ro2\n",
    "print \"equivalent reactance referred to the secondary is,(Ohm)=\",xo2\n",
    "print \"equivalent impedance referred to the primary is,(Ohm)=\",round(zo1,3)\n",
    "print \"equivalent impedance referred to the secondary is,(Ohm)=\",round(zo2,3)\n",
    "print \"part (b) \"\n",
    "print \"total copper losses considering individual resistance is,(W)=\",round(tcl,3)\n",
    "print \"total copper losses consdering equivalent resistance (for primary) is,(W)=\",round(tcl1,3)\n",
    "print \"total copper losses consdering equivalent resistance (for secondary) is,(W)=\",round(tcl2,3)\n",
    "#copper losses are calculated wrong in the textbook\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 9 : pg 82"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " part (a)\n",
      "magnetising component of no load current (Im) is,(A)= 0.87\n",
      "working component of no load current (Iw) is,(A)= 0.5\n",
      "resistance for primary side  (Rm) is,(Ohm)= 400.0\n",
      "reactance for primary ohms (Xm) is,(Ohm)= 230.94\n",
      "impedence for primary side (X01) is,(Ohm)= 0.31\n",
      "part (b)\n",
      "percentage regulation on lagging load is,(%)= 3.55\n",
      "percentage regulation on leading load is,(%)= -0.15\n",
      "part (c)\n",
      "efficiency at full load is,(%)= 94.53\n",
      "efficiency at half load is,(%)= 92.96\n"
     ]
    }
   ],
   "source": [
    "# Example 4.9;\n",
    "#calculate the parameter of primary side ,regulation and efficiency\n",
    "from math import sqrt\n",
    "#given\n",
    "po=100.;#watts\n",
    "v1=200.;#volts\n",
    "io=1;#amperes\n",
    "#calculations and results\n",
    "ocpf=po/(v1*io);#open circuit power factor\n",
    "sinpf=sqrt(1-ocpf**2);#\n",
    "im=io*sinpf;#in amperes\n",
    "iw=io*ocpf;#current in amperes\n",
    "rm=v1/iw;#ohms\n",
    "xm=v1/im;#in ohms\n",
    "vs=15.;#volts\n",
    "ia=10.;#amperes\n",
    "zo2=vs/ia;#in ohms\n",
    "wa=85.;#watts\n",
    "ro2=wa/(ia)**2;#ohms\n",
    "e2=400.;#volts\n",
    "e1=200.;#volts\n",
    "k=e2/e1;#transformation ratio\n",
    "zo1=zo2/k**2;#ohms\n",
    "ro1=ro2/k**2;#ohms\n",
    "xo1=sqrt(zo1**2-ro1**2);#ohms\n",
    "print \" part (a)\"\n",
    "print \"magnetising component of no load current (Im) is,(A)=\",round(im,2)\n",
    "print \"working component of no load current (Iw) is,(A)=\",iw\n",
    "print \"resistance for primary side  (Rm) is,(Ohm)=\",round(rm,2)\n",
    "print \"reactance for primary ohms (Xm) is,(Ohm)=\",round(xm,2)\n",
    "print \"impedence for primary side (X01) is,(Ohm)=\",round(xo1,2)\n",
    "print \"part (b)\"\n",
    "kva=4000;#kVA\n",
    "i2=kva/e2;#in amperes\n",
    "xo2=sqrt(zo2**2-ro2**2);#ohms\n",
    "pf=0.8;# power factor\n",
    "vlag=i2*(ro2*pf+xo2*sqrt(1-pf**2));#in volts\n",
    "prld=(vlag*po)/e2;#\n",
    "vlag1=i2*(ro2*pf-xo2*sqrt(1-pf**2));#in volts\n",
    "prld1=(vlag1*po)/e2;#\n",
    "print \"percentage regulation on lagging load is,(%)=\",round(prld,2)\n",
    "print \"percentage regulation on leading load is,(%)=\",round(prld1,2)\n",
    "print \"part (c)\"\n",
    "cl=85;#copper losses\n",
    "nloss=100;#no load losses\n",
    "fll=cl+nloss;#full load losses\n",
    "pf=0.8;#power factor\n",
    "flo=kva*pf;#efficiency \n",
    "effl=flo/(flo+fll);#efficiency \n",
    "hll=(1./2)**2*cl+nloss;#loss in watts\n",
    "op=(1./2)*kva*pf;#ouput power in watts\n",
    "efhl=op/(hll+op);#efficiency at half load\n",
    "print \"efficiency at full load is,(%)=\",round(effl*100,2)\n",
    "print \"efficiency at half load is,(%)=\", round(efhl*100,2)\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
}