##Basic Circuit Concepts
##page no-1.9
##example1.1
print("Current through 15Ohm resistor is given by:");
print("I1=30/15");
I1=30/15
print"%s %.2f %s "%("current through 15Ohm resistor = ",I1," Ampere")
print("Current through 5Ohm resistor is given by:")
print("I2=5+2");
I2=5+2
print"%s %.2f %s "%("current through 5ohm resistor = ",I2," Ampere")
print("R=100-30-5*I2/I1");
R=(100-30-5*I2)/I1
print"%s %.2f %s "%("R = ",R," Ohm");
##Basic Circuit Concepts
##page no-1.10
##example1.2
import math
import numpy
print("from the given fig:")
print("I2-I3=13");
print("-20*I1+8*I2=0");
print("-12*I1-16*I3=0");
##solving these equations in the matrix form
A=numpy.matrix([[0, 1 ,-1],[-20, 8, 0],[-12 ,0 ,-16]])
B=numpy.matrix([[13], [0] ,[0]])
print("A=")
print[A]
print("B=")
print[B]
X=numpy.dot(numpy.linalg.inv(A),B)
print("X=")
print[X]
print("I1 = 4Ampere")
print("I2 = 10Ampere")
print("I3 = -3Ampere")
##Basic Circuit Concepts
##pg no-1.11
##example 1.3
print("Iaf=x")
print("Ife=x-30")
print("Ied=x+40")
print("Idc=x-80")
print("Icb=x-20")
print("Iba=x-80")
print("Applying KVL to the closed path AFEDCBA:")##Applying KVL to the path AFEDCBA
print("x=4.1/0.1")
x=4.1/0.1;
Iaf=x;
print"%s %.2f %s "%("\nIaf = ",Iaf," Ampere");
Ife=x-30.
print"%s %.2f %s "%("\nIfe = ",Ife," Ampere");
Ied=x+40.;
print"%s %.2f %s "%("\nIed = ",Ied," Ampere");
Idc=x-80;
print"%s %.2f %s "%("\nIdc = ",Idc," Ampere");
Icb=x-20.;
print"%s %.2f %s "%("\nIcb = ",Icb," Ampere");
Iba=x-80.;
print"%s %.2f %s "%("\nIba = ",Iba," Ampere");
##Basic Circuit Concepts
##pg no- 1.12
##example 1.4
import math
import numpy
print("Applying KVL to the closed path OBAO");##Applying KVL to the closed path OBAO
print("3*x-3*y=2");
print("Applying KVL to the closed path ABCA");##Applying KVL to the closed path ABCA
print("9*x+12*y=4");
a=numpy.matrix([[3, -3],[9, 12]]);
b=([[2] ,[4]])
print("a=")
print[a]
print("b=")
print[b]
X=numpy.dot(numpy.linalg.inv(a),b)
print(X)
print("x=0.5714286 Ampere");
print("y=-0.095238 Ampere");
print("Ioa=0.57A")
print("Iob=1-0.57")
Iob=1-0.57;
print"%s %.2f %s "%("\nIob = ",Iob," A");
print("Iab = 0.095");
Iac=0.57-0.095;
print"%s %.2f %s "%("\nIac =",Iac," A");
print("Iab=1-0.57 + 0.095")
Iab=1-0.57 + 0.095;
print"%s %.2f %s "%("\nIob = ",Iab," A")
##Basic Circuit Concepts
##pg no-1.12
##example 1.5
I1=2./5.;
print"%s %.2f %s "%("I1=2/5= ",I1," Ampere")
I2=4./8.;
print"%s %.2f %s "%("\nI2=4/8= ",I2," Ampere")
print("\nPotential difference between points x and y = Vxy = Vx-Vy")
print("\nWriting KVL equations for the path x to y")##Writing KVL equation from x to y
print("\nVs+3*I1+4-3*I2-Vy=0")
print("\nVs+3*(0.4) + 4- 3*(0.5) -Vy = 0")
print("\nVs+3*I1+4-3*I2-Vy = 0")
print("\nVx-Vy = -3.7")
print("\nVxy = -3.7V")
##Basic Circuit Concepts
##pg no-1.13
##example 1.6
import math
#calculate the
I1=20/15.;
print'%s %.2f %s'%("I1=2/5= ",I1," Ampere")
I2=15./10.;
print'%s %.2f %s'%("\nI2=4/8= ",I2," Ampere")
print("Voltage between points A and B = VAB = VA-VB");
print("Writing KVL equations for the path A to B:");##Writing KVL equations for the path A to B
print("VA - 5*I1 - 5 - 15 + 6*I2 - VB = 0");
print("VA - VB = 5*1.33 + 5 + 15 + 6*1.5");
VAB=(5*1.33)+5.+15.-(6*1.5);
print'%s %.2f %s'%("VAB = ",VAB," Volt")
##Basic Circuit Concepts
##page no-1.13
##example1.7
import math
#calculate the
I1=5./2.;
print'%s %.2f %s'%("I1=2/5= ",I1," Ampere")
I2=2.;
print'%s %.2f %s'%("\nI2=4/8= ",I2," Ampere")
print("Potential difference VAB = VA - VB");
print("Writing KVL equations for path A to B") ##Writing KVL equations for path A to B
print("VA - 2*I1 + 8 - 5*I2 - VB = 0");
print("VA - VB = (2*2.5) - 8 5 + (5*2)");
VAB=(2.*2.5)-8.+(5.*2.)
print'%s %.2f %s'%("VAB = ",VAB," Volt");
##Basic Circuit Concepts
##page no-1.14
##example1.8
import math
#calculate the
I1=10./8.;
print'%s %.2f %s'%("I1=2/5= ",I1," Ampere")
I2=5.;
print'%s %.2f %s'%("\nI2=4/8= ",I2," Ampere")
print("Applying KVL to the path from A to B") ##Applying KVL to the path from A to B
print("VA - 3*I1 - 8 + 3*I2 - VB = 0");
print("VA - VB = 3*1.25 + 8 - 3*5")
VAB= (3*1.25)+8.-(3.*5.);
print'%s %.2f %s'%("VAB = ",VAB," Volt");
##Basic Circuit Concepts
##page no-1.17
##example1.12
print("Applying KVL to the circuit :");
print("50 - 5*I - 1.2*I - 16 = 0")
I=(50.-16.)/6.2;
print'%s %.2f %s'%("I= ",I," Amp");
P=50.*I;
print'%s %.2f %s'%("\nPower delivered 50 V source = 50 * 5.48= ",P," W");
##Basic Circuit Concepts
##page no-1.18
##example1.13
print("By Current Division formula ;");
I4=4.*(2./(2.+4.));
print'%s %.2f %s'%("I4 = 4 * (2/(2+4)) = ",I4," Amp");
##Basic Circuit Concepts
##page no-1.19
##example1.14
print("Applying KVL to the mesh");
print("15 - 50*I - 50*I - 5*I");
I=15./105.;
print'%s %.2f %s'%("I=15/105 = ",I," Amp");
V=15-(50*0.143);
print'%s %.2f %s'%("\nVoltage at node 2 = 15 - 50*I = ",V," Volt");
##Basic Circuit Concepts
##pg no.-1.20
##example 1.15
r1=3.;
r2=2.33;
r3=6.;
v1=18.;
v2=5.985;
print("\nApplying KCL at the node, \n(Va-18)/3+(Va-5.985)/2.33+Va/6 = 0");
Va=((v1*r2*r3)+(v2*r1*r3))/((r2*r3)+(r1*r3)+(r1*r2));
print'%s %.2f %s'%("\nSolving the equation,we get, \nVa = ",Va," V");