# Laplace Transfer Function

In this topic:

## Overview

The Laplace transfer function device implements a linear device defined in the frequency domain by a Laplace transform. For example the Laplace transform $\frac{1}{s+1}$ defines a first order low pass filter while $exp(-s)$ defines a 1 second delay.

The SIMetrix Laplace transfer function device features two different methods of implementation, namely "lumped network" and "convolution". The lumped network implementation is fast and efficient and may be used for transfer functions that can be represented in polynomial form. The convolution method is more general purpose and can model a wide range of transfer functions. High performance is achieved by using a fast FFT-based convolution method.

## User Interface

Selecting the menu Place > Analog Behavioural > Laplace Transfer Function brings up the following dialog The operation of the various controls is described below.

Definition See Laplace expression
Delay Adds delay in seconds. Requires convolution method. Equivalent to multiplying transfer functions by $exp(-delay.s)$
Frequency scale factor Multiplier for frequency
Device type
 Transfer function Expression defines output/input. Impedance V/I Two terminal device, expression defines voltage/current. Admittance I/V Two terminal device, expression defines current/voltage.
Input Input configuration for transfer function
Output Output configuration for transfer function
Implementation See Implementation
Convolution Options Convolution size. Increase this value to increase the upper frequency limit. This will slow down the simulation and increase memory consumption. Memory usage for a single device is approximately $96*2^N$ bytes where $N$ is the value entered here. Note that memory is partly shared for multiple devices. The upper frequency is of the order of $2^{N-1}/T$ where T is the simulation time. So for example, with a simulation time of 1ms and N=15, the upper frequency limit will be in the region of 16MHz. Higher frequencies will be gradually attenuated. As well as increasing memory consumption, higher values of convolution size will slow the simulation. This does not become significant until N exceeds about 17 to 18 but increases markedly for higher values.

The Advanced Options tab displays the following:

Error control Configures time-step control algorithm. For rapidly changing inputs the time step must be kept small to retain good accuracy. The parameters entered here control this mechanism.
Diagnostics Check box to enable some diagnostic run-time messages. These provide information on the extraction of the impulse response.
Impulse extraction

method
Parameters controlling extraction of the impulse response.
 Try all methods All methods attempted in sequence Analytic Attempt analytic method only Inverse FFT Attempt inverse FFT method only Stehfest Attempt Stehfest method only Size of inverse FFT as power of 2 Using a longer inverse FFT to extract an impulse response can increase the accuracy of the results especially if the impulse response decays slowly

## Laplace Expression

The Laplace expression defines the behaviour of the device in the frequency domain. For example '1/(s+1)', defines a simple single pole low-pass filter. The expression may contain arithmetic operators and a number of functions as described in the following sections. Be aware that not any expression is physically realisable; for example 'exp(s)' defines a negative delay, that is a device whose output responds to an input in the future.

### Operators

+ - * / ^
where \^ means raise to power. For lumped network implementation, the power must be an integer. Non-integral powers may be entered for convolution implementation.

### Constants

Any decimal number following normal rules. SPICE style engineering suffixes are accepted.

### s Variable

This can be raised to a power using \^, for example s^2. If the power is an integer between 0 and 9 the \^ may be omitted. For example: s2 is the same as s^2.

### Functions

The following functions may be used in convolution mode only.
 Function Syntax Description sqrt(x) $\sqrt{x}$ exp(x) $e^{x}$ ln(x) $\log_e(x)$ log10(x) $\log_{10}(x)$ sin(x) $\sin(x)$ cos(x) $\cos(x)$ tan(x) $\tan(x)$ acos(x) $\cos^{-1}(x)$ asin(x) $\sin^{-1}(x)$ atan(x) $\tan^{-1}(x)$ sinh(x) $\sinh(x)$ cosh(x) $\cosh(x)$ tanh(x) $\tanh(x)$ asinh(x) $\sinh^{-1}(x)$ acosh(x) $\cosh^{-1}(x)$ atanh(x) $\tanh^{-1}(x)$ atan2(x,y) $\tan^{-1}(\frac{y}{x})$ pow(x,y) $x^y$

### Filter response functions

Filter response functions may be used in both lumped network implementation and convolution implementation.

These are described in the following table:

 Function Syntax Filter Response BesselLP(order, cut-off) Bessel low-pass BesselHP(order, cut-off) Bessel high-pass ButterworthLP(order, cut-off) Butterworth low-pass ButterworthHP(order, cut-off) Butterworth high-pass ChebyshevLP(order, cut-off, passband_ripple) Chebyshev low-pass ChebyshevHP(order, cut-off, passband_ripple) Chebyshev high-pass
Where:
 order Integer specifying order of filter. There is no maximum limit but in practice orders larger than about 50 tend to give accuracy problems. cut-off -3dB Frequency in Hertz. passband_ripple Chebyshev only. Passband ripple spec. in dB.

### Lookup tables

