https://github.com/aradzie/jecs
Electronic circuit simulator written in JavaScript.
https://github.com/aradzie/jecs
circuit circuit-simulator electronics simulator spice
Last synced: 8 months ago
JSON representation
Electronic circuit simulator written in JavaScript.
- Host: GitHub
- URL: https://github.com/aradzie/jecs
- Owner: aradzie
- License: agpl-3.0
- Created: 2021-08-30T09:54:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-28T11:36:07.000Z (over 1 year ago)
- Last Synced: 2025-03-31T17:25:21.399Z (about 1 year ago)
- Topics: circuit, circuit-simulator, electronics, simulator, spice
- Language: TypeScript
- Homepage: https://aradzie.github.io/jecs
- Size: 18.6 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Electronic Circuit Simulator
**jecs** is an electronic circuit simulator written in TypeScript.
It supports AC, DC and transient analyses.
## Example
Create a netlist file `netlist.txt`:
```text
Vac:Vin pow gnd V=1 f=1k
R:R1 pow vout R=1k
C:C1 vout gnd C=$C1
R:R2 vout gnd R=1k
.tr
stopTime=3m timeStep=1u
.sweep $C1 type="lin" start=1u stop=3u points=3
```
and run the simulator in the terminal:
```shell
jecs --verbose netlist.txt
```
The simulator will produce a dataset file `netlist.data`.
## Example
The following code:
```typescript
// Create an empty circuit.
const circuit = new Circuit();
// Allocate circuit nodes.
const GND = circuit.groundNode;
const N1 = circuit.makeNode("N1");
const N2 = circuit.makeNode("N2");
// Create devices.
const V1 = new Vdc("V1");
const R1 = new Resistor("R1");
const D1 = new Diode("D1");
// Connect devices in the circuit.
circuit.connect(V1, [N1, GND]);
circuit.connect(R1, [N1, N2]);
circuit.connect(D1, [N2, GND]);
// Set device properties.
V1.props.set("V", 10);
R1.props.set("R", 1000);
D1.props.set("temp", 26.85);
// Perform DC analysis, compute node voltages and branch currents.
const analysis = new DcAnalysis();
analysis.props.set("maxIter", 10);
analysis.props.set("abstol", 1e-12);
analysis.props.set("vntol", 1e-6);
analysis.props.set("reltol", 1e-3);
analysis.run(circuit);
// Print the operating points.
console.log(dumpCircuit(circuit));
```
prints the following result:
```typescript
[
"V(N1)=10V", // voltage at node N1
"V(N2)=712.407mV", // voltage at node N2
"V1{V=10V,I=-9.288mA,P=-92.876mW}", // voltage source output params
"R1{V=9.288V,I=9.288mA,P=86.259mW}", // resistor output params
"D1{V=712.407mV,I=9.288mA,P=6.617mW}", // diode output params
];
```
## Virtual Curve Tracer
The following non-linear device I/V curves were obtained from the simulator.
### Diode I/V Curve

### BJT I/V Curve

### MOSFET I/V Curve

### JFET I/V Curve

### BJT Amplifier I/V Curve

### MOSFET Amplifier I/V Curve
