Alagator Language Description: Difference between revisions

From Flooxs
Jump to navigation Jump to search
Line 80: Line 80:
=== Differential Functions ===
=== Differential Functions ===


The differential functions are for use in pde's only, and are not evaluated with the [../Post/select.html select] command. There are five operators - three of which are truly differential, and the others are used to return scalar evaluation of vectors parallel and perpindicular to edges of evaluation.
The differential functions are for use in pde's only, and are not evaluated with the [[SelectCommand|select]] command. There are five operators - three of which are truly differential, and the others are used to return scalar evaluation of vectors parallel and perpindicular to edges of evaluation.


Time derivatives are supported with the ddt operator. It takes a single argument, and computes the time derivative of the argument for use in a partial differential equation. Timestep integration is provided automatically using the Bank-Rose TRBDF method.
Time derivatives are supported with the ddt operator. It takes a single argument, and computes the time derivative of the argument for use in a partial differential equation. Timestep integration is provided automatically using the Bank-Rose TRBDF method.

Revision as of 18:27, 10 November 2008

Language Reference

The alagator language is used to specify partial differential equations and boundary conditions for use with diffusion and device simulation. The equations are expressed in a Newton iteration ready form - all equations are assumed to be equal to zero. Most mathematical operators are supported for use in specifying equations, and a variety of operators for differential terms are also available. Derivatives are taken automatically, so there is no need to specify derivative information.

Basic Expression Types and Operators

The alagator uses a natural arithmetic approach to specification of the partial differential equations. Normal mathematical expressions are used, so most algebraic quantities can be constructed. Binary operators, functions, and constants and parameters are supported. Addition of expressions is not difficult. If you have something that you want to see added, contact law@tec.ufl.edu.

Care has to be used about tcl expansion of variables and strings, as usually users want variables to be expanded at run time, not when they are read in. Please refer to tcl command documentation ] for help on string expansion.

Binary Operators

Most common binary algebraic operators are supported. Addition " ", subtraction "-", multiplication "*", and division "/" are all included. Unary negation is also supported with the usual mathematical rules applying. Normal precedence rules apply (See [#Table 1 table 1]). Parenthesis "(" ")" are also supported for grouping operations. In addition to the basic four mathematical operators, power "^" is also supported. a^b raises a to the b power.

A large number of comparison operators are also implemented. These do no t have supported derivative operation, so they can not be used in the specification of a differential equation. However, they can be used in the [../Post/select.html select] command and the [callback.htm#ComputeNode compute node call back]. The operators ">", "<", ">=", "<=", "==", and "!=" are all implemented with their usual meanings. Care must be used with equals and not equals, since comparison of floating point values in this way can be problematic.

Logical operators and, "&&", and or, "||", are also provided for use with call backs and initialization. They now provide derivative values, and can be used as part of differential equations. Care has to be used, however, as Newton's method does not guarantee convergence for problems that are not first order continuous.

Table 1 - Operator Precedence

Operator

Description

Power

-

Unary Minus

*,/

Multiplication, Division

,-

Addition, Subtraction

<. <=, >=, >

Comparison

==, !=

equality, inequality

&&

logical and

||

logical or

?: Arithmetic if then else
, comma operator for lists

Simple Functions

The simple functions all take one argument which must be enclosed in parenthesis. The argument can be any expression. Most common functions are available, including "exp" natural exponentiation, "log" natural log, "log10" log base 10, and "sqrt" square root. Additionally, the complimentary error function,"erfc", and error function, "erf", are also provided to help build initial doping profiles. All of these functions have supported derivatives and can be used in the specification of partial differential equations.

Abs and sign provide an absolute value and sign operation. The sign operation is a positive one if the argument is greater than zero and minus one for less than zero.These functions do provide derivatives and can be used as part of a differential equation.

Differential Functions

The differential functions are for use in pde's only, and are not evaluated with the select command. There are five operators - three of which are truly differential, and the others are used to return scalar evaluation of vectors parallel and perpindicular to edges of evaluation.

Time derivatives are supported with the ddt operator. It takes a single argument, and computes the time derivative of the argument for use in a partial differential equation. Timestep integration is provided automatically using the Bank-Rose TRBDF method.

Spatial derivatives are supported two ways. A simple gradient is supported with grad. Implied is the evaluation in a discrete sense, and the integral around a control volume. For this reason, div is not required. Device simulation requires the Scharfetter-Gummel current, and sgrad is provided for this purpose. Sgrad requires two arguments. The first is the concentration and the second is potential. These are integrated to build a drift-diffusion flux based on a constant electric field along the edge.

The electric field is frequently required for the evaluation of mobility in a device. The "diff" operator returns the magnitude of the derivative of the argument parallel to the edge of evaluation. The "trans" operator returns the magnitude of the derivative of the argument perpindicular to the edge of evaluation. These can be used to generate the parallel and perpindicular electric fields if the argument is the potential.

Resolution of String Names

Strings that are not recognized as real numbers, operators, or functions are handed to the resolution phase of the parser. These strings are compared to three sets of possible matches. The first are valid [solutions.htm solution] names created with the solution command. The second are named subexpressions created with the [term.htm term] command. Finally, remaining strings are passed to tcl's expression function to see if they can be parsed to a real number constant. This allows placement of parameters from [../Misc/pdb.html pdb] into differential equations.

Solution Names

Solution names must match the string exactly as specified in the [solutions.htm solution] command. These are the most important resolution since they allow linking of the equations to the variables to be solved. Derivatives are automatically taken of all equations with respect to each solution name found in the equation.

Subexpressions - Terms

Terms are useful for common subexressions as they can save significant computation time. The string must match exactly the name given in the [term.htm term] command. Derivatives and values in terms are precomputed for each evaluation.

Constants and Parameters

Anything that does not match a term or a solution is handed to tcl's expression parser to see if it evaluates as a valid expression. The result is treated as a constant. The expression evaluation is redone in the code if the temperature or time changes, so that parameters can have dependencies on these values explicitly.

Simple Examples

sel z=log10(Boron)

Select the log10 of the Boron solution variable.

sel z = log10(abs(Doping))*sign(Doping)

Select the signed log of the doping field.

set eqn "ddt(Boron) - 9.0e-16 * grad(Boron)"

Set the eqn variable to a string that contains a simple Fickian diffusion with a constant diffusivity.

See Also

[tutorials.htm language tutorials], [examples.htm complex examples], [callback.htm callbacks], [eqn.htm equation], [term.htm term], [solutions.htm solution], [../Post/select.html select]