# Difference between revisions of "B sources (complete reference)"

m (moved B sources to B sources (complete reference)) |
|||

Line 1: | Line 1: | ||

== '''B-sources''' == | == '''B-sources''' == | ||

− | This is supposed to be like the corresponding Help file topic, but with more complete information. | + | This is supposed to be like the corresponding Help file topic, but with more complete information.<br />(Note: some of information is somewhat out-of-date, but is still generally correct and should be updated soon.) |

− | (Note: some of information is somewhat out-of-date, but is still generally correct.) | ||

'''B. Arbitrary behavioral voltage or current sources.''' | '''B. Arbitrary behavioral voltage or current sources.''' | ||

Line 20: | Line 19: | ||

The Laplace transform is applied to the result of the behavioral current or voltage signal. The Laplace transform must be a function of s. The frequency response at frequency f is found by substituting s with sqrt(-1)*2*pi*f. The time domain behavior is found from the impulse response obtained from the Fourier transform of the frequency domain response. LTspice must guess an appropriate frequency range and resolution. The response must drop at high frequencies or an error is reported. It is recommended that the LTspice first be allowed to make a guess at this and then check the accuracy by reducing reltol and/or mtol (*default=1) or explicitly setting nfft and the window. The reciprocal of the val-ue of the window is the frequency resolution. The value of nfft times this resolution is the highest fre-quency considered. For Laplace expressions, ^ signifies exponentiation. | The Laplace transform is applied to the result of the behavioral current or voltage signal. The Laplace transform must be a function of s. The frequency response at frequency f is found by substituting s with sqrt(-1)*2*pi*f. The time domain behavior is found from the impulse response obtained from the Fourier transform of the frequency domain response. LTspice must guess an appropriate frequency range and resolution. The response must drop at high frequencies or an error is reported. It is recommended that the LTspice first be allowed to make a guess at this and then check the accuracy by reducing reltol and/or mtol (*default=1) or explicitly setting nfft and the window. The reciprocal of the val-ue of the window is the frequency resolution. The value of nfft times this resolution is the highest fre-quency considered. For Laplace expressions, ^ signifies exponentiation. | ||

− | + | <nowiki>*</nowiki> The transfer function of the Freq circuit element is specified by an ordered list of points of freq(Hz), mag(dB) and phase(deg) as follows: <(f1,m1,p1)[(f2,m2,p2)...]> where f1<f2<f3, etc. The following units specifiers may optionally precede the Freq keyword: “rad”=radians, “mag”=non dB, (“dB” and “deg” return the defaults), “r_i”=real and imaginary in place of magnitude and phase. If a delay value is called out, the phases of the table values are modified to reflect the delay (delay is automatically adjusted to maintain causality in any case). | |

+ | |||

+ | <nowiki>*</nowiki> The NoJacob parameter unburdens a device from carrying the mathematical overhead of a Jacobian. For linear or certain well behaved b-source expressions, this small reduction in computational burden can reduce run times slightly. ''Use with extreme caution, as this greatly increases the risk of creating convergence problems or other errors if misapplied.'' | ||

Expressions can contain the following: | Expressions can contain the following: |

## Revision as of 13:48, 7 August 2009

**B-sources**

This is supposed to be like the corresponding Help file topic, but with more complete information.

(Note: some of information is somewhat out-of-date, but is still generally correct and should be updated soon.)

**B. Arbitrary behavioral voltage or current sources.**

Symbol names: BV, BI, *BR (arbitrary resistor)

Syntax (* denotes undocumented features):

