# Circuit Analyses

VACASK supports a range of circuit analyses, from DC operating point to frequency-domain small-signal, time-domain transient simulation, and harmonic balance analysis. Each analysis is requested by an `analysis` statement in the control block and writes its results to a SPICE raw file.

## Circuit equation formulation

VACASK formulates circuit equations in the form

$$g(x) + \frac{d}{dt} q(x) = 0$$

where $x$ is the vector of circuit unknowns (node voltages and branch currents), $g(x)$ is the resistive residual (conductances, controlled sources, nonlinear device currents), and $q(x)$ is the reactive residual (charges and fluxes stored in capacitors and inductors). Each analysis derives its equations from this common formulation:

- **Operating point** sets $\frac{d}{dt} q = 0$ and solves $g(x) = 0$.
- **Transient** approximates $\frac{d}{dt} q$ with a numerical integration formula and solves the resulting algebraic system at each timestep.
- **Harmonic balance** assumes $x(t)$ is almost periodic and solves for its complex spectrum directly in the frequency domain.
- **Periodic steady state (shooting)** integrates the circuit equations over one period and solves $x(0) = x(T)$ with Newton iteration in the time domain.
- **DC and AC Small-signal analyses** linearize $g$ and $q$ at the operating point to obtain the resistive and reactive Jacobians $J_r$ and $J_c$.
- **(Quasi)periodic small-signal analysis** linearizes $g$ and $q$ along the (quasi)periodic steady state computed by harmonic balance and solves the resulting conversion matrix at each small-signal frequency.

The Jacobian matrices are defined as

$$J_r = \frac{\partial g}{\partial x}\bigg|_{x_0}, \qquad J_c = \frac{\partial q}{\partial x}\bigg|_{x_0}$$

where $x_0$ is the operating point. $J_r$ captures resistive behavior (conductances, transconductances) and $J_c$ captures reactive behavior (capacitances, inductances). Together they form the small-signal model used by AC, noise, and transfer function analyses.

## Available analyses

| Analysis | Type keyword | Description |
|----------|-------------|-------------|
| [Operating Point](cmd-analysis-op.md) | `op` | Computes the DC steady-state solution. |
| [DC Small-Signal](cmd-analysis-dcinc.md) | `dcinc` | Linearizes the circuit at the operating point and computes small-signal node voltages and branch currents for a given excitation. |
| [DC Small-Signal Transfer Function](cmd-analysis-dcxf.md) | `dcxf` | Computes DC small-signal transfer functions, input and output impedances. |
| [AC Small-Signal](cmd-analysis-ac.md) | `ac` | Sweeps frequency and computes the small-signal response at each point. |
| [AC Small-Signal Transfer Function](cmd-analysis-acxf.md) | `acxf` | Computes AC small-signal transfer functions, input and output impedances as a function of frequency. |
| [AC Small-Signal Stability](cmd-analysis-acstb.md) | `acstb` | Computes AC open-loop gain of a feedback circuit as a function of frequency. |
| [AC Small-Signal S-Parameter](cmd-analysis-acsp.md) | `acsp` | Computes small-signal S-parameters of a multi-port circuit as a function of frequency. |
| [Small-Signal Noise](cmd-analysis-noise.md) | `noise` | Computes small-signal noise spectral densities referred to a chosen output or input. |
| [Transient](cmd-analysis-tran.md) | `tran` | Integrates the circuit equations over time. |
| [Transient noise](cmd-analysis-trannoise.md) | `tran` | Integrates the circuit equations over time, takes device noise into account. |
| [Periodic Steady-State](cmd-analysis-pss.md) | `pss` | Computes the periodic steady-state response in the time domain with the shooting Newton method; for autonomous circuits also finds the oscillation period. |
| [Harmonic Balance](cmd-analysis-hb.md) | `hb` | Computes the periodic steady-state response in the frequency domain. |
| [(Quasi)Periodic Small-Signal (Harmonic Balance-based)](cmd-analysis-hbac.md) | `hbac` | Sweeps frequency and computes the small-signal response around a harmonic balance operating point. |

## Stored solutions

Several analyses can save their computed solution under a name (the `store` parameter) so that a later analysis can reuse it as a nodeset or as initial conditions (the `nodeset` or `ic` parameter). Stored solutions live in a single namespace that is shared across the whole control block and keyed by name only; it is not partitioned per analysis.

Because the namespace is shared and keyed by name, the same name can be used by different analyses, but it refers to one slot. Storing under a name that already exists overwrites the previous contents, regardless of which analysis wrote it. Pick distinct names when you need to keep several solutions available at once.

Each stored solution carries a type tag identifying the analysis family that produced it, and an analysis accepts a stored solution only when the tag matches what it expects:

- Time- and DC-domain analyses (operating point, transient, and the small-signal analyses that build on an operating point) produce and consume `op`-tagged solutions.
- Harmonic balance produces `hb`-tagged solutions, consumed by harmonic balance and the harmonic-balance-based small-signal analysis.

The two families are therefore not interchangeable: a harmonic balance solution cannot be used as the nodeset for an operating point, even if the names match. A name lookup that resolves to a solution with the wrong tag is rejected as if no stored solution were found.
