# wheatstone bridge
import math
#Variable declaration
Vs=12.0 #source voltage
R=120.0 #resistance of arms
delv=0.3 #variation in output voltage(+/-)0.3
Rm=100.0 #meter resistance
#Calculations
delRbyR=(4.0/Vs)*(delv)*100
delIm=(delRbyR/100.0)/(4.0*R*(1+(Rm/R)))
#Result
print("percent change in resistance:")
print("delRbyR = %.f%% \n"%delRbyR)
print("current variation:")
print("delIm = %.6f A"%delIm)
# Answer current variation is not matchhing with the book
# high resistance measurement bridge
import math
#variable declaration
#in absence of the guard point arrangement, two 10^10 ohm resistances in series become parallel
#to the 10^9 ohm resistance, making the effective unknown resistance
#case-1
Rh=10.0**9
Ra1=10.0**10
Rb1=10.0**10
#case-2
Ra2=10.0**9
Rb2=10.0**9
#Calculations
Rue1=((Rh*2*Ra1)/(Rh+(2*Ra1))) #effective resistance
err1=((Rh-Rue1)/Rh)*100 #percentage error
Rue2=((Rh*2*Ra2)/(Rh+(2*Ra2))) #effective resistance
err2=((Rh-Rue2)/Rh)*100 #percentage error
#Result
print("percentage error case-1:")
print("err1 = %.0f%% \n"%err1)
print("percentage error case-2:")
print("err2 = %.1f%%"%err2)
# capacitance and resistance of AC bridge
import math
#Variable declaration
Z1=20.0+80.0j #impedance in first arm
Z2=200.0 #impedance in second arm
Z3=100.0+200.0j #impedance in third arm
f=50.0 #excitation frequency
#Calculations
Zu=((Z2*Z3)/Z1) #impedance of fourth arm
Cu=(1.0/(2*math.pi*f*Zu.real)) #capacitance in fourth arm
Ru=-Zu.imag #resistance in fourth arm
#Result
print("capacitance in fourth arm:")
print("Cu = %f F\n"%(Cu*10**6))
print("resistance in fourth arm:")
print("Ru = %.2f ohm"%Ru)
#Answer is slightly different than book
# schering bridge
import math
#Variable declaration
C3=0.001*10**-6 #capacitor
Fd=6.0*10**-4 #dissipation factor
f=1.0*10**3 #schering bridge frequency
R1=10.0*10**3
R2=10.0*10**3
#Calculations
Ru=(Fd/(2*math.pi*f*C3)) #standard resistor
C1=C3*(1/R2)*Ru
#Result
print("standard resistor:")
print("Ru = %.3f ohm\n"%Ru)
print("capacitor:")
print("C1 = %.1f pF"%(C1*10**12))
#Answer do not match with the book
# wein bridge
import math
#Variable declaration
R=10*10**3 #resistor
C=0.001*10**-6 #capacitor
R3=10.0*10**3 #reistance in third arm
#Calculations
f=(1.0/(2*math.pi*R*C)) #supply frequency
R4=(R3/2) #reistance in fourth arm
#Result
print("supply frequency:")
print("f = %.2f kHz\n"%(f/1000))
print("reistance in fourth arm:")
print("R4 = %.1f k-ohm"%(R4/1000))
# balance condition in wein bridge
import math
#Variable declaration
f=47.76*10**3 #supplu frequency
C=10**-9 #assume
#Calculations
CR=(1.0/(2*math.pi*f)) #resistor capacitor product
R=(CR/C) #resistor
#Result
print("for (R3/R4) = 2\nR3 and R4 may be maintained at earlier values")
# relation between Vo and t for Vi given
import math
#Variable declaration
a1=3.81*10**-3
a2=-6.17*10**-7
#R1=(R2/2),i.e R2/R1=2
R1=10*10**3
R2=20*10**3
R5=4*10**3
R6=20*10**3
#Calculations
B=(R5/(R5+R6))
#using relation 10.68(b)
#Result
print("(Vo/Vi)= (-3.05*10^-3)t/(1+0.76*10^-3)t")
print("thus for, t<=130 C, Vo is approx. linear. This however can be extended with proper choice")
print("i.e R5 and R6 in relation to R1,R3 and R4")
# find deflection in galvanometer
import math
#Variable declaration
R1=120.0 #resistance of arm-1
R2=120.0 #resistance of arm-2
R3=120.0 #resistance of arm-3
R4=121.0 #resistance of arm-4
Rm=100.0 #meter resistance
Vs=6.0 #source voltage
n=1*10**-3 #meter sensitivity
#Calculations
k=(R3/(R3+R4))
k = math.floor(k*10**3)/10**3
Vm=Vs*((R1/(R1+R2))-k) #voltage across meter
Rb=((R1*R2)/(R1+R2))+((R3*R4)/(R3+R4)) #thevenised bridge resistance
Rb=math.floor(Rb*1000)/1000
Ig=(Vm/(Rb+Rm)) #current through galvanometer
D=Ig*10**6
#Result
print("deflection in meter:")
print("D = %f mm"%D)
#Calcualtions in the book are not correct
# find insulating post resistance
import math
#Variable declaration
err=0.5/100.0 #(+/-)0.5%
R=100.0*10**6 #test resistance
#Calculations
#Re=((R*2*Rip)/(R+(2*Rip)))
Re1=R-(err*R) #err=+0.5
Re2=R+(err*R) #err=-0.5
Rip1=((R*Re1)/(2*(R-Re1))) #err=+0.5
Rip2=((R*Re2)/(2*(Re2-R))) #err=-0.5
#Result
print("resistance of each insulating post-1:")
print("Rip1 = %.2f M-ohm\n"%(Rip1*10**-6))
print("resistance of each insulating post-2:")
print("Rip2 = %.2f M-ohm"%(Rip2*10**-6))
# Answer in the book are not matching
# maxwell bridge
import math
#Variable declaration
Ru=130.0 #resistance
Lu=31*10**-3 #inductance
R2=10*10**3 #resistance in arm-2
C1=0.01*10**-6 #capacitance in arm
#Calculations
R3=(Lu/(C1*R2)) #resistance in arm-3
R1=((R2*R3)/Ru) #resistance in arm-1
#Result
print("R1 = %.2f k-ohm"%(R1/1000))
print("R3 = %.f ohm"%R3)
print("yes values are unique")
# hay bridge
import math
#Variable declaration
f=1000.0 #supply frequency
C1=0.04*10**-6 #capacitance
R1=220.0 #resistance in arm-1
R2 = 10*10**3 #resistance in arm-2
Lu=22.0*10**-3 #inductance
#Calculations
pi= math.floor(math.pi*100)/100
Ru=((2*pi*f)**2)*C1*R1*Lu #resistance
R3=((R1*Ru)+(Lu/C1))/R2 #resistance in arm-3
#Result
print("resistance of inductor:")
print("Ru = %.3f ohm\n"%Ru)
print("resistance of arm-3:")
print("R3 = %.2f ohm"%R3)
#Answer for R3 is not matching.
# find C1 C3 and dissipation factor
import math
#Variable declaration
C4=0.0033*10**-6 #lossy capacitor
R2=12.0*10**3 #arm-2 resistance
R1=10.0*10**3 #arm-1 resistance
f = 50.0 # frequency
#Calculations
C3=((C4*R2)/R1) #standard capacitance
R4=0.1
C1=((R4*C3)/R2)
Fd=2*math.pi*f*C4*R4 #dissipation factor
#Result
print("capacitance set value:")
print("C1 = %.5f * 10^12 F\n"%(C1*10**12))
print("value of standard capacitance:")
print("C3 = %.5f *10^6 F\n"%(C3*10**6))
print("dissipation factor:")
print("Fd = %.4f * 10^-6"%(math.floor(Fd*10**10)/10**4))
#Answer for C1 is wrong
# wein bridge
import math
#Variable declaration
f=10.0*10**3 #supply frequency
R1=10.0*10**3 #reistance of arm-1
C1=0.01*10**-6
C2=0.01*10**-6
R3=20*10**3 #resistance of arm-3
#Calaculations
R2=(1/(f**2))*(1/(C1*C2*R1)) #resistance of arm-2
R4=(R3/((R1/R2)+(C2/C1))) #resistance of arm-4
#Result
print("resistance of arm-2:")
print("R4 = %.f k-ohm\n"%(R2/1000))
print("resistance of arm-4:")
print("R2 = %.f k-ohm\n"%(R4/1000))