A dependency-free numerical kernel for nonlinear circuit operating points. It combines damped Newton-Raphson iteration, analytic or numerical Jacobians, parameter continuation, step limiting, and a nonlinear modified-nodal-analysis bridge.
- Multi-variable damped Newton iteration.
- Analytic, central-difference, or forward-difference Jacobians.
- Backtracking line search with residual reduction.
- Maximum-step limiting for exponential semiconductor models.
- Absolute, relative, step, iteration, and pivot tolerances.
- Full convergence history and failure diagnostics.
- Sequential parameter continuation using the previous solution as the next initial guess.
- Nonlinear two-terminal device stamping into an MNA system.
- Analytic or numerically estimated device conductance.
import { solveNonlinear } from '@opencircuitlabs/nonlinear-solver';
const result = solveNonlinear(
([x, y]) => [x*x + y*y - 1, x - y],
[0.8, 0.6],
{ jacobian: ([x, y]) => [[2*x, 2*y], [1, -1]] }
);import { solveNonlinearMNA } from '@opencircuitlabs/nonlinear-solver';
const result = solveNonlinearMNA({
linearMatrix: [[1 / 1000]],
rhs: [5 / 1000],
devices: [{
id: 'D1',
positive: 0,
negative: null,
current: voltage => 1e-12 * Math.expm1(voltage / 0.02585),
conductance: voltage => 1e-12 / 0.02585 * Math.exp(voltage / 0.02585)
}],
initialGuess: [0.6]
});null or undefined terminals represent ground. Device current is positive from the positive terminal to the negative terminal.
Non-convergence, singular Jacobians, invalid model output, and line-search failure throw NonlinearSolverError. When iteration has begun, error.diagnostics contains the last solution, residual norm, iteration number, and convergence history.
npm install
npm test
npm run exampleMIT © 2026 OpenCircuitLabs