# Vwsim-term

The VWSIM Mathematical Term Language.

### Introduction

VWSIM provides a language to express mathematical
terms (expressions). Here, the subset of this language available to
the user is presented. These expressions can be used when the user
is describing netlists using the vwsim-hdl. At simulation
time, these terms are evaluated to double-precision floating point
numbers.

A term is one of the following:

- Quoted constant
- Symbol constant
- Symbol variable
- Function Call

#### Quoted Constant

A quoted constant is a QUOTE followed by a rational or
double-precision floating point number.

Examples:

#### Symbol Constant

A symbol constant is a symbolp that has * as the
first and last character. The available constants are:

Constant name |
Description |

*pi* |
Pi |

*e* |
Euler's number |

*h* |
Planck's constant (Joules * seconds) |

*h_bar* |
Planck's Constant divided by two pi |

*e_C* |
Charge of an electron (Coulombs) |

*K_b* |
Boltzmann's constant (Joules/Kelvin) |

*deltaV* |
Size of the Josephson junction (JJ) transition region (Volts) |

*phi0* |
Magnetic Flux Quantum (Webers) |

*Icfact* |
Ratio of JJ critical current to quasiparticle step height |

The constants also include the multipliers *kilo*,
*mega*, *giga*, *tera*, *peta*, *milli*,
*micro*, *nano*, *pico*, and *femto*. See vwsim-constants for the values of all of the constants.

#### Symbol Variable

A symbol variable is a symbolp that denotes a variable
value that will be looked up at simulation time. The user is allowed
to use the $time$ and $hn$ symbol variables.

$time$ is the current simulation time as a floating point
number.

$hn$ is the current simulation step size as a floating point
number.

Note: it is recommended to use the $time$< function whenever
possible. See the description below.

#### Function Call

A function call is of the form:

`(fun-name arg0 arg1 ...)`

where each available fun-name and its arity is described below,
and each argument is a term.

A note on the use of booleans: the vwsim-term language provides a
few functions that deal with booleans ($time$<, f-not,
f<, f=, if). Since the evaluation of terms only
produces a floating point number, these functions understand the
number 0.0d0 to be FALSE and any other value to be TRUE.

##### Unary Functions

Function |
Description |

$time$< |
Check whether the current simulation time is less than the
provided argument. Returns a boolean (see discussion above about
booleans). |

f-not |
Logical not |

f0- |
Negation |

f-abs |
Absolute value |

f-1/x |
Reciprocal |

f-sqrt |
Square root |

f-sin |
Sine |

f-cos |
Cosine |

f-tan |
Tangent |

f-tanh |
Hyperbolic tangent |

f-exp |
Expontential function (e^x) |

##### Binary Functions

Function |
Description |

f+ |
Addition |

f- |
Subtraction |

f* |
Multiplication |

f/ |
Division |

f< |
Less than |

f= |
Equality |

f-mod |
Modulo |

##### Ternary Functions

Function |
Description |

if |
If the first argument evaluates to 0.0d0 (FALSE), then the
third argument is evaluated. Otherwise, the second argument is
evaluated. |

Some more examples of terms:

- (f+ '1 '2)
- (f+ '1.2d0 *pi*)
- (f* '2 $hn$)
- (if (f-not (f< '1 *phi0*)) '4 '5)
- (if ($time$< '2/100) '1.0d0 '2.0d0)