The frequency response of a system may be defined in tabular form using lookup tables. The lookup table consists of a sequence of values arranged in triplets. Each triplet is in the form $frequency, value1, value2$ where $value1$ and $value2$ define the magnitude and phase in various ways as described below.

There are five variants of the lookup table as described below:

 Function Name value1 value2 Table dB phase in degrees Table_M magnitude phase in degrees Table_R dB phase in radians Table_MR magnitude phase in radians Table_RI real part imaginary part

Example

Table_M(0.01,1,30,  1,1,30,  10,0.1,30,  100,0.01,-30)

The above defines a response with a gain of 1 and a phase shift of 30 degrees from 0.01Hz to 1Hz. From 1Hz to 10Hz the gain falls from 1 to 0.1 with the phase shift remaining at 30 degrees. From 10Hz to 100Hz the gain falls from 0.1 to 0.01 and the phase changes from 30 to -30 degrees.

In real life it is not possible to implement a characteristic with the above behaviour as it is non-causal. However, it can be implemented if a suitable delay is added to the characteristic. The delay may be added in the Define Laplace Transfer Function dialog box in the Definition section - see the Delay entry. Alternatively it may be added to the Laplace expression using $exp(-delay.s)$. E.g:

Table_M(0.01,1,30,  1,1,30,  10,0.1,30,  100,0.01,-30) * exp(-s*2)

The above adds a 2 second delay.

For ease of reading, each triplet in the table may be placed on a separate line by prefixing each line with a '+' character. E.g.

Table_M(
+ 0.01,		1,		30,
+ 1,		1,		30,
+ 10,		0.1,		30,
+ 100,		0.01,		-30)

Interpolation Between defined frequency points, the Laplace transfer function finds the magnitude and phase using interpolation. The interpolation is performed logarithmically on the magnitude data. Values outside the table frequency range are defined by their respective end points.

For the above example the magnitude and phase are shown below:

### Parameters

Parameters (defined with .PARAM) may be used in Laplace expressions but currently only if convolution implementation is selected.

For the lumped network implementation you can use parameters in the underlying simulator device if you define the expression in terms of the numerator and denominator coefficients. Refer to the S-domain Transfer Function Block in the Simulator Reference Manual for further details.

## Device type

 Transfer function Expression defines output/input. Impedance V/I Two terminal device, expression defines voltage/current. Admittance I/V Two terminal device, expression defines current/voltage.

## Implementation

Describes the method the simulator uses to implementation the Laplace expression. There are two choices:
 Lumped network The Laplace transform is implemented using a network of integrators. Convolution The Laplace transform is implemented by convolving the impulse response of the Laplace transform with the input signal.
See below for further details.

### Lumped Network

The diagram below shows the configuration used for a third order network. This method can implement a quotient of polynomials in the s variable and any expression that can be reduced to a quotient of polynomials. For such expressions it is fast and efficient.

This method cannot implement expressions containing arbitrary functions such as square-root or exponentials. Such Laplace expressions must be implemented using the convolution method.

### Convolution

This is a general purpose method and can implement a wide range of Laplace transforms.

In the frequency domain, a linear system may be represented by: $Vout(s) = Vin(s).f(s)$ where $f(s)$ is the transfer function.

In the time domain the same system may be represented by: $Vout(t) = Vin(t) \ast f(t)$ Where $f(t)$ is the impulse response of $f(s)$ and $\ast$ is the convolution operator.

This method is challenging to implement as simple convolution applied to simulation data in its raw form is an $\mathcal{O}(n^2)$ algorithm. This means that the number of computations required at each step is proportional to the square of the number of steps. In practice this becomes unacceptably slow when there are more than about 10000 time steps.

SIMetrix overcomes this performance limitation by using an FFT based fast convolution method with a computation speed of $\mathcal{O}(n\log{}^2n)$. Although dramatically faster, this algorithm requires data to be presented to it at fixed-interval steps which has the effect of placing an upper frequency limit. The actual upper frequency limit can be arbitrarily increased by increasing the number of steps (the value of $n$) at the expense of speed and the memory consumed. In practice the default settings work well in most applications and give good performance and accuracy.

To perform the convolution, the simulator must also extract the impulse response of the Laplace transform. SIMetrix has three methods to do this:
 Analytical Matches the Laplace transform to known analytical solutions. For example $\frac{1}{\sqrt{}(s)}$ has the impulse response of $\frac{1}{2.\pi\sqrt{t}}$. SIMetrix will automatically detect this and other known Laplace transforms. Inverse FFT Calculates the inverse Fourier transform of the Laplace expression. This is a general purpose method that can be applied to a wide-range of Laplace transforms. However, it has the condition that the impulse response must decay to zero during the time interval. Stehfest method A method to calculate the inverse Laplace transform. Sometimes this method works for slowly decaying transforms that fail with the inverse FFT method.

## Impulse Response

### Problems with Impulse Response Extraction

For the convolution method an impulse response of the Laplace transfer function must be extracted. As mentioned above, three methods are attempted. The inverse FFT method and Stehfest methods are approximate in nature and for this reason, the result from each method is tested. If the test fails the impulse response is rejected and another method is attempted. If all methods fail the simulation will abort.

