{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5: Three Phase Systems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.1: Page number-317"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ia= 51.962 A\n",
      "ib= 43.30129 A\n",
      "ic= 34.64103 A\n",
      "IN= 15.0 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#given\n",
    "vl=400 #line voltage\n",
    "va=vl/math.sqrt(3)\n",
    "vb=230.94  #angle(-120)\n",
    "vc=230.94  #angle(-240)\n",
    "#case a\n",
    "#the line currents are given by\n",
    "ia=12000/230.94  #with angle 0\n",
    "ib=10000/230.94  #with angle 120\n",
    "ic=8000/230.94   #with angle 240\n",
    "print\"ia=\",round(ia,3),\"A\"\n",
    "print \"ib=\",round(ib,5),\"A\"\n",
    "print \"ic=\",round(ic,5),\"A\"\n",
    "#case b\n",
    "#IN=ia+ib+ic\n",
    "#ia,ib and ic are phase currents hence contain with angles they are in the form sin(angle)+icos(angle)\n",
    "#IN=51.96*(sin(0)+i*cos(0))+43.3*(sin(120)+i*cos(120))+34.64*(sin(240)+i*cos(240))\n",
    "#IN=51.96+(-21.65+i*37.5)+34.64*(-0.5-i*0.866)\n",
    "#12.99+i*7.5 on which the sin+icos=sin**2+cos**2 operation is performed\n",
    "#therefore  \n",
    "IN=15 #at angle 30\n",
    "print \"IN=\",round(IN,10),\"A\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.2:Page number-320 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iab= 2.0 A\n",
      "ibc=5.4414-j3.1416 A\n",
      "ica=3.1463+j4.2056 A\n",
      "ia=4.2328 with an angle of -96.51 A\n",
      "ib=4.1915 with angle of -48.55 A\n",
      "ic=7.6973 with an angle of 107.35 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#case a\n",
    "vab=400 #phase angle of 0\n",
    "vbc=400 #phase angle of 120\n",
    "vca=400 #phase angle of 240\n",
    "#the phase currents are given by iab,ibc,ica\n",
    "iab=400/150 #from the diagram \n",
    "print \"iab=\",round(iab,5),\"A\"\n",
    "#ibc=(400*314*50)/10**6  numerator with an angle of -120 and denominator angle of -90 which amounts to -30 in numerator\n",
    "#this leads to simplifying with the formula as the value obtained for ibc after simplification from above mutiplied by values of cos(-30)+jsin(-30)\n",
    "#therefore print as below\n",
    "print\"ibc=5.4414-j3.1416\",\"A\"\n",
    "#same method for ica\n",
    "print \"ica=3.1463+j4.2056\",\"A\"\n",
    "#case b\n",
    "#ia=iab-ica\n",
    "#ia=2.667-(3.1463+j4.2056)\n",
    "#leads to 4.2328 with an angle of -96.51\n",
    "#angle calculated using tan formula\n",
    "print \"ia=4.2328 with an angle of -96.51\",\"A\"\n",
    "#same for ib and ic\n",
    "print \"ib=4.1915 with angle of -48.55\",\"A\"\n",
    "print \"ic=7.6973 with an angle of 107.35\",\"A\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.3:Page number:321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "power factor =0.8\n",
      "p= 25601.1 KW\n",
      "q= 19200.82 Kvar\n",
      "t= 32001.0 KVA\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#case a\n",
    "#given\n",
    "zl=5 #load impedanc with an angle of 36.87 degrees\n",
    "vl=400 #line voltage\n",
    "il=46.19\n",
    "va=400/3**0.5 #phase voltage\n",
    "ia=va/zl  #line current with an angle of -36.87 degrees\n",
    "#ib and ic are also the same values with changes in in their angles\n",
    "#case b\n",
    "#cos(-36.87)=0.8 lagging\n",
    "print \"power factor =0.8\"\n",
    "#case c\n",
    "p=3**0.5*vl*il*0.8 #power where 0.8 is power factor\n",
    "print\"p=\",round(p,2),\"KW\"\n",
    "#case d\n",
    "q=3**0.5*vl*il*0.6 #where 0.6 is sin(36.87) and q is reactive volt ampere\n",
    "print\"q=\",round(q,2),\"Kvar\"\n",
    "#case e\n",
    "t=3**0.5*vl*il #total volt ampere\n",
    "print \"t=\",round(t,0),\"KVA\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.4: Page number-321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ia=29.33A\n",
      "ib=73.83A\n",
      "ic=73.82A\n",
      "vr=1466.5V\n",
      "vl=73.83V\n",
      "vc=73.83V\n",
      "vn=1212.45V\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#given\n",
    "za=50\n",
    "zb=15  #j15\n",
    "zc=-15 #-j15\n",
    "vl=440\n",
    "vab=440 #with an angle of 0\n",
    "vbc=440 #with an angle of -120\n",
    "vca=440 #with an angle of -240\n",
    "#applying kvl to meshes as in the diagram we get the following equations\n",
    "#50i1+j15(i1-i2)-440(angle 0)=0,j15(i2-i1)+(-j15)i2-440(angle 120)=0\n",
    "#solving the above 2 eqns we get the values of ia,ib and ic as follows\n",
    "print \"ia=29.33A\" #at angle -30\n",
    "print \"ib=73.83A\" #at angle -131.45\n",
    "print \"ic=73.82A\" #at angle 71.5\n",
    "#the voltage drops across vr,vl and vc which are voltages across resistance ,inducctance and capacitance are given as follows\n",
    "print \"vr=1466.5V\" #at angle -30\n",
    "print \"vl=73.83V\"  #at angle -41.45\n",
    "print \"vc=73.83V\"  #at angle -18.5\n",
    "#the potential of neutral point\n",
    "print \"vn=1212.45V\" #at angle 150\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.5:Page number-323"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "il= 42.88104 A\n",
      "ip= 24.75738 A\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#given\n",
    "v=440 #voltage\n",
    "o=25000 #output power\n",
    "e=0.9 #efficiency\n",
    "p=0.85 #poer factor\n",
    "#case a\n",
    "il=o/(3**0.5*v*p*e) #line current\n",
    "print \"il=\",round(il,5),\"A\"\n",
    "#case b\n",
    "ip=o/(3*v*e*p) #phase current for delta current winding\n",
    "print \"ip=\",round(ip,5),\"A\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Example 5.7:Page number-329"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iab= 34.78 A\n",
      "ibc= 55.648 A\n",
      "ica= 41.736 A\n",
      "ia=76.38A\n",
      "ib=87.85A\n",
      "ic=32.21A\n",
      "w1=31.63KW\n",
      "w2=12.827KW\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#given\n",
    "#25kW at power factor 1 for branch AB\n",
    "#40KVA at power factor 0.85 for branch BC\n",
    "#30KVA at power factor 0.6 for branch CA\n",
    "#line voltages with vab as reference phasor\n",
    "vab=415 #at angle 0\n",
    "vbc=415 #at angle -120\n",
    "vca=415 #at angle -240\n",
    "#phase currents are given with x+jy form of an imaginary number and vary according to angles.The values below are only the values of the currents without conversion into imaginary form\n",
    "iab=(25*10**3)/(3**0.5*415*1)\n",
    "print \"iab=\",round(iab,3),\"A\"\n",
    "ibc=(40*10**3)/(3**0.5*415)\n",
    "print \"ibc=\",round(ibc,3),\"A\"\n",
    "ica=(30*10**3)/(3**0.5*415)\n",
    "print \"ica=\",round(ica,3),\"A\"\n",
    "#the line currents are as below.The following values can also be converted to x+iy form where x is real and y is imaginary\n",
    "#ia=iab-ibc and subtraction is done of x+iy forms where the value of the term varies as obtained by sqrt(x**2+y**2)\n",
    "print \"ia=76.38A\" #at angle -3.75\n",
    "#ib=ibc-iab\n",
    "print \"ib=87.85A\"\n",
    "#ic=ica-ibc\n",
    "print \"ic=32.21A\"\n",
    "#wattmeter readings on phase A\n",
    "#w1=vab*ia*cos(-3.35) where the cos angle is given by phase angle between ia and vab\n",
    "print \"w1=31.63KW\"\n",
    "#same formula for wattmeter readings in phase c where the angle is 16.35\n",
    "print \"w2=12.827KW\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5.8:Page number-331"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the total input power= 700.0 KW\n",
      "power factor=0.803\n",
      "il= 0.22877 A\n",
      "output= 0.845 hp\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "#given\n",
    "w1=500\n",
    "w2=200\n",
    "w=w1+w2\n",
    "#case a\n",
    "print \"the total input power=\",round(w,0),\"KW\"\n",
    "#case b\n",
    "#tan(angle)=3**0.5*(w1-w2)/(w1+w2) where the angle=36.58 and cos(36.58)=0.803 which is the power factor\n",
    "print \"power factor=0.803\"\n",
    "#case c\n",
    "#given\n",
    "vl=2200\n",
    "il=w/(3**0.5*vl*0.803)  #0.803 is the value of the cos angle and il is the line current\n",
    "print \"il=\",round(il,5),\"A\"\n",
    "#case d\n",
    "#efficiency=o/i #i is input and o is output\n",
    "hp=746 #horse power\n",
    "o=0.9*w/hp #0.9 is efficiency\n",
    "print \"output=\",round(o,3),\"hp\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}