|
The
entire Python language is at the disposal of the
script writer but the yammp
module does not expose the majority of its internal
data structures to Python. Thus, scripting is
rather limited. However, you have to use a script
to drive any simulation with
yammp.
Fortunately, there is a graphically driven tool to
assist you. You may never need to write your own
script; see the Scripter item in the User Manual.
For more advanced applications of
yammp,
you may still use the script generator to generate
a first draft of your script that you can then
modify.
In
order to write your own script, you have to have a
basic knowledge of the Python language.
To
use the yammp
module: start the Python interpreter and import the
yammp
module. The three most common forms of the import
statement are:
- import
Taro.Yammp.yammp
- from Taro.Yammp import
yammp
- from
Taro.Yammp.yammp
import *
Note
the capitalization. With the first and second
forms, you must subsequently prefix the module name
on the name of every module object. With the third
form you must not. Thus the
setup()
function must be called after the above import
statements in one of the three corresponding
forms:
- Taro.Yammp.yammp.setup(
descriptor
= "example.ds",
archive
= "example.ar" )
- yammp.setup(
descriptor
= "example.ds",
archive
= "example.ar" )
- setup(
descriptor
= "example.ds",
archive
= "example.ar" )
The
preparatory steps have been coded in a shell script
called Yammp.
It starts the Python interpreter, uses the third
form of the import statement and then hands you
back to the interpreter. If you use
Yammp
you can (almost) forget about the Python
interpreter and concentrate on Yammp commands. You
will be using the function names without
qualification (the third form in the above
examples).
Note
that some functions return values, possibly
multiple values. If you do not assign the return
values to a variable, the values are printed on the
standard output. To avoid this, assign the return
values to a variable which you may then ignore. In
some cases the return value is a result code. These
functions may be used in a conditional
construct.
Most
functions use keyword arguments. The keywords must
be spelt out in full. String values must be
quoted.
In
the following pages, functions are documented in
tables like this:
|
Function
|
Summary
|
Return
Values
|
|
funct()
|
what
this function does
|
(
#a, #b )
|
|
Keyword
|
Argument
|
Type
or Values
|
Interpretation
|
Initial
Value
|
|
word
|
#1
|
"yes",
"no"
|
what
this argument is
|
#0
|
|
another
|
#2
|
Integer
|
what
this argument is
|
#0
|
#
refer to notes at the bottom of the page. The
function name appears in red and the keywords (if
any) in blue. Remember that function names must be
qualified or not depending on how the
yammp
module is imported. Keyword-value pairs (e.g.
descriptor
= "example.ds") may appear in any order. You can
also enter argument values without the keyword
provided you enter all the leading arguments in the
order listed in the table from top to bottom. You
can also mix keyword-value pairs and keyword-less
arguments. For example:
- yammp.setup(
"example.ds", "example.ar" )
- yammp.setup(
"example.ds",
archive
= "example.ar" )
Notes:
#0 : none or no value
#1 : some argument must always be specified, these
are invariably at the beginning of the argument
list
#2 : some arguments are optional, i.e., you need
not specify them if the current value is
acceptable.
#a : what the first return value is
#b : what the second return value is
The
functions are documented in the last two lines of
links below. The setup()
function must be called before any other. The
setenviron()
and edit*()
functions constifute the Modify functions. Once the
setup()
function is called, the Modify and Run functions
(bottom right link) may be called any number of
times and, with some exceptions, in any
order.
|