Transfer functions that decay slowly are likely to fail the inverse FFT method as this method requires that the impulse response decay to zero or nearly to zero. If the Stehfest method also fails, the problem can sometimes be resolved by increasing the inverse FFT size. This increases the duration over which the inverse FFT is evaluated so providing a longer time to decay.

In many situations the impulse response extraction fails because the transfer function is non-causal. This means that it has a response in negative time. Non-causal transfer functions can be made causal by adding a delay.

### Impulse Response Cache

The impulse response is cached to speed up subsequent simulations with the same response. The cache is located here:

where <login-name> is the name used to log in to your system. This can be deleted at any time. The cache is size limited to 250Mbytes by default. This can be changed using the option variable LaplaceCacheSizeMBytes. Type 'Set LaplaceCacheSizeMBytes=nnn' at the command line to set a new value.

### Impulse Response Analytical Extraction

The impulse response analytical extraction attempts to match the transfer function to one of the following patterns. The parameters $a$, $b$, $c$ etc represent constant values.

 Laplace expression Impulse response $a$ $a.\delta(t)$ $a/(b.s)$ $a/b$ $a/\sqrt{b.s}$ $a/\sqrt{2.\pi.b.t}$ $a/(b.s+c)$ $a/b.e^{-c/b.t}$ $a/\sqrt{b.s+c}$ $a*e^{-c.t/b}/\sqrt{b.\pi.t}$ $\sqrt{a/(b.s+c)}$ $\sqrt{a}*e^{-c.t/b}/\sqrt{b.\pi.t}$ ${\displaystyle \frac{a}{b.s^2+c.s+d}}$ ${\displaystyle \frac{-(e^{-t/2(\sqrt{p^2-4q}+p)}-e^{t/2(\sqrt{p^2-4q}-p)}}{\sqrt{p^2-4q}}}$ $p=c/b$ and $q=d/b$ $a.e^{b.s}$ $a.\delta(b+t)$ $a/(b.s^c)$ ${\displaystyle \frac{a.t^{c-1}}{b.\Gamma(c)}}$ ${\displaystyle \frac{a.s^2+b.s+c}{d.s^2+g.s+f}}$ ${\textstyle [\frac{-(e^{t.arg2}-e^{t.arg3})*(-p.u+2q+u^2-2v)}{2arg1} - \frac{ (u-p)(e^{t.arg2}+e^{t.arg3}) }{2}+\delta(t)]\frac{a}{d}}$ $p = b/a$ $q = c/a$ $u = g/d$ $v = f/d$ $arg1 = \sqrt{u^2-4v}$ $arg2 = -arg1/2-u/2$ $arg3 = arg1/2-u/2$ ${\displaystyle \frac{a.s+b}{c.s^2+d.s+f}}$ ${\displaystyle \frac{a}{c}.\frac{(2q-u)(arg2 - arg3) + \sqrt{u^2-4v}(arg3 + arg2)}{2\sqrt{u^2-4v}}}$ $q = b/a$ $u = d/c$ $v = f/c$ $arg2 = e^{t.(\sqrt{u^2-4v}/2-u/2)}$ $arg3 = e^{t.(-\sqrt{u^2-4v}/2-u/2)}$ ${\displaystyle \frac{a.s+b}{c.s+d}}$ ${\displaystyle \frac{e^{-d.t/c}(b.c-a.d)}{c^2}+\frac{a.\delta(t)}{c}}$ ${\displaystyle \frac{\sqrt{a.s+b}}{\sqrt{c.s+d}}}$ $(\alpha.(I1(\alpha.t)-I0(\alpha.t)) + \delta(t)).e^{-\beta.t}.Y$ $Y = \sqrt{a/c}$ $\alpha = (d/c-b/a)/2$ $\beta = (d/c+b/a)/2$ I0 and I1 are Bessel functions

The analytic matching algorithm will attempt to match partial expressions as well as the whole expression if they are combined by addition, subtraction or multiplication. For example:

$(1/(s+1))*exp(-s)$

will be matched to the product of $1/(s+1)$ and $exp(-s)$. Respectively these have impulse responses of $e^{-t}$ and $\delta(1+t)$ and those two impulse responses will be convolved to yield the final result. Note that this only succeeds if all partial expressions can be matched analytically.

To exploit this method, ensure that the expression is entered in a manner that keeps each partial expression distinct. For example, the following would be matched correctly:

$1/(s+1)*1/(s+2)$

as this would be seen as the two partial expressions $1/(s+1)$ and $1/(s+2)$ each of which can be resolved analytically. The final result would be obtained by convolving the two impulse responses.

However the following mathematically identical expression would not be matched:

$1/((s+1)*(s+2))$

The analysis algorithm does not attempt to decompose denominator products so this will not be recognised analytically. The above would be extracted using inverse FFT which would usually be successful but might not be if the run time is considerably shorter than the time constant.