The Siml language has a built in library. The objects from this library are always visible in the global name space. (One can type sqrt(2) instead of __siml_builtin__.sqrt(2).)
Shadowing built in objects is possible, by defining an object with the same name. The following two lines make the built in function sqrt invisible, in the module where they a are written.
func sqrt(x):
return x + 1
Shadowing a built in object with your own object will almost always create confusion. The possibility to do so, provides flexibility for the exceptional case, where it may be necessary.
A Floating point number.
This is the data type you will use most often. Declaring variables of any other data type is only rarely necessary.
Todo
Mention all operators of Float and their associated special functions.
A logical (binary) value; its value can be either TRUE or FALSE.
The comparison operators (<, >, ==, ...) return Bool values. The logical operators (and, or, not) work only on Bool values and also return Bool vaues.
Todo
Mention all operators of Bool and their associated special functions.
A sequence of characters.
Siml’s string class implements only very few operations:
Special global variable that contains the current time.
At compile time it is an unknown variable, which is defined globally. It can be used in any main function, any computations with it on a global level results in an error.
At runtime it is always known, it has sensible values in all main functions:
Compute the square root of a number.
Compute the natural logarithm of a number.
Compute .
Compute the sinus of a number.
Compute the cosinus of a number.
Compute the tangens of a number.
Return the bigger of the two arguments.
Return the smaller of the two arguments.
Print text at compile time.
The printc function takes an arbitrary number of positional arguments. The arguments are converted to strings and printed at compile time. The function prints unevaluated expressions as ASCII-art trees, that show the structure of the AST.
Additionally the function supports a number of keyword arguments (see below).
The function executes at compile time; calling this function does not create code.
ARGUMENTS
Only produce output when area is in global set of strings (debug areas). The special value “” means: print unconditionally.
To enable debug areas use command line option --debug-area=area1,area2,... of the compiler.
RETURNS
See also: ifc Statement, :function:`print`
Print text at run time.
The print function takes an arbitrary number of positional arguments. For each argument print calls its __siml_str__ function to create a text representation of the object.
Additionally the function supports a number of keyword arguments (see below).
ARGUMENTS
Only produce output when area is in global set of strings (debug areas). The special value “” means: print unconditionally.
To enable debug areas use command line option --debug-area=area1,area2,... of the generated program (or the compiler).
RETURNS
See also: :function:`printc`
Create a graph (at runtime).
The graph function takes an arbitrary number of positional arguments. These values must be Float values that were created with a data statement, and whose values are also recorded during the solution process. The function’s arguments are interpreted specially: As all recorded values at all points in time; not as a single value at a specific moment in time, like variables are interpreted normally.
Additionally the function supports a keyword argument title (see below).
ARGUMENTS
RETURNS
Save the simulation’s results (at runtime).
Stores the data in a CSV or Pickle file. The encoding is determined by the filename’s extension:
When the filename ends in ”.csv” the data is stored in a human readable format, where values are separated by commas: CSV.
ARGUMENTS
Name of the file where the simulation results are stored.
When the filename ends with ”.csv” a human readable file with comma separated values is created. Otherwise Python’s “pickle” format (version 2) is used.
RETURNS
Determine parameters for the solver (at run time).
ARGUMENTS
RETURNS
Check if an object has a certain type.
Similar to isinstance(...) but works with unevaluated expressions too, because attribute __siml_type__ is used instead of __class__. If an expression (in_object) would evaluate to an object of the correct type, the function returns TRUE.
This function executes at compile time and does not produce any code in the compiled program.
ARGUMENTS
The class that in_object must be an instance of.
The argument can be a tuple of classes, then the function returns TRUE if in_object is an instance of any of these classes.
RETURNS
The function returns TRUE if in_object is an instance of class_or_tuple. It returns FALSE otherwise.
class_or_tuple can be a tuple of classes, then the function returns TRUE if in_object is an instance of any of these classes.
Associate a state variable and its time derivative.
Sets the correct roles on both variables.
ARGUMENTS
RETURNS