Bxxx n1 n2 V=<expression> OR I=<expression> [Rpar=<value>] + [[ic=<value>] tripdv=<value>] [tripdt=<value>] + [Laplace=<func(s)> [window=

The first syntax specifies a behavioral voltage source and the next is a behavioral current source. For the current source, a parallel resistance may be specified with the Rpar instance parameter.

Tripdv and tripdt control step rejection. If the voltage across a source changes by more than tripdv volts in tripdt seconds, that simulation time step is rejected.

The Laplace transform is applied to the result of the behavioral current or voltage signal. The Laplace transform must be a function of s. The frequency response at frequency f is found by substituting s with sqrt(-1)*2*pi*f. The time domain behavior is found from the impulse response obtained from the Fourier transform of the frequency domain response. LTspice must guess an appropriate frequency range and resolution. The response must drop at high frequencies or an error is reported. It is recommended that the LTspice first be allowed to make a guess at this and then check the accuracy by reducing reltol and/or mtol (*default=1) or explicitly setting nfft and the window. The reciprocal of the val-ue of the window is the frequency resolution. The value of nfft times this resolution is the highest fre-quency considered. For Laplace expressions, ^ signifies exponentiation.

* The transfer function of the Freq circuit element is specified by an ordered list of points of freq(Hz), mag(dB) and phase(deg) as follows: <(f1,m1,p1)[(f2,m2,p2)...]> where f1<f2<f3, etc. The following units specifiers may optionally precede the Freq keyword: “rad”=radians, “mag”=non dB, (“dB” and “deg” return the defaults), “r_i”=real and imaginary in place of magnitude and phase. If a delay value is called out, the phases of the table values are modified to reflect the delay (delay is automatically adjusted to maintain causality in any case).

* The NoJacob parameter unburdens a device from carrying the mathematical overhead of a Jacobian. For linear or certain well behaved b-source expressions, this small reduction in computational burden can reduce run times slightly. *Use with extreme caution, as this greatly increases the risk of creating convergence problems or other errors if misapplied.*

Expressions can contain the following:

- Node voltages and differences, e.g. V(n1) and V(n1,n2).
- Circuit element currents, e.g. I(S1), the current through switch S1 or Ib(Q1), the base current of Q1. However, it is assumed that the circuit element current is varying quasi-statically, that is, there is no instantaneous feedback between the current through the referenced device and the behavioral source output.
- The following operations, grouped in order of precedence of evaluation (* denotes undocu-mented features):

Symbol | Operation --------+-------------------------------------------------- ! | convert succeeding expression to Boolean then * or ~ | invert ** | floating point exponentiation ^ | floating point exponentiation (Laplace only) --------+-------------------------------------------------- / | floating point division * | floating point multiplication --------+-------------------------------------------------- - | floating point subtraction + | floating point addition --------+-------------------------------------------------- * == | true if preceding expression is equal to | succeeding expression, otherwise false >= | true if preceding expression is greater than or | equal to succeeding expression, otherwise false <= | true if preceding expression is less than or | equal to succeeding expression, otherwise false > | true if preceding expression is greater than | succeeding expression, otherwise false < | true if preceding expression is less than | succeeding expression, otherwise false --------+-------------------------------------------------- ^ | convert adjacent expressions to Boolean then XOR | | convert adjacent expressions to Boolean then OR & | convert adjacent expressions to Boolean then AND

For Boolean operations True is 1 and False is 0. Boolean conversions return True if <expression> eva-luates to greater than .5, else False.

- The following keywords (global variables and constants):

Name | Value | Description ----------+----------------+-------------------------------- time | variable | time in seconds pi | 3.14159265359 | * boltz | 1.38062 e-23 | Boltzmann constant * planck | 6.62620 e-34 | Planck's constant * echarge | 1.6021765e-19 | charge of an electron * kelvin | -2.73150 e+02 | absolute zero in degrees C

- Any user defined parameters or functions. Note that the parameter substitution scheme is gen-erally symbolic, but that when curly braces are encountered, the enclosed expression is evaluated immediately. With functions all parameter substitution evaluation is always done before the simulation begins. For details, refer to the .param and the .func simulator directives defined in Help under the subchapter on Dot Commands.

- The following functions (* denotes undocumented functions):

*Status Name | Function -------------------+--------------------------------------- sin(x) | sine cos(x) | cosine tan(x) | tangent asin(x) | arc sine acos(x) | arc cosine atan(x) | arc tangent atan2(y,x) | arc tangent of y/x (four quadrant) hypot(y,x) | hypotenuse: sqrt(x*x+y*y) sinh(x) | hyperbolic sine cosh(x) | hyperbolic cosine tanh(x) | hyperbolic tangent asinh(x) | arc hyperbolic sine acosh(x) | arc hyperbolic cosine atanh(x) | arc hyperbolic tangent exp(x) | exponential ln(x) or log(x) | natural logarithm log10(x) | base 10 logarithm sgn(x) | sign (0 if x = 0) abs(x) | absolute value sqrt(x) | square root * square(x) | x**2 * pow(x,y) | x**y * pwr(x,y) | abs(x)**y * pwrs(x,y) | sgn(x)*abs(x)**y * round(x) | round to nearest integer int(x) | truncate to integer part of x floor(x) | integer equal or less than x ceil(x) | integer equal or greater than x min(x,y) | the lesser of x or y max(x,y) | the greater of x or y limit(x,y,z) | equivalent to min(max(x,y),z) if(x,y,z) | if x > .5 then y else z table(x,x1,y1...) | interpolate y(x) per a lookup table or *tbl: x1<x2... | of x-ordered point pairs uramp(x) | x if x > 0, else 0. *stp(x) or u(x) | unit step, 1 if x > 0, else 0 buf(x) | 1 if x > .5, else 0 !(x) or inv(x) | 0 if x > .5, else 1 rand(x) | 0 < random num < 1 at x sharp steps/sec random(x) | 0 < random num < 1 at x soft steps/sec * white(x) | -.5 < ran num < .5 at x smooth steps/sec * fra(x) | white(x), but 0 if not SMPS steady state * ddt(x) v time derivative (v = Verilog-A compatible) * idt(x) or sdt(x) v time integral: idt(x[,ic[,assert]]) * v ic=initial constant, assert<>0 resets idt * idtmod(x) v wrapping idt: idtmod(x[,ic[,mod[,offset]]]) * v offset < idtmod(x) < offset+mod * delay(x,y) v delay of x by y seconds *absdelay(x,y[,z]) v delay of x by min(y,z) seconds