def circuit(): circuit = Circuit() circuit.add_resistor(value="430", node1="n1", node2="nm") circuit.add_capacitor(name="c1", value="10u", node1="nm", node2="gnd") circuit.add_resistor(value="43k", node1="nm", node2="nout") circuit.add_capacitor(value="47p", node1="nm", node2="nout") circuit.add_library_opamp(model="LT1124", node1="gnd", node2="nm", node3="nout") return circuit
def test_input_noise_units(self): """Check units when projecting noise to input.""" circuit = Circuit() circuit.add_capacitor(value="10u", node1="gnd", node2="n1") circuit.add_resistor(value="430", node1="n1", node2="nm", name="r1") circuit.add_resistor(value="43k", node1="nm", node2="nout") circuit.add_capacitor(value="47p", node1="nm", node2="nout") circuit.add_library_opamp(model="LT1124", node1="gnd", node2="nm", node3="nout") analysis = AcNoiseAnalysis(circuit=circuit) kwargs = { "frequencies": self.f, "node": "n1", "sink": "nout", "incoherent_sum": True } # Check the analysis without projecting. solution = analysis.calculate(input_type="current", **kwargs) self.assertRaises(ValueError, solution.get_noise, source="R(r1)", sink="input") rnoise = solution.get_noise(source="R(r1)", sink="nout") self.assertEqual(rnoise.sink_unit, "V") # Check the analysis, projecting to input, with voltage input. solution = analysis.calculate(input_type="voltage", input_refer=True, **kwargs) self.assertRaises(ValueError, solution.get_noise, source="R(r1)", sink="nout") rnoise = solution.get_noise(source="R(r1)", sink="n1") self.assertEqual(rnoise.sink_unit, "V") # Check the analysis, projecting to input, with current input. solution = analysis.calculate(input_type="current", input_refer=True, **kwargs) self.assertRaises(ValueError, solution.get_noise, source="R(r1)", sink="nout") rnoise = solution.get_noise(source="R(r1)", sink="input") self.assertEqual(rnoise.sink_unit, "A")
import numpy as np from zero import Circuit from zero.analysis import AcNoiseAnalysis from zero.tools import create_response if __name__ == "__main__": # 1000 frequencies between 0.1 Hz to 100 kHz frequencies = np.logspace(-1, 5, 1000) # Create circuit object. circuit = Circuit() # The photodiode is a current source that connects through a photodiode circuit model (shunt # capacitor and series resistor). circuit.add_capacitor(value="200p", node1="gnd", node2="nD") circuit.add_resistor(value="10", node1="nD", node2="nm") # Transimpedance amplifier. circuit.add_library_opamp(model="OP27", node1="gnd", node2="nm", node3="nout") circuit.add_resistor(value="1k", node1="nm", node2="nout") # Solve circuit. analysis = AcNoiseAnalysis(circuit=circuit) solution = analysis.calculate(frequencies=frequencies, input_type="current", node="nD", sink="nout",
Sean Leavey """ import numpy as np from zero import Circuit from zero.analysis import AcSignalAnalysis if __name__ == "__main__": # 1000 frequencies between 1 Hz to 1 MHz. frequencies = np.logspace(0, 6, 1000) # Create circuit object. circuit = Circuit() # Add components. circuit.add_capacitor(value="10u", node1="gnd", node2="n1") circuit.add_resistor(value="430", node1="n1", node2="nm") circuit.add_resistor(value="43k", node1="nm", node2="nout") circuit.add_capacitor(value="47p", node1="nm", node2="nout") circuit.add_library_opamp(model="LT1124", node1="gnd", node2="nm", node3="nout") # Solve circuit. analysis = AcSignalAnalysis(circuit=circuit) solution = analysis.calculate(frequencies=frequencies, input_type="current", node="n1") # Scale transfer functions by 2 (e.g. to account for 50Ω network analyser as discussed in