# DC Incremental Analysis

`andcinc.h`/`coredcinc.h` (with `lib/andcinc.cpp`/`lib/coredcinc.cpp`) implement the DC incremental small-signal analysis: it solves an operating point, linearizes the circuit around it, and reports the incremental (delta) response of every unknown to the DC increments (`mag`, possibly negative) specified simultaneously on the circuit's independent sources. It is the small-signal counterpart of `op` restricted to a single, fixed DC operating point - no frequency sweep is involved.

## Class and Data Structures

`DCIncremental` is the typedef `SmallSignal<DCIncrementalCore, DCIncrementalData>` ([Small-Signal Analysis Template](ansmsig.md)) - the generic template that pairs an `OperatingPointCore` ([Operating Point Analysis](anop.md)) with an analysis-specific core, sharing one real Jacobian (`jac`) between them. `DCIncrementalData` (`andcinc.h`) supplies the one extra vector the template's `DataMixin` slot needs:

- `incrementalSolution` - the incremental solution vector (`Vector<double>`, one entry per unknown plus the bucket at index 0).

`DCIncrementalCore` (`coredcinc.h`) is the concrete `AnalysisCore` ([Analysis Core Base Class](core.md)) doing the work. It holds a reference to the shared `OperatingPointCore` (`opCore_`), the shared real Jacobian, and `incrementalSolution`. `DCIncrementalParameters` (also `coredcinc.h`) is the parameter struct, embedding `OperatingPointParameters opParams` for the dependency op core.

`SmallSignal<DCIncrementalCore, DCIncrementalData>` is specialized in `andcinc.cpp` for its constructor, `resolveSave()`, and `dump()`, as is required of every instantiation of the template (see [Small-Signal Analysis Template](ansmsig.md)).

## Core Algorithm

The governing circuit equation (documented in a comment block at the top of `coredcinc.h`, shared verbatim by all four small-signal analyses in this section) is

```
            d
   f(x(t)) + ---- q(x(t)) = 0
            dt
```

with `x(t)` the circuit unknowns, `f(x)` the resistive residual, and `q(x)` the reactive residual. DC incremental analysis assumes `t=0`, first solves the operating point `f(x0) = 0` (delegated to `opCore_`, which also produces the factored resistive Jacobian `Jr`), then solves the linear incremental system

```
   Jr dx = du
```

where `du` is assembled from the DC increments (`mag`, which may be negative) of every independent source flagged `Device::Flags::GeneratesDCIncremental` (`devbase.h`), loaded via `circuit.evalAndLoad()` with `LoadSetup::dcIncrementResidual` pointing at `incrementalSolution`, then sign-flipped because it was loaded as a residual and needs to sit on the right-hand side. `Jr` is already LU-factored by the op core, so `DCIncrementalCore::coroutine()` only has to call `jacobian.solve()`. Unlike DC transfer function analysis (see below), all sources' increments are excited together in a single solve, so the result already reflects their combined incremental effect. See [Operating Point Analysis](anop.md) for how nodesets seed the initial op solve.

## Parameters

`DCIncrementalParameters` (`coredcinc.h`), registered for introspection in `coredcinc.cpp`:

| Parameter | Type | Description |
|---|---|---|
| `write` | Int | Write the incremental-response results to a file (default 1). |
| `writeop` | Int | Exposes `opParams.write`: write the operating-point results to a separate `<name>.op` file (default 0). |
| `nodeset` | Value | Exposes `opParams.nodeset`: stored-solution slot name to read, or a list of nodesets for the op solve. See [Operating Point Analysis](anop.md). |
| `store` | String | Exposes `opParams.store`: stored-solution slot name to write after the op solve. |

## Recognized Save Directives

Resolved in `SmallSignal<DCIncrementalCore, DCIncrementalData>::resolveSave()` (`andcinc.cpp`). Anything not in the first table falls through to `resolveOpSave()`, the operating-point save handling shared by every small-signal analysis (see [Small-Signal Analysis Template](ansmsig.md)); its directives are saved to the separate `.op` output file.

| Save directive | Arguments | Description |
|---|---|---|
| `default` | none | All circuit unknowns' incremental values (`smsigCore.addAllUnknowns()`); the fallback when no save directive produces any descriptor. |
| `full` | none | Incremental value of every non-ground node. |
| `dv` | one node name | Incremental voltage at the given node. |
| `di` | one instance name | Incremental branch current of the given instance (`<inst>:flow(br)`). |

| OP save directive (via `resolveOpSave()`) | Arguments | Description |
|---|---|---|
| `opdefault` | none | All circuit unknowns, operating-point values. |
| `opfull` | none | Every non-ground node, operating-point values. |
| `v` | one node name | Operating-point voltage at the given node. |
| `i` | one instance name | Operating-point branch current of the given instance. |
| `p` | instance name, outvar name | One instance output variable's operating-point value. |

Note that `dv`/`di` and `v`/`i` can name the same node or instance: `dv`/`di` read `incrementalSolution` (this core), while `v`/`i` read the op core's DC solution - they are genuinely different quantities landing in different output files.

## Related Documentation

- [Small-Signal Analysis Template](ansmsig.md) - the `SmallSignal<CoreClass, DataMixin>` template this analysis instantiates.
- [Operating Point Analysis](anop.md) - the dependency core providing the DC bias point and nodeset mechanism.
- [Analysis Core Base Class](core.md) - `AnalysisCore`, the save-directive helpers, and the core pipeline.
- [DC Transfer Function Analysis](andcxf.md) - the per-source unity-excitation counterpart of this analysis.
- [AC Analysis](anac.md) - the frequency-swept counterpart of this analysis.
