Add spice -> kernel pipeline (spice_kernel) for the --shape fast constants - #31
Open
WillMatthews wants to merge 6 commits into
Open
Add spice -> kernel pipeline (spice_kernel) for the --shape fast constants#31WillMatthews wants to merge 6 commits into
WillMatthews wants to merge 6 commits into
Conversation
…tants
src/spice_kernel.cpp runs the equivalent circuit (spice/jseries_fastout.cir),
extracts the single-photon fast-output pulse, and derives the two constants
the fast/bench shapers consume:
tauLoad = R_Lfast * N * C_f (fast-rail RC, read from the deck's .param
values so it cannot drift from the circuit)
tauRecovery = loaded fit on the fast tail
It validates the analytic kernel shape_fast() implements against the SPICE
pulse (peak-normalised shape RMS 0.088 < 0.10) and writes a ready-to-run
sipm_fast.json (via save_params_json) whose tauLoad is circuit-calibrated, so
simspad -p sipm_fast.json -i light.npy -o resp.npy --shape fast
produces a circuit-calibrated fast-output trace instead of one with a
hand-picked time constant.
Built via `make spice_kernel` (excluded from the default `all` link, like
server.cpp). Needs ngspice on PATH; the generated params file is gitignored.
Closes #29.
WillMatthews
force-pushed
the
spice-to-kernel-pipeline
branch
from
June 12, 2026 00:16
92702d8 to
45878b3
Compare
Datasheet-grounded fast-output equivalent circuits for the J-Series 35 um parts (MicroFJ-30035/40035/60035), with all inputs traced to MICROJ-SERIES/D Tables 1-3 (gain, cell count, recharge tau, fast/anode capacitance). The datasheet is internally consistent with the model: Cmicro = G*e/OV gives N*Cmicro within 96-100% of the datasheet anode capacitances. Also: - template_fastout.cir / template_stdout.cir: parameterised templates that derive all internal component values from datasheet headline numbers, so no component is hand-picked. The stdout template covers devices with no fast pin. - pulse_to_kernel.py: coupling-aware net-charge diagnostic (bipolar/AC fast output ~0 vs unipolar/DC standard output ~1), so the slow-output path is legible. The anode v(a) in every fast deck builds a slow kernel directly. - spice/README.md: device library, datasheet provenance, and an honest fidelity note -- the lumped N*Cf fast rail over-broadens the fast output (deck FWHM 1.8/2.7/5.4 ns vs datasheet 1.5/1.7/3.0 ns, worse for large arrays); the standard output (set by recharge tau) is well-matched. For an exact fast output, digitise the datasheet's measured pulse (Figs. 5/6) into a kernel. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lFile was lost) A non-numeric (string) value only advanced the scan past the colon, so the next '"' search landed on the value's opening quote: the value became a key and stole the following key's number. Concretely, "kernelDt" after "kernelFile" was dropped, kernelDt fell back to the simulation dt, and resample_kernel became a no-op -- a 10 ps SPICE kernel played back on a 50 ps grid came out 5x too slow (FWHM 9.7 ns instead of 1.93 ns). Skip past the closing quote instead. Caught by the sipm-eq-paper cross-validation smoke test (--shape kernel at dt != kernelDt).
…rnels The 120 ns window truncated the ~24.5 ns loaded fast tail, leaving a +1.3%-of-lobe net-charge residual in any kernel tabulated from the run (the physical AC-coupled terminal has exactly zero). Downstream, a pure-integrator conservation observer integrates that DC into 4-6 V of spurious drift over a ~6 us payload -- enough to rail the state estimate. At 350 ns the residual is ~1e-6 of the lobe (sub-mV drift).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of two stacked PRs. Stacked on #30 (archive) — review/merge #30 first; the base will retarget to
master(viafast-output-shaping) as the stack lands.This PR (pipeline):
src/spice_kernel.cpp— a C++ tool that closes the loop from the circuit to the shaper. It:spice/jseries_fastout.cirvia ngspice and extracts the single-photon fast-output pulse;--shape fasttime constants —tauLoad = R_Lfast·N·C_f(read from the deck's.paramlines, so it can't drift from the circuit) andtauRecovery(fitted on the fast tail);shape_fast()implements against the SPICE pulse;sipm_fast.json(via the existingsave_params_json) whosetauLoadis circuit-calibrated.Built via
make spice_kernel(excluded from the defaultalllink, likeserver.cpp):Then
simspad -p sipm_fast.json -i light.npy -o resp.npy --shape fastgives a fast-output trace calibrated to the circuit rather than to a hand-picked constant (verified to round-trip throughsimspad). Needsngspiceon PATH; the generated params file is gitignored.C++ only — no Python added to the package.
Closes #29.