## 4.2 Functions

Gnucap behavioral modeling functions are an extension of the Spice source time dependent values.

### 4.2.1 The extensions

They apply to all elements (primitive components).
All accept either Spice compatible order dependent parameters, or easier keyword=value notation.
The syntax is identical for all supported components.

### 4.2.2 Fixed sources

Time dependent functions are voltage or current as a function of time. They are mostly Spice compatible, with extensions.
Nonlinear transfer functions use time as the independent variable. Some may not make sense, but they are there anyway.

### 4.2.3 Capacitors and inductors

Time dependent functions are capacitance or inductance as a function of time. They are voltage/current conserving, not charge/flux conserving.
Nonlinear transfer functions are charge or flux as a function of input (voltage or current). Charge and flux are conserved, and can be probed.

### 4.2.4 Resistors and conductances

Time dependent functions are resistance or conductance as a function of time.
Nonlinear transfer functions are current or voltage as a function of input (voltage or current). Resistors define voltage as a function of current. Conductances define current as a function of voltage.

### 4.2.5 Controlled sources

Time dependent functions are gain (v/v, transconductance, etc) function of time.
Nonlinear transfer functions are output (voltage or current) as a function of input (voltage or current).

### 4.2.6 Available functions

`COMPLEX`
  Complex (re, im) value.
`EXP`
  Spice Exp source. (time dependent value).
`FIT`
  Fit a curve with splines.
`GENERATOR`
  Value from Generator command.
`POLY`
  Polynomial (Spice style).
`POSY`
  Posynomial (Like poly, non-integer powers).
`PULSE`
  Spice Pulse source. (time dependent value).
`PWL`
  Piece-wise linear.
`SFFM`
  Spice Frequency Modulation (time dependent value).
`SIN`
  Spice Sin source. (time dependent value).
`TANH`
  Hyperbolic tangent transfer function.

In addition, you may name a ``function'' defined by a `.model` statement. The following `.model` types may be used here:

`TABLE`
  Fit a curve with splines.
`Cap`
  Spice semiconductor ``capacitor'' model.
`Res`
  Spice semiconductor ``resistor'' model.

### 4.2.7 Parameters that apply to all functions

These parameters are available with all functions. Some may not make sense in some cases, but they are available anyway.

`Bandwidth` = x
  AC analysis bandwidth. (Default = infinity.) The transfer function is frequency dependent, with a 3 DB point at this frequency. There is frequency dependent phase shift ranging from 0 degrees at low frequencies to 90 degrees at high frequencies. The phase shift is 45 degrees at the specified frequency. AC ANALYSIS ONLY.
`Delay` = x
  AC analysis delay. (Default = 0.) The signal is delayed by x seconds, effectively by a frequency dependent phase shift. AC ANALYSIS ONLY.
`Phase` = x
  AC analysis phase. (Default = 0.) A fixed phase shift is applied. This is primarily intended for sources, but applies to all elements. AC ANALYSIS ONLY.
`IOffset` = x
  Input offset. (Default = 0.) A DC offset is added to the ``input'' of the element, before evaluating the function.
`OOffset` = x
  Output offset. (Default = 0.) A DC offset is added to the ``output'' of the element, after evaluating the function.
`Scale` = x
  Transfer function scale factor. (Default = 1.) The transfer function is multiplied by a constant.
`TNOM` = x
  Nominal temperature. (Default = .option TNOM) The nominal values apply at this temperature.
`TC1` = x
  First order temperature coefficient. (Default = 0.)
`TC2` = x
  Second order temperature coefficient. (Default = 0.)
`IC` = x
  Initial condition. An initial value, to force at time=0. The actual parameter applied depends on the component. (Capacitor voltage, inductor current. All others ignore it.) You must use the ``UIC'' option for it to be used.

Temperature adjustments and scaling use the following formula:

    value *= _scale * (1 + _tc1*tempdiff
                  + _tc2*tempdiff*tempdiff)

where `tempdiff` is `t - _tnom`.