diff options
author | hardythe1 | 2015-07-03 12:23:43 +0530 |
---|---|---|
committer | hardythe1 | 2015-07-03 12:23:43 +0530 |
commit | 5a86a20b9de487553d4ef88719fb0fd76a5dd6a7 (patch) | |
tree | db67ac5738a18b921d9a8cf6e86f402703f30bdf /Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb | |
parent | 37d315828bbfc0f5cabee669d2b9dd8cd17b5154 (diff) | |
download | Python-Textbook-Companions-5a86a20b9de487553d4ef88719fb0fd76a5dd6a7.tar.gz Python-Textbook-Companions-5a86a20b9de487553d4ef88719fb0fd76a5dd6a7.tar.bz2 Python-Textbook-Companions-5a86a20b9de487553d4ef88719fb0fd76a5dd6a7.zip |
add/remove books
Diffstat (limited to 'Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb')
-rwxr-xr-x | Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb | 751 |
1 files changed, 751 insertions, 0 deletions
diff --git a/Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb b/Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb new file mode 100755 index 00000000..6b8c7b81 --- /dev/null +++ b/Electrical_Measurements_Measuring_Instruments_by_K._Shinghal/Chapter4.ipynb @@ -0,0 +1,751 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 4 - Potentiometers"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 1 - pg 256"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Unknown resistor (ohm) = 0.08275\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 256\n",
+ "#Example 4.1: Unknown resistor\n",
+ "#calculate the Unknown resistor\n",
+ "#given data :\n",
+ "Vd=0.83942;# volt-drop in V\n",
+ "emf=23*10**-6;# in V\n",
+ "Vds=1.01575;# volt-drop in V\n",
+ "Rs=0.10014;# in ohm\n",
+ "#calculations\n",
+ "Vdt=Vd-emf;# in V\n",
+ "I=Vds/Rs;\n",
+ "R=Vdt/I;\n",
+ "#results\n",
+ "print \"Unknown resistor (ohm) = \",round(R,5)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 2 - pg 257"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(a). emf of the cell,(V) = 1.42562\n",
+ "(b). % error (high),(%) = 1.98\n",
+ "(c). % error (high),(%) = 1.59\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 257\n",
+ "#Example 4.2: emf and % error \n",
+ "#calculate the emf and % error \n",
+ "#given data :\n",
+ "l=50;# in cm\n",
+ "l1=70;# in cm\n",
+ "l2=65;# in cm\n",
+ "l3=43.5;# in cm\n",
+ "I=0.45;# in A\n",
+ "V=1.0183;# in V\n",
+ "V1=1.35;# in V\n",
+ "R=2;# in ohm\n",
+ "#calculations\n",
+ "Vpl=V/l;# in V/cm\n",
+ "emf=Vpl*l1;\n",
+ "Vr=Vpl*l2;\n",
+ "P_error1=((V1-Vr)/Vr)*100;\n",
+ "Ir=(Vpl*l3)/R;# in A\n",
+ "P_error2=((I-Ir)/Ir)*100;\n",
+ "#results\n",
+ "print \"(a). emf of the cell,(V) = \",emf\n",
+ "print \"(b). % error (high),(%) = \",round(P_error1,2)\n",
+ "print \"(c). % error (high),(%) = \",round(P_error2,2)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 3 - pg 258"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "part a \n",
+ "current is (A)= 0.02\n",
+ "resistance is (ohm)= 100.0\n",
+ "part b\n",
+ "current is (mA)= 7.078\n",
+ "resistance is (k-ohm)= 2035.32\n",
+ "resistance is calculated wrong in the textbook\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 258\n",
+ "#Example 4.3.a: current and resistance\n",
+ "#calculate the current and resistance\n",
+ "#given\n",
+ "import numpy\n",
+ "from numpy import linalg\n",
+ "e1=1.0191;#V\n",
+ "r1=100.;#ohms\n",
+ "l=2;#m\n",
+ "e2=4;#V\n",
+ "#calculations and results\n",
+ "I=l/r1;#A\n",
+ "rh=(e2/I)-r1;#\n",
+ "print 'part a '\n",
+ "print \"current is (A)=\",I\n",
+ "print \"resistance is (ohm)=\",rh\n",
+ "e1=4;#V\n",
+ "e2=1.0191;#V\n",
+ "R1=100;#OHM\n",
+ "R2=49.045;#OHMS\n",
+ "r3=R1-R2;#ohms\n",
+ "rg=50;#ohms\n",
+ "r4=200;#ohms\n",
+ "A=numpy.matrix([[r4, -r3],[-r3, (r4+rg+r3)]]);#\n",
+ "B=numpy.matrix([[e1],[e2]]);#\n",
+ "X=numpy.dot(numpy.linalg.inv(A),B)\n",
+ "I2=X[1,0]*10**3;#\n",
+ "I1=((e1+(r3*10**-5))/r4);#mA\n",
+ "rp=((e2+(r3*I1)-(r4+rg+r3)*10**-5)/10**-5);#\n",
+ "#results\n",
+ "print 'part b'\n",
+ "print \"current is (mA)=\",round(I2,3)\n",
+ "print \"resistance is (k-ohm)=\",round(rp*10**-2,2)\n",
+ "print 'resistance is calculated wrong in the textbook'\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4 - pg 259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "internal resistance,Ri(ohm) = 176.689\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 259\n",
+ "#Example 4.4: Resistance\n",
+ "#calculate the internal resistance\n",
+ "#given data :\n",
+ "emf=1.01892;# in V\n",
+ "R=1;# in M-ohm\n",
+ "V=1.01874;# in V\n",
+ "#calculations\n",
+ "Ic=V/R;\n",
+ "Vd=emf-V;\n",
+ "Ri=Vd/(Ic*10**-6);\n",
+ "#results\n",
+ "print \"internal resistance,Ri(ohm) = \",round(Ri,3)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 5 - pg 259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Internal resistance,Ri(ohm) = 3.636\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 259\n",
+ "#Example 4.5: Resistance\n",
+ "#calculate the resistance\n",
+ "#given data :\n",
+ "l=65;# in cm\n",
+ "V=0.1;# in V\n",
+ "V1=5.5;# in V\n",
+ "R=20;# in ohm\n",
+ "#calculations\n",
+ "E=V*l;\n",
+ "I=V1/R;\n",
+ "Ri=(E-V1)/I;\n",
+ "#results\n",
+ "print \"Internal resistance,Ri(ohm) = \",round(Ri,3)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6 - pg 259"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resistance is (k-ohm)= 50.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 259\n",
+ "#Example 4.6: Resistance\n",
+ "#calculate the resistance\n",
+ "#given\n",
+ "vr=5.;#V\n",
+ "r=10.;#k-ohm\n",
+ "#calculations\n",
+ "x=vr*r*10**3;#\n",
+ "R=x;#\n",
+ "#results\n",
+ "print \"resistance is (k-ohm)=\",R*10**-3\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 7 - pg 260"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The length of slide wire (cm) = 200.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 260\n",
+ "#Example 4.7: Length\n",
+ "#calculate the length of the slide wire\n",
+ "#given data :\n",
+ "l=40.;# in cm\n",
+ "r=0.5;# ion ohm\n",
+ "V=1.2;# in V\n",
+ "V1=6;# in V\n",
+ "#calculations\n",
+ "R=r*l/1;# in ohm\n",
+ "I=V/R;\n",
+ "x=V1/(r*I);\n",
+ "#results\n",
+ "print \"The length of slide wire (cm) = \",x\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 8 - pg 260"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resistance R is (ohm)= 20.0\n",
+ "resistance R1 is (ohm)= 2.0\n",
+ "resistance R2 is (ohm)= 4.0\n",
+ "resistance per cm of slide wire is (ohm/cm)= 0.02\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 260\n",
+ "#Example 4.8: design\n",
+ "#calculate the resistance in all cases\n",
+ "#given\n",
+ "vab=1.;#V\n",
+ "i=50.;#mA\n",
+ "n=10.;#\n",
+ "l=100.;#cm\n",
+ "#calculations\n",
+ "vr=2-vab;#V\n",
+ "R=vr/(i*10**-3);#ohm\n",
+ "R1=(vr/10)/(i*10**-3);#ohm\n",
+ "tr1=n*R1;#ohm\n",
+ "r2=2*R1;#\n",
+ "x=R1/l;#\n",
+ "#results\n",
+ "print \"resistance R is (ohm)=\",R\n",
+ "print \"resistance R1 is (ohm)=\",R1\n",
+ "print \"resistance R2 is (ohm)=\",r2\n",
+ "print \"resistance per cm of slide wire is (ohm/cm)=\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 9 - pg 261"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resistance is (ohm) = 39.5\n",
+ "resolution of the instrument is (micro-V) = 20.0\n",
+ "error is (micro-V) = 2.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 261\n",
+ "#Example 4.9.a:resistance\n",
+ "#calculate the resistance, resolution and error\n",
+ "#given\n",
+ "st=15.;#steps\n",
+ "r=5.;#ohm\n",
+ "rsw=5.5;#ohm\n",
+ "vr=1.61;#V\n",
+ "e2=1.61;#V\n",
+ "e1=2.40;#V\n",
+ "trn=11.;#turns\n",
+ "dv=100.;#divisions\n",
+ "ig=0.05;#micro-A\n",
+ "vlt=1.1;#V\n",
+ "ir=50.;#ohm\n",
+ "#calculations\n",
+ "tr=(st*r)+rsw;#ohm\n",
+ "i=vr/tr;#A\n",
+ "rh=(e1-e2)/i;#ohm \n",
+ "slwr=rsw/trn;#ohm\n",
+ "vd=slwr*i;#V\n",
+ "vedv=(1/dv)*vd;#\n",
+ "rs=vedv/5;#\n",
+ "em=((ig*ir));#\n",
+ "#results\n",
+ "print \"resistance is (ohm) = \",rh\n",
+ "print \"resolution of the instrument is (micro-V) = \",rs*10**6\n",
+ "print \"error is (micro-V) = \",em\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 10 - pg 262"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "power dissipated in the resistor is (mW)= 0.4176\n",
+ "power dissipated in the coil is (mW)= 0.264\n",
+ "power dissipated in the capacitor is (mW)= 0.036\n",
+ "energy stored in the coil is (micro-J)= 0.61\n",
+ "energy stored in capacitor is (micro-J)= 0.42\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 262\n",
+ "#Example 4.10:power dissipated\n",
+ "#calculate the power dissipated and energy stored\n",
+ "#given\n",
+ "import math,cmath\n",
+ "r1=0.6-1j*0.24;#V\n",
+ "r2=0.6+1j*0.4;#V\n",
+ "r3=-0.1-1j*0.4;#V\n",
+ "f=50;#Hx\n",
+ "ir=1000;#ohm\n",
+ "#calculations\n",
+ "i1=r1/ir;#A\n",
+ "pdr=(r1.real*i1.real)+(r1.imag*i1.imag);#W\n",
+ "pdC=(r1.real*i1.real)+(r2.imag*i1.imag);#W\n",
+ "pdc=(r3.real*i1.real)-(r2.imag*i1.imag);#W\n",
+ "imp=(r2/r1)*10**3;#ohm\n",
+ "rc=imp.imag;#ohm\n",
+ "indu=rc/(2*math.pi*f);#H\n",
+ "ersl=(1./2)*(i1.imag**2+i1.real**2)*indu;#joules\n",
+ "admc=(r1*10**-3)/r3;#ohm**-1\n",
+ "C=admc.imag/(2*math.pi*f);#\n",
+ "ersc=(1./2)*(r3.imag**2+r3.real**2)*C;#\n",
+ "#results\n",
+ "print \"power dissipated in the resistor is (mW)=\",pdr*10**3\n",
+ "print \"power dissipated in the coil is (mW)=\",pdC*10**3\n",
+ "print \"power dissipated in the capacitor is (mW)=\",pdc*10**3\n",
+ "print \"energy stored in the coil is (micro-J)=\",round(ersl*10**6,2)\n",
+ "print \"energy stored in capacitor is (micro-J)=\",round(ersc*10**6,3)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 11 - pg 263"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "measuring range of the potentiometer is (V)= 1.9\n",
+ "resolution is (mV)= 0.5\n",
+ "current through the dial is (mA)= 10.0\n",
+ "setting of the rheostat is (ohm)= 410.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 263\n",
+ "#Example 4.11:measuring range,resulution,working current,setting of the rheostat\n",
+ "#calculate the measuring range,resulution,working current,setting of the rheostat\n",
+ "#given\n",
+ "sd=18.;#steps\n",
+ "v1=0.1;#V\n",
+ "dv=100;#divisions\n",
+ "dr=10;#ohm\n",
+ "wbc=6;#V\n",
+ "#calculations\n",
+ "mr=(sd*v1)+v1;#V\n",
+ "rs=(v1/dv)*(1./2);#mV\n",
+ "cdd=v1/dr;#A\n",
+ "rsv=wbc-mr;#V\n",
+ "sh=rsv/cdd;#ohm\n",
+ "#results\n",
+ "print \"measuring range of the potentiometer is (V)=\",mr\n",
+ "print \"resolution is (mV)=\",rs*10**3\n",
+ "print \"current through the dial is (mA)=\",cdd*10**3\n",
+ "print \"setting of the rheostat is (ohm)=\",sh\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 12 - pg 263"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "true value of drop across the resistance is (V)= 0.6529\n",
+ "percentage error is (%)= 0.06\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 263\n",
+ "#Example 4.12:voltage and percentage error\n",
+ "#calculate the voltage and percentage error\n",
+ "#given\n",
+ "st=15;#steps\n",
+ "r1=10;#ohm\n",
+ "v1=0.1;#V\n",
+ "r2=10;#ohm\n",
+ "r3=9.9;#ohm\n",
+ "v2=0.0185;#V\n",
+ "v3=1.0185;#V\n",
+ "n=6;#\n",
+ "vg=0.6525;#\n",
+ "#calculations\n",
+ "acr=(r1*r3)+((r2*v2)/v1);#ohm\n",
+ "I=v3/acr;#\n",
+ "acr1=(n*r3)+(r2*0.0525)/v1;#ohm\n",
+ "tvr=I*acr1;#V\n",
+ "er=((tvr-vg)/tvr)*100;#\n",
+ "#results\n",
+ "print \"true value of drop across the resistance is (V)=\",round(tvr,4)\n",
+ "print \"percentage error is (%)=\",round(er,2)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 13 - pg 264"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "reactance is (ohm)= 1.28\n",
+ "inductance of the coil is (mH)= 30.0\n",
+ "The answer is a bit different due to rounding off error in textbook\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 264\n",
+ "#Example 4.13:resistance and reactance\n",
+ "#calculate the resistance and reactance\n",
+ "#given\n",
+ "import math,cmath\n",
+ "from math import sqrt,atan,sin\n",
+ "r1=2.;#ohm\n",
+ "r2=9.;#\n",
+ "vm=85.;#V\n",
+ "va=40.;#degree\n",
+ "vm1=90.;#V\n",
+ "va1=45.;#degree\n",
+ "f=50.;#Hz\n",
+ "#calculations\n",
+ "imp=r1+1j*r2;#ohm\n",
+ "mg=sqrt(r1**2+r2**2);#\n",
+ "th=atan(r2/r1) *57.3;#\n",
+ "ccm=vm/mg;#A\n",
+ "cca=va-th;#degree\n",
+ "impm=vm1/ccm;#ohm\n",
+ "impa=va1-cca;#degree\n",
+ "reac=impm*sin(impa/57.3);#ohm\n",
+ "rc=sqrt(impm**2-reac**2);#ohm\n",
+ "ind=reac/(2*math.pi*f);#\n",
+ "#results\n",
+ "print \"reactance is (ohm)=\",round(rc,2)\n",
+ "print \"inductance of the coil is (mH)=\",math.floor(ind*10**3)\n",
+ "print 'The answer is a bit different due to rounding off error in textbook'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 14 - pg 265"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "limit of error in the reading is 48.6 micro-V\n",
+ "deflection of the galvanometer is (mm)= 8.1\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 265\n",
+ "#Example 4.14:limit of error,deflection\n",
+ "#calculate the limit of error and deflection of galvanometer\n",
+ "#given\n",
+ "x=17.5;#mm/micro-A\n",
+ "r1=850.;#ohm\n",
+ "v1=2.;#V\n",
+ "r2=80.;#\n",
+ "v3=1.43;#V\n",
+ "v2=0.1;#V\n",
+ "l=50.;#cm\n",
+ "l1=2.;#mm\n",
+ "fr1=22.784;#\n",
+ "#calculations\n",
+ "lr=r1*(1./x);#micro V\n",
+ "i1=v1/r2;#A\n",
+ "r3=v2/i1;#ohm\n",
+ "r4=v3/i1;#ohm\n",
+ "r5=((l1/10.)/l)*r3;#ohm\n",
+ "fr=r4+r5;#ohm\n",
+ "R=(fr*fr1)/r2;#ohm\n",
+ "e=i1*fr;#V\n",
+ "ig=(e-v3)/(r1+R);#A\n",
+ "dg=ig*x*10**6;#mm\n",
+ "#results\n",
+ "print \"limit of error in the reading is \",round(lr,1),\" micro-V\"\n",
+ "print \"deflection of the galvanometer is (mm)=\",round(dg,1)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 15 - pg 266"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Current in one direction,I1(mA) = 10.0\n",
+ "Current in another direction,I2(mA) = 10.34\n"
+ ]
+ }
+ ],
+ "source": [
+ "#pg 266\n",
+ "#Example 4.15: Current \n",
+ "#calculate the Current \n",
+ "#given data :\n",
+ "V1=4.2;# in V\n",
+ "V2=1.43;# in V\n",
+ "r1=21.0;# in ohm\n",
+ "r2=1.;# in ohm\n",
+ "r3=15.;# in ohm\n",
+ "#calculations\n",
+ "I=V1/r1;# in A\n",
+ "R=V2/I;# in ohm\n",
+ "R1=R+r2;\n",
+ "R2=R-r2;\n",
+ "R3=round(R1*(r1-R1)/r1);\n",
+ "R4=R2*(r1-R2)/r1;\n",
+ "e1=R1*I;\n",
+ "e2=R2*I;\n",
+ "I1=(e1-V2)*10**3/(R3+r3);\n",
+ "I2=(V2-e2)*10**3/(R4+r3);\n",
+ "#results\n",
+ "print \"Current in one direction,I1(mA) = \",I1\n",
+ "print \"Current in another direction,I2(mA) = \",round(I2,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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
|