Running a script

To get started with BornAgain scripting, run a first example.

We assume that BornAgain and Python are installed and that the Python interpreter can import bornagain (see preceding page, “Check Installation”).

We shall now run a first example script. This and all other example scripts can also be found in the BornAgain distribution, in directory auto/Examples.

Download the following example script, using the link just below the code frame. Save the script under the name AlternatingLayers1.py.

auto/Examples/specular/AlternatingLayers1.py

For a discussion of the content of this script, see simulation/reflectometry.

From the command line

At the command prompt in a terminal, launch the script with the command

python AlternatingLayers1.py

(on systems that still have Python2, the command may rather be python3).

As result, a MatPlotLib window should pop up, and display this reflectometry curve:

Short call (Linux, Mac)

Under a Unix shell, the script can also be launched without typing python at the command prompt:

AlternatingLayers1.py

This is made possible by the line “#!/usr/bin/env python3” on top of the script. It may be necessary to make the script executable by

chmod a+x AlternatingLayers1.py