Documentation‎ > ‎

Math Parser (muParser) Functions


muParser Functions

muParser is a wonderful program. It is what allows Mason to process text equations. More information can be found on sourceforge. Also see the muParser license.

Run-time variables

Name
Explanation
frequency   
Changes as the simulation runs, this is the simulation frequency 

Built-in variables

For convenience, some constants are built into the library. Please note that the underscore must be used as shown in the table.
Name
Explanation
_e
e (2.71828...)
_pi
pi (3.1415...)
_j
sqrt(-1)
_c
speed of light in a vacuum
_eps0
permittivity of a vacuum
_mu0
permeability of a vacuum

Built-in constants (v 4.4.9)

For convenience, some unit constants are built into the library. Please note that the underscore must be used as shown in the table.  These are used for making conversions in calculations: "width = 10 * _mil * length"
Name
Explanation
_mil, _mils
2.54e-5
_in
0.0254
_ft
0.3028
_mi
1609.34
_m
1
_cm
1e-2
_mm, _mH, _mF
1e-3
_um, _uF, _uH
1e-6
_nm, _nF, _nH
1e-9
_pm, _pF, _pH
1e-12
_deg
_pi / 180
_rad
180 / _pi

Built-in functions

The following table gives an overview of the functions supported by the default implementation. It lists the function names, the number of arguments and a brief description.
Name
Argument Count
Explanation
Uses the...
sin
1
sine function (radians)
complex argument
cos
1
cosine function (radians) complex argument
tan
1
tangent function (radians) complex argument
asin
1
arc sine function (radians) real part
acos
1
arc cosine function (radians) real part
atan
1
arc tangent function (radians) real part
sinh
1
hyperbolic sine function  complex argument
cosh
1
hyperbolic cosine function  complex argument
tanh
1
hyperbolic tangent function
complex argument
asinh
1
hyperbolic arc sine function
complex argument
acosh
1
hyperbolic arc cosine function
complex argument
atanh
1
hyperbolic arc tangent function
complex argument
Ci 1 Cosine integral function
complex argument
Si
1 Sine Integral function
complex argument
K 
1 First order elliptic integral
complex argument
Ji(x,i)  2 First order Bessel function of order i complex argument
Y0(x)   1 Second order Bessel function of order 0 real part
Y1(x)  1 Second order Bessel function of order 1 real part
log2
1
logarithm to the base 2
complex argument
log10
1
logarithm to the base 10
complex argument
log
1
natural log (base e)
complex argument
ln
1
logarithm to the base e (2.71828...)
complex argument
exp
1
e raised to the power of x
complex argument
sqrt
1
square root of a value
complex argument
sign
1
sign function: -1 if x<0; 1 if x> 0
real part
rint
1
round to the nearest integer
real part
abs
1
absolute value
complex argument
arg
1
argument- angle in degrees
complex argument
real
1
returns the real part
complex argument
imag
1
returns the imaginary part
complex argument
if
3
if(condition,then,else)
   example if statement:
   Y1 = if(B>0, m*X+B, m*X-B)
   [same as: Y1 = m*X+abs(B)]
complex argument
pow
2
power: pow(x,y) == x^y
complex argument
min
variable
minimum of all arguments
real part
max
variable
maximum of all arguments
real part
sum
variable
sum of all arguments
complex argument
avg
variable
mean value of all arguments
complex argument       
lor
variable
logical or of all arguments
list of arguments, e.g. lor(A==B,C==D,E>F)
land
variable
logical and of all arguments
list of arguments, e.g. land(A==B,C==D,E>F) 

Built-in binary operators

The following table lists the default binary operators supported by the parser.
Operator
Meaning
Priority
=
assignment*
-1
<=
less or equal
2
>=
greater or equal
2
!=
not equal
2
==
equality
2
>
greater than
2
<
less than
2
+
addition
3
-
subtraction
3
*
multiplication
4
/
division
4
^
raise x to the power of y
5

*The assignment operator is special since it changes one of its arguments and can only be applied to variables.

MOR Code (Method of Relaxation- 2D Finite Difference)

The MOR code is accessed through muParser calls.  Several "dummy" functions are called to set up the problem- dummy in the sense that they do not return any useful value, the only set up the geometry.

MORSetStrip(X, Y, Width, Thickness, Value):
Set up the a line of voltage "Value" whose left most point is at coordinates (X, Y), goes Width to the right, and is Thickness tall.  The impedance and the permittivity will be calculated for the line associated with the first call to MORSetStrip. 
A value of 1 is consistent with a "positive" side of a coupled line.
A value of -1 is consistent with a "negative' side of a coupled line.
A value of 0 is consistent with a ground line.  Balanced structures like CPS should use +/-1; unbalanced structures like CPW should use 0/1.
Use Thickness = 0 for infinitely thin PEC.
The current loop is 2 cells from the first strip... try to keep gaps between lines at least four cells.


MORSetStrip1(X, Y, Width, Thickness): [deprecated for MORSetStrip]
Set up the "positive" line whose left most point is at coordinates (X, Y), goes Width to the right, and is Thickness tall.
Use Thickness = 0 for infinitely thin PEC. The impedance and the permittivity will be calculated for the line associated with this call. 

MORSetStrip2(X, Y, Width, Thickness): [deprecated for MORSetStrip]
Set up the "negative" (-1) line whose left most point is at coordinates (X, Y), goes Width to the right, and is Thickness tall.
Use Thickness = 0 for infinitely thin PEC.

MORSetStrip3(X, Y, Width, Thickness): [deprecated for MORSetStrip]
Optional "negative" (-1) line whose left most point is at coordinates (X, Y), goes Width to the right, and is Thickness tall.
Use Thickness = 0 for infinitely thin PEC.
MORSetStrip2 MUST be called before MORSetStrip3

MORSetDielectric(EpsR, DYmin, DYMax):
Set up a dielectric slab of EpsR relative permittivity, from DYmin to DYMax.

MORSetBounds(XMax, YMax)
Set the boundary conditions, bottom left of grid is (0,0), upper right of grid is (XMax, YMax).

MORImpedance(dummy_variable)
Run the MOR code, returns a complex number whose real part is the even impedance, the imaginary is the odd.

MORPermittivity(dummy_variable)
Run the MOR code, returns a complex number whose real part is the even mode EpsR, the imaginary is the odd.



Comments