As a first step towards writing sample and simulation specifications
of your own, let us expand the simulation script
AlternatingLayers.py
from the preceding pages.
Instead of the shorthand calls to modules
std_samples and
std_simulations,
we provide explicit code for the functions get_sample
and get_simulation
:
|
|
get_sample
is a function without arguments.
It returns an object of type MultiLayer.
The return statement is preceded by three stances. Each stance starts with a comment line,
# comment extends from hash character to end of line
BornAgain functions that start with a capital letter,
like MaterialBySLD
or Layer
are constructors or
constructor-like global functions.
They return new objects. An object is an instance of a class.
The function MaterialBySLD
instantiates an object of type
Material
the function Layer
an object of type
Layer.
Function like addLayer
is a member function of class
MultiLayer.
This can be seen from the two lines
sample = ba.MultiLayer()
sample.addLayer(ambient_layer)
sample
is created as a new instance of class MultiLayer
.
get_simulation(sample, scan_size=500)
is a function with one
required argument (sample
) and one optional keyword argument
(scan_size
). If the function is called with only one argument,
then scan_size
is assigned the default value 500.
angstrom
and deg
are numeric constants. They are used to
convert physical quantities to internal units nanometer and radian.
The function returns an object of type SpecularSimulation.