Skip to content
Snippets Groups Projects
Commit 82e152cb authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm charm screenshot

parent 5a02494b
No related branches found
No related tags found
1 merge request!1474Webdoc: reflectometry ...
......@@ -22,10 +22,6 @@ one can
* extend the functionality of the BornAgain core, for instance
by adding particle form factors or correlation functions.
{{< figscg src="nodes_pycharm_ide.png" width="500" class="center"
caption="A BornAgain script running in the PyCharm IDE.">}}
## Installing the Python package
The installer for any supported platform includes, among others, a Python package ('wheel');
for instance, for Python 3.9, the package can be found under `python/3.9/wheel` folder.
......
hugo/content/py/nodes_pycharm_ide.png

224 KiB

+++
title = "Modify the script"
weight = 40
+++
## Expanded simulation script
As a first step towards writing sample and simulation specifications
of your own, let us expand the simulation script
[AlternatingLayers1.py]({{% ref-src "Examples/specular/AlternatingLayers1.py" %}})
from the preceding pages.
Instead of the shorthand calls to modules
[std_samples]({{% ref-src "Wrap/Python/std_samples.py" %}}) and
[std_simulations]({{% ref-src "Wrap/Python/std_simulations.py" %}}),
we provide explicit code for the functions `get_sample` and `get_simulation`:
{{< highlightfile file="Examples/specular/AlternatingLayers1.py">}}
<p>
### Sample
`get_sample` is a function without arguments.
It returns an object of type [MultiLayer]({{% ref-api "classMultiLayer" %}}).
The return statement is preceded by three stances.
Each stance starts with a comment line,
{{< highlight python >}}
# comment extends from hash character to end of line
{{< /highlight >}}
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]({{% ref-api "classMaterial" %}})
the function `Layer` an object of type
[Layer]({{% ref-api "classLayer" %}}).
Function like `addLayer` is a member function of class
[MultiLayer]({{% ref-api "classMultiLayer" %}}).
This can be seen from the two lines
{{< highlight python >}}
sample = ba.MultiLayer()
sample.addLayer(ambient_layer)
{{< /highlight >}}
where `sample` is created as a new instance of class `MultiLayer`.
### Simulation
`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]({{% ref-api "classSpecularSimulation" %}}).
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment