def test_forwardBiasSeries(self): Vf = 0.6 Rf = 10 D1 = Diode.Diode(Vf, Rf) D2 = Diode.Diode(Vf, Rf) R = resistor.Resistor(100000) gnd = AbsoluteVoltage.AbsoluteVoltage(0.0, name="gnd") j = Junction.Junction() k = Junction.Junction() #Vcc=VoltageSource.VoltageSource(5.0,name="Vcc") Vcc = AbsoluteVoltage.AbsoluteVoltage(5.0, name="Vcc") probe = VoltageProbe.VoltageProbe() #Vcc.connect(R,"positive") #Vcc.connect(gnd,"negative") Vcc.connect(R) R.connect(j) D1.connect(j, "anode") D1.connect(k, "cathode") D2.connect(k, "anode") D2.connect(gnd, "cathode") probe.connect(j) import Infrastructure.graph as graph graph.graph(j).output("../junk/diode.gv") print probe.getVoltageResistance()
def test_reverseBias(self): D = Diode.Diode() R = resistor.Resistor(1000000) gnd = AbsoluteVoltage.AbsoluteVoltage(0.0, name="gnd") j = Junction.Junction() #Vcc=VoltageSource.VoltageSource(5.0,name="Vcc") Vcc = AbsoluteVoltage.AbsoluteVoltage(5.0, name="Vcc") probe = VoltageProbe.VoltageProbe() #Vcc.connect(R,"positive") #Vcc.connect(gnd,"negative") Vcc.connect(R) R.connect(j) D.connect(j, "cathode") D.connect(gnd, "anode") probe.connect(j) print probe.getVoltageResistance()
def test_TwoVoltageSources(self): V1 = VoltageSource.VoltageSource(5, name="SRC") V2 = VoltageSource.VoltageSource(5, name="SRC") gnd = AbsoluteVoltage.AbsoluteVoltage(0, name="gnd") probe = VoltageProbe.VoltageProbe(name="probe") j = Junction.Junction() V1.connect(gnd, "negative") V1.connect(j, "positive") V2.connect(j, "negative") V2.connect(probe, "positive") self.assertEqual(probe.getVoltageResistance(), (10.0, 0.0))
def twoResistorDivider(self, R1, R2, V): src = AbsoluteVoltage.AbsoluteVoltage(V, name="Vcc") gnd = AbsoluteVoltage.AbsoluteVoltage(0, name="GND") probe = VoltageProbe.VoltageProbe() j = Junction.Junction(name="Joint") R = resistor.Resistor(R1, name="R1") S = resistor.Resistor(R2, name="R2") R.connect(src) R.connect(j) probe.connect(j) S.connect(j) S.connect(gnd) return probe.getVoltageResistance()
def test_ProbeReturnsCorrectValue(self): src = AbsoluteVoltage.AbsoluteVoltage(5, name="Vcc") gnd = AbsoluteVoltage.AbsoluteVoltage(0, name="GND") probe = VoltageProbe.VoltageProbe() j = Junction.Junction(name="Joint") R = resistor.Resistor(1000, name="R1") S = resistor.Resistor(1000, name="R2") R.connect(src) R.connect(j) S.connect(j) S.connect(gnd) probe.connect(j) atJ = j.getVoltageResistance() atProbe = probe.getVoltageResistance()
def test_ProbeInfluence(self): src = AbsoluteVoltage.AbsoluteVoltage(5, name="Vcc") gnd = AbsoluteVoltage.AbsoluteVoltage(0, name="GND") probe = VoltageProbe.VoltageProbe() j = Junction.Junction(name="Joint") R = resistor.Resistor(1000, name="R1") S = resistor.Resistor(1000, name="R2") R.connect(src) R.connect(j) S.connect(j) S.connect(gnd) before = j.getVoltageResistance() probe.connect(j) after = j.getVoltageResistance()