Fix NPN/PNP transport currents to use NF/NR emission coefficients by ChrisRackauckas-Claude · Pull Request #528 · SciML/ModelingToolkitStandardLibrary.jl · GitHub
Skip to content

Fix NPN/PNP transport currents to use NF/NR emission coefficients - #528

Draft
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:mainfrom
ChrisRackauckas-Claude:agent/527-bjt-emission-coeffs
Draft

ChrisRackauckas-Claude wants to merge 3 commits into
SciML:mainfrom
ChrisRackauckas-Claude:agent/527-bjt-emission-coeffs

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

Summary

NPN/PNP ICC/IEC transport currents omitted forward/reverse emission coefficients NF/NR while the diffusion capacitances already used them, so C_DE ≠ Tau_f·∂ICC/∂V_BE whenever NF ≠ 1 (and likewise for NR). This matches the Modelica Standard Library v4.0.0 Gummel-Poon NPN/PNP: both currents and capacitances use V/(NF·vt) / V/(NR·vt). Defaults NF=NR=1 leave existing behaviour unchanged.

Changes

  • src/Electrical/Analog/transistors.jl: ICC ~ Is*(exp(V_BE/(NF*V_T))-1) and IEC ~ Is*(exp(V_BC/(NR*V_T))-1) (PNP: V_EB/V_CB analogues).
  • test/analog.jl: regression testset "BJT emission coefficients" asserting capacitance ≡ Tau × symbolic derivative of the matching transport current for NF∈{1,2}, NR∈{1,3} on NPN and PNP.

Verification

Fail-before (src fix stashed; test kept; Julia 1.12):

BJT emission coefficients: Test Failed
  Expression: ev(rhs(npn.C_DE), d) ≈ ev(npn.Tau_f * Symbolics.derivative(rhs(npn.ICC), npn.V_BE), d)
   Evaluated: 0.5 ≈ 1.0
...
Test Summary:             | Pass  Fail  Total  Time
BJT emission coefficients |    8     8     16  15.6s
ERROR: Some tests did not pass: 8 passed, 8 failed, 0 errored, 0 broken.

Pass-after (fix restored):

Test Summary:             | Pass  Total  Time
BJT emission coefficients |   16     16  13.1s

Full test/analog.jl (scratch test env with package developed from this branch):

Test Summary:             | Pass  Total  Time
BJT emission coefficients |   16     16  0.4s
=== analog.jl FINISHED OK ===

Commands (env):

export TMPDIR=.../527-cursor/tmp
export JULIA_DEPOT_PATH=".../527-cursor/scratch/depot:$HOME/.julia"
julia +1.12 --project=.
# fail-before: git stash push -- src/.../transistors.jl; run BJT testset
# pass-after: git stash pop; rerun
# full analog: include("test/analog.jl") in a scratch env with test deps

Runic --check and typos on the two touched files: pass.

Not verified

  • Full Core / CI matrix (GROUP=Core / Pkg.test() of every top-level test file).
  • Transient BJT circuit behaviour with NF≠1 beyond the symbolic consistency check.
  • Direct numerical comparison against a Modelica simulator run.

Risk assessment

  • Risk: low
  • Blast radius: NPN/PNP transport currents only when NF/NR ≠ 1; diffusion capacitances and default NF=NR=1 unchanged
  • Evidence: fail-before 0.5 ≈ 1.0 at NF=2; pass-after BJT testset 32/32 including direct ICC == Is*(exp(V/(NF*V_T))-1) assertions; full test/analog.jl previously green; Runic/typos clean on test/analog.jl
  • Independent review: Claude Code + Opus 5.5 (claude-opus-5-5): MERGE, low; checked against MSL v4.0.0 NPN.mo/PNP.mo; defaults NF=NR=1 are bit-identical.
  • Merge: auto-merge candidate after CI; behaviour change for NF/NR≠1 belongs in the release notes

Reviewer pushback

  • Whether base currents / Early-effect paths need further NF/NR consistency beyond transport + diffusion C (Modelica also folds NF into ibe; we only changed the ICC/IEC lines the issue names).
  • Whether using Symbolics at the top of analog.jl is preferred over a narrower import.

Fixes #527

Please ignore this draft until reviewed by @ChrisRackauckas.

Harness: Cursor Agent CLI 2026.10.01-14929f9; model: auto; transcript: /log.txt

ChrisRackauckas and others added 3 commits October 9, 2026 10:49
Diffusion capacitances already assume C_DE = Tau_f * ∂ICC/∂V_BE (and the
NR analogue); without NF/NR in ICC/IEC those identities fail for NF≠1,
unlike Modelica/SPICE Gummel-Poon.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/orch-ibmtk/sl/jobs/527-cursor/log.txt on amdci2.julia.csail.mit.edu
Asserts C_DE/C_DC equal Tau times the symbolic derivative of the matching
transport current for NF/NR ≠ 1 on both NPN and PNP (issue SciML#527).

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/orch-ibmtk/sl/jobs/527-cursor/log.txt on amdci2.julia.csail.mit.edu
Drop the issue tag from the comment, and assert ICC/IEC equal the
NF/NR Gummel-Poon transport expressions directly.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.10.01-14929f9
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/orch-ibmtk/sl/jobs/527-cursor/log.txt on amdci2.julia.csail.mit.edu

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPN/PNP: emission coefficients NF/NR are used in the diffusion capacitances but not in the transport currents

2 participants