LIBRARY
Analog.Semiconductors.Tests.NPNTest ​
Test circuit for NPN: a resistively loaded common-emitter stage under a slow base ramp.
The base is driven 0 to 1 V over 1 s through 10 kΩ, with the collector fed from a 5 V rail through 1 kΩ. The run carries the device from cut-off through forward active into saturation: the collector resistor voltage rc.v tracks the collector current, rising from zero until the collector saturates near the ground rail.
The base resistor is not optional: an ideal source placed directly across the base-emitter junction sits across C_jE, which is structurally singular. The substrate pin is grounded, reproducing the upstream use_substrate = false behavior.
Usage ​
ElectricalComponents.Analog.Semiconductors.Tests.NPNTest()
Behavior ​
Source ​
dyad
"""
Test circuit for NPN: a resistively loaded common-emitter stage under a slow
base ramp.
The base is driven 0 to 1 V over 1 s through 10 kΩ, with the collector fed
from a 5 V rail through 1 kΩ. The run carries the device from cut-off through
forward active into saturation: the collector resistor voltage `rc.v` tracks
the collector current, rising from zero until the collector saturates near
the ground rail.
The base resistor is not optional: an ideal source placed directly across the
base-emitter junction sits across `C_jE`, which is structurally singular. The
substrate pin is grounded, reproducing the upstream `use_substrate = false`
behavior.
"""
test component NPNTest
"Supply rail level (5 V)"
supply_lvl = BlockComponents.Sources.Constant(k = 5) {
"Dyad": {"placement": {"diagram": {"x1": 20, "y1": 220, "x2": 120, "y2": 320}}}
}
"Collector supply"
supply = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {"placement": {"diagram": {"x1": 155, "y1": 335, "x2": 255, "y2": 435}}}
}
"Base ramp: 0 to 1 V over 1 s"
bias_sig = BlockComponents.Sources.Ramp(height = 1, duration = 1) {
"Dyad": {"placement": {"diagram": {"x1": 150, "y1": 120, "x2": 250, "y2": 220}}}
}
"Base drive"
bias = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {"placement": {"diagram": {"x1": 285, "y1": 235, "x2": 385, "y2": 335}}}
}
"Base series resistance (10 kΩ)"
rb = ElectricalComponents.Analog.Basic.Resistor(R = 10000) {
"Dyad": {"placement": {"diagram": {"x1": 415, "y1": 130, "x2": 515, "y2": 230}}}
}
"Collector load resistor (1 kΩ)"
rc = ElectricalComponents.Analog.Basic.Resistor(R = 1000) {
"Dyad": {"placement": {"diagram": {"x1": 285, "y1": 20, "x2": 385, "y2": 120}}}
}
"Transistor under test"
q = ElectricalComponents.Analog.Semiconductors.NPN() {
"Dyad": {"placement": {"diagram": {"x1": 545, "y1": 130, "x2": 645, "y2": 230}}}
}
"Ground reference"
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {"placement": {"diagram": {"x1": 415, "y1": 340, "x2": 515, "y2": 440}}}
}
relations
"Base drive starts at 0: junctions discharged, collector at the rail"
initial q.V_BE = 0
initial q.V_CS = 5
connect(supply_lvl.y, supply.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 270}], "E": 2}], "path": {}}}
connect(bias_sig.y, bias.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 335, "y": 170}], "E": 2}], "path": {}}}
connect(supply.p, rc.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 140, "y": 385}, {"x": 140, "y": 70}], "E": 2}],
"path": {}
}
}
connect(rc.n, q.c) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 595, "y": 70}], "E": 2}], "path": {}}}
connect(bias.p, rb.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 270, "y": 285}, {"x": 270, "y": 180}], "E": 2}],
"path": {}
}
}
connect(rb.n, q.b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(q.e, q.s, supply.n, bias.n, ground.g) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 595, "y": 245}, {"x": 660, "y": 245}, {"x": 660, "y": 180}],
"E": 2
},
{
"S": 2,
"M": [{"x": 670, "y": 180}, {"x": 670, "y": 490}, {"x": 270, "y": 490}],
"E": -1
},
{"S": -1, "M": [], "E": 3},
{"S": -1, "M": [{"x": 400, "y": 385}], "E": -2},
{"S": -2, "M": [], "E": 4},
{"S": -2, "M": [{"x": 465, "y": 285}], "E": 5}
],
"junctions": [{"x": 270, "y": 385}, {"x": 400, "y": 285}],
"path": {}
}
}
metadata {
"Dyad": {"tests": {"case1": {"stop": 1, "expect": {"signals": ["q.V_BE", "rc.v"]}}}}
}
endFlattened Source
dyad
"""
Test circuit for NPN: a resistively loaded common-emitter stage under a slow
base ramp.
The base is driven 0 to 1 V over 1 s through 10 kΩ, with the collector fed
from a 5 V rail through 1 kΩ. The run carries the device from cut-off through
forward active into saturation: the collector resistor voltage `rc.v` tracks
the collector current, rising from zero until the collector saturates near
the ground rail.
The base resistor is not optional: an ideal source placed directly across the
base-emitter junction sits across `C_jE`, which is structurally singular. The
substrate pin is grounded, reproducing the upstream `use_substrate = false`
behavior.
"""
test component NPNTest
"Supply rail level (5 V)"
supply_lvl = BlockComponents.Sources.Constant(k = 5) {
"Dyad": {"placement": {"diagram": {"x1": 20, "y1": 220, "x2": 120, "y2": 320}}}
}
"Collector supply"
supply = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {"placement": {"diagram": {"x1": 155, "y1": 335, "x2": 255, "y2": 435}}}
}
"Base ramp: 0 to 1 V over 1 s"
bias_sig = BlockComponents.Sources.Ramp(height = 1, duration = 1) {
"Dyad": {"placement": {"diagram": {"x1": 150, "y1": 120, "x2": 250, "y2": 220}}}
}
"Base drive"
bias = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {"placement": {"diagram": {"x1": 285, "y1": 235, "x2": 385, "y2": 335}}}
}
"Base series resistance (10 kΩ)"
rb = ElectricalComponents.Analog.Basic.Resistor(R = 10000) {
"Dyad": {"placement": {"diagram": {"x1": 415, "y1": 130, "x2": 515, "y2": 230}}}
}
"Collector load resistor (1 kΩ)"
rc = ElectricalComponents.Analog.Basic.Resistor(R = 1000) {
"Dyad": {"placement": {"diagram": {"x1": 285, "y1": 20, "x2": 385, "y2": 120}}}
}
"Transistor under test"
q = ElectricalComponents.Analog.Semiconductors.NPN() {
"Dyad": {"placement": {"diagram": {"x1": 545, "y1": 130, "x2": 645, "y2": 230}}}
}
"Ground reference"
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {"placement": {"diagram": {"x1": 415, "y1": 340, "x2": 515, "y2": 440}}}
}
relations
"Base drive starts at 0: junctions discharged, collector at the rail"
initial q.V_BE = 0
initial q.V_CS = 5
connect(supply_lvl.y, supply.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 270}], "E": 2}], "path": {}}}
connect(bias_sig.y, bias.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 335, "y": 170}], "E": 2}], "path": {}}}
connect(supply.p, rc.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 140, "y": 385}, {"x": 140, "y": 70}], "E": 2}],
"path": {}
}
}
connect(rc.n, q.c) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 595, "y": 70}], "E": 2}], "path": {}}}
connect(bias.p, rb.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 270, "y": 285}, {"x": 270, "y": 180}], "E": 2}],
"path": {}
}
}
connect(rb.n, q.b) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
connect(q.e, q.s, supply.n, bias.n, ground.g) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [{"x": 595, "y": 245}, {"x": 660, "y": 245}, {"x": 660, "y": 180}],
"E": 2
},
{
"S": 2,
"M": [{"x": 670, "y": 180}, {"x": 670, "y": 490}, {"x": 270, "y": 490}],
"E": -1
},
{"S": -1, "M": [], "E": 3},
{"S": -1, "M": [{"x": 400, "y": 385}], "E": -2},
{"S": -2, "M": [], "E": 4},
{"S": -2, "M": [{"x": 465, "y": 285}], "E": 5}
],
"junctions": [{"x": 270, "y": 385}, {"x": 400, "y": 285}],
"path": {}
}
}
metadata {
"Dyad": {"tests": {"case1": {"stop": 1, "expect": {"signals": ["q.V_BE", "rc.v"]}}}}
}
endTest Cases ​
Test Case case1 ​
julia
pltjulia
plt