spicex API#
Circuit#
- class spicex.Circuit(n_nodes: int)#
JAX-based Modified Nodal Analysis (MNA) circuit solver.
Node 0 is ground.
- add_current_source(node_neg: int, node_pos: int, current: float) None#
Add an independent current source.
node_neg is the - terminal, node_pos is the + terminal. Conventional current flows from node_neg to node_pos inside the source (i.e., current is injected into node_pos and extracted from node_neg).
- add_resistor(node_a: int, node_b: int, resistance: float) None#
Add a resistor between node_a and node_b.
- add_voltage_source(node_neg: int, node_pos: int, voltage: float) None#
Add an independent voltage source.
node_neg is the - terminal, node_pos is the + terminal. V(node_pos) - V(node_neg) = voltage.
- solve() tuple#
Solve the circuit with MNA.
- Returns:
jnp array shape (n_nodes,), node voltages; v_nodes[0] = 0. i_vsrc: jnp array shape (n_vsrc,), current through each voltage source (positive = current flowing from + terminal through the external circuit).
- Return type:
v_nodes