# Controlled Sources

`devctlsrc.h`/`devctlsrc.cpp` implement the four linear controlled sources - VCCS, VCVS, CCCS, CCVS - plus mutual inductance coupling, as instantiations of [the builtin device template framework](devbuiltin.md). All five share one empty `DevCtlSourceModelParams` (no model-level parameters).

## Voltage- vs. current-controlled instance parameters

`DevVctlSourceInstanceParams` (VCCS, VCVS) is just `mfactor` and `gain` - a voltage-controlled source's control signal is the voltage between two of its own device nodes, so no further reference is needed. `DevCctlSourceInstanceParams` (CCCS, CCVS) adds `ctlinst` (the controlling instance's name) and `ctlnode` (defaulting to `"flow(br)"`, the internal branch-current node name convention) - a current-controlled source's control signal is another instance's branch current, so it must name which instance and which of its internal nodes to read that current from.

## Per-device instance data

`DevVccsInstanceData`/`DevVcvsInstanceData`/`DevCccsInstanceData`/`DevCcvsInstanceData` each hold the unknown indices and Jacobian pointers for that device's specific equation structure - a VCVS, for instance, needs its own branch-current equation (`uFlow`) in addition to the controlling and controlled node pairs, matching a voltage source's structure but with the excitation driven by `gain * ctl` instead of a waveform. All four cache the resolved controlling value (`ctl`), the instance's own terminal voltage (`v`), and current (`i`) for output-variable access.

## Mutual inductance

`DevMutualInstanceParams` (`k`, `ind1`, `ind2`, `ctlnode1`, `ctlnode2`) names the two inductor instances being coupled and which of their internal nodes carry the relevant current, rather than device node pairs of its own - a mutual-inductance element has no terminals in the usual sense, only a coupling coefficient between two other instances. `DevMutualInstanceData` reflects this: it holds raw `Instance*`/`Node*` pointers to the two coupled inductors and their control nodes (resolved once during setup) and the cross Jacobian pointers (`jacReact12`/`jacReact21`) connecting one inductor's reactive equation to the other's current - structurally different from the other four devices here, since it reaches into another instance's state rather than only its own. `BuiltinMutual` additionally specializes `setupCore()`/`preAnalysisCore()` (to resolve `ind1`/`ind2` into actual `Instance*`s and validate them), which the four simple controlled sources don't need.

## Registered specializations

Each of the five devices specializes `defineInternals()`, `principalParameterIndex()`, `setStaticTolerancesCore()`, `populateStructuresCore()`, `bindCore()`, `evalCore()`, and `loadCore()` (plus, for the controlled sources, `deleteHierarchy()`/`buildHierarchy()`, `getOutvar()`, and `outvarOutputSource()`) - the same specialization set pattern as [Independent Sources](devvisrc.md), declared explicitly in the header for each device.
