#Question:
"""Finding the value of capacitance parameter."""
#Variable Declaration:
per_free_space=8.854e-12 #Permittivity of free space(in Farad per metre)
A=0.113 #Total area(in square metre)
rel_per=10.0 #Relative permittivity of mica layer
d=0.1e-03 #Thickness of mica layer(in metre)
#Calculations:
C1=(per_free_space*rel_per*A)/d
W=0.05
V=100.0
C2=(2*W)/(V*V)
i=5e-03
dv=100
dt=0.1
C3=i/(dv/dt)
#Result:
print "(i)The value of capacitance is %.2f micro Farad." %(C1*1000000)
print "(ii)The value of capacitance is %.2f micro Farad." %(C2*1000000)
print "(iii)The value of capacitance is %.2f micro Farad." %(C3*1000000)
#Question:
"""Finding the inductance of the coil for different cases."""
#Variable Declaration:
W=0.2 #Energy stored in magnetic field(in Joules)
i=0.2 #Current producing magnetic field(in Amperes)
#Calculations:
L1=(2*W)/(i*i)
v=10
di=0.1
dt=0.2
L2=v/(di/dt)
p=2.5
di=0.5
dt=1
i=0.1
L3=p/(i*(di/dt))
#Result:
print "(i)The inductance of the coil is %.2f H." %(L1)
print "(ii)The inductance of the coil is %.2f H." %(L2)
print "(iii)The inductance of the coil is %.2f H." %(L3)
#Question:
"""Finding the inductance of 2 coils."""
#Variable Declaration:
Leq=0.7 #Equivalent self-inductance(in Henry)
#Calculations:
""" Leq=0.7 H;
Leq=((L1*L2)/(L1+L2))+0.5 ;
L1=(2*L2); """
L2=(Leq-0.5)*(3.0/2)
L1=2*L2
#Result:
print "L1=%.2f H. \nL2=%.2f H." %(L1,L2)
#Question:
"""Finding the equivalent capacitance of the network and the voltage drop across each capacitor. """
#Variable Declaration:
V=220.0 #Voltage of the DC source(in Volts)
C1=0.05e-06 #Capacitance of the capacitor 1(in Farad)
C2=0.10e-06 #Capacitance of the capacitor 2(in Farad)
C3=0.20e-06 #Capacitance of the capacitor 3(in Farad)
C4=0.05e-06 #Capacitance of the capacitor 4(in Farad)
#Calculations:
Cs=1/((1/C1)+(1/C2)+(1/C3)+(1/C4))
Q=Cs*V
V1=Q/C1
V2=Q/C2
V3=Q/C3
V4=Q/C4
#Result:
print "The equivalent capacitance of the network is %.4f micro Farad." %(Cs*1000000)
print "The voltage across capacitor C1= %.2f V." %(V1)
print "The voltage across capacitor C2= %.2f V." %(V2)
print "The voltage across capacitor C3= %.2f V." %(V3)
print "The voltage across capacitor C4= %.2f V." %(V4)
#Question:
"""Finding the voltage across each capacitor."""
#Variable Declaration:
Q1=400e-06 #Charge on the capacitor 1(in Coulombs)
Q2=200e-06 #Charge on the capacitor 2(in Coulombs)
C1=2e-06 #Capacitance of the capacitor 1(in Farad)
C2=10e-06 #Capacitance of the capacitor 2(in Farad)
#Calculations:
Q=Q1+Q2
C=C1+C2
V=Q/C
#Result:
print "After the switch is closed, the voltage that exists across each capacitor is %.2f V." %(V)
#Question:
""" A series combination of 2 capacitances C1=2 micro-F and C2=8 micro-F is connected across a dc-supply of 300-V.Determine(a)the charge,
(b)the voltage,and(c)the energy stored in each capacitor. """
#Variable Declaration:
C1=2e-06 #Capacitance of the capacitor 1(in Farad)
C2=8e-06 #Capacitance of the capacitor 2(in Farad)
V=300.0 #Voltage of Dc supply(in Volts)
#Calculations:
C=(C1*C2)/(C1+C2)
Q=C*V
V1=Q/C1
V2=Q/C2
W1=(1.0/2)*C1*(V1*V1)
W2=(1.0/2)*C2*(V2*V2)
#Result:
print "(a)When connected in series,the charge on each capacitor is the same.The charge on each capacitor is %.2f micro Coulomb." %(Q*1000000)
print "(b)The voltage across the capacitor C1= %.2f V.\n The voltage across the capacitor C2= %.2f V." %(V1,V2)
print "(c)The energy stored in the capacitor C1= %.2f milli Joule." %(W1*1000)
print " The energy stored in the capacitor C2= %.2f milli Joule." %(W2*1000)
#Question:
"""Finding the value of capacitance."""
#Variable Declaration:
C_eq=1e-06 #Equivalent capacitance of the network(in Farad)
C1=1e-06 #Capacitance of the capacitor 1(in Farad)
C2=8e-06 #Capacitance of the capacitor 2(in Farad)
C3=2e-06 #Capacitance of the capacitor 3(in Farad)
C4=2e-06 #Capacitance of the capacitor 4(in Farad)
C5=6e-06 #Capacitance of the capacitor 5(in Farad)
C6=12e-06 #Capacitance of the capacitor 6(in Farad)
C7=4e-06 #Capacitance of the capacitor 7(in Farad)
#Calculations:
C8=C3+C4
C9=1/((1/C5)+(1/C6))
C10=1/((1/C2)+(1/C8))
C11=C7+C9
C12=1/((1/C1)+(1/C11))
C13=C12+C10
C=1/((1/C_eq)-(1/C13))
#Result:
print "The value of capacitance C is %.2f micro Farad." %(C*1e06)
#Question:
"""Finding the % change in V_L and I_L."""
#Variable Declaration:
E=3.0 #EMF of the battery(in Volts)
Ri=1.0 #Internal resistance of the battery(in Ohms)
R_L_min=100.0 #Minimum value of variable load resistance(in Ohms)
R_L_max=1000.0 #Maximum value of variable load resistance(in Ohms)
#Calculations and Result:
I_L1=E/(R_L_min+Ri)
I_L2=E/(R_L_max+Ri)
V_L1=E-(I_L1*Ri)
V_L2=E-(I_L2*Ri)
if I_L1>I_L2 :
change_I_L= ((I_L1-I_L2)/I_L1)*100
ans="(a)The percentage decrease in I_L is %.2f percent" %(round(change_I_L,2))
print(ans)
elif I_L2>IL1 :
change_I_L= ((I_L2-I_L1)/I_L1)*100
ans="(a)The percentage increase in I_L is %.2f percent" %(round(change_I_L,2))
print(ans)
else: print("(a)The percentage change in I_L is 0 percent.")
if V_L2>V_L1 :
change_V_L= ((V_L2-V_L1)/V_L1)*100
ans=" The percentage increase in V_L is %.2f percent" %(round(change_V_L,2))
print(ans)
elif V_L1>V_L2 :
change_V_L= ((V_L1-V_L2)/V_L1)*100
ans=" The percentage decrease in V_L is %.2f percent" %(round(change_V_L,2))
print(ans)
else : print(" The percentage change in V_L is 0","%")
R_L_min=1e-03
R_L_max=10e-03
I_L1=E/(R_L_min+Ri)
I_L2=E/(R_L_max+Ri)
V_L1=round((E-(I_L1*Ri)),3)
V_L2=round((E-(I_L2*Ri)),2)
if I_L1>I_L2 :
change_I_L= ((I_L1-I_L2)/I_L1)*100
ans="(b)The percentage decrease in I_L is %.2f percent" %(round(change_I_L,2))
print(ans)
elif I_L2>I_L1 :
change_I_L= ((I_L2-I_L1)/I_L1)*100
ans="(b)The percentage increase in I_L is %.2f percent" %(round(change_I_L,2))
print(ans)
else : print("(b) The percentage change in I_L is 0 percent")
if V_L2>V_L1 :
change_V_L= ((V_L2-V_L1)/V_L1)*100
ans=" The percentage increase in V_L is %.3f percent" %(change_V_L)
print(ans)
elif V_L1>V_L2 :
change_V_L= ((V_L1-V_L2)/V_L1)*100
ans=" The percentage decrease in V_L is %.2f percent" %(change_V_L)
print(ans)
else: print(" The percentage change in V_L is 0 percent")
#Question:
"""Finding the power delivered by the ideal part of the sources."""
#Variable Declaration:
R_S=2.0 #Resistance of the current source(in Ohms)
I_S=3.0 #Current from the current source(in Amperes)
R_L=4.0 #Resistance of the load(in Ohms)
#Calculations:
V_S=R_S*I_S
I_L1=I_S*(R_S/(R_S+R_L))
V_L1=I_L1*R_L
R1=1/((1/R_S)+(1/R_L))
P_S1=I_S*I_S*R1
I_L2=V_S/(R_S+R_L)
V_L2=V_S*(R_L/(R_S+R_L))
R2=R_S+R_L
P_S2=(V_S*V_S)/R2
#Result:
print "Case 1:"
print "I_L=%.2f A. \nV_L=%.2f V. \nP_S=%.2f W." %(I_L1,V_L1,P_S1)
print "\nCase 2:"
print "I_L=%.2f A. \nV_L=%.2f V. \nP_S=%.2f W." %(I_L2,V_L2,P_S2)
print "\nWe find that the two energy sources are equivalent as regards the terminal relationships. But, the total power delivered by the ideal part of the two sources is different."
#Question:
"""Finding the currents through the two resistors in the circut."""
#Calculations:
I_2_ohm1=16.0*(6.0/(6+2))
I_6_ohm1=16-I_2_ohm1
V_eq=16*2
I_2_ohm2=V_eq/(2+6)
I_6_ohm2=I_2_ohm2
#Result:
print "The current through the 2 ohm resistor is %.2f A." %(I_2_ohm1)
print "The current through the 6 ohm resistor is %.2f A. \n" %(I_6_ohm1)
print "After transformation,\nThe current through the 2 ohm resistor is %.2f A." %(I_2_ohm2)
print "The current through the 6 ohm resistor is %.2f A." %(I_6_ohm2)
#Question:
"""Finding the reduced network using source transformation."""
#Calculations:
"""First all the voltage sources are transformed to equivalent current sources."""
I1=8.0/2.0
I2=6.0/1.0
I3=6.0/2.0
I4=3.0/1.0
I5=I1+I2
I6=I3+I4
R1=1.0/((1.0/2.0)+(1.0/1.0))
R2=1.0/((1.0/2.0)+(1.0/1.0))
V5=I5*R1
V6=I6*R2
V_tot=V5+V6
R_tot=R1+R2
#Result:
print "The network is equivalent to a voltage source of %.3f V with an internal resistance of %.2f Ohms." %(V_tot,R_tot)
#Question:
"""Finding the voltage across 3 Ohms resistor."""
#Variable Declaration:
I1=4.0 #Current delivered by source 1(in Amperes)
R1=1.0 #Resitance of resistor parallel to current source 1(in Ohms)
V2=6.0 #Voltage of the voltage source 2(in Volts)
I2=5.0 #Current delivered by source 2(in Amperes)
R2=2.0 #Resistance of resistor 2(in Ohms)
R3=3.0 #Resistance of resistor 3(in Ohms)
#Calculations:
V1=I1*R1
V3=V1+V2
I3=V3/R1
I4=I3-I2
V4=I4*R1
V_res=V4*(R3/(R1+R2+R3))
#Result:
print "The voltage across 3 Ohms resistor is %.2f Volts." %(V_res)
#Question:
"""Finding the current in the circuit."""
#Variable Declaration:
V=24.0 #Supply voltage(in Volts)
R1=4.0 #Resistance of resistor 1(in Ohms)
R2=2.0 #Resistance of resistor 2(in Ohms)
#Calculations:
""" V1=4*I;
Applying Kirchoff's Voltage Law to the closed loop, 24-(4*I)-(2*I)-(4.5*4*I)=0 ; """
I=24/((R1+R2)-(4.5*R1))
P=-4.5*R1*I*I
R=V/I
#Result:
print "(a)The value of the current I is %.2f A." %(abs(I))
print "(b)The power absorbed by the dependent source is %.2f W." %(P)
print "(c)The resistance 'seen' by the independent voltage source is %.2f Ohms." %(R)
print "\nNOTE: The negative sign of the resistance is a result of the action of the dependent source."
#Question:
"""Finding the voltage in the circuit."""
#Variable Declaration:
V=100.0 #Supply voltage(in Volts)
#Calculations:
"""Appling KVL in the closed loop, +100-(40*I)-(60*I)=0."""
I=V/(40.0+60.0)
V1=I*60.0
"""Appling KVL in the open loop, -10+V1+(0*10)+30-Vab=0."""
Vab=30+V1-10
#Result:
print "The voltage Vab in the circuit is %.2f V." %(Vab)
#Question:
"""Finding the unknown voltages Vx and Vcd."""
#Variable Declaration:
V=10.0 #Supply voltage(in Volts)
Vca=4.0 #Voltage between points c and a(in Volts)
V1=6.0 #Voltage across resistor R1(in Volts)
V2=-4.0 #Voltage across resistor R2(in Volts)
#Calculations:
Vx=Vca-V2
Vcd=Vca-V1
#Result:
print "The voltage Vx in the circuit is %.2f V." %(Vx)
print "The voltage Vcd in the circuit is %.2f V." %(Vcd)
#Question:
"""Finding the currents in the network."""
from sympy import *;
#Calculations:
"""KVL equations for loops 1,2 and 3 are written and the equations are solved using SymPy."""
print "Note: All currents are expressed in Amperes."
Ix, Iy, I1 = symbols('Ix Iy I1');
solve([(5*Ix)+(0*Iy)+(10*I1)-100,(7*Ix)+(2*Iy)+(-2*I1)+50,(3*Ix)+(-5*Iy)+(-3*I1)+50], [Ix,Iy,I1])
#Question:
"""Finding the currents using Kirchoff's laws."""
from sympy import *;
#Calculations:
"""KCL equations at nodes B and C,we get
I1+I2=20;
I3-I2=30;"""
"""KVL equation for the outer loop ABCDEFGHA, I1-(3*I2)-(2*I3)=-100; """
print "All the currents are expressed in Amperes."""
print "Resistances R1 and R2 are in Ohms."""
I1, I2,I3,R1,R2 = symbols('I1 I2 I3 R1 R2')
solve([I1+I2+(0*I3)-20,(0*I1)-I2+I3-30,I1+(-3*I2)+(-2*I3)+100,(110-(0.1*I1))-(20*R1),(120-(0.2*I3))-(30*R2)],[I1,I2,I3,R1,R2])
#Question:
"""Finding the current through resistor in the circuit."""
#Variable Declaration:
I=2.0 #Loop current(in Amperes)
#Calculations:
"""KVL Equation: 10-(5*(I1-2))-(8*I1)=0."""
I1=(10.0+10.0)/(8.0+5.0)
#Result:
print "The current through the 8 Ohms resistor is %.3f A." %(I1)
#Question:
"""Finding the unknown voltage."""
#Calculations:
"""Writing the KVL equation around the loop of I, -(2*I)+(3*I)+6-(1*(I+5-4))=0."""
I=(6.0-1.0)/(2+3+1)
v=3*I
#Result:
print "The unknown voltage in the circuit is %.2f V." %(v)
#Question:
"""Finding the current drawn by the source."""
from sympy import *;
#Calculations:
"""Apply KVL for the loops 1, 2 and 3 and solving for currents."""
print "All the currents are expressed in Amperes."""
print "The current delivered by the source is I1."
I1, I2,I3,Is = symbols('I1 I2 I3 Is')
solve([(19*I1)+(-12*I2)+(0*I3)-60,(-12*I1)+(18*I2)+(-6*I3),(0*I1)+(-6*I2)+(18*I3),Is-I1], [I1,I2,I3,Is])
#Question:
"""Finding the mesh currents using mesh analysis."""
from sympy import *;
#Calculations:
"""Apply KVL for the loops 1, 2 and 3 and solving for currents."""
print "All the currents are expressed in Amperes."""
I1, I2, I3 = symbols('I1 I2 I3')
solve([(7*I1)+(-4*I2)+(0*I3)-13,(-4*I1)+(15*I2)+(-6*I3)-12,(0*I1)+(-6*I2)+(13*I3)-1], [I1,I2,I3])
#Question:
"""Finding the voltage across resistor using node-voltage analysis."""
from sympy import *;
#Calculations:
"""Apply KCL at nodes a and b and finding the nodal voltages."""
print "All the voltages are expressed in Volts."""
Va,Vb,Vab = symbols('Va Vb Vab')
solve([(Va/2)+((Va-Vb)/3)-5,((Vb-Va)/3)+(Vb/4)+6,Va-Vb-Vab], [Va,Vb,Vab])
#Question:
"""Finding the current through resistor."""
#Calculations:
"""Applying KCL at node 1,
((V1-0)/12.0)+((V1-60.0)/7.0)+((V1-0)/4.0)=0; """
V1=(60.0/7.0)/((1.0/12.0)+(1.0/7.0)+(1.0/4.0))
I1=V1/12.0
#Result:
print "The current I1 through the 12 Ohms resistor is %.2f A." %(I1)
#Question:
"""Finding the current through a resistor."""
from sympy import *;
#Calculations:
"""Apply KCL for supernode (a,b) and for node c and finding the nodal voltages."""
print "All the voltages are expressed in Volts."""
print "The current I is in Amperes."
Va,Vb,Vc,I = symbols('Va Vb Vc I')
solve([Va-Vb-6,(Va/3)+((Vb-Vc)/4)-2,((Vc-Vb)/4)+(Vc/5)+7,((Vb-Vc)/4)-I], [Va,Vb,Vc,I])
#Question:
"""Finding the voltage across resistor by nodal-voltage method."""
#Calculations:
"""Applying KCL at node a,
((Va-6.0)/1.0)+((Va-0.0)/5.0)=-4.0+5.0 ; """
Va=(6.0-1.0)/1.2
v=Va*(3.0/(2.0+3.0))
#Result:
print "The voltage across 3 Ohms resistor is %.2f V." %(v)
#Question:
"""Finding the current through resistor."""
from sympy import *;
#Calculations:
"""Applying KCL at nodes 1 and 2 and solving for nodal voltages."""
print "All the voltages are expressed in Volts."""
print "The current I is in Amperes."
V1,V2,I = symbols('V1 V2 I')
solve([(0.7*V1)+(-0.2*V2)-3,(-0.2*V1)+(1.2*V2)-2,((V1-V2)/5.0)-I],[V1,V2,I])
#Question:
"""Finding the current through a resistor."""
#Calculations:
"""Applying KCL at node 1,
((V-10.0)/2.0)+((V-0.0)/(1.0+3.0))+((V-8.0)/6.0)=0 ; """
V=((10.0/2.0)+(8.0/6.0))/((1.0/2.0)+(1.0/4.0)+(1.0/6.0))
I=V/(1.0+3.0)
#Result:
print "The current I is %.2f A." %(I)
#Question:
"""Finding the values of capacitances."""
from sympy import *;
#Variable Declaration:
Vs=200.0 #Voltage of the dc supply(in Volts)
V1=120.0 #Potential difference across C1(in Volts)
V_new=140.0 #Potential difference across C1 when a capacitor is added(in Volts)
#Calculations:
"""Case 1: The charge on each capacitor is the same.
(C1*V1)=(C2*V2);
(120*C1)=(80*C2);"""
"""Case 2: The capacitance of 3 micro Farad in parallel with C2 gives an equivalent capacitance of (C2+3) micro Farad.
(140*C1)=(60*(C2+3)) ;"""
print "Note:The capacitances are expressed in Farads."
C1,C2 = symbols('C1 C2')
solve([(120*C1)-(80*C2),(140*C1)-(60*(C2+(3e-06)))],[C1,C2])
#Question:
"""Finding the current in each branch."""
#Calculations:
I1=20.0/10.0
I4=10.0/5.0
I5=10.0/2.0
I2=(20.0-(10.0+9.0))/1.0
I3=(20.0-50.0-10.0)/20.0
Ia=I1+I2+I3
Ib=I4+I5-I2-I3
#Result:
print "The currents are:"
print " I1=%.2f A \n I2=%.2f A \n I3=%.2f A \n I4=%.2f A \n I5=%.2f A \n Ia=%.2f A \n Ib=%.2f A" %(I1,I2,I3,I4,I5,Ia,Ib)
#Question:
"""Finding the currents through resistors."""
from sympy import *;
#Calculations:
"""Apply KVL for the loops 1 and 2 and solving for currents."""
print "All the currents are expressed in Amperes."""
print "Current through R1= Current through R2=I1"
print "Current through R3=I3"
print "Current through R4=I2"
I1, I2, I3 = symbols('I1 I2 I3')
solve([(4.5*I1)+(-3*I2)-2,(-3*I1)+(4*I2)-5,I1-I2-I3], [I1,I2,I3])
#Question:
"""Finding the current through each resistor."""
#Variable Declaration:
E1=4.0 #EMF of cell 1(in Volts)
E2=8.0 #EMF of cell 2(in Volts)
R1=0.5 #Internal resistance of cell 1(in Ohms)
R2=1.0 #Internal resistance of cell 2(in Ohms)
#Calculations:
R3=1.0/((1.0/3.0)+(1.0/6.0))
Rt=R1+R2+R3+4.5
E=E2-E1
I=E/Rt
I_3=I*(6.0/(3.0+6.0))
I_6=I*(3.0/(3.0+6.0))
V1=E1+(I*R1)
V2=E2-(I*R2)
#Result:
print "(a)The current the 3 Ohms resistor is %.2f A." %(I_3)
print " The current the 6 Ohms resistor is %.2f A." %(I_6)
print " The current the 4.5 Ohms resistor is %.2f A." %(I)
print "(b)The potential difference across cell 1 is %.2f V and across cell 2 is %.2f V." %(V1,V2)
print " Note that the pd of cell E1 is greater than its EMF.This is so because the cell is working as a load."
#Question:
"""Finding the potential of point A."""
#Variable Declaration:
E1=8.0 #EMF of first source(in Volts)
E2=6.0 #EMF of second source(in Volts)
E3=4.0 #EMF of third source(in Volts)
R1=5.0 #Resistance of resistor 1(in Ohms)
R2=9.0 #Resistance of resistor 2(in Ohms)
#Calculations:
V_A=E3+E2-E1
#Result:
print "The potential of point A is %.2f V." %(V_A)
#Question:
"""Finding the energy stored in a capacitor."""
#Variable Declaration:
C=4e-06 #Capacitance of the capacitor(in Farad)
#Calculations:
""" Applying KCL to the node at the top of the capacitor, current through 5 Ohms resistance is 1+2=3 A.
Applying KCL to the node at the bottom of the capacitor, current through 2 Ohms resistance is 2-1=1 A."""
V=(3*5)+(3*1)+(1*2)
W=0.5*C*V*V
#Result:
print "The energy stored in the capacitor is %e J." %(W)
#Question:
"""Finding the potential differnce between two points."""
#Variable Declaration:
E1=3.0 #EMF of cell 1(in Volts)
E2=2.0 #EMF of cell 2in Volts)
E3=1.0 #EMF of cell 3in Volts)
r1=1.0 #Internal resistance of cell 1(in Ohms)
r2=1.0 #Internal resistance of cell 2(in Ohms)
r3=1.0 #Internal resistance of cell 3(in Ohms)
R=1.0 #Resistance of resistor R(in Ohms)
#Calculations:
"""Assigning loop currents as I1 and I2 and writing KVL equations for the two loops,
E1-(I1*r1)-((I1-I2)*r2)-E2=0; which is (-2*I1)+I2+1=0;
E2-(I2*r3)-((I2-I1)*r2)-E3=0; which is (-2*I2)+I1+1=0; """
eq1=-1
eq2=-1
I1=((2*eq1)+eq2)/(-3.0)
I2=((2*eq2)+eq1)/(-3.0)
Vab=E2+((I1-I2)*r2)+(0*R)
V_CB=E2
V_B=0.0
V_C=V_CB+V_B
I3=(V_C-E1)/r1
I4=(V_C-E3)/r3
I6=V_C/R
I5=I3+I4+I6
#Result:
print "(a)The potential difference between points A and B is %.2f V." %(Vab)
print " The current through r1 is %.2f A,the current through r2=%.2f A." %(I1,(I1-I2))
print " The current through r3=%.2f A and the current through R is 0(no closed loop)." %(I2)
print "(b)The current through E1 is %.2f A." %(I3)
print " The current through E2 is %.2f A." %(I5)
print " The current through E3 is %.2f A." %(I4)
print " The current through R is %.2f A." %(I6)
#Question:
"""Finding the potential diiference between two points."""
#Calculations:
pd_9=0.0
pd_13=0.0
pd_10=6.0*10.0
pd_5=5.0*8.0
pd_18=15.0
Vab=pd_5-pd_10-pd_18
#Result:
print "The voltage drop Vab is %.2f V." %(Vab)
print "The resistors 4 Ohms,11 Ohms,9 Ohms,18 Ohms and 13 Ohms have no effect on the voltage drop Vab."
#Question:
"""Finding the voltage of dependent voltage source."""
from sympy import *;
#Calculations:
"""Apply KVL for the loops 1 and 2."""
print "The current I1 is expressed in Amperes and the voltage V1 is expressed in Volts."""
V1,I1 = symbols('V1 I1')
solve([V1+(2*I1),24-(16*I1)-(4*V1)], [V1,I1])
#Question:
"""Finding the voltage V."""
from sympy import *;
#Calculations:
"""Apply KCL at the upper node and KVL equation for the left loop."""
print "The currents I1 and I2 are expressed in Amperes and the voltage V is expressed in Volts."""
I1,I2,V = symbols('I1 I2 V')
solve([I1-I2+(10*I2),36-(20e03*I1),V+(10*I2*(5e03))], [I1,I2,V])
#Question:
"""Finding the loop currents."""
from sympy import *;
#Calculations:
"""Apply KVL for the loops 1 and 2."""
print "The loop currents i1 and i2 are expressed in Amperes."
i1,i2 = symbols('i1 i2')
solve([(3*i2)-((i2-i1)*1)-(i2*2)-3,4-(i1*1)-((i1-i2)*1)-(3*i2)], [i1,i2])
#Question:
"""Finding the nodal voltages."""
from sympy import *;
#Calculations:
"""Applying KCL at top node and solving for nodal voltages."""
print "All the voltages are expressed in Volts."""
print "The current I is in Amperes."
V1,V2,I = symbols('V1 V2 I')
solve([9-I-(V1/10)+(3*I),9-(4*V1/5)-(V1/10),V2-V1-108],[V1,V2,I])
#Question:
"""Finding the current I by nodal analysis."""
from sympy import *;
#Calculations:
"""Apply KCL at the nodes 1 and 2."""
print "The nodal voltages V1 and V2 are expressed in Volts."
print "The current I is expressed in Amperes."
V1,V2,I = symbols('V1 V2 I')
solve([(2*V1)-(V2)-12,(-2*V1)+(4*V2)-6,I-((V1-V2)/3)], [V1,V2,I])
#Question:
"""Finding the current I in the circuit."""
from sympy import *;
#Calculations:
"""Apply KCL at the nodes 1 and 2."""
print "The nodal voltages V1 and V2 are expressed in Volts."
print "The current I is expressed in Amperes."
V1,V2,I = symbols('V1 V2 I')
solve([(1*V1)-(0.5*V2)-6,(-0.5*V1)+(0.625*V2)-3,I-((V1-V2)/2)], [V1,V2,I])
#Question:
"""Finding the current through resistor."""
from sympy import *;
#Calculations:
"""Apply KCL at the nodes 1,2. and 3"""
print "The nodal voltages V1,V2 and V3 are expressed in Volts."
print "The current I flowing through the 2 Ohms resistor is expressed in Amperes."
V1,V2,V3,I = symbols('V1 V2 V3 I')
solve([(7*V1)-(3*V2)-(4*V3)+11,(-3*V1)+(6*V2)-(2*V3)-3,(-4*V1)-(2*V2)+(11*V3)-25,I-(2*(V2-V3))], [V1,V2,V3,I])
#Question:
"""Finding the nodal voltages in the circuit."""
from sympy import *;
#Calculations:
Ieq=13.0*5.0 #Equivalent current source
"""Apply KCL at the nodes 1 and 2."""
print "The nodal voltages V1 and V2 are expressed in Volts."
V1,V2 = symbols('V1 V2')
solve([(9*V1)-(5*V2)-10,(-5*V1)+(11*V2)-52], [V1,V2])