In a later section, we provide links to more information on Scheme and Guile.
guile
at the command-line.
If you run your libctl program without passing any arguments, or
pass a ctl file that never invokes (run)
, this will also
drop you into a Guile interactive mode. What's more, all the special
features supported by libctl and your program are available from this
interactive mode. So, you can set parameters of your program, invoke
it with (run)
, get help with (help)
, and do
anything else you might otherwise do in a ctl file. It is possible
that your program supports other calls than just (run)
,
in which case you could control it on an even more detailed level.
There is a boolean variable called interactive?
that
controls whether interactive mode will be entered. This variable is
true
initially, but is typically set to
false
by (run)
. You can force interactive
mode to be entered or not by set!
-ing this variable to
true
or false
, respectively.
R
in your ctl file:
(define-param R 0.2)
You would then use R
instead of a numeric value
whenever you wanted this radius. If nothing is specified on the
command-line, R
will take on a default value of
0.2
. However, you can change the value of R
on a particular run by specifying R=value
on the
command-line. For instance, to set R
to
0.3
, you would use:
program R=0.3 ctl-file
You can have as many command-line parameters as you want. In fact,
all of the predefined input variables for a program are defined via
define-param
already, so you can set them via the command
line too.
For example, consider the following case where we set the
k-points
of a band-structure computation. We define the
corners of the Brillouin zone, and then call a libctl-provided
function, interpolate, to linearly interpolate between them.
(define Gamma-point (vector3 0 0)) (define X-point (vector3 0.5 0)) (define M-point (vector3 0.5 0.5)) (set! k-points (list Gamma-point X-point M-point Gamma-point)) (set! k-points (interpolate 4 k-points))
The resulting list has 4 points interpolated between each pair of corners:
(0,0,0) (0.1,0,0) (0.2,0,0) (0.3,0,0) (0.4,0,0) (0.5,0,0) (0.5,0.1,0)
(0.5,0.2,0) (0.5,0.3,0) (0.5,0.4,0) (0.5,0.5,0) (0.4,0.4,0)
(0.3,0.3,0) (0.2,0.2,0) (0.1,0.1,0) (0,0,0)
The interpolate
function is provided as a convenience
by libctl, but you could have written it yourself if it weren't. With
past programs, it has often been necessary to write a program to
generate control files--now, the program can be in the control file
itself.
(help)
command lists not only input variables, but also output
variables--these variables are set by the simulation and are available
for the ctl program to examine after (run)
returns.
For example, a band-structure computation might return a list of the band-gaps. Using this, the ctl file could vary, say, the radius of a sphere and loop until a band-gap is maximized.