struct
SushiDSP::dk::DkNetlist
template <std::size_t S, std::size_t N, std::size_t I, std::size_t O>Describes a circuit on the control thread: node indices and component values.
- Declared in
include/SushiDSP/math/dk/DkNetlist.hpp
Node 0 is ground and non-ground nodes are numbered from 1 upwards. The add methods assert where DkCircuit::prepare returns false (include/SushiDSP/README.md).
Template parameters
SReactive element (state) count.
NNonlinear branch count.
IInput voltage source count.
OOutput probe count.
Public attributes
std::size_t node_count = 0Number of non-ground nodes; node indices run from 1 to this value.
std::array< Branch, kMaximumResistors > resistors_ {}Resistor branches, pot sections included.
std::size_t resistor_count_ = 0Populated entries of resistors_.
std::array< Branch, S > reactive_ {}Capacitors and inductors, in state order.
std::array< double, S > reactive_sign_ {}Z: +1 for a capacitor, -1 for an inductor.
std::size_t reactive_count_ = 0Populated entries of reactive_.
std::array< Branch, I > sources_ {}Input sources, in input-vector order.
std::size_t source_count_ = 0Populated entries of sources_.
std::array< Branch, N > nonlinear_ {}Nonlinear branches, in nonlinear-port order.
std::size_t nonlinear_count_ = 0Populated entries of nonlinear_.
std::array< Branch, O > outputs_ {}Output probes, in output-vector order.
std::size_t output_count_ = 0Populated entries of outputs_.
std::array< PotentiometerEntry, kMaximumPotentiometers > potentiometers_ {}Potentiometer tracks.
std::size_t potentiometer_count_ = 0Populated entries of potentiometers_.
std::array< NullorEntry, kMaximumNullors > nullors_ {}Ideal op-amps, in the order added.
std::size_t nullor_count_ = 0Populated entries of nullors_.
Public member functions
void resistor(std::size_t a, std::size_t b, double ohms)Adds a resistor.
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.
ohmsResistance, strictly positive.
void capacitor(std::size_t a, std::size_t b, double farads)Adds a capacitor, discretised by the trapezoidal rule.
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.
faradsCapacitance, strictly positive.
void inductor(std::size_t a, std::size_t b, double henries)Adds an inductor, discretised by the trapezoidal rule.
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.
henriesInductance, strictly positive.
void voltage_source(std::size_t a, std::size_t b)Adds an ideal input voltage source.
Its entry of the input vector u is the driven voltage V(a) minus V(b), in the order the sources were added.
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.
std::size_t potentiometer(std::size_t a, std::size_t wiper, std::size_t b, double ohms)Adds a potentiometer as two resistor sections, a-to-wiper and wiper-to-b.
Position 0 puts the wiper at a and position 1 puts it at b, so the a-to-wiper section is ohms times the position.
Parameters
aOne end of the track; 0 is ground.
bThe other end of the track; 0 is ground.
ohmsEnd-to-end track resistance, strictly positive.
Returns
The potentiometer's index, for DkCircuit::set_potentiometer.
std::size_t nullor(std::size_t sense_positive, std::size_t sense_negative, std::size_t output_positive, std::size_t output_negative)Adds an ideal op-amp, stamped as a nullor: the sensed pair is forced to zero volts and draws no current, and the driven pair carries the current that demands.
Parameters
sense_positiveThe non-inverting input node; 0 is ground.
sense_negativeThe inverting input node; 0 is ground.
output_positiveThe node the output current flows out of; 0 is ground.
output_negativeThe node it returns to; 0 is ground.
Precondition
The op-amp sits inside a negative-feedback loop (include/SushiDSP/README.md).
Returns
The nullor's index, in the order they were added.
void nonlinear(std::size_t a, std::size_t b)Adds a nonlinear branch.
The model receives v = V(a) minus V(b) as this branch's entry of the nonlinear voltage vector, and a positive returned current flows from a to b through the device.
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.
void output(std::size_t a, std::size_t b)Adds an output probe measuring V(a) minus V(b).
Parameters
aPositive terminal; 0 is ground.
bNegative terminal; 0 is ground.

