Seve - @shibo I think I know what we need to do...
@shibo I think I know what we need to do on the spice side. It took me a while to figure out but we need to run the spice simulation inside of core with a "plugin" SPICE engine so that we don't need to bundle any WASM. Just going to jot some thoughts:
- We need to introduce
simulation_*
circuit json properties
- Each simulation_*
has a simulation_experiment_id
, there is stuff like simulation_voltage_graph
and simulation_current_graph
(tbd exact names, but these are probably ok to start)
- Each <simulation>
tag in tsx defines a separate experiment
- platformConfig.spiceEngine
specifies what will run SPICE
- We need a basic SPICE engine for testing that is in JS, this may be easy or hard no idea, but it just needs to be basic so that core has a default
- <voltageprobe />
/ <ammeter />
will be added and their names become the nodes for SPICE
- SPICE code generation happens in core
- Experiments are run while rendering (async)
- In the docs, inside CircuitPreview, but also in the RunFrame analog tab, we show the simulation with the probes also shown, with color. This makes it clear what part you're looking at
- Circuit-to-svg should also be able to output SPICE graphs
10 Replies
Sounds awesome, count me in
one insane byproduct of this is we can literally have "analog tutorials" where you can see the code and the simulation side by side in the docs. So we can have entire documents on H-bridges and random analog configurations
does any particular part appeal to you to jump into, I was thinking about proposing various specs today, then we can write "by hand" some circuit json and look at the generated result in
circuit-to-svg
. I think circuit-to-svg
will literally just have something like convertCircuitJsonToSchematicWithSimulationGraph(circuitJson, {simulation_experiment_id})
, we could also output the simulation graph independently but I think we'll want to generate the "combined" SVG a lot of the time because it's easier for e.g. snapshot testing
was thinking i could assign to you an issue for making that circuit-to-svg func?
(since you've done a lot of work on the svg gen recently)I'm interested in the whole thing, assign me what ever you think is the best starter
yea i need help w/ something else related to the JS SPICE version
sg
i got GPT5-pro to generate a fully-javascript SPICE engine but i need to verify it's output against EEcircuit-engine to make sure it's not too far off
going to open up the repo in a sec
cool
GitHub
Bootstrapping repo · Issue #1 · tscircuit/spicey
Compare with results from eecircuit engine in tests (to make sure we're somewhat accurate) Clean up lib/index.ts (break into separate files) Add basic support for mosfets/transistors Add svg sn...
usage is pretty simple

we don't need it to be super complicated or fast, we just want to be able to run basic tests. For virtually all examples, like docs examples and stuff we'll use the WASM build of ngspice. This is just to have a default available inside core
we need to break up the formatting/parsing stuff from the simulation logic so that GPT5-Pro can implement transistors without dealing with formatting IMO