# Documentation on BornAgain

file:///usr/share/doc/bornagain/html/index.html Recent content in Documentation on BornAgain Hugo en-us

# 1D lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/lattice1d.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/lattice1d.html <h2 id="1d-lattice">1D lattice</h2> <p>In this example we simulate the scattering from infinite 1D repetition of rectangular patches (rectangular grating). This is done by using the interference function of a 1D lattice together with very long boxes.</p> <ul> <li>By-default, the axis of the one-dimensional lattice coincides with the $x$-axis of the reference cartesian frame, so it coinsides with the beam direction.</li> <li>Long boxes are placed along a one-dimensional lattice on top of substrate, the lattice_length parameter corresponds to the grating period.</li> <li>The size of boxes is initially chosen to form a grating which is perpendicular to the beam (long side of the box is along $y$-axis).</li> <li>Keep in mind that <code>length</code>, <code>width</code>, <code>height</code> in the <code>Box(length, width, height)</code> constructor correspond to the directions in the $x,y,z$ axes, in that order, so to achieve the desired setup we use the values: <code>length</code>= $10$ nm, <code>width</code>= $10000$ nm, <code>height</code>= $10$ nm.</li> <li>The whole grating is rotated at the end by an angle of $45^{\circ}$ with respect to the beam axis. This is achieved by rotating <em>both</em> the 1D lattice and the long boxes (see lines 25 and 34).</li> <li>To avoid the problem of rapidly oscillating form factors of long boxes (see <a href="file:///usr/share/doc/bornagain/html/ref/sim/setup/options/mc">this example</a> for more details), the simulation is performed in monte carlo integration mode.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/Interference1DLattice_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/Interference1DLattice_setup.jpg" width="200px"> </a> <figcaption> <p>Real-space model</p>

# Compound particle

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/compound-particle.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/compound-particle.html <h2 id="compound-particle-example">Compound particle example</h2> <p>In this example it is modelled a multi layer consisting of a substrate layer and an air layer. Cylindrical particles made of two materials are added to the air layer and their $z$ coordinate is shifted downwards in order to cross the air-substrate interface.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/BiMaterialCylinders.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/BiMaterialCylinders.png" width="450px"> </a> <figcaption> <p></p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/BiMaterialCylinders.py"/>auto/Examples/scatter2d/BiMaterialCylinders.py</a>

# Core and shell

file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/core-shell.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/core-shell.html <h2 id="core-and-shell-particle">Core-and-shell particle</h2> <p>To construct a particle made of a core and a shell, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">composite_particle</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">CoreAndShell</span><span class="p">(</span><span class="n">core</span><span class="p">,</span> <span class="n">shell</span><span class="p">)</span> </span></span></code></pre></div><p>where <code>core</code> and <code>shell</code> typically are simple particles generated by the <a href="../">Particle</a> constructor.</p> <p>Adjusting the internal positions of the core and shell can be node with a prior call</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">core</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="n">core_position</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">shell</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="n">shell_position</span><span class="p">)</span> </span></span></code></pre></div><p>The <code>composite_particle</code> can also be translated as a whole.</p> <p>Note that core must be fully contained in shell. The scattering is computed as the coherent sum of the scattering from shell and core where the scattering power of the latter has been modified by subtracting the scattering power of the shell material.</p>

# Core and shell

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/core-shell-particle.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/core-shell-particle.html <h3 id="core-and-shell-nanoparticles">Core-and-shell nanoparticles</h3> <p>Scattering from cuboidal core-shell particles.</p> <ul> <li>The sample is made of core-shell particles whose outer and inner shells are boxes with dimensions $L_1 = W_1 = 16$ nm, $H_1 = 8$ nm and $L_2 = W_2 = 12$ nm, $H_2 = 7$ nm, respectively, where $L_i$, $W_i$ and $H_i$ are the length, width and height of box $i$.</li> <li>The smaller box is positioned so that the centres of the bottom faces of both particles coincide.</li> <li>The simulation is run using the Born approximation. There is no substrate and no interference between the different scattered beams.</li> <li>The planar distribution of the particles is diluted and random.</li> <li>The incident wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CoreShellNanoparticles_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CoreShellNanoparticles_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Crossing an interface

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/interface-crossing.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/interface-crossing.html <h3 id="particles-crossing-an-interface">Particles crossing an interface</h3> <p>In this example, very similar to our <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas">basic GISAS example</a>, it is shown how to position particles in order to cross multilayer interfaces: the $z$ position of particles originally located within the air layer must be adjusted slightly downwards in order to cross the air-substrate interface.</p> <p>The simulation kernel automatically detects particles crossing interfaces and adjusts the calculations accordingly, causing a drop on speed to complete each simulation.</p>

# Example

file:///usr/share/doc/bornagain/html/ref/sim/class/specular/ex.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/specular/ex.html <h2 id="basic-specular-reflectometry-example">Basic specular reflectometry example</h2> <p>As introductory example, we simulate specular reflectometry by a sample that consists of 10 Ti/Ni double layers on a Si substrate.</p> <h5 id="full-script">Full script</h5> <p>The same script has been used in the tutorial to explain <a href="file:///usr/share/doc/bornagain/html/py/run">usage</a> and <a href="file:///usr/share/doc/bornagain/html/py/syntax">syntax</a> of BornAgain Python code.</p> <p>Root class reference: <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">SpecularSimulation</a>.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/specular/AlternatingLayers1.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/specular/AlternatingLayers1.png" width="500"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/specular/AlternatingLayers1.py"/>auto/Examples/specular/AlternatingLayers1.py</a> <h5 id="shorthand-with-standard-sample">Shorthand with standard sample</h5> <p>Since we will use the same sample in several other examples, we provide the shorthand <code>std_samples.alternating_layers()</code> so that the above script can be shortened as</p>

# Fitting with masks

file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-with-masks.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-with-masks.html <h2 id="fitting-with-masks">Fitting with masks</h2> <p>In this example we demonstrate how to mask certain areas on the detector image to exclude their influence on the fitting procedure. This can be done by invoking the method <code>addMask</code> on a simulation object.</p> <pre tabindex="0"><code>simulation = ScatteringSimulation() simulation.addMask(Rectangle(x1, y1, x2, y2), mask_value) </code></pre><p>where <code>Rectangle</code> is related to the shape of the mask in detector coordinates, <code>mask_value</code> can be either <code>True</code> (area is excluded from the simulation and fit) or <code>False</code> (area will stay in the simulation and will be taken into account in $\chi^2$ calculations during the fit). There can be an arbitrary number of masks of various shapes added to the simulation one after another. Each subsequent mask overrides the previously defined <code>mask_value</code> in the given area.</p>

# Footprint

file:///usr/share/doc/bornagain/html/ref/instr/beam/footprint.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/beam/footprint.html <h3 id="footprint-correction">Footprint correction</h3> <p>The footprint effect originates from the angle-dependent intersection of a finite beam with a finite sample. It should be considered for all scanning simulations.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/FootprintScheme.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/FootprintScheme.png" width="350px"> </a> <figcaption> <p></p> </figcaption> </figure> </div> </div> <p>When taking into account footprint correction, there are two possible options for the beam shape in <code>BornAgain</code>:</p> <ul> <li>Square beam &mdash; the beam has sharp edges and square cross-section, its intensity is uniformly distributed.</li> <li>Gaussian beam &mdash; the beam is infinite in space, while its intensity has Gaussian distribution along the radius of the beam.</li> </ul> <p>The footprint correction for square beam is defined by <code>FootprintSquare</code> command, which has the signature</p>

# Functionality overview

file:///usr/share/doc/bornagain/html/introduction/functionality.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/introduction/functionality.html <h2 id="functionality-overview">Functionality overview</h2> <p>This section provides a bird&rsquo;s-eye view of the functionality provided by BornAgain.</p> <h3 id="operation-modes">Operation modes</h3> <ul> <li>Graphical user interface (GUI) for intuitive model construction, quick visualization of simulation results, and interactive variation of model parameters.</li> <li>Python scripting for full control and arbitrarily complicated sample models.</li> </ul> <h3 id="instrument-models">Instrument models</h3> <h5 id="experiment-types">Experiment types</h5> <ul> <li>Specular reflectometry</li> <li>Off-specular scattering</li> <li>Grazing-incidence small-angel scattering (GISAS)</li> <li>Small-angel scattering (SAS)</li> </ul> <h5 id="beam">Beam</h5> <ul> <li>Polarized or unpolarized neutrons</li> <li>X-rays</li> <li>Divergence of the beam (wavelength, incident angles) according to different distributions</li> </ul> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/draw/fct_beamdiv.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/fct_beamdiv.png" width="400px"> </a> <figcaption> <p>Beam with angular divergence</p>

# Functions

file:///usr/share/doc/bornagain/html/ref/plot/functions.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/functions.html <h1 id="plot-functions">Plot functions</h1> <p>The following plot functions are provided by the module <code>ba_plot</code> in the <code>bornagain</code> Python package.</p> <h3 id="plot-single-datafield">Plot single Datafield</h3> <p>A single Datafield can be plotted with</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">bornagain</span> <span class="kn">import</span> <span class="n">ba_plot</span> <span class="k">as</span> <span class="n">bp</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span> <span class="o">=</span> <span class="o">...</span> </span></span><span class="line"><span class="cl"><span class="n">result</span> <span class="o">=</span> <span class="n">simulation</span><span class="o">.</span><span class="n">simulate</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">bp</span><span class="o">.</span><span class="n">plot_simulation_result</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">bp</span><span class="o">.</span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span></span></code></pre></div><p>This function is used in a majority of our scripting examples, for instance in the following short, basic examples:</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular/ex">specular reflectivity</a></li> <li><a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas">GISAS</a></li> </ul> <h3 id="plot-several-curves">Plot several curves</h3> <p>Specular simulations yield one-dimensional Datafields that are plotted as curves y(x). Several such curves can be plotted in one frame. This is often used to demonstrate the effect of varying one parameter. See e.g. the examples</p>

# Get announcements

file:///usr/share/doc/bornagain/html/howto/announcements.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/howto/announcements.html <h2 id="how-to-get-announcements">How to get announcements</h2> <p>Subscribe to the mailing list <a href="https://lists.fz-juelich.de/mailman/listinfo/BornAgain-announcements">BornAgain announcements</a>. It is moderated, and has very low traffic. It is used to announce new releases and workshops.</p>

# GISAS

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas.html <h2 id="gisas-simulation-example">GISAS simulation example</h2> <p>In the following introductory example, we take a standard sample model from module <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Wrap/Python/std_samples.py">bornagain.std_samples</a>, a dilute random assembly of monodisperse cylindrical disks on a substrate.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CylindersInDWBA_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CylindersInDWBA_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Cylinders.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Cylinders.png" width="350px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/Cylinders.py"/>auto/Examples/scatter2d/Cylinders.py</a> <p> <h3 id="explanation">Explanation</h3> <h4 id="function-get_simulation">Function get_simulation</h4> <p>The simulation of type <a href="../">ScatteringSimulation</a> is defined by beam, sample, and detector.</p> <p>The incoming beam is defined by the constructor <code>Beam</code> with arguments intensity, wavelength, and glancing angle.</p> <p>To define the wavelength, we use the unit multiplier <code>nm</code>. As it happens, the internal unit for microscopic lengths in BornAgain is one nanometer; therefore the constant <code>nm</code> is just <code>1</code>, and <code>*nm</code> could be omitted from the code, but we recommend to leave it for the benefit of human readers.</p>

# Install third-party software

file:///usr/share/doc/bornagain/html/deploy/building/unix/third-party.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/building/unix/third-party.html <h2 id="install-third-party-software">Install third-party software</h2> <p>As a prerequisite, Python and some Python modules must be installed. For the recommended installation under pyenv, see</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/deploy/py/linux">Python on Linux</a>.</li> <li><a href="file:///usr/share/doc/bornagain/html/deploy/py/mac">Python on Mac</a>.</li> </ul> <p>Further required software:</p> <ul> <li>Compiler with basic C++-20 support (<code>gcc</code> or <code>clang</code>)</li> <li><code>cmake &gt;= 3.20</code></li> <li><code>gsl &gt;= 1.15</code> (GNU scientific library)</li> <li><code>fftw3 &gt;= 3.3.1</code> (fast Fourier transform)</li> <li><code>libtiff &gt;= 4.0.2</code> (TIFF image loader)</li> <li><code>libcerf &gt;= 3</code> (complex error function) [1]</li> <li><code>boost &gt;= 1.74</code> [2]</li> <li><code>zlib1g-dev &gt;= 1.2.11</code> (zlib compression library)</li> <li><code>bzip2 &gt;= 1.0.8</code> (bzip2 compression library)</li> <li><code>Qt6</code></li> </ul> <p>[1] The library <code>libcerf</code> happens to be maintained by our own group. Nonetheless it is treated as an external dependency because packages are provided by all major Linux distributions (see <a href="https://pkgs.org">https://pkgs.org</a>).</p>

# Magnetic layer

file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/magnetic-layer.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/magnetic-layer.html <h3 id="polarized-neutron-reflectometry-with-a-magnetic-layer">Polarized neutron reflectometry with a magnetic layer</h3> <p>This is the introductory example for specular reflectometry with polarized neutrons.</p> <p>The sample consists of a single magnetic layer on top of a substrate. The magnetic field vector <code>B</code> lies in the xy plane. The field direction forms an angle of <code>Bang = 30 * deg</code> with the x axis. The field magnitude <code>Bmag=1e8</code> is in units of A/m. The field is passed as an optional function argument to the constructor <code>ba.MaterialBySLD</code>.</p>

# Mesocrystal

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/mesocrystal-particle.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/mesocrystal-particle.html <h3 id="mesocrystal-particles-example">Mesocrystal particles example</h3> <p>Scattering from cylindrically shaped mesocrystals on a substrate.</p> <ul> <li>The sample is made of cylinder-shaped mesocrystals with outer dimensions: $R = 20$ nm, $H = 50$ nm.</li> <li>The lattice axes are directed along x, y and z, with lattice parameter $5$ nm in each direction.</li> <li>The nodes are spheres with $R = 2$ nm.</li> <li>The planar distribution of the particles is diluted and random.</li> <li>The incident wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Mesocrystal.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Mesocrystal.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p>

# Monte-Carlo

file:///usr/share/doc/bornagain/html/ref/sim/setup/options/mc.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/options/mc.html <h2 id="option-monte-carlo-integration">Option: Monte-Carlo integration</h2> <p>If for some reason the midpoint of a detector pixel is not representative for the average scattering intensity of the entire pixel it is possible to resort to Monte-Carlo integration.</p> <p>To request Monte-Carlo integration over detector pixels, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">options</span><span class="p">()</span><span class="o">.</span><span class="n">setMonteCarloIntegration</span><span class="p">(</span><span class="kc">True</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span> </span></span></code></pre></div><p>where <code>n</code> is the number of scattering intensity evaluations per pixel.</p> <p>Example: <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/mc">Monte-Carlo</a>.</p>

# Python on Linux

file:///usr/share/doc/bornagain/html/deploy/py/linux.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/py/linux.html <h2 id="install-python-on-linux">Install Python on Linux</h2> <p>Any Linux distribution (Debian/Ubuntu, Fedora, etc) provides packages for Python and for many Python modules. This approach, however, runs into difficulties if one needs Python modules that are <em>not</em> available in the distribution. Installing them using the Python package manager Pip can cause inconsistencies and break the system. Therefore, distributions at some point (e.g. Debian 12) disabled Pip, which terminates with <code>error: externally-managed-environment</code>. While this behavior can be overridden by a special flag, we advise against. Rather, we recommend escaping from Python version hell by using the Python version manager <a href="https://github.com/pyenv/pyenv">pyenv</a>.</p>

# Quick Start

file:///usr/share/doc/bornagain/html/gui/quick-start.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/gui/quick-start.html <h2 id="quick-start">Quick Start</h2> <p>This tutorial demonstrates how to run the simulation and get the simulated intensity data image in a few mouse clicks.</p> <h3 id="1-run-bornagain-graphical-user-interface-gui">1. Run BornAgain graphical user interface (GUI)</h3> <p><figure class="float-left"> <a href="file:///usr/share/doc/bornagain/html/img/draw/BornAgain_48x48.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/BornAgain_48x48.png" width="48px"> </a> <figcaption> <p></p> </figcaption> </figure> Use the BornAgain icon located on the desktop (Windows) or on Launchpad (MacOS) to start the GUI.</p> <p>For Linux users: run an executable located in BornAgain installation directory from the command line:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ &lt;install_dir&gt;/bin/bornagain </span></span></code></pre></div><p>When you start the BornAgain GUI, you will be presented with the Projects panel. Click on the &ldquo;New Project&rdquo; button to create a new project.</p>

# Run a script

file:///usr/share/doc/bornagain/html/py/run.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/py/run.html <h2 id="running-a-script">Running a script</h2> <p>To get started with BornAgain scripting, run a first example.</p> <p>We assume that BornAgain and Python are <a href="file:///usr/share/doc/bornagain/html/deploy">installed</a> and that the Python interpreter can <code>import bornagain</code> (see <a href="file:///usr/share/doc/bornagain/html/py">preceding page</a>, &ldquo;Check Installation&rdquo;).</p> <p>We shall now run a first example script. This and all other example scripts can also be found in the BornAgain distribution, in directory <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples">auto/Examples</a>.</p> <p>Download the following example script, using the link just below the code frame. Save the script under the name <code>AlternatingLayers1.py</code>.</p>

# SphericalDetector

file:///usr/share/doc/bornagain/html/ref/instr/det/spherical.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/det/spherical.html <h2 id="sphericaldetector">SphericalDetector</h2> <p>For SAS and GISAS simulations, the two-dimensional area detector is modelled by the <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Device/Detector/SphericalDetector.h">SphericalDetector</a> class.</p> <h3 id="geometry">Geometry</h3> <p>A <code>SphericalDetector</code> is a 2D detector defined in angular coordinates. All pixels have equal size.</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/detector1.svg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/detector1.svg" width="100%"> </a> <figcaption> <p></p> </figcaption> </figure> <p>In BornAgain, detector images are shown as seen from the back of the detector. In this way we ensure that the $\varphi$ or $q_y$ axis has the same orientation as the real-space $y$ axis.</p> <p>For plotting and data import and export, BornAgain pretends that the detector bins correspond to bins of constant width in $\varphi$ or $q_y$ and $\alpha$ or $q_z$, even though this is only true in first approximation.</p>

# Square lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/square-lattice.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/square-lattice.html <h3 id="basic-square-lattice-example">Basic square lattice example</h3> <p>This example shows scattering from cylinders positioned in an infinite square lattice. The lattice axes form a 30 degree angle with the $x$, $y$ axes. This rotation breaks the $\varphi \leftrightarrow -\varphi$ symmetry of the scattering pattern.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/SquareLattice30deg_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/SquareLattice30deg_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DRotatedSquareLattice.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DRotatedSquareLattice.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/Interference2DRotatedSquareLattice.py"/>auto/Examples/scatter2d/Interference2DRotatedSquareLattice.py</a>

# Thin film

file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/depthprobe1.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/depthprobe1.html <h2 id="intensity-distribution-in-a-thin-film-sample">Intensity distribution in a thin-film sample.</h2> <p>We consider a thin film on a substrate.</p> <p>We compute the neutron intensity as function of depth and incident angle $\alpha_i$.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/varia/Depthprobe1.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/varia/Depthprobe1.png" width="500"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/varia/Depthprobe1.py"/>auto/Examples/varia/Depthprobe1.py</a>

# TIFF

file:///usr/share/doc/bornagain/html/ref/fit/data-import/tiff.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/data-import/tiff.html <h2 id="tiff-data-format">TIFF data format</h2> <p>Before loading the main binary data, BornAgain reads the following metadata tags from <code>tiff</code> file:</p> <ul> <li><a href="https://www.awaresystems.be/imaging/tiff/tifftags/imagewidth.html">ImageWidth</a></li> <li><a href="https://www.awaresystems.be/imaging/tiff/tifftags/imagelength.html">ImageLength</a></li> <li><a href="https://www.awaresystems.be/imaging/tiff/tifftags/bitspersample.html">BitsPerSample</a></li> <li><a href="https://www.awaresystems.be/imaging/tiff/tifftags/samplesperpixel.html">SamplesPerPixel</a></li> <li><a href="https://www.awaresystems.be/imaging/tiff/tifftags/sampleformat.html">SampleFormat</a></li> </ul> <p>If any of these tags is not found, an error message will be shown.</p> <p>The requirement to values of the tags are following:</p> <ul> <li><code>BitsPerSample</code> should be 8, 16 or 32.</li> <li><code>SamplesPerPixel</code> should be 1, which means grayscale image with one channel, corresponding to signal intensity.</li> <li><code>SampleFormat</code> should be 1, 2 (integer numbers) or 3 (floating-point numbers). <code>SampleFormat==3</code> requires value of <code>BitsPerSample==32</code>.</li> </ul> <h3 id="checking-tags">Checking tags</h3> <p>File tags can be checked by external utilites.</p>

# Transmitted modulus

file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/transmitted_modulus.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/transmitted_modulus.html <h2 id="transmitted-modulus">Transmitted modulus</h2> <p>Modulus of the amplitude of the partial wave field propagating in transmission direction, as function of depth and incident angle $\alpha_i$.</p> <p>Same sample as in the basic example <a href="depthprobe1">depthprobe1</a>, a thin film on a substrate.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/varia/TransmittedModulus.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/varia/TransmittedModulus.png" width="500"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/varia/TransmittedModulus.py"/>auto/Examples/varia/TransmittedModulus.py</a>

# Ditto, realistic instrument

file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/magnetic-layer-imperfect.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/magnetic-layer-imperfect.html <h3 id="polarized-specular-reflectometry-with-non-perfect-polarizer-and-analyzer">Polarized specular reflectometry with non-perfect polarizer and analyzer</h3> <p>In this example, we show how to perform a specular reflectometry simulation with polarized neutrons and both a non-perfect polarizer as well as analyzer. The example is inspired by and performed with parameters close to the ones in <a href="https://doi.org/10.1063/1.4790717">the paper by Devishvili et al.</a>. This example is a saturated iron film on top of a MgO substrate. On top of the iron layer is a thin Pd cap layer.</p>

# Interface model

file:///usr/share/doc/bornagain/html/ref/sample/roughness/interface.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/roughness/interface.html <h1 id="rough-interface-models">Rough interface models</h1> <h3 id="interface-model">Interface model</h3> <p>The mathematical model for one interface must be specified through one of</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">SelfAffineFractalModel</span><span class="p">(</span><span class="o">...</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">LinearGrowthModel</span><span class="p">(</span><span class="o">...</span><span class="p">)</span> </span></span></code></pre></div><p>These models define the behavior of autocorrelation function of roughness or, better to say, its Fourier spectrum in the full range of spatial frequencies from 0 to infinity.</p> <h5 id="self-affine-fractal-model">Self-affine fractal model</h5> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">SelfAffineFractalModel</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="n">hurst</span><span class="p">,</span> <span class="n">lateral_corr_length</span><span class="p">,</span> <span class="n">max_spatial_freq</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span> </span></span></code></pre></div><p>where</p> <ul> <li><code>sigma</code>, $\sigma$, is the root-mean-square amptitude of out-of-plane (transversal) fluctuation.</li> <li><code>hurst</code>, $H$, is a fractal exponent <code>H</code> with <code>0&lt;H&lt;1</code>. The smaller $H$ is, the more serrate the surface profile looks.</li> <li><code>lateral_corr_length</code>, $\xi$, is the lateral (in-plane) correlation length.</li> <li><code>max_spatial_freq</code>, $\nu_{max}$, is a cut-off spatial frequency.</li> </ul> <p>This is the K-correlation model of <a href="https://doi.org/10.1103/PhysRevB.48.14472">Palasantzas 1993</a>. The autocorrelation spectrum is</p>

# Lattice orientation distribution

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/xi-distrib.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/xi-distrib.html <h3 id="distribution-of-lattice-orientations">Distribution of lattice orientations</h3> <p>This example shows GISAS by an isotropic mixture of lattices. On top of a substrate, we have square lattices of cylinders. The lattice orientation has a uniform <a href="file:///usr/share/doc/bornagain/html/ref/other/distributions">distribution</a> over the full range form $0^\circ$ to $90^\circ$.</p> <p>The differently oriented lattices are incoherently summed using a loop over the parameter distribution samples. This is currently supported only under Python scripting, not in the GUI.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/LatticeOrientationDistribution.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/LatticeOrientationDistribution.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p>

# Understand the syntax

file:///usr/share/doc/bornagain/html/py/syntax.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/py/syntax.html <h2 id="python-syntax-used-in-bornagain-scripts">Python syntax used in BornAgain scripts</h2> <p>We shall employ the same reflectometry script as on the <a href="run">preceding page</a> to explain some Python syntax used in BornAgain scripts.</p> <p>For easy reference, here again the full script:</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/specular/AlternatingLayers1.py"/>auto/Examples/specular/AlternatingLayers1.py</a> <p> <p>We shall now explain the code.</p> <p>The <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a> line</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="ch">#!/usr/bin/env python3</span> </span></span></code></pre></div><p>makes the script executable under Unix-like operating systems, see the chapter on <a href="file:///usr/share/doc/bornagain/html/py/run">how to run</a> scripts from the command line. It is ignored otherwise, as is all text from the comment start character <code>#</code> to the end of the line.</p>

# Transient

file:///usr/share/doc/bornagain/html/ref/sample/roughness/transient.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/roughness/transient.html <h1 id="interlayer-transients">Interlayer transients</h1> <p>The interlayer transient describes the in-depth material profile of laterally averaged roughness.</p> <p>It must be specified through one of</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">ErfTransient</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">TanhTransient</span><span class="p">()</span> </span></span></code></pre></div><p>This defines the type of height distribution, while the root-meas-square value $\sigma$ is taken from <a href="../interface">interface autocorrelation model</a></p> <h3 id="erf-transient">Erf transient</h3> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">ErfTransient</span><span class="p">()</span> </span></span></code></pre></div><p>Corresponds to roughness with Gaussian height statistics.</p> <p>The profile function:</p> <p>$$ \dfrac{1}{2}\Big[1+erf\Big( \dfrac{x}{\sqrt{2}\sigma}\Big)\Big] $$</p> <h3 id="tanh-transient">Tanh transient</h3> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">TanhTransient</span><span class="p">()</span> </span></span></code></pre></div><p>Corresponds to roughness with non-Gaussian height statistics, with longer tails.</p>

# Cross-correlation

file:///usr/share/doc/bornagain/html/ref/sample/roughness/xcorr.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/roughness/xcorr.html <h1 id="inter-interface-correlation">Inter-interface correlation</h1> <p>The correlation between different interfaces is an optional argument of the <code>Roughness</code> constructor.</p> <p>It can be specified through one of</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">SpatialFrequencyCrosscorrelation</span><span class="p">(</span><span class="n">base_crosscorr_depth</span><span class="p">,</span> <span class="n">base_frequency</span><span class="p">,</span> <span class="n">power</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">CommonDepthCrosscorrelation</span><span class="p">(</span><span class="n">cross_corr_depth</span><span class="p">)</span> </span></span></code></pre></div><p>Cross-correlation models determine interaction of the current interface with <em>underlying</em> ones.</p> <p>If the interface is already using <a href="../interface">linear growth model</a>, the other cross-correlation settings are not needed.</p> <h3 id="spatial-frequency-model">&ldquo;Spatial frequency&rdquo; model</h3> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">SpatialFrequencyCrosscorrelation</span><span class="p">(</span><span class="n">base_crosscorr_depth</span><span class="p">,</span> <span class="n">base_frequency</span><span class="p">,</span> <span class="n">power</span><span class="p">)</span> </span></span></code></pre></div><ul> <li><code>base_crosscorr_depth</code>, $\xi_{\perp base}$, is the vertical distance over which the correlation of rougness spectrum at base spatial frequency $\nu_{base}$ between interfaces is damped by a factor $1/e$,</li> <li><code>base_frequency</code>, $\nu_{base}$, is a spatial frequency, for which the correlation of rougness spectrum between interfaces is damped by a factor $1/e$ at vertical distance $\xi_{\perp base}$,</li> <li><code>power</code>, $p$, is a degree that determines the dependence of cross-correlation on spatial frequency.</li> </ul> <p>Cross-correlation spectrum between interfaces $i$ and $j$ is</p>

# without DWBA terms

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/born-approximation.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/born-approximation.html <h2 id="gisas-without-dwba-terms">GISAS without DWBA terms</h2> <p>This example shows scattering from a monolayer that contains a dilute random assembly of monodisperse cylindrical disks.</p> <p>This is the same system as in our <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas">basic GISAS example</a> except that there is no substrate. In consequence, there are no reflections, and therefore the DWBA boils down to the ordinary Born approximation.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CylindersInBA_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CylindersInBA_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/CylindersInBA.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/CylindersInBA.png" width="350px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/CylindersInBA.py"/>auto/Examples/scatter2d/CylindersInBA.py</a>

# with specular peak

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/with-specular.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/with-specular.html <h2 id="option-include-specular-reflection">Option: include specular reflection</h2> <p>Only if option <a href="file:///usr/share/doc/bornagain/html/ref/sim/setup/options/specular">include specular</a> is set, simulated detector images will include the specular reflection of the incident beam.</p> <p>Example: scattering by dilute boxes on a substrate.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/BoxesWithSpecularPeak.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/BoxesWithSpecularPeak.png" width="500px"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/BoxesWithSpecularPeak.py"/>auto/Examples/scatter2d/BoxesWithSpecularPeak.py</a>

# # threads

file:///usr/share/doc/bornagain/html/ref/sim/setup/options/threads.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/options/threads.html <h2 id="option-number-of-threads">Option: number of threads</h2> <p>Multithreading can be controlled through</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">options</span><span class="p">()</span><span class="o">.</span><span class="n">setNumberOfThreads</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> </span></span></code></pre></div><p>where <code>n</code> is the number of threads to be used during the simulation.</p> <p>If this option is not set, or set to <code>n=0</code>, then the default value will be taken from the hardware.</p>

# 2d detector resolution

file:///usr/share/doc/bornagain/html/ref/instr/det/resolution.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/det/resolution.html <h3 id="resolution-function-of-a-two-dimensional-scattering-detector">Resolution function of a two-dimensional scattering detector</h3> <p>If a detector has a resolution function, then the simulated intensity map is blurred by convolution with that function.</p> <p>Currently, only Gaussian resolution functions are supported.</p> <h2 id="gaussian-distribution">Gaussian distribution</h2> <p>Create a Gaussian resolution function, and attach it to a detector, as follows:</p> <pre tabindex="0"><code>resol = ba.ResolutionFunction2DGaussian(horizontal_width, vertical_width) detector.setResolutionFunction(resol) </code></pre><p>For an example, see <a href="file:///usr/share/doc/bornagain/html/ref/instr/ex/resol/2d">resolution 2d example</a>.</p>

# 2D detector resolution

file:///usr/share/doc/bornagain/html/ref/instr/ex/resol/2d.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/ex/resol/2d.html <h3 id="resolution-function-of-a-two-dimensional-scattering-detector">Resolution function of a two-dimensional scattering detector</h3> <p>This example illustrates the effect of <a href="file:///usr/share/doc/bornagain/html/ref/instr/det/resolution">detector resolution</a>.</p> <p>The left image shows scattering from a dilute assembly of large, oriented boxes recorded by a perfect detector without resolution function.</p> <p>In the middle image, for the purpose of demonstration, a broad and very anisotropic Gaussian resolution function is applied.</p> <p>In the right image, the resolution is isotropic.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Resolution.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Resolution.png" width="700px"> </a> <figcaption> <p>Resolution.png</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/Resolution.py"/>auto/Examples/scatter2d/Resolution.py</a>

# Architectural overview

file:///usr/share/doc/bornagain/html/introduction/architecture.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/introduction/architecture.html <h2 id="architectural-overview">Architectural overview</h2> <p>BornAgain is a multi-platform framework available in Windows, MacOS and Linux. The C++ code, all configuration files, tests and Python scripts are all open-source, available at <a href="https://jugit.fz-juelich.de/mlz/bornagain">https://jugit.fz-juelich.de/mlz/bornagain</a>.</p> <h5 id="general-structure">General Structure</h5> <p>The framework consists of shared libraries and a standalone graphical user interface, all written in C++. Thanks to the Python bindings the libraries can be imported into Python as external modules.</p> <p>BornAgain depends on a few external and well established open-source libraries: <a href="http://www.boost.org/">boost</a>, <a href="http://www.gnu.org/software/gsl/">GNU Scientific Library</a>, <a href="http://www.fftw.org/">Fast Fourier Transformation</a> and <a href="http://www.qt.io/developers/">Qt6</a> libraries. They must be installed on the system to run BornAgain on Unix platforms. In the case of Windows and MacOS they are added to the system automatically during the installation of BornAgain.</p>

# Bar ripple

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/bar.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/bar.html <h2 id="bar-ripple">Bar ripple</h2> <p>A ripple with a symmetric rectangular profile that is uniform in $x$-direction.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Box.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Box_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Box_xz.svg" width="30%"> <h4 id="constructors">Constructors</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Box</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">BarGauss</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">BarLorentz</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length</li> <li>W, width</li> <li>H, height</li> </ul> <p>Bar with rectangular longitudinal profile is equvalent to <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/box">Box</a> particle.</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Bar.h">Bar</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q}) = f_\parallel(q_x) f_\bot(q_y,q_z), $$</p> <p>where $$ f_\bot(q_y,q_z) = WH \space \exp\Big(iq_{z}\dfrac{H}{2}\Big) \space \text{sinc}\Big(q_{y}\dfrac{W}{2}\Big) \space \text{sinc}\Big(q_{z}\dfrac{H}{2}\Big).$$</p> <p>Corresponding factor $ f_\parallel(q_x) $ is chosen according to <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/">longitudinal profile</a>.</p>

# Cosine ripple

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/cosine.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/cosine.html <h2 id="cosine-ripple">Cosine ripple</h2> <p>A ripple with a symmetric cosine profile that is uniform in $x$-direction.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/CosineRipple.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/CosineRipple_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/CosineRipple_yz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">CosineRippleBox</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">CosineRippleGauss</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">CosineRippleLorentz</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length</li> <li>W, width</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/CosineRipple.h">CosineRipple</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q}) = f_\parallel(q_x) f_\bot(q_y,q_z), $$</p> <p>where $ f_\bot(q_y,q_z) $ is calculated numerically and $ f_\parallel(q_x) $ is chosen according to <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/">longitudinal profile</a>.</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V=\dfrac{LWH}{2}. $$</p>

# Custom objective function

file:///usr/share/doc/bornagain/html/ref/fit/ex/custom-objective-function.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/custom-objective-function.html <h2 id="custom-objective-function">Custom objective function</h2> <p>The BornAgain fitting API allows users to define a custom objective function to for the minimization engine.</p> <p>In this example we are going to construct a vector of residuals calculated between the experimental and simulated intensity values after applying an additional $sqrt$ function to the amplitudes.</p> <p>$$ residuals = [r_{0}, r_{1}, &hellip; , r_{n-1}], ~~~ r_{i} = \sqrt{e_{i}} - \sqrt{s_{i}} $$</p> <p>The length of vector <code>n</code> corresponds to the total number of <em>non-masked</em> detector channels.</p>

# Export

file:///usr/share/doc/bornagain/html/ref/data/datafield/export.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/data/datafield/export.html <h2 id="export-a-datafield">Export a Datafield</h2> <h4 id="save-in-various-formats">Save in various formats</h4> <p>A <code>Datafield</code> can be saved in various data formats through the BornAgain Python method</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">bornagain</span> <span class="k">as</span> <span class="nn">ba</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span> <span class="o">=</span> <span class="o">...</span> </span></span><span class="line"><span class="cl"><span class="n">result</span> <span class="o">=</span> <span class="n">simulation</span><span class="o">.</span><span class="n">simulate</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">IOFactory</span><span class="o">.</span><span class="n">writeDatafield</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">file_name</span><span class="p">)</span> </span></span></code></pre></div><p>where <code>file_name</code> must have one of the extensions</p> <ul> <li><code>.txt</code> &mdash; ASCII file with 2D array [nrow][ncol], layout as in NumPy,</li> <li><code>.int</code> &mdash; BornAgain internal ASCII format,</li> <li><code>.tif</code> &mdash; 32-bits TIFF file,</li> </ul> <p>to which one may append a second extension that specifies compression:</p> <ul> <li><code>.gz</code>,</li> <li><code>.bz2</code>.</li> </ul> <h4 id="export-to-numpy">Export to NumPy</h4> <p>To extract data from <code>Datafield</code> in form of NumPy arrays, use</p>

# Finite square lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/finite-lattice2d.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/finite-lattice2d.html <h3 id="finite-square-lattice">Finite square lattice</h3> <p>In this example, the lattice is finite, consisting of 40 times 40 unit cells. Otherwise the sample model is the same as in the <a href="file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/square-lattice">basic square lattice example</a>.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/SquareLattice30deg_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/SquareLattice30deg_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DSquareFiniteLattice.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DSquareFiniteLattice.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DRotatedSquareLattice.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/Interference2DRotatedSquareLattice.png" width="500px"> </a> <figcaption> <p>For comparison, scattering intensity with infinite lattice</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/Interference2DSquareFiniteLattice.py"/>auto/Examples/scatter2d/Interference2DSquareFiniteLattice.py</a>

# Fitting

file:///usr/share/doc/bornagain/html/py/fit.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/py/fit.html <h2 id="overview">Overview</h2> <p>In fitting, we estimate the optimum parameters in a numerical model, specifically a scattering simulation, by minimizing the difference between simulated and reference data.</p> <p>BornAgain supports</p> <ul> <li>a variety of minimization algorithms;</li> <li>choice of fitting parameters, their properties and correlations;</li> <li>full control over objective function calculations, including the use of different normalizations and assignments of different masks and weights to different areas of the reference data;</li> <li>possibility to fit simultaneously an arbitrary number of data sets.</li> </ul> <p>In the following we will show how to fit using the BornAgain Python API. For fitting through the graphical user interface, see <a href="file:///usr/share/doc/bornagain/html/gui/gui-fitting">GUI &gt; Fitting</a>.</p>

# Fitting along slices

file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-along-slices.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-along-slices.html <h2 id="fitting-along-slices">Fitting along slices</h2> <p>Here we demonstrate how to fit along slices. The idea is that the user defines the positions of vertical and horizontal lines crossing the detector plane in regions of most interest (Yoneda wings, Bragg peaks, etc.) and then finds the sample parameters which fits those regions best.</p> <p>Such an approach uses much less CPU while still giving a chance to find the optimal sample parameters. In general, however, it is arguable whether fitting along slices makes more sense than fitting using the whole detector image.</p>

# Get the source

file:///usr/share/doc/bornagain/html/deploy/building/unix/get-source.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/building/unix/get-source.html <h2 id="get-the-sources">Get the sources</h2> <p>Besides the sources of <a href="https://jugit.fz-juelich.de/mlz/bornagain">BornAgain</a> you need those of our support libraries <a href="https://jugit.fz-juelich.de/mlz/libheinz">libheinz</a> and <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>If in doubt, install the tarballs of the latest published release:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">https://jugit.fz-juelich.de/mlz/libheinz/-/releases </span></span><span class="line"><span class="cl">https://jugit.fz-juelich.de/mlz/libformfactor/-/releases </span></span><span class="line"><span class="cl">https://jugit.fz-juelich.de/mlz/bornagain/-/releases </span></span></code></pre></div><p>If you are ready to live on the edge, you may also clone our Git repository and work on the current &ldquo;main&rdquo; branch.</p> <h4 id="source-tarballs">Source tarballs</h4> <p>The <code>tar</code> command allows downloading and unpacking in one go:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ wget -qO- https://jugit.fz-juelich.de/mlz/libheinz/-/archive/main/libheinz-main.tar.gz <span class="p">|</span> tar zx </span></span><span class="line"><span class="cl">$ wget -qO- https://jugit.fz-juelich.de/mlz/libformfactor/-/archive/main/libformfactor-main.tar.gz <span class="p">|</span> tar zx </span></span><span class="line"><span class="cl">$ wget -qO- https://jugit.fz-juelich.de/mlz/bornagain/-/archive/main/bornagain-main.tar.gz <span class="p">|</span> tar zx </span></span></code></pre></div><h4 id="git">Git</h4> <p>You can also get access to the source code by cloning our public Git repository:</p>

# GISAS 2D fits

file:///usr/share/doc/bornagain/html/ref/fit/ex/gisas-fit2d.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/gisas-fit2d.html <h1 id="fitting-gisas-in-2d">Fitting GISAS in 2D</h1> <p>This example demonstrates fitting of 2D GISAS data.</p> <h2 id="faked-experimental-data">Faked experimental data</h2> <p>The sample and instrument model is basically the same as in our <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas">basic GISAS simulation example</a>, except that it depends on four external parameters: beam intensity, detector background, radius and height of the cylindrical nanoparticles.</p> <p>Faked experimental data have been generated by the script <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/devtools/fakeData/fake-gisas1.py">devtools/fakeData/fake-gisas1.py</a>.</p> <p>The intensity for each detector pixel has been drawn at random from a Poisson distribution, with rate basically given by the fit model except for some imperfections that have been introduced on purpose to make the subsequent fitting more difficult and more realistic:</p>

# GUI overview

file:///usr/share/doc/bornagain/html/gui/gui-overview.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/gui/gui-overview.html <h2 id="gui-overview">GUI overview</h2> <p>The basic features of the interface are explained below.</p> <ul> <li><a href="#projects-view">Projects View</a></li> <li><a href="#instrument-view">Instrument View</a></li> <li><a href="#sample-view">Sample View</a></li> <li><a href="#simulation-view">Simulation View</a></li> <li><a href="#jobs-view">Jobs View</a></li> </ul> <h3 id="projects-view">Projects view</h3> <p>When you start BornAgain GUI, you will be presented with the Projects View, where you can</p> <ul> <li>Create new projects</li> <li>Open recent projects</li> </ul> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/draw/gui_projectsview_l.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/gui_projectsview_l.png" width="800px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>You can use the view selector located on the left vertical panel (1) to change to one of the following views.</p> <table> <thead> <tr> <th style="text-align: left"></th> <th style="text-align: left"></th> </tr> </thead> <tbody> <tr> <td style="text-align: left"><figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/draw/main_projectsview.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/main_projectsview.png" width="50px"> </a> <figcaption> <p></p> </figcaption> </figure> </td> <td style="text-align: left">Switch to Projects View</td> </tr> <tr> <td style="text-align: left"><figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/draw/main_instrumentview.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/main_instrumentview.png" width="50px"> </a> <figcaption> <p></p>

# Manual checks

file:///usr/share/doc/bornagain/html/dev/dev/manual_checks.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/dev/manual_checks.html <h2 id="manual-checks">Manual checks</h2> <p>Tests that cannot be automatized should occasionally be run manually.</p> <h4 id="unused-code">Unused code</h4> <p>Unused code, in particular unused functions, can be detected with the tool <a href="https://github.com/mgehre/xunused">xunused</a>.</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> build </span></span><span class="line"><span class="cl">cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS<span class="o">=</span>ON </span></span><span class="line"><span class="cl">vi compile_commands.json <span class="c1"># rm source files in 3rdparty and Fit/3rdparty</span> </span></span><span class="line"><span class="cl">xunused compile_commands.json 2&gt;<span class="p">&amp;</span><span class="m">1</span> &gt;/dev/null <span class="p">|</span> tee /io/unused.txt </span></span></code></pre></div><p>Use judgement: not all currently unused functions must be removed.</p> <h4 id="static-code-analysis-with-clang-tidy">Static code analysis with clang-tidy</h4> <p>&hellip;</p> <h4 id="coverage">Coverage</h4> <p>&hellip;</p>

# Off-specular

file:///usr/share/doc/bornagain/html/ref/sim/class/offspec/ex.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/offspec/ex.html <h2 id="off-specular-scattering-examples">Off-specular scattering examples</h2> <p>Class reference: <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/offspec">OffspecSimulation</a>.</p> <h4 id="sample-model">Sample model</h4> <p>Off-specular scattering from a monodisperse distribution of long boxes.</p> <ul> <li>The sample is made of very long boxes with length equal to $1000$ nm, width $20$ nm and height $10$ nm.</li> <li>The particles are distributed along a one-dimensional lattice with a lattice spacing of $100$ nm in the $x$-direction.</li> <li>The particles are rotated around the $z$-axis by $90^{\circ}$ so that their &ldquo;infinite&rdquo; dimension is parallel to the $y$-direction.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/Offspec_Setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/Offspec_Setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Python on Windows

file:///usr/share/doc/bornagain/html/deploy/py/win.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/py/win.html <h2 id="install-python-on-windows">Install Python on Windows</h2> <p>Run the installer and follow the steps.</p> <p>To use BornAgain GUI application, the installation directory should be added to the system <code>PATH</code>:</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/win_add_to_PATH.png"> <img src="file:///usr/share/doc/bornagain/html/img/win_add_to_PATH.png" width="450px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>Ensure that <code>pip</code> package manager is checked for installation. Command</p> <pre tabindex="0"><code>$ python -m ensurepip </code></pre><p>will install <code>pip</code> if it is missing.</p> <h4 id="bornagain-with-anaconda">BornAgain with Anaconda</h4> <p>BornAgain can also work the Python from the Anaconda platform. Note that the path to directory which includes the Python platform should be added to the system <code>PATH</code>.</p>

# Rotation

file:///usr/share/doc/bornagain/html/ref/other/rotation.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/other/rotation.html <h2 id="particle-rotation">Particle rotation</h2> <h5 id="constructors">Constructors</h5> <p>Rotations are created by the following constructors:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># Euler z-x-z sequence of rotations</span> </span></span><span class="line"><span class="cl"><span class="n">RotationEuler</span><span class="p">(</span><span class="n">alpha</span><span class="p">,</span> <span class="n">beta</span><span class="p">,</span> <span class="n">gamma</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># rotation around X axis by given angle</span> </span></span><span class="line"><span class="cl"><span class="n">RotationX</span><span class="p">(</span><span class="n">angle</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># rotation around Y axis by given angle</span> </span></span><span class="line"><span class="cl"><span class="n">RotationY</span><span class="p">(</span><span class="n">angle</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># rotation around Z axis by given angle</span> </span></span><span class="line"><span class="cl"><span class="n">RotationZ</span><span class="p">(</span><span class="n">angle</span><span class="p">)</span> </span></span></code></pre></div><p>Angle arguments are understood in radians. Use <code>*deg</code> to convert from degrees.</p> <p>The Euler angles <code>alpha</code>, <code>beta</code>, <code>gamma</code> refer to the <code>z-x'-z''</code> convention:</p>

# Sawtooth ripple

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/sawtooth.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/ripples/sawtooth.html <h2 id="sawtooth-ripple">Sawtooth ripple</h2> <p>A ripple with an asymmetric saw-tooth profile that is uniform in $x$-direction.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/SawtoothRipple.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SawtoothRipple_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SawtoothRipple_yz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">SawtoothRippleBox</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">SawtoothRippleGauss</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">SawtoothRippleLorentz</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length</li> <li>W, width</li> <li>H, height</li> <li>d, asymmetry</li> </ul> <p>Constraint:</p> <p>$ |d| \le W/2 $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/SawtoothRipple.h">SawtoothRipple</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q}) = f_\parallel(q_x) f_\bot(q_y,q_z), $$</p> <p>where $$ f_\bot(q_y,q_z) = Hi\frac{\text{e}^{-i q_y d}}{q_y} \left[ \text{e}^{i \alpha_{-}/2} \text{sinc}\left( \frac{\alpha_{+}}{2} \right) - \text{e}^{i \alpha_{+}/2} \text{sinc}\left( \frac{\alpha_{-}}{2} \right) \right], $$</p>

# SLD profile with rough interfaces

file:///usr/share/doc/bornagain/html/ref/data/sld-profile/sld-profile-rough-interfaces.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/data/sld-profile/sld-profile-rough-interfaces.html <h3 id="sld-profile-with-rough-interfaces">SLD profile with rough interfaces</h3> <p>This example shows how to plot the Scattering Length Density (SLD) profile for a multilayer sample with rough interfaces.</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/varia/MaterialProfile.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/varia/MaterialProfile.png" width="500px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>The sample consists of alternating Ti and Ni layers with rough interfaces.</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/varia/MaterialProfile.py"/>auto/Examples/varia/MaterialProfile.py</a>

# Build

file:///usr/share/doc/bornagain/html/dev/config/build.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/config/build.html <h2 id="building-as-developer">Building as developer</h2> <p>As developer, configure CMake with</p> <pre tabindex="0"><code>cmake .. -DDEV=ON </code></pre><p>This activates additional build targets. In particular, all contents of the <code>auto</code> directory is regenerated if out of sync.</p> <h4 id="prerequisites">Prerequisites</h4> <p>Developers need additional tools, beyond those required for building BornAgain from source:</p> <ul> <li>Swig, to regenerate <code>auto/Wrap</code>;</li> <li>Ruby, which provides the embedded interpreter erb, to regenerate <code>auto/Examples</code> and <code>auto/MiniExamples</code>;</li> <li>Doxygen, to autogenerate the API documentation;</li> <li>clang-format, to enforce proper source formatting.</li> </ul> <p>Of these, clang-format is not controlled by <code>make</code>, but must be run manually.</p>

# Build and install BornAgain

file:///usr/share/doc/bornagain/html/deploy/building/unix/build-and-install.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/building/unix/build-and-install.html <h2 id="build-and-install-bornagain">Build and install BornAgain</h2> <p>The following instructions must be executed for the software projects</p> <ul> <li>libheinz,</li> <li>libformfactor,</li> <li>BornAgain,</li> </ul> <p>in the given order.</p> <p>Each source package comes with configuration files for the cross-platform build system <a href="https://cmake.org">CMake</a>. Using CMake, it takes the following commands to build and install the software:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ <span class="nb">cd</span> &lt;source_dir&gt; </span></span><span class="line"><span class="cl">$ mkdir build <span class="c1"># see note [1]</span> </span></span><span class="line"><span class="cl">$ <span class="nb">cd</span> build </span></span><span class="line"><span class="cl">$ cmake <span class="o">[</span>&lt;options&gt;<span class="o">]</span> .. <span class="c1"># see note [4]</span> </span></span><span class="line"><span class="cl">$ make -j4 <span class="c1"># see note [2]</span> </span></span><span class="line"><span class="cl">$ make ba_wheel <span class="c1"># make the Python wheel</span> </span></span><span class="line"><span class="cl">$ ctest -j4 </span></span><span class="line"><span class="cl">$ make install <span class="c1"># see note [3]</span> </span></span></code></pre></div><h5 id="note-1-build-directory">Note [1]: Build directory</h5> <p>The build process must take place &ldquo;out of place&rdquo;, i.e. not directly in the source directory. Otherwise, location and name of the build directory are arbitrary. We nonetheless recommend to follow our convention, create a subdirectory under the source directory, and call it <code>build</code>.</p>

# Experiment at GALAXI

file:///usr/share/doc/bornagain/html/ref/fit/ex/galaxi.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/galaxi.html <h2 id="experiment-at-galaxi">Experiment at GALAXI</h2> <p>This is an example of a real data fit. We use our own measurements performed at the laboratory diffractometer <a href="https://www.fz-juelich.de/en/jcns/jcns-2/expertise/in-house-x-ray/galaxi">GALAXI</a> in Forschungszentrum Jülich.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/FitGALAXIData_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/FitGALAXIData_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/FitGALAXIData.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/FitGALAXIData.png" width="350px"> </a> <figcaption> <p>Fit window</p> </figcaption> </figure> </div> </div> <ul> <li>The sample represents a 4 layer system (substrate, teflon, hmdso and air) with Ag nanoparticles placed inside the hmdso layer on top of the teflon layer.</li> <li>The sample is generated with the help of a <code>SampleBuilder</code>, which is able to create samples depending on parameters defined in the constructor and passed through to the <code>create_sample</code> method.</li> <li>The nanoparticles have a broad log-normal size distribution.</li> <li>The detector is created to represent the PILATUS detector from the experiment (line 19).</li> <li>In the simulation settings the beam is initialized and the detector is assigned to the simulation. A region of interest is assigned at line 39 to simulate only a small rectangular window. Additionally, a rectangular mask is added to exclude the reflected beam from the analysis (line 40).</li> <li>The real data is loaded from a tiff file into a histogram representing the detector&rsquo;s channels.</li> <li>The <code>run_fitting()</code> function contains the initialization of the fitting kernel: loading experimental data, assignment of fit pair, fit parameters selection (line 62).</li> </ul> <h2 id="experiment-description">Experiment description</h2> <p>To successfully simulate and fit results of some real experiment it is important to have</p>

# Find background

file:///usr/share/doc/bornagain/html/ref/fit/ex/find-background.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/find-background.html <h2 id="find-background">Find background</h2> <p>This example demonstrates how to introduce a background in the simulation and fit its value. Here we are simulating cylinders on top of a substrate without interference. The function <code>get_simulation</code> requires 4 parameters:</p> <ul> <li>the height of the cylinders</li> <li>the radius of the cylinders</li> <li>the value of the constant background</li> <li>a scale factor for the beam&rsquo;s intensity</li> </ul> <p>The radius and height of the cylinders are passed to the function constructing the multi layer while the scale and background values are used to initialize the instrument.</p>

# Fitting in the GUI

file:///usr/share/doc/bornagain/html/gui/gui-fitting.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/gui/gui-fitting.html <h2 id="fitting-in-the-gui">Fitting in the GUI</h2> <p>This tutorial gives a brief overview of the fitting functionality in the GUI.</p> <p>As a first example, this tutorial will focus on fitting data simulated with BornAgain itself. More complex fitting examples will be addressed in coming releases. This tutorial is organized as follows:</p> <ul> <li><a href="#1-preparing-the-data-for-fitting">Preparing the data for fitting</a></li> <li><a href="#2-simulating-the-model">Simulating the model</a></li> <li><a href="#3-importing-the-experimental-data">Importing &ldquo;experimental&rdquo; data in BornAgain</a></li> <li><a href="#4-performing-a-fit">Performing a fit</a></li> </ul> <div class="notices note" >Although this tutorial consideres GISAS data fitting, the steps described are equally applicable to fitting reflectometry or off-specular data (after choosing the appropriate type of instrument).</div> <h3 id="1-preparing-the-data-for-fitting">1. Preparing the data for fitting</h3> <p>First, as explained in the GUI Overview chapter, create a project and select and instrument (here, GISAS).</p>

# Lattice with basis

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/with-basis.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/with-basis.html <h3 id="2d-lattice-with-basis">2D lattice with basis</h3> <p>This example shows how to simulate a lattice with more than one particle per unit cell. The particles that form a basis of the Bravais lattice are combined into a compound particle.</p> <p>The sample of this specific example could also be represented by a square lattice with only one particle per unit cell: Just rotate by 45 degrees, and reduce the lattice constant to $1/\sqrt{2}$. These two equivalent representations allow for a cross-check.</p>

# Linux

file:///usr/share/doc/bornagain/html/deploy/install/linux.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/install/linux.html <h2 id="install-on-linux">Install on Linux</h2> <h3 id="prequisites">Prequisites</h3> <h5 id="python">Python</h5> <p>As a prerequisite, Python must be installed. For the recommended installation under pyenv, see <a href="file:///usr/share/doc/bornagain/html/deploy/py/linux">Python on Linux</a>.</p> <h5 id="glibc">glibc</h5> <p>Our BornAgain binaries (pip package and installer) are built on Debian 11 and require <a href="https://www.gnu.org/software/libc">glibc</a> version 2.31 or higher.</p> <p>To see which glibc version is available on your system, run</p> <pre tabindex="0"><code>$ ldd --version </code></pre><p>Versions for other Linux distributions can be seen at <a href="https://repology.org/project/glibc/versions">https://repology.org/project/glibc/versions</a></p> <h3 id="installation-methods">Installation methods</h3> <h5 id="as-python-only-package">as Python-only package</h5> <p>If the BornAgain GUI is not required as only Python scripting mode is to be used, then BornAgain can be installed as a Python package from the <code>pip</code> repository:</p>

# Minimizer settings

file:///usr/share/doc/bornagain/html/ref/fit/ex/minimizer-settings.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/minimizer-settings.html <h2 id="minimizer-settings">Minimizer settings</h2> <p>This example demonstrates how to change the minimizer algorithm and some of its settings. For example, the following lines</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">minimizer</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Minimizer</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">minimizer</span><span class="o">.</span><span class="n">setMinimizer</span><span class="p">(</span><span class="s2">&#34;Minuit2&#34;</span><span class="p">,</span> <span class="s2">&#34;Migrad&#34;</span><span class="p">,</span> <span class="s2">&#34;MaxFunctionCalls=500;Strategy=2&#34;</span><span class="p">)</span> </span></span></code></pre></div><p>will set the internal minimizer to &ldquo;Minuit2&rdquo;, its internal algorithm to &ldquo;Migrad&rdquo; and then pass additional options, limiting the maximum number of calls and an internal minimization strategy.</p> <p>The list of available minimizers and their options can be seen with</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">ba</span><span class="o">.</span><span class="n">MinimizerFactory</span><span class="p">()</span><span class="o">.</span><span class="n">catalogueDetailsToString</span><span class="p">())</span> </span></span></code></pre></div><p>For more information, see the <a href="file:///usr/share/doc/bornagain/html/ref/fit/minimizers">minimizer settings tutorial</a>.</p>

# Python on Mac

file:///usr/share/doc/bornagain/html/deploy/py/mac.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/py/mac.html <h2 id="install-python-on-mac">Install Python on Mac</h2> <p>The pre-installed system Python on MacOS may be outdated, and may be in conflict with external module requirements. Therefore we strongly recommend to install Python and the Python module manager <code>pip</code> from scratch.</p> <p>The preferred installation method for Python is using <a href="https://brew.sh/">Homebrew</a>. For instance, to install Python 3.11, use</p> <pre tabindex="0"><code>brew install python@3.11 </code></pre>

# Radial paracrystal

file:///usr/share/doc/bornagain/html/ref/sample/interference/para_radial.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/para_radial.html <h2 id="radial-paracrystal">Radial paracrystal</h2> <p>Scattering from a monolayer of monodisperse cylinders, positioned according to the radial paracrystal model.</p> <ul> <li>The sample is made of cylinders with radii and heights equal to $5$ nm, deposited on a substrate.</li> <li>The distribution of particles follows a radial paracrystal, characterized by a peak distance of $20$ nm and a damping length of $1$ $\mu$m.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <p><strong>Note:</strong></p>

# SLD profile with a sliced particle layer

file:///usr/share/doc/bornagain/html/ref/data/sld-profile/sld-profile-sliced-layer.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/data/sld-profile/sld-profile-sliced-layer.html <h3 id="sld-profile-with-a-sliced-particle-layer">SLD profile with a sliced particle layer</h3> <p>This example shows how to plot a z dependent Scattering Length Density (SLD) profile caused by a dense assembly of conical particles.</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/varia/MaterialProfileWithParticles.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/varia/MaterialProfileWithParticles.png" width="500px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>The staircase profile comes from slicing of the vacuum layer that accounts for the z dependent particle density. The slicing is specified by the statement</p> <pre tabindex="0"><code>ambient_layer.setNumberOfSlices(20). </code></pre><div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/varia/MaterialProfileWithParticles.py"/>auto/Examples/varia/MaterialProfileWithParticles.py</a>

# TOF reflectometry

file:///usr/share/doc/bornagain/html/ref/instr/scan/tof.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/scan/tof.html <h2 id="time-of-flight-reflectometry">Time-of-flight reflectometry</h2> <p>This example shows how to set up a $q_z$ scan using a NumPy array. This can be used to simulate a time-of-flight (TOF) reflectometry experiment.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/specular/TimeOfFlightReflectometry.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/specular/TimeOfFlightReflectometry.png" width="500px"> </a> <figcaption> <p></p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/specular/TimeOfFlightReflectometry.py"/>auto/Examples/specular/TimeOfFlightReflectometry.py</a>

# TOF resolution

file:///usr/share/doc/bornagain/html/ref/instr/scan/tof-resolution.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/scan/tof-resolution.html <h2 id="resolution-effects-in-tof-reflectometry">Resolution effects in TOF Reflectometry</h2> <p>In the following reflectometry example, each scan point has a distribution of $q_z$ values.</p> <p>The constructor</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">ba</span><span class="o">.</span><span class="n">DistributionGaussian</span><span class="p">(</span><span class="mf">0.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mi">25</span><span class="p">,</span> <span class="mf">2.</span><span class="p">)</span> </span></span></code></pre></div><p>specifies a Gaussian distribution with mean 0, standard deviation 1, 25 sampling points, and a cut-off at 2 sigma. For other distributions (besides Gaussian), see <a href="file:///usr/share/doc/bornagain/html/ref/other/distributions">distributions</a>.</p> <p>The statements</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">scan</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">QzScan</span><span class="p">(</span><span class="n">qzs</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">scan</span><span class="o">.</span><span class="n">setVectorResolution</span><span class="p">(</span><span class="n">distr</span><span class="p">,</span> <span class="n">dq</span><span class="p">)</span> </span></span></code></pre></div><p>take arrays <code>qzs</code> and <code>dq</code> as arguments. These arrays must have the same length <code>n</code>. For each scan point (i=0,..,n-1), the $q_z$ values have a Gaussian distribution with mean <code>qzs[i]</code> and <code>dq[i]</code>.</p>

# Upgrading

file:///usr/share/doc/bornagain/html/py/upgrading.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/py/upgrading.html <h1 id="upgrading-python-scripts-after-bornagain-version-change">Upgrading Python scripts after BornAgain version change</h1> <p>As we are working on simplifying and unifying the BornAgain Python API, each major release of BornAgain brings some changes that breaks some scripts.</p> <p>With BornAgain-22, we provide for the first time a conversion script that replaces <em>some</em> of the outdated constructs. This script can be found in the BornAgain source tree at <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/scripts/upgrade-21-to-22.py">scripts/upgrade-21-to-22.py</a>.</p>

# Rotation example

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/particle-rotation.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/particle-rotation.html <h3 id="rotated-pyramids">Rotated Pyramids</h3> <p>Scattering from a monodisperse distribution of rotated pyramids.</p> <p>This example illustrates how the in-plane rotation of non-radially symmetric particles influences the scattering pattern.</p> <ul> <li>The sample is made of pyramids deposited on a substrate.</li> <li>Each pyramid is characterized by a squared-base side length of $10$ nm, a height of $5$ nm, and a base angle $\alpha$ equal to $54.73^{\circ}$.</li> <li>These particles are rotated in the $(x, y)$ plane by $45^{\circ}$.</li> <li>There is no interference between the scattered waves.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/RotatedPyramids_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/RotatedPyramids_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Layer

file:///usr/share/doc/bornagain/html/ref/sample/multilayer/layer.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/multilayer/layer.html <h2 id="class-layer">Class Layer</h2> <p>A <a href="file:///usr/share/doc/bornagain/html/ref/sample/multilayer">Sample</a> and <a href="file:///usr/share/doc/bornagain/html/ref/sample/multilayer/stack">LayerStack</a> contain one or several instances of class <code>Layer</code>.</p> <h5 id="create-an-instance">Create an instance</h5> <p>Each instance is created using the constructor call</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">layer_i</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Layer</span><span class="p">(</span><span class="n">material</span><span class="p">,</span> <span class="n">thickness</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">roughness</span><span class="o">=</span><span class="n">nullptr</span><span class="p">)</span> </span></span></code></pre></div><p>Typically, the variable name will contain an index <code>i</code>. By convention, the numbering starts with the top layer, typically <code>layer_1</code>.</p> <p>For the first argument, see <a href="file:///usr/share/doc/bornagain/html/ref/sample/material">Material</a>.</p> <p>The optional second argument is the layer thickness in nm. If it is omitted, then the default value of 0 indicates an infinite thickness; this is to be used for the bottom or top layer, or for the sole component of a single-layer sample.</p>

# LayerStack

file:///usr/share/doc/bornagain/html/ref/sample/multilayer/stack.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/multilayer/stack.html <h2 id="class-layerstack">Class LayerStack</h2> <p>A <a href="file:///usr/share/doc/bornagain/html/ref/sample/multilayer">Sample</a> or outer <code>LayerStack</code> may contain one or several instances of class <code>LayerStack</code>.</p> <p>Each instance is created using the constructor call</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">stack</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">LayerStack</span><span class="p">(</span><span class="n">n_periods</span><span class="p">)</span> </span></span></code></pre></div><p>or</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">stack</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">LayerStack</span><span class="p">()</span> <span class="c1"># by default n_periods = 1</span> </span></span></code></pre></div><p>The stack is created empty. To populate it with <a href="file:///usr/share/doc/bornagain/html/ref/sample/multilayer/layer">layers</a> or other stacks, call</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">stack</span><span class="o">.</span><span class="n">addLayer</span><span class="p">(</span><span class="n">layer</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">stack</span><span class="o">.</span><span class="n">addStack</span><span class="p">(</span><span class="n">sub_stack</span><span class="p">)</span> </span></span></code></pre></div><p>The numper of repetitions can be changed with</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">stack</span><span class="o">.</span><span class="n">setNumberOfPeriods</span><span class="p">(</span><span class="n">n_periods</span><span class="p">)</span> </span></span></code></pre></div><p>or returned with</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">stack</span><span class="o">.</span><span class="n">numberOfPeriods</span><span class="p">()</span> </span></span></code></pre></div>

# Layout

file:///usr/share/doc/bornagain/html/ref/sample/multilayer/layout.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/multilayer/layout.html <h2 id="class-particlelayout">Class ParticleLayout</h2> <p>A <a href="layer">Layer</a> may contain any number of instances of class <code>ParticleLayout</code>. If a layer has more than one layout, then their scattering intensities add incoherently.</p> <h5 id="create-an-instance-and-add-particles">Create an instance and add particles</h5> <p>To create a particle layout and add kinds of particles, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">layout</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">ParticleLayout</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">layout</span><span class="o">.</span><span class="n">addParticle</span><span class="p">(</span><span class="n">particle</span><span class="p">,</span> <span class="n">abundance</span><span class="p">)</span> </span></span></code></pre></div><p>For the <code>particle</code> argument, see <a href="../particle">Particle</a>.</p> <p>If the <code>abundance</code> argument is omitted, then the abundance will be taken from the particle, which by default has an abundance of 1.</p>

# 2D paracrystal

file:///usr/share/doc/bornagain/html/ref/sample/interference/para2d.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/para2d.html <h2 id="2d-paracrystal">2D Paracrystal</h2> <p>Scattering from monodisperse cylinders distributed along a two-dimensional square paracrystal.</p> <ul> <li>The particles are cylinders with constant radii and heights equal to $5$ nm.</li> <li>They are deposited on a substrate, following a two-dimensional square paracrystalline pattern.</li> <li>This 2D paracrystal is characterized by: <ul> <li>a lattice length of $20$ nm along both axes of the reference Cartesian frame,</li> <li>a damping length equal to $0$,</li> <li>&ldquo;coherent&rsquo; domains with a size of $20$ $\mu$m along the axes of the reference Cartesian frame.</li> </ul> </li> <li>The incident beam is characterized by a wavelength of 0.1 nm and angles $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <p><strong>Note:</strong></p>

# Average materials

file:///usr/share/doc/bornagain/html/ref/sim/setup/options/avgmat.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/options/avgmat.html <h2 id="option-use-average-materials">Option: use average materials</h2> <p>With the setting</p> <pre tabindex="0"><code>simulation.options().setUseAvgMaterials(True) </code></pre><p>the refractive properties of material layers are computed by taking the average of the matrix material and the embedded particles.</p>

# Bayesian Sampling

file:///usr/share/doc/bornagain/html/ref/fit/ex/bayesian.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/bayesian.html <h2 id="bayesian-sampling">Bayesian sampling</h2> <p>Bayesian sampling of reflectometry models is a common tool in the analysis of specular reflectometry data. The Python programming language has a powerful infrastructure for this modelling, including packages such as <a href="https://docs.pymc.io">PyMC3</a> and <a href="https://pystan.readthedocs.io/en/latest/">PyStan</a>. Here, we will show how the <a href="https://emcee.readthedocs.io/en/stable/">emcee</a> Python may be used to enable Bayesian sampling in BornAgain and the differential evoulation optimisation algorithm from the <a href="https://docs.scipy.org/doc/scipy/">scipy</a>.</p> <h3 id="example-script">Example script</h3> <p>To generate these images of the probability distributions of the parameters and the maximum likelihood reflectometry profile</p>

# Consecutive fitting

file:///usr/share/doc/bornagain/html/ref/fit/ex/consecutive-fitting.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/consecutive-fitting.html <h2 id="consecutive-fitting">Consecutive fitting</h2> <p>This example demonstrates how to run two fits one after the other using different minimizer settings and starting values of the fit parameters.</p> <ul> <li>In this example we are looking for the <code>radius</code> and <code>height</code> of cylindrical nano particles randomly distributed on a surface.</li> <li>During the first (started at line 101) fit we are setting the initial values of the fit parameters to be quite far from the expected values and use a genetic minimizer to explore a large parameter space.</li> <li>The second fit at line 112 starts from the best parameter values found in the previous step and uses one of the gradient descent algorithms to find the precise location of the minimum.</li> </ul> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/fit/scatter2d/consecutive_fitting.py"/>auto/Examples/fit/scatter2d/consecutive_fitting.py</a>

# Considering uncertainties

file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-with-uncertainties.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/fit-with-uncertainties.html <h2 id="taking-uncertainties-into-account">Taking uncertainties into account</h2> <p>In this example we are demonstrating how to allow for uncertainties during a Reflectometry fitting job. The sample to fit consists of twenty Titanium-Nickel bilayers. Assuming that all Titanium layers have the same thickness, the goal is to find that thickness.</p> <p>The reference data was generated with GENX, setting the thickness of the Ti layers equal to 3 nm.</p> <p>The main points to focus on here are the following:</p>

# External minimizer

file:///usr/share/doc/bornagain/html/ref/fit/ex/external-minimizer.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/external-minimizer.html <h2 id="external-minimizer">External minimizer</h2> <p>In this example we are demonstrating how to run a typical fitting task in BornAgain using a third party minimizer.</p> <p>The BornAgain fit parameters and minimizer interface were developed with the idea to simplify the switch between our own minimization engines and other, possibly more advanced minimization libraries. Particularly, we have been inspired by the <a href="https://lmfit.github.io/lmfit-py/">lmfit Python package</a>.</p> <p>This makes the switch between the BornAgain and <code>lmfit</code> minimizers very easy.</p>

# External minimizer: plotting

file:///usr/share/doc/bornagain/html/ref/fit/ex/external-minimizer-with-plotting.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/external-minimizer-with-plotting.html <h2 id="external-minimizers-plotting-fit-progress">External Minimizers: Plotting Fit Progress</h2> <p>In this example we are demonstrating how to run a typical fitting task in BornAgain using a third party minimizer while plotting the results. As in our <a href="file:///usr/share/doc/bornagain/html/ref/fit/ex/external-minimizer">previous example</a>, we use lmfit for sake of illustration.</p> <p>To plot the fit progress, it is needed to use the lmfit iteration callback function. It will come handy to define the plotting callback function as a specialized class:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="k">class</span> <span class="nc">Plotter</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="s2">&#34;&#34;&#34; </span></span></span><span class="line"><span class="cl"><span class="s2"> Adapts standard plotter for lmfit minimizer. </span></span></span><span class="line"><span class="cl"><span class="s2"> &#34;&#34;&#34;</span> </span></span><span class="line"><span class="cl"> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fit_objective</span><span class="p">,</span> <span class="n">every_nth</span> <span class="o">=</span> <span class="mi">10</span><span class="p">):</span> </span></span><span class="line"><span class="cl"> <span class="bp">self</span><span class="o">.</span><span class="n">fit_objective</span> <span class="o">=</span> <span class="n">fit_objective</span> </span></span><span class="line"><span class="cl"> <span class="bp">self</span><span class="o">.</span><span class="n">plotter_gisas</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">PlotterGISAS</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="bp">self</span><span class="o">.</span><span class="n">every_nth</span> <span class="o">=</span> <span class="n">every_nth</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">,</span> <span class="nb">iter</span><span class="p">,</span> <span class="n">resid</span><span class="p">):</span> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nb">iter</span><span class="o">%</span><span class="bp">self</span><span class="o">.</span><span class="n">every_nth</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> </span></span><span class="line"><span class="cl"> <span class="bp">self</span><span class="o">.</span><span class="n">plotter_gisas</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fit_objective</span><span class="p">)</span> </span></span></code></pre></div><p>An instance of this class is then passed to the lmfit minimization function:</p>

# GISAS

file:///usr/share/doc/bornagain/html/ref/sample/roughness/ex/scatter.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/roughness/ex/scatter.html <h3 id="gisas-by-rough-interfaces">GISAS by rough interfaces</h3> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CorrelatedRoughness_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CorrelatedRoughness_setup.jpg" width="350px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>Scattering from a multilayered sample with correlated roughness.</p> <ul> <li>The sample is composed of a substrate on which is sitting a stack of layers. These layers consist in a repetition of 5 times two different superimposed layers (from bottom to top): <ul> <li>layer A: $2.5$ nm thick with a real refractive index $n = 5 \cdot 10^{-6}$.</li> <li>layer B: $5$ nm thick with a real refractive index $n = 10 \cdot 10^{-6}$.</li> </ul> </li> <li>There is no added particle.</li> <li>All layers present the same type of roughness on the top surface, which is characterized by: <ul> <li>a rms roughness of the interfaces $\sigma = 1$ nm,</li> <li>a Hurst parameter $H$ equal to $0.3$,</li> <li>a lateral correlation length $\xi$ of $5$ nm,</li> <li>a common cross correlation length $\xi_{\perp}$ equal to $10$ nm,</li> <li>a height distribution is normal.</li> </ul> </li> <li>The incident beam is characterized by a wavelength of 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <p>So the model with <a href="file:///usr/share/doc/bornagain/html/ref/sample/roughness/interface">SelfAffineFractalModel</a>, <a href="file:///usr/share/doc/bornagain/html/ref/sample/roughness/transient">ErfTransient</a>, <a href="file:///usr/share/doc/bornagain/html/ref/sample/roughness/xcorr">CommonDepthCrosscorrelation</a> is used here.</p>

# Include specular

file:///usr/share/doc/bornagain/html/ref/sim/setup/options/specular.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/options/specular.html <h2 id="option-include-specular-reflection">Option: include specular reflection</h2> <p>To include the specular reflected beam intensity along with the scattered intensity in a GISAS simulation, use</p> <pre tabindex="0"><code>simulation.options().setIncludeSpecular(True) </code></pre><p>Example: <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular/ex">GISAS with specular peak</a>.</p>

# Minimizer settings

file:///usr/share/doc/bornagain/html/ref/fit/minimizers.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/minimizers.html <h2 id="minimizer-settings">Minimizer settings</h2> <p>The BornAgain minimizer interface was developed with the following ideas in mind:</p> <ul> <li>Provide an interface which looks more or less familiar for users of other Python minimization packages.</li> <li>Enable the use of our minimizer for optimization problems outside the BornAgain context.</li> <li>Allow the usage of other, possibly more advanced minimization libraries, for BornAgain fits.</li> </ul> <p>Particularly, we have been inspired by the <a href="https://lmfit.github.io/lmfit-py/">lmfit Python package</a>, so the BornAgain setup looks very similar. In the code snippet below we give an example of finding the minimum of the <a href="https://en.wikipedia.org/wiki/Rosenbrock_function">Rosenbrock function</a> using the BornAgain minimizer with default settings.</p>

# Multi-layer lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/lattice-layers.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/lattice-layers.html <h3 id="lattice-with-several-layers">Lattice with several layers</h3> <p>A sample with several lattice layers can be modelled as a 2d lattice with a 3d particle basis.</p> <p>In this example, the sample consists of two hexagonal close packed layers of spheres.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/HexagonalLatticesWithBasis_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/HexagonalLatticesWithBasis_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/HexagonalLatticesWithBasis.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/HexagonalLatticesWithBasis.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/HexagonalLatticesWithBasis.py"/>auto/Examples/scatter2d/HexagonalLatticesWithBasis.py</a>

# Run a first simulation

file:///usr/share/doc/bornagain/html/deploy/building/unix/first-simulation.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/building/unix/first-simulation.html <h2 id="run-a-first-simulation">Run a first simulation</h2> <p>This section explains how to run a first simulation.</p> <ul> <li><a href="#post-installation-steps%22">Post installation steps</a></li> <li><a href="#running-the-first-python-simulation%22">Running the first Python simulation</a></li> <li><a href="#running-the-borngain-gui%22">Running the BornAgain GUI</a></li> </ul> <h4 id="post-installation-steps">Post installation steps</h4> <p>If a Python package is produced in the build phase, then after installation, the Python package (&lsquo;wheel&rsquo;) can be found under the folder <code>&lt;install_dir&gt;/python/&lt;python-version&gt;/wheel</code>. The wheel can be installed via <code>pip</code>; for instance</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">python3 -m pip install bornagain-&lt;detailed-wheel-tag&gt;.whl </span></span></code></pre></div><p>or</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">pip3 install bornagain-&lt;detailed-wheel-tag&gt;.whl </span></span></code></pre></div><h4 id="running-the-first-python-simulation">Running the first Python simulation</h4> <p>In your installation directory you will find the following directory structure:</p>

# SAS

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/sas.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/sas.html <h2 id="simulation-types-small-angle-scattering">Simulation types: Small-angle scattering</h2> <p>While BornAgain is designed for GISAS experiments (using the Distorted Wave Born Approximation), it naturally also contains the regular (plane wave) Born Approximation. Accordingly, BornAgain can also simulate standard small-angle scattering (SAS).</p> <p>However, there exist <a href="http://smallangle.org/content/software">several other specialized SAS softwares</a>. Therefore we do not advertise BornAgain for analysing SAS experiments, and in general we do not provide user support for this application domain. We rather recommend <a href="https://www.sasview.org/">SASView</a>, which is institutionally supported by the European Spallation Source, and was designated as standard SAS software in the European SINE2020 project.</p>

# Simultaneous fit of two datasets

file:///usr/share/doc/bornagain/html/ref/fit/ex/multiple-datasets.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/multiple-datasets.html <h2 id="simultaneous-fit-of-two-datasets">Simultaneous fit of two datasets</h2> <p>In this example we demonstrate how to fit two datasets simultaneously.</p> <p>Suppose that we have a sample measured twice for two different incident angles. We are going to fit both datasets simultaneously to find the unknown sample parameters.</p> <p>To do this, we define one dataset (a pair of real data and corresponding simulation builder) for the first incidence angle and another pair for the second incidence angle. We add both pairs to the <code>FitObjective</code> and run the fit as usual.</p>

# Spin asymmetry example

file:///usr/share/doc/bornagain/html/ref/instr/pol/polarized-spinasymmetry.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/pol/polarized-spinasymmetry.html <h3 id="spin-asymmetry-example-from-nist">Spin-asymmetry example from NIST</h3> <p>This example shows how to simulate the magnetic layer described on the NIST homepage in the <a href="https://www.nist.gov/ncnr/magnetically-dead-layers-spinel-films">Magnetically Dead Layers in Spinel Films</a> example. In particular, we want to show how to use BornAgain in order to simulate the spin asymmetry. The sample simulated in this example is very similar to the previous examples introduced in this section. It just consists of a magnetic layer on top of a substrate. During these tutorials, we neglect the magnetically dead layer that forms below the magnetic layer, as there is currently no API in BornAgain to support such a scenario out of the box.</p>

# Spin asymmetry fit example

file:///usr/share/doc/bornagain/html/ref/fit/ex/polarized-spinasymmetry-fit.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/polarized-spinasymmetry-fit.html <h3 id="fitting-the-spin-asymmetry-example-from-nist">Fitting the spin-asymmetry example from NIST</h3> <p>This example shows how to fit the parameters in the <a href="file:///usr/share/doc/bornagain/html/ref/instr/pol/polarized-spinasymmetry">spin-asymmetry example</a>.</p> <p>For this demonstration, we choose initial parameters that are not too far from the fitting results. In particular, the magnetization is initially set to zero, such that the spin asymmetry identically vanishes.</p> <p>With the initial parameters, we obtain the following reflectivity and spin-asymmetry curves:</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/files/fitted/SpinAsymmetryInitial1.png"> <img src="file:///usr/share/doc/bornagain/html/files/fitted/SpinAsymmetryInitial1.png" width="350px"> </a> <figcaption> <p>Reflectivity</p> </figcaption> </figure> <figure > <a href="file:///usr/share/doc/bornagain/html/files/fitted/SpinAsymmetryInitial2.png"> <img src="file:///usr/share/doc/bornagain/html/files/fitted/SpinAsymmetryInitial2.png" width="350px"> </a> <figcaption> <p>Spin Asymmetry</p> </figcaption> </figure> </div> </div> <h4 id="setup-of-the-fit">Setup of the Fit</h4> <p>For fitting of reflectometry data covering several orders of magnitude we use the $\chi^2$ metric</p>

# Polarized SANS

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/polarized_sans.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/polarized_sans.html <h3 id="polarized-sans">Polarized SANS</h3> <p>This example shows how to simulate polarized SANS with BornAgain, using the Born Approximation.</p> <p>The main difference between simulating GISAS and SAS in BornAgain is the presence of only a single layer in the multilayer object. This triggers the software to calculate the differential scattering cross section in the Born Approximation.</p> <p>In this example, a sample with a magnetic core-shell particle is constructed. Beam and detector are setup to detect the spin-flip scattering channel and the result of this simulation is plotted as usual.</p>

# Beam divergence

file:///usr/share/doc/bornagain/html/ref/instr/beam/divergence.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/beam/divergence.html <h2 id="beam-divergence">Beam divergence</h2> <p>By default, the incident beam is perfectly monochromatic and collimated. Here we show how to set finite distributions of wavelengths and of grazing angles.</p> <ul> <li>The wavelength follows a log-normal distribution around the mean value of 0.1 nm with a scale parameter equal to $0.1$.</li> <li>Both incident angles follow a Gaussian distribution around the average values $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$, respectively and $\sigma_{\alpha_i} = \sigma_{\varphi_i} = 0.1^{\circ}$.</li> </ul> <p>First, the <a href="file:///usr/share/doc/bornagain/html/ref/other/distributions">distributions</a> should be defined:</p>

# Configuration

file:///usr/share/doc/bornagain/html/ref/plot/config.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/config.html <h1 id="plot-configuration">Plot configuration</h1> <p>Images in BornAgain examples are generated using the Python library <a href="https://matplotlib.org">MatPlotLib</a>.</p> <p>Default settings can be overridden by function arguments or MatPlotLib ressources.</p> <p>Exceptionally, <a href="heatmap">heat map</a> supports an environment variable.</p> <h3 id="parameterization-with-plotargs">Parameterization with plotargs</h3> <p>In the functions</p> <pre tabindex="0"><code>plot_simulation_result(result, **plotargs) plot_multicurve(results, **plotargs) make_plot(results, ncol, **plotargs) make_plot_row(results, **plotargs) </code></pre><p>the placeholder <code>**plotargs</code> stands for optional keyword arguments. These can be supplied in three ways:</p> <p>(1) Directly like in</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"> <span class="n">bp</span><span class="o">.</span><span class="n">plot_simulation_result</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="s1">&#39;viridis&#39;</span><span class="p">,</span> <span class="n">legendloc</span><span class="o">=</span><span class="s1">&#39;lower right&#39;</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">bp</span><span class="o">.</span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span></span></code></pre></div><p>(2) Through a dictionary variable like in</p>

# Reflectometry: Fit Pt layer

file:///usr/share/doc/bornagain/html/ref/fit/ex/reflectometry-pt-layer.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/reflectometry-pt-layer.html <h3 id="reflectometry-fit-pt-layer">Reflectometry: Fit Pt layer</h3> <p>In this example, we want to demonstrate how to fit experimental reflectivity data that was obtained by a time-of-flight experiment with unpolarized neutrons. Experimental data is available for a sample of a roughly 50 nm thick platinum layer on top of a silicon substrate that is published in <a href="https://doi.org/10.5281/zenodo.4072376">this repository</a>.</p> <p>The mesaurements were made by Timothy Charlton, Haile Ambaye and Michael Fitzsimmons (ORNL) on a sample provided by Eric Fullerton (UCSD).</p>

# Windows

file:///usr/share/doc/bornagain/html/deploy/building/windows.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/building/windows.html <h2 id="build-under-windows">Build under Windows</h2> <p>The following instructions have been tested under Windows 10.</p> <h3 id="prerequisites">Prerequisites</h3> <h4 id="visual-studio">Visual Studio</h4> <p>Download <strong>Visual Studio Community Edition</strong> from from the official website <a href="https://visualstudio.microsoft.com">visualstudio.microsoft.com</a> The current build instructions are tested with Visual Studio 2022.</p> <h4 id="qt">Qt</h4> <p>Download Qt from from the official website <a href="https://www.qt.io/download-open-source">qt.io</a></p> <blockquote> <p>Make sure to choose the open source version of Qt and download the online installer.</p> </blockquote> <p>Select the latest Qt version with long-time support (LTS) and open the sub tree. To build BornAgain, only the &lsquo;MSVC 2019 64-bit&rsquo; component is needed. Qt Installer Framework is required for creating the installer executable.</p>

# Windows

file:///usr/share/doc/bornagain/html/deploy/install/windows.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/install/windows.html <h2 id="install-on-windows">Install on Windows</h2> <h4 id="install-python-environment">Install Python environment</h4> <p>As a prerequisite, Python must be installed, see <a href="file:///usr/share/doc/bornagain/html/deploy/py/win">Python on Windows</a>.</p> <h4 id="install-bornagain-as-a-python-package">Install BornAgain as a Python package</h4> <p>To install BornAgain as a pure Python package (for scripting only, no GUI), download and install the latest BornAgain Python wheel from the <a href="https://pypi.org">PyPI</a> repository:</p> <pre tabindex="0"><code>$ python -m pip install bornagain </code></pre><h4 id="install-full-bornagain-gui-and-python-scripting">Install full BornAgain (GUI and Python scripting)</h4> <p>To install full BornAgain (GUI app and Python module), download an installer from <a href="https://bornagainproject.org/ext/files/23.0">https://bornagainproject.org/ext/files/23.0</a>. The installer should be chosen accordingly to the Python minor version installed on the destination machine, for example <code>BornAgain-23.0-python3.12-win64.exe</code>.</p>

# Dense cylinders

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/dense-cylinders.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/dense-cylinders.html <h2 id="dense-cylinders">Dense cylinders</h2> <p>Supposing a <code>Simulation</code> has been defined in which some layers contain embedded particles of different materials; to regard those layers as composed by a single material, the <code>setUseAvgMaterials</code> method is used:</p> <pre tabindex="0"><code>simulation.options().setUseAvgMaterials(True) </code></pre><figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/CylindersInAverageLayer.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/CylindersInAverageLayer.png" width="500px"> </a> <figcaption> <p>The figure shows the intensity map produced by the script below.</p> </figcaption> </figure> <p>The script below shows how to average materials when simulating scattering from a square lattice of cylinders inside a finite layer.</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/CylindersInAverageLayer.py"/>auto/Examples/scatter2d/CylindersInAverageLayer.py</a>

# Dense hemispheres

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/dense-hemispheres.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/dense-hemispheres.html <h2 id="dense-hemispheres">Dense hemispheres</h2> <p>Supposing a <code>Simulation</code> has been defined in which some layers contain embedded particles of different materials; to regard those layers as composed by a single material, the <code>setUseAvgMaterials</code> method is used:</p> <pre tabindex="0"><code>simulation.options().setUseAvgMaterials(True) </code></pre><figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/HalfSpheresInAverageTopLayer.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/HalfSpheresInAverageTopLayer.png" width="500px"> </a> <figcaption> <p>The figure shows the intensity map produced by the script below.</p> </figcaption> </figure> <p>The script below shows how to average materials when simulating scattering from a square lattice of hemispheres on a substrate.</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/HalfSpheresInAverageTopLayer.py"/>auto/Examples/scatter2d/HalfSpheresInAverageTopLayer.py</a>

# Beam Angular Spread

file:///usr/share/doc/bornagain/html/ref/instr/scan/angular-divergence.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/scan/angular-divergence.html <h3 id="beam-angular-spread-in-specular-simulations">Beam Angular Spread in Specular Simulations</h3> <p>This example demonstrates beam angular spread effects in reflectivity computations. It also offers a comparison with data generated using another well known code: GenX. Further information about reflectometry simulations can be found in the <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">Reflectometry Simulation Tutorial</a>.</p> <p>The observed reflectometry signal can be affected either by a spread in the beam wavelength or in the incident angle.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/specular/VsGenx.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/specular/VsGenx.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <p>In this example, a Gaussian distribution is used to spread the incident angle, with a standard deviation of $\sigma_{\alpha} = 0.01^{\circ}$.</p>

# Cosine ripples in a lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/cosine-ripples-at-rect-lattice.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/cosine-ripples-at-rect-lattice.html <h3 id="cosine-ripples-in-a-rectangular-lattice">Cosine Ripples in a Rectangular Lattice</h3> <p>Scattering from elongated particles positioned in a two-dimensional rectangular lattice.</p> <ul> <li>Each particle has a sinusoidal profile (&ldquo;Ripple1&rdquo; form factor) with a length of $100$ nm, a width of $20$ nm and a height of $4$ nm.</li> <li>They are placed along a rectangular lattice on top of a substrate.</li> <li>This lattice is characterized by a lattice length of $200$ nm in the direction of the long axis of the particles and of $50$ nm in the perpendicular direction.</li> <li>The lattice&rsquo;s base vectors coincide with the reference Cartesian frame.</li> <li>The wavelength is equal to 0.16 nm.</li> <li>The incident angles are $\alpha_i = 0.3 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CosineRipplesAtRectLattice_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CosineRipplesAtRectLattice_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Custom formfactor

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/custom.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/custom.html <h3 id="custom-formfactor">Custom formfactor</h3> <p>Scattering from a monodisperse distribution of particles, whose form factor is defined by the user.</p> <ul> <li>This example shows how users can simulate their own particle shape by implementing the analytical expression of its form factor.</li> <li>The particular shape used here is a polyhedron, whose planar cross section is a &ldquo;plus&rdquo; shape with a side length of $20$ nm and a height of $15$ nm.</li> <li>These particles are distributed on a substrate.</li> <li>There is no interference between the scattered waves.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CustomFormfactor_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CustomFormfactor_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Debug

file:///usr/share/doc/bornagain/html/dev/dev/debug.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/dev/debug.html <h2 id="using-gdb">Using gdb</h2> <p>If BornAgain GUI or a script crashes, re-run under gdb.</p> <h4 id="scripts-under-pyenv">Scripts under pyenv</h4> <p>If Python is under pyenv control the command</p> <pre tabindex="0"><code>gdb python </code></pre><p>will not work. Instead, use</p> <pre tabindex="0"><code>gdb -ex r --args bash python &lt;script&gt; </code></pre><p>(source: <a href="https://stackoverflow.com/a/53007303/1017348">https://stackoverflow.com/a/53007303/1017348</a>)</p>

# Distributions

file:///usr/share/doc/bornagain/html/ref/other/distributions.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/other/distributions.html <h2 id="parameter-distributions">Parameter distributions</h2> <h5 id="constructors">Constructors</h5> <p>A distribution is constructed by one of the following:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">distr</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">DistributionGate</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">stop</span><span class="p">,</span> <span class="n">n_samples</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">distr</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">DistributionCosine</span><span class="p">(</span><span class="n">mean</span><span class="p">,</span> <span class="n">hwhm</span><span class="p">,</span> <span class="n">n_samples</span> <span class="o">=</span> <span class="mi">25</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">distr</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">DistributionGaussian</span><span class="p">(</span><span class="n">mean</span><span class="p">,</span> <span class="n">std_dev</span><span class="p">,</span> <span class="n">n_samples</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="n">rel_samplig_width</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">distr</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">DistributionLorentz</span><span class="p">(</span><span class="n">mean</span><span class="p">,</span> <span class="n">hwhm</span><span class="p">,</span> <span class="n">n_samples</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="n">rel_samplig_width</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">distr</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">DistributionLogNormal</span><span class="p">(</span><span class="n">median</span><span class="p">,</span> <span class="n">scale_param</span><span class="p">,</span> <span class="n">n_samples</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="n">rel_samplig_width</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> </span></span></code></pre></div><h5 id="usage">Usage</h5> <p>Parameter distributions are either supplied to beam divergence or detector resolution classes as described there, or they are used programmatically.</p> <p>In programmatical usage, the function call</p> <pre tabindex="0"><code>parsamples = distr.distributionSamples() </code></pre><p>returns a vector of parameter samples. Each <code>ParameterSample</code> has a <code>value</code> and a <code>weight</code>. The sample (scattering target) model is then constructed as incoherent sum of components with given parameter values and weights. For instance, in the <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/polydispersity">PolydisperseCylinders example</a>, a layout is filled with uncorrelated particles:</p>

# Position variance

file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/position-variance.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/lattice2d/position-variance.html <h2 id="2d-lattice-with-position-variance">2D lattice with position variance</h2> <p>A position variance parameter describes fluctuations of particle position around lattice points. It gives rise to an attenuation factor of Debye-Waller type.</p> <p>It can be set using the method <code>setPositionVariance(variance)</code> of class Interference2DLattice. The argument <code>variance</code> is in nm$^2$.</p> <p>By default the variance is zero.</p> <h3 id="example-square-lattice-without-and-with-variance">Example: square lattice without and with variance</h3> <p>A square lattice of hemispheres on a substrate, for different lattice orientation angles xi.</p>

# Reflectometry: Fit honeycomb

file:///usr/share/doc/bornagain/html/ref/fit/ex/reflectometry-honeycomb.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/ex/reflectometry-honeycomb.html <h3 id="reflectometry-fit-honeycomb-lattice">Reflectometry: Fit honeycomb lattice</h3> <p>In this example, we want to demonstrate how to fit a more complex sample. For this purpose, we utilize the reflectometry data of an artificial magnetic honeycomb lattice published by A. Glavic et al., in <a href="https://doi.org/10.1002/advs.201700856">this paper</a></p> <p>The experiment was performed with polarized neutrons, but without polarization analysis. Since the magnetization of the sample was parallel to the neutron spin, there is no spin flip and we apply the scalar theory to this problem. This is primarily done to speed up computations: when the polarized computational engine is utilized the fitting procedure takes roughly three times as long.</p>

# Triangular ripples in a lattice

file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/triangular-ripples.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/triangular-ripples.html <h3 id="triangular-ripples-in-a-rectangular-lattice">Triangular Ripples in a Rectangular Lattice</h3> <p>Scattering from elongated particles positioned in a two-dimensional rectangular lattice.</p> <ul> <li>Each particle has a triangular profile (&ldquo;Ripple2&rdquo; form factor) with a length of $100$ nm, a width of $20$ nm and a height of $4$ nm.</li> <li>They are placed along a rectangular lattice on top of a substrate.</li> <li>This lattice is characterized by a lattice length of $200$ nm in the direction of the long axis of the particles and of $50$ nm in the perpendicular direction.</li> <li>The lattice&rsquo;s base vectors coincide with the reference Cartesian frame.</li> <li>The wavelength is equal to 0.16 nm.</li> <li>The incident angles are $\alpha_i = 0.3 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <p>View the example on <a href="file:///usr/share/doc/bornagain/html/ref/sample/interference/grating/cosine-ripples-at-rect-lattice">Cosine Ripples on a Rectangular Lattice</a> for comparison.</p>

# Heat map

file:///usr/share/doc/bornagain/html/ref/plot/heatmap.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/heatmap.html <h1 id="heat-map">Heat map</h1> <p>MatPlotLib supports various color schemes for plotting color-coded pixel values in 2d, see the <a href="https://matplotlib.org/stable/tutorials/colors/colormaps.html">MatPlotLib color schemes tutorial</a>.</p> <p>It is generally recommended to use one of the five &ldquo;perceptually uniform sequential&rdquo; color schemes: <img src="file:///usr/share/doc/bornagain/html/img/matplotlib_pus_colormaps.png" alt="MatPlotLib perceptually uniform sequential color schemes" title="Perceptually uniform sequential color schemes from MatPlotLib."></p> <p>When plotting through <code>ba_plot</code>, the color scheme is determined in this order:</p> <ul> <li>from the optional <code>plotargs</code> arguments if there is one with keyword <code>cmap</code>, like <code>cmap='jet'</code>;</li> <li>otherwise from the environment variable <code>CMAP</code>, if defined;</li> <li>otherwise from the hard-coded default &ldquo;inferno&rdquo;.</li> </ul> <p>Note that the variable <code>image.cmap</code> from <a href="https://matplotlib.org/stable/users/explain/customizing.html">matplotlib.pyplot.rcParams</a> is ignored. This is a concious choice, intended to facilitate configuration for BornAgain users who are no MatPlotLib experts.</p>

# Beam Wavelength Spread

file:///usr/share/doc/bornagain/html/ref/instr/scan/full-divergence.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/scan/full-divergence.html <h3 id="beam-wavelength-spread-in-specular-simulations">Beam Wavelength Spread in Specular Simulations</h3> <p>This example demonstrates beam wavelength spread effects in reflectivity computations. All simulation parameters (except for those related to beam spread itself) coincide with those defined in <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">reflectometry simulation tutorial</a>.</p> <p>In real specular experiments the observed reflectivity is always affected by the beam spread in both wavelength and incident angle.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/specular/BeamFullDivergence.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/specular/BeamFullDivergence.png" width="500px"> </a> <figcaption> <p>Scattering intensity</p> </figcaption> </figure> </div> </div> <p>In this example the following parameters related to the spread of the beam were set to the simulation:</p>

# LaTeX markup

file:///usr/share/doc/bornagain/html/ref/plot/latex.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/latex.html <h1 id="latex-markup">LaTeX markup</h1> <p>Text enclosed between dollar signs <code>$...$</code> is interpreted as LaTeX markup. It allows us to plot greek letters (<code>$\alpha$</code>), superscripts (<code>$F^2$</code>), subscripts (<code>$\phi_{\rm i}</code>$), and special symbols (<code>$90^\circ$</code>).</p> <p>By default, it is processed by MatPlotLib&rsquo;s own LaTeX processor. However, if <em>usetex mode</em> is activated, then the original LaTeX text processor is used, and labels are typeset in LaTeX&rsquo;s computer modern fonts. For <em>usetex mode</em> to work, it may be necessary to install extra software. Under Debian, the required packages are <code>texlive-latex-extra</code> (and dependencies), <code>dvipng</code> and <code>cm-super-minimal</code>. We have no clue how to support <em>usetex mode</em> under Windows.</p>

# Export

file:///usr/share/doc/bornagain/html/ref/plot/export.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/export.html <h1 id="export-plot-to-file">Export plot to file</h1> <h3 id="interactively">Interactively</h3> <p>To create image files interactively, run a script that contains the usual</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bp</span><span class="o">.</span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span></span></code></pre></div><p>then click the &ldquo;diskette&rdquo; icon in the MatPlotLib window.</p> <h3 id="programmatically">Programmatically</h3> <p>To create image files programmatically, replace the Python statement</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bp</span><span class="o">.</span><span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span></span></code></pre></div><p>by one of</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bp</span><span class="o">.</span><span class="n">export</span><span class="p">(</span><span class="o">**</span><span class="n">plotargs</span><span class="p">)</span> </span></span></code></pre></div><p>and use one of the three parameterization mechanisms described in the <a href="config">Configuration</a> page to pass a keyword argument <code>figfile=&lt;filename&gt;</code>. The image format is deduced from the extension of the filename.</p>

# Find intensity peaks

file:///usr/share/doc/bornagain/html/ref/data/datafield/find-peaks.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/data/datafield/find-peaks.html <h2 id="finding-intensity-peaks">Finding intensity peaks</h2> <p>To find the intensity peaks from a GISAXS simulation, use the method <code>FindPeaks</code>. It returns an array of (x,y) coordinates:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"> <span class="n">result</span> <span class="o">=</span> <span class="n">run_simulation</span><span class="p">()</span><span class="o">.</span><span class="n">histogram2d</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="n">peaks</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">FindPeaks</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="s2">&#34;nomarkov&#34;</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="n">peaks_x</span> <span class="o">=</span> <span class="p">[</span><span class="n">peak</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">peak</span> <span class="ow">in</span> <span class="n">peaks</span><span class="p">]</span> </span></span><span class="line"><span class="cl"> <span class="n">ypeak_y</span> <span class="o">=</span> <span class="p">[</span><span class="n">peak</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">peak</span> <span class="ow">in</span> <span class="n">peaks</span><span class="p">]</span> </span></span></code></pre></div> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/FindPeaks.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/FindPeaks.png" width="670px"> </a> <figcaption> <p>Intensity images</p> </figcaption> </figure> </div> </div> <p>The following script offers a complete example in which the peaks are found after carrying on a GISAXS simulation. This particular example uses as a sample a grating of long boxes distributed along a 1D lattice.</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/FindPeaks.py"/>auto/Examples/scatter2d/FindPeaks.py</a>

# MacOS

file:///usr/share/doc/bornagain/html/deploy/install/macos.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/install/macos.html <h2 id="install-on-macos">Install on MacOS</h2> <h4 id="prequisite-python">Prequisite: Python</h4> <p>As a prerequisite, Python must be installed, see <a href="file:///usr/share/doc/bornagain/html/deploy/py/mac">Python on Mac</a>.</p> <h4 id="install-bornagain-gui-application">Install BornAgain GUI application</h4> <p>To install BornAgain on MacOS, one should use the official MLZ Homebrew Tap hosted at <a href="https://jugit.fz-juelich.de/mlz/homebrew/">https://jugit.fz-juelich.de/mlz/homebrew/</a>.</p> <p>First, add the tap to the local Homebrew taps via</p> <pre tabindex="0"><code>$ brew tap mlz/homebrew https://jugit.fz-juelich.de/mlz/homebrew/ </code></pre><p>After that, Homebrew will be able to work with formulae in <code>mlz/homebrew</code> as if they were in <code>homebrew-core</code> canonical repository.</p> <p>To install BornAgain v22.2 from the tap, use</p>

# Webdoc

file:///usr/share/doc/bornagain/html/dev/dev/webdoc.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/dev/webdoc.html <h2 id="how-to-contribute-to-this-documentation">How to contribute to this documentation</h2> <p>Here we explain how to edit this documentation locally and submit changes for online publication.</p> <h3 id="general-information">General information</h3> <p>This web site is generated using the static site generator <a href="https://gohugo.io/">Hugo</a>. Sources are mostly writen in the MarkDown format. Hugo translates them into HTML.</p> <p>To submit improvements of the documentation proceed as follows:</p> <h3 id="install-hugo">Install Hugo</h3> <p>Install Hugo either using a package manager, or directly from upstream: Download the archive file for your platform from <a href="https://github.com/gohugoio/hugo/releases">https://github.com/gohugoio/hugo/releases</a> . This archive contains a single binary. Put it into a directory that is in your PATH.</p>

# Uncorrelated mixture

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/mixture.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/mixture.html <h3 id="uncorrelated-mixture-of-particles">Uncorrelated mixture of particles</h3> <p>Scattering from a mixture of cylinders and prisms without interference.</p> <ul> <li>The sample comprises a substrate on which are deposited, in equal proportion, cylinders and prisms.</li> <li>All particles are made of the same material.</li> <li>Each type of particle has the same orientation.</li> <li>The cylinders are $5$ nm high and $5$ nm in radius.</li> <li>Each prism is $5$ nm high with an equilateral triangular base, whose side length is equal to $10$ nm.</li> <li>There is no interference between the waves scattered by these particles. The distribution is therefore diluted.</li> <li>The incident neutron beam is characterized by a wavelength of 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> <li>The simulation is performed using the Distorted Wave Born Approximation (due to the presence of a substrate).</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/draw/CylindersAndPrisms_setup.jpg"> <img src="file:///usr/share/doc/bornagain/html/img/draw/CylindersAndPrisms_setup.jpg" width="350px"> </a> <figcaption> <p>Real-space model</p>

# Background

file:///usr/share/doc/bornagain/html/ref/sim/setup/bg.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/bg.html <h3 id="poisson-background">Poisson background</h3> <p>To add a Poisson background to a <code>Simulation</code> instance, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bg</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">PoissonBackground</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setBackground</span><span class="p">(</span><span class="n">bg</span><span class="p">)</span> </span></span></code></pre></div><p>In this case, the output intensity is randomly distributed around the exact value with discrete Poisson statistics.</p> <p>The lower the intensity of the probing beam, the lower the signal-to-noise ratio.</p> <h3 id="constant-background">Constant background</h3> <p>To add a constant background to a <code>Simulation</code> instance, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">bg</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">ConstantBackground</span><span class="p">(</span><span class="mf">1e3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setBackground</span><span class="p">(</span><span class="n">bg</span><span class="p">)</span> </span></span></code></pre></div><p>Background is applied before the <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">specular simulation</a> is normalized, so the threshold value will also be divided by the probe beam intensity.</p>

# Code analyses

file:///usr/share/doc/bornagain/html/dev/dev/analyses.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/dev/analyses.html <h2 id="some-code-analyses">Some code analyses</h2> <h4 id="gui">GUI</h4> <p>Data and job view class hierarchy:</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/src_doc/data&#43;job-view.svg"> <img src="file:///usr/share/doc/bornagain/html/img/auto/src_doc/data&#43;job-view.svg" width="800px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>Qt graphics classes:</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/src_doc/qclasses.svg"> <img src="file:///usr/share/doc/bornagain/html/img/auto/src_doc/qclasses.svg" width="800px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>Mask collaboration:</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/src_doc/mask-classes.svg"> <img src="file:///usr/share/doc/bornagain/html/img/auto/src_doc/mask-classes.svg" width="800px"> </a> <figcaption> <p></p> </figcaption> </figure> <h4 id="python">Python</h4> <p>Calls inside ba_plot:</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/src_doc/ba_plot.svg"> <img src="file:///usr/share/doc/bornagain/html/img/auto/src_doc/ba_plot.svg" width="800px"> </a> <figcaption> <p></p> </figcaption> </figure>

# Compound particle

file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/compound.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/compound.html <h2 id="compound-particle">Compound particle</h2> <p>This tutorial demonstrates how to construct complex shape particles.</p> <p>All particles implemented in BornAgain are defined by their form factors, their sizes and the materials they are made of. The form factor library provides access to a list of about 20 elementary shapes. A special <code>Compound</code> object allows to compose elementary particles and their compositions into complex shapes and treat the resulting object as a single particle: it can be rotated, translated and included in the layer via a particle layout. The scattering from such a particle will account for coherent interference between sub particles.</p>

# Magnetization

file:///usr/share/doc/bornagain/html/ref/sample/material/magnetization.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/material/magnetization.html <h2 id="magnetization">Magnetization</h2> <p>Magnetic fields are described by real-valued 3d vectors. They are always understood in units of A/m.</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">magnetic_field</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">R3</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span> </span></span></code></pre></div><p>Magnetic materials are constructed as</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">material</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">RefractiveMaterial</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">delta</span><span class="p">,</span> <span class="n">beta</span><span class="p">,</span> <span class="n">magnetic_field</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># or</span> </span></span><span class="line"><span class="cl"><span class="n">material</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">MaterialBySLD</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">sld_real</span><span class="p">,</span> <span class="n">sld_imag</span><span class="p">,</span> <span class="n">magnetic_field</span><span class="p">)</span> </span></span></code></pre></div><p>Examples are under <a href="file:///usr/share/doc/bornagain/html/ref/instr/ex/pol">Examples &gt; Instrument &gt; Neutron polarization</a>.</p>

# Mesocrystal

file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/meso.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/composition/meso.html <h2 id="mesocrystal-particle">Mesocrystal particle</h2> <p>Mesocrystal is a crystal-like grain, defined by internal crystall lattice and the outer shape.</p> <p>The <code>Mesocrystal</code> object is created via</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># create mesocrystal</span> </span></span><span class="line"><span class="cl"><span class="n">meso</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Mesocrystal</span><span class="p">(</span><span class="n">crystal</span><span class="p">,</span> <span class="n">outer_shape</span><span class="p">)</span> </span></span></code></pre></div><p>and requires the objects <code>crystal</code> and <code>outer_shape</code> to be defined.</p> <p><code>outer_shape</code> is formfactor, describing shape and size of the mesocrystal, for example</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">outer_shape</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Cylinder</span><span class="p">(</span><span class="mi">20</span><span class="o">*</span><span class="n">nm</span><span class="p">,</span> <span class="mi">50</span><span class="o">*</span><span class="n">nm</span><span class="p">)</span> </span></span></code></pre></div><p><code>crystal</code> is built from the node and lattice:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># Basis node</span> </span></span><span class="line"><span class="cl"><span class="n">node</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Particle</span><span class="p">(</span><span class="n">material_node</span><span class="p">,</span> <span class="n">formfactor</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># 3D lattice</span> </span></span><span class="line"><span class="cl"><span class="n">lattice</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Lattice3D</span><span class="p">(</span><span class="n">lattice_vec_1</span><span class="p">,</span> <span class="n">lattice_vec_2</span><span class="p">,</span> <span class="n">lattice_vec_3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Crystal</span> </span></span><span class="line"><span class="cl"><span class="n">crystal</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">Crystal</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">lattice</span><span class="p">)</span> </span></span></code></pre></div><p>Alternatively, <code>node</code> can be not just simple particle, but also another compositon:</p>

# Monte-Carlo

file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/mc.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/mc.html <h2 id="scattering-by-large-particles-with-monte-carlo-integration">Scattering by large particles with Monte-Carlo integration</h2> <p>Reference: <a href="file:///usr/share/doc/bornagain/html/ref/sim/setup/options/mc">Monte-Carlo</a></p> <p>This example demonstrates that for large particles (~$1000$ nm) the contribution to the scattered intensity from the form factor oscillates rapidly within one detector bin and analytical calculations (performed for the bin center) give completely a wrong intensity pattern. In this case Monte-Carlo integrations over detector bin should be used.</p> <p>The simulation generates four plots using different sizes of the particles, (radius $=10$ nm, height $=20$ nm) or (radius $=1$ $\mu$m, height $=2$ $\mu$m), and different calculation methods: analytical calculations or Monte-Carlo integration. The other parameters are identical:</p>

# Multiple datasets

file:///usr/share/doc/bornagain/html/ref/fit/multiple-datasets.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/fit/multiple-datasets.html <h2 id="fitting-several-datasets-at-once">Fitting several datasets at once</h2> <p>Several datasets can be fitted simultaneously, either using the BornAgain fit facilities, or using external minimizers.</p> <h3 id="with-the-bornagain-fit-facilities">With the BornAgain fit facilities</h3> <p>Add different data and different fit models to an instance of class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sim/Fitting/FitObjective.h">FitObjective</a>:</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"> <span class="n">fit_objective</span> <span class="o">=</span> <span class="n">ba</span><span class="o">.</span><span class="n">FitObjective</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="n">fit_objective</span><span class="o">.</span><span class="n">addSimulationAndData</span><span class="p">(</span><span class="n">simulation1</span><span class="p">,</span> <span class="n">data1</span><span class="p">[,</span> <span class="n">stdv1</span><span class="p">][,</span> <span class="n">wgt1</span><span class="p">])</span> </span></span><span class="line"><span class="cl"> <span class="n">fit_objective</span><span class="o">.</span><span class="n">addSimulationAndData</span><span class="p">(</span><span class="n">simulation2</span><span class="p">,</span> <span class="n">data2</span><span class="p">[,</span> <span class="n">stdv2</span><span class="p">][,</span> <span class="n">wgt2</span><span class="p">])</span> </span></span></code></pre></div><p>The optional <code>stdv</code> arguments hold error estimates. The optional weights <code>wgt</code> are by default set to 1.</p> <p>For a full example, see <a href="file:///usr/share/doc/bornagain/html/ref/fit/ex/multiple-datasets">Examples &gt; Fitting &gt; Simultaneous fit</a>.</p> <h3 id="with-external-minimizer">With external minimizer</h3> <p>See the <a href="file:///usr/share/doc/bornagain/html/ref/fit/ex/reflectometry-honeycomb">honeycomb fit example</a>, where differential evolution is called with an objective function that has contributions from several reflectometry datasets and models:</p>

# Offspec detector

file:///usr/share/doc/bornagain/html/ref/instr/det/offspec.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/det/offspec.html <h2 id="off-specular-detector">Off-specular detector</h2> <p>The constructor is</p> <pre tabindex="0"><code>ba.OffspecDetector(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max) </code></pre><p>Scattering intensity is computed for <code>n_phi</code> azimuthal bins, then naively summed.</p> <p>Results may vary widely for even vs odd <code>n_phi</code>. Check! Choose the phi range so narrow, and <code>n_phi</code> so large that results become stable.</p>

# Polydispersity

file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/polydispersity.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ex/polydispersity.html <h2 id="polydisperse-particles-example">Polydisperse particles example</h2> <p>This example shows GISAS by polydisperse cylinders on a substrate. The radii of the cylinders follow a Gaussian distribution.</p> <p>The uncorrelated particles are added to a layout using a loop over the parameter distribution samples. This is currently supported only under Python scripting, not in the GUI.</p> <p>Class references: <a href="../../multilayer/layout">Layout</a>, <a href="file:///usr/share/doc/bornagain/html/ref/other/distributions">Distributions</a>.</p> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/PolydisperseCylinders.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/PolydisperseCylinders.png" width="450px"> </a> <figcaption> <p></p> </figcaption> </figure> </div> </div> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/PolydisperseCylinders.py"/>auto/Examples/scatter2d/PolydisperseCylinders.py</a>

# Pyenv

file:///usr/share/doc/bornagain/html/dev/config/pyenv.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/config/pyenv.html <h2 id="pyenv">pyenv</h2> <p><a href="https://github.com/pyenv/pyenv">Pyenv</a> is a platform to install and manage different versions of Python, isolated from the default Python version. Its advantage compared to the other options, like Anaconda, is its simplicity and smallness. Currently, to build BornAgain libraries for different versions of Python, we use the <code>pyenv</code> platform.</p> <h4 id="installation">Installation</h4> <h5 id="linux">Linux</h5> <p>Obtain the installer from <a href="https://github.com/pyenv/pyenv-installer">https://github.com/pyenv/pyenv-installer</a>. To install <code>pyenv</code>, use</p> <pre tabindex="0"><code>curl https://pyenv.run | bash </code></pre><p>By default, <code>pyenv</code> is installed in <code>$HOME/.pyenv</code>.</p> <p>The dependencies must be installed before building Python; see <a href="https://github.com/pyenv/pyenv/wiki#suggested-build-environment">https://github.com/pyenv/pyenv/wiki#suggested-build-environment</a>:</p>

# Python modules

file:///usr/share/doc/bornagain/html/deploy/py/modules.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/py/modules.html <h2 id="python-modules-required-by-bornagain">Python modules required by BornAgain</h2> <p>The BornAgain GUI (unless specially built without Python support) requires the Python module</p> <ul> <li>numpy</li> </ul> <p>All BornAgain Python scripting examples require</p> <ul> <li>matplotlib</li> </ul> <p>Furthermore, a small number of fit script examples require the Python modules</p> <ul> <li>corner</li> <li>emcee</li> <li>fabio</li> <li>lmfit</li> <li>scipy</li> <li>tqdm</li> </ul> <p>These are not required for <em>installing</em> and <em>running</em> most of BornAgain. However, they should be present when <em>building</em> BornAgain lest some tests will fail.</p>

# Resonator

file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/resonator.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/class/depthprobe/ex/resonator.html <h2 id="intensity-distribution-in-neutron-resonator">Intensity distribution in neutron resonator</h2> <p>We consider a neutron resonator, composed of one Ti/Pt bilayer.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/draw/ResonatorSample.png"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ResonatorSample.png" width="500"> </a> <figcaption> <p></p> </figcaption> </figure> <p>The beam comes from the Si side. By convention the beam always comes &lsquo;&lsquo;from above&rsquo;&rsquo;. Accordingly, we consider Si the &lsquo;&lsquo;ambient&rsquo;&rsquo; material, placed &lsquo;&lsquo;on top&rsquo;&rsquo; of the sample.</p> <p>As a result, we obtain the neutron intensity as function of depth and incident angle $\alpha_i$.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/varia/Resonator.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/varia/Resonator.png" width="500"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/varia/Resonator.py"/>auto/Examples/varia/Resonator.py</a>

# Progress monitor

file:///usr/share/doc/bornagain/html/ref/sim/setup/progress.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sim/setup/progress.html <h3 id="terminal-progress-monitor">Terminal progress monitor</h3> <p>To monitor progress of a time-consuming simulation, use</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">setTerminalProgressMonitor</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">simulation</span><span class="o">.</span><span class="n">simulate</span><span class="p">()</span> </span></span></code></pre></div><p>While the simulation is running, progress will be printed in the form</p> <pre tabindex="0"><code>... 17% </code></pre><p>To prevent problems if the script is run in batch mode, use the conditional</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="k">if</span> <span class="ow">not</span> <span class="s2">&#34;__no_terminal__&#34;</span> <span class="ow">in</span> <span class="nb">globals</span><span class="p">():</span> </span></span><span class="line"><span class="cl"> <span class="n">simulation</span><span class="o">.</span><span class="n">setTerminalProgressMonitor</span><span class="p">()</span> </span></span></code></pre></div><p>This is used for example in</p> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/FindPeaks.py"/>auto/Examples/scatter2d/FindPeaks.py</a>

# Development snapshot

file:///usr/share/doc/bornagain/html/deploy/install/snapshot.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/deploy/install/snapshot.html <h2 id="install-development-snapshot">Install development snapshot</h2> <p>Usually, we recommend installing the latest public release. However, users who need specific novel features or/and are willing to help us as testers are welcome to download the latest development snapshot.</p> <p>Here, we explain the download path for Windows. For other platforms, pertinent paths will be easily found by analogy.</p> <p>Go to the jobs listing at <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/jobs">https://jugit.fz-juelich.de/mlz/bornagain/-/jobs</a>.</p> <p>Look for an entry like <figure class="float-left"> <a href="file:///usr/share/doc/bornagain/html/img/job_win_main.png"> <img src="file:///usr/share/doc/bornagain/html/img/job_win_main.png" > </a> <figcaption> <p></p> </figcaption> </figure> that has the green tag <img src="file:///usr/share/doc/bornagain/html/img/job_tag_passed.png"/>, the gray tag <img src="file:///usr/share/doc/bornagain/html/img/job_tag_main.png"/>, and the blue tag <img src="file:///usr/share/doc/bornagain/html/img/job_tag_win.png"/>.</p>

# Manual GUI test

file:///usr/share/doc/bornagain/html/dev/release/test.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/dev/release/test.html <h2 id="manual-gui-test">Manual GUI test</h2> <p>Repeat tests on all platforms.</p> <p>Only importing samples from Python examples is worth repeating for different Python versions.</p> <p>All steps are given in order of execution.</p> <h3 id="backward-compatibility">Backward compatibility</h3> <ul> <li>open projects from <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/GUIprojects">Tests/GUIprojects</a></li> <li>for each project check that all parameters are loaded and represented properly</li> <li>check that jobs are loaded</li> <li>rerun all jobs and ensure that the new simulation results look as expected</li> <li>repeat simulations for each instrument choosing it from the list in &ldquo;Simulation&rdquo; view</li> <li>close GUI</li> </ul> <h3 id="importing-samples-from-python">Importing samples from Python</h3> <ul> <li>install Python package</li> <li>open GUI application</li> <li>open new project</li> <li>go to &ldquo;Sample&rdquo; view and load one example from <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/specular">specular</a> and one from <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d">scatter2d</a></li> </ul> <h3 id="pure-simulation">Pure simulation</h3> <ul> <li>switch to &ldquo;Instrument&rdquo; view</li> <li>create instances of &ldquo;GISAS&rdquo;, &ldquo;Offspecular&rdquo;, &ldquo;Specular&rdquo; and &ldquo;Depthprobe&rdquo; instruments with default parameters</li> <li>switch to &ldquo;Simulation&rdquo; view</li> <li>create simulations: <ul> <li>with &ldquo;scatter2d&rdquo; example for &ldquo;GISAS&rdquo; and &ldquo;Offspecular&rdquo;</li> <li>with &ldquo;specular&rdquo; example for &ldquo;Specular&rdquo; and &ldquo;Depthprobe&rdquo;</li> </ul> </li> <li>switch to &ldquo;Instrument&rdquo; view</li> <li>add distributions: <ul> <li>lambda, alpha and phi to GISAS instrument</li> <li>lambda, alpha to Specular instrument</li> </ul> </li> <li>switch to &ldquo;Simulation&rdquo; view</li> <li>turn on simulation options &ldquo;Average layer material for Fresnel calculations&rdquo; and &ldquo;Include specular peak&rdquo;</li> <li>repeat simulations with distributions</li> <li>export simulations as script and run them in Python as is</li> </ul> <h3 id="data-loading">Data loading</h3> <ul> <li>switch to &ldquo;Data&rdquo; view</li> <li>load 1D data from <a href="https://jugit.fz-juelich.de/mlz/intern/ba-intern/-/blob/main/expdata/Reflectivity_from_Ni_film/Ni_LabCourse_R(Q).txt">ba-intern</a>, units: 1/A <ul> <li>data should be loadable with default loader settings</li> <li>look at the plot axes, labels, units, values should be correct</li> <li>link 1D data to the &ldquo;Specular&rdquo; instrument, click &ldquo;Yes, please modify instrument&rdquo; if asked</li> <li>switch to &ldquo;Specular&rdquo; instrument in &ldquo;Instrument&rdquo; view</li> <li>check that scan points are picked from the loaded data and non-editable</li> <li>open &ldquo;Properties&rdquo; panel and check that axis units are switchable after linking</li> </ul> </li> <li>load 2D (REFSANS filter) data from <a href="https://jugit.fz-juelich.de/mlz/intern/ba-intern/-/blob/main/expdata/REFSANS_example/p15101_00008744_8_16.csv">ba-intern</a> <ul> <li>switch to &ldquo;Mask Editor&rdquo; presentation and add a mask</li> <li>link 2D data to the &ldquo;GISAS&rdquo; instrument, click &ldquo;Yes, please modify instrument&rdquo; if asked</li> <li>open &ldquo;Properties&rdquo; panel and check that axis units are switchable after linking</li> </ul> </li> </ul> <h3 id="simulation-with-data">Simulation with data</h3> <ul> <li>specular simulation: <ul> <li>switch to &ldquo;Simulation&rdquo; view</li> <li>choose specular instrument with corresponding sample and 1D data</li> <li>simulate</li> <li>check that both curves are given at the same argument points</li> </ul> </li> <li>GISAS simulation: <ul> <li>switch to &ldquo;Simulation&rdquo; view</li> <li>choose GISAS instrument with corresponding sample and 2D data</li> <li>simulate</li> <li>check that all color maps have the same range and scale</li> <li>check that mask is present in both simulation and loaded data</li> </ul> </li> </ul> <h3 id="save-and-load">Save and load</h3> <ul> <li>save the project</li> <li>close GUI</li> <li>open GUI</li> <li>open the project</li> <li>check that everything is loaded correctly</li> </ul>

# Request help or report bugs

file:///usr/share/doc/bornagain/html/howto/get-help.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/howto/get-help.html <p>Let us know if you encounter a problem installing or running BornAgain, or if you have a question about BornAgain models or numerics.</p> <p>You may contact us in private by <a href="mailto:contact@bornagainproject.org">email</a>, or in public by submitting an issue to our <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/issues">issue tracker</a>. External users need to self-register to get write access to our git manager Jugit, as described at <a href="https://computing.mlz-garching.de/tech/jugit-login">computing.mlz-garching.de/tech/jugit-login</a>.</p> <p>Public conversation has the advantage that solved issues, over time, will form a worldwide readable, and searchable, data base.</p>

# Size-distribution model: decoupling approximation

file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-da.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-da.html <h3 id="size-distribution-model-decoupling-approximation">Size-distribution model: decoupling approximation</h3> <p>Scattering from a distribution of cylinders of two different sizes using the Decoupling Approximation.</p> <ul> <li>The sample is made of cylinders deposited on a substrate.</li> <li>The distribution of particles is made of: <ul> <li>80% of cylinders with radii and heights equal to $5$ nm</li> <li>20% of cylinders with radii and heights equal to $8$ nm.</li> </ul> </li> <li>The interference function is Radial Paracrystal with a peak distance of $18$ nm and a damping length of $1$ $\mu$m.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationDA.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationDA.png" width="350px"> </a> <figcaption> <p>Scattering intensity</p>

# Cite BornAgain

file:///usr/share/doc/bornagain/html/howto/cite.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/howto/cite.html <h1 id="how-to-cite-bornagain">How to cite BornAgain</h1> <h2 id="generic-reference">Generic reference</h2> <p>The canonical reference for BornAgain is the journal article:</p> <blockquote> <p>Gennady Pospelov, Walter Van Herck, Jan Burle, Juan M. Carmona Loaiza, Céline Durniak, Jonathan M. Fisher, Marina Ganeva, Dmitry Yurov and Joachim Wuttke:<br> <em>BornAgain</em>: software for simulating and fitting grazing-incidence small- angle scattering.<br> <a href="https://doi.org/10.1107/S1600576719016789">J. Appl. Cryst. 53, 262–276 (2020)</a></p> </blockquote> <p>When using release 1.17 or later, also cite the update</p> <blockquote> <p>Ammar Nejati, Mikhail Svechnikov and Joachim Wuttke:<br> BornAgain, software for GISAS and reflectometry: Releases 1.17 to 20.<br> <a href="https://doi.org/10.1051/epjconf/202328606004">EPJ Web Conf. 286, 06004 (2023)</a></p>

# Set Python environmental variables under Windows

file:///usr/share/doc/bornagain/html/howto/troubleshooting/set_env_py_win.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/howto/troubleshooting/set_env_py_win.html <h4 id="setting-python-environmental-variables-under-windows">Setting Python environmental variables under Windows</h4> <p>With Python 3.10 in Conda or Pyenv platforms, the BornAgain GUI might crash when a Python script is imported. This problem is not observed with Python 3.11 or newer. Therefore, we recommend upgrading to a newer Python version <code>&gt;= 3.11</code>.</p> <p>If Python 3.10 is the preferred version, the Python-related environmental variables must be set <em>manually</em> before running the BornAgain GUI to avoid the crash.</p>

# Size-distribution model: local monodisperse approximation

file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-lma.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-lma.html <h3 id="size-distribution-model-local-monodisperse-approximation">Size-distribution model: local monodisperse approximation</h3> <p>Scattering from cylinders of two different sizes using the Local Monodisperse Approximation (LMA).</p> <ul> <li>The sample is made of cylinders deposited on a substrate.</li> <li>The cylinders are of two different sizes: <ul> <li>80% of Type $1$: radius $R_1 = 5$ nm, height $H_1 = 5$ nm. The interference function is a radial paracrystal with a peak distance equal to $16.8$ nm and a damping length of $1$ $\mu$m.</li> <li>20% of Type $2$: radius $R_2 = 8$ nm, height $H_2 = 8$ nm. The interference function is also a radial paracrystal but with a peak distance of $22.8$ nm and a damping length equal to $1$ $\mu$m.</li> </ul> </li> <li>Each type of cylinders is associated with a &ldquo;particle layout&rdquo;.</li> <li>The LMA is used since the sample is made of two domains containing particles of the same size and shape.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationLMA.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationLMA.png" width="350px"> </a> <figcaption> <p>Scattering intensity</p>

# Reflectivity

file:///usr/share/doc/bornagain/html/ref/sample/roughness/ex/specular.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/roughness/ex/specular.html <h3 id="specular-reflectivity-with-interface-roughness">Specular reflectivity with interface roughness</h3> <p>This example demonstrates how to compute reflected signal from a multilayered sample with surface roughness. All the experiment layout is exactly the same as the one described in <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">reflectometry tutorial</a>, but now all the layers (except the ambient media) have roughness on the top surface. The roughness is characterized by root-mean-square deviation from the mean surface position $\sigma = 1$ nm.</p> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/specular/SpecularSimulationWithRoughness.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/specular/SpecularSimulationWithRoughness.png" width="350px"> </a> <figcaption> <p></p> </figcaption> </figure> <p>When comparing the result of the simulation to the result obtained in the <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/specular">reflectometry tutorial</a>, one can notice up to two orders of magnitude attenuation of the reflected signal due to the roughness of the sample.</p>

# Size-distribution model: size-spacing coupling approximation

file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-ssca.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-ssca.html <h3 id="size-distribution-model-size-spacing-coupling-approximation">Size-distribution model: size-spacing coupling approximation</h3> <p>Scattering from cylinders of two different sizes using the Size-Spacing Coupling Approximation.</p> <ul> <li>The sample is made of cylinders deposited on a substrate.</li> <li>The distribution of particles is made of: <ul> <li>80% of cylinders with radii and heights equal to $5$ nm</li> <li>20% of cylinders with radii and heights equal to $8$ nm.</li> </ul> </li> <li>The interference function is Radial Paracrystal with a peak distance of $18$ nm and a damping length of $1$ $\mu$m.</li> <li>The wavelength is equal to 0.1 nm.</li> <li>The incident angles are $\alpha_i = 0.2 ^{\circ}$ and $\varphi_i = 0^{\circ}$.</li> <li>The Size-Spacing Coupling Approximation is implemented using the function setApproximation. By default the Decoupling Approximation is used (see <a href="file:///usr/share/doc/bornagain/html/ref/sample/interference/other/approximation-da">Size-distribution model: Decoupling Approximation</a>).</li> <li>For this size-distribution model, an additional dimensionless parameter, the coupling parameter <code>Kappa</code>, has to be specified (see line 33). It defines how the distance between particles is linked with their sizes.</li> </ul> <div class="galleryscg "> <div class="row justify-content-center align-items-center"> <figure > <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationSSCA.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/ApproximationSSCA.png" width="350px"> </a> <figcaption> <p>Scattering intensity</p>

# Polarized scattering

file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/polarized-scattering.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/instr/ex/pol/polarized-scattering.html <h2 id="polarized-scattering-by-magnetic-particles">Polarized scattering by magnetic particles</h2> <p>This example shows a GISAS simulation with polarized beam, magnetic sample, and polarization analyzing detector.</p> <p>The sample is made of magnetic spherical particles embedded in the substrate of a simple 2-layer system. The magnetization is in z direction.</p> <p>The incident beam is polarized in +z direction. The polarization analyzer transmits neutron with -z polarization component. Accordingly, only spin-flip scattering is detected.</p> <figure class="center"> <a href="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/MagneticSpheres.png"> <img src="file:///usr/share/doc/bornagain/html/img/auto/scatter2d/MagneticSpheres.png" width="500px"> </a> <figcaption> <p></p> </figcaption> </figure> <div class="highlight"><div class="chroma"> <table class="lntable"><tr><td class="lntd"> <pre tabindex="0" class="chroma"><code></code></pre></td> <td class="lntd"> <pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"></code></pre></td></tr></table> </div> </div> <a class="linktofile" href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/scatter2d/MagneticSpheres.py"/>auto/Examples/scatter2d/MagneticSpheres.py</a>

# Plot axes in different units

file:///usr/share/doc/bornagain/html/ref/plot/axes-in-different-units.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/plot/axes-in-different-units.html <h3 id="plotting-with-axes-in-different-units">Plotting with axes in different units</h3> <p><em>The functionality demonstrated in this example is currently broken.</em></p> <p>Repair is on our agenda: <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/issues/716">https://jugit.fz-juelich.de/mlz/bornagain/-/issues/716</a>.</p> <p>&hellip;.</p> <p>In this example we demonstrate how modify coordinate axes in 2D plots.</p> <p>The example is based on the standard GISAS simulation <a href="file:///usr/share/doc/bornagain/html/ref/sim/class/scattering/ex/gisas">Cylinders in DWBA</a>.</p> <p>The simulated Datafield are transformed using the function calls</p> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">result</span> <span class="o">=</span> <span class="n">simulation</span><span class="o">.</span><span class="n">simulate</span><span class="p">()</span> </span></span><span class="line"><span class="cl"><span class="n">result2</span> <span class="o">=</span> <span class="n">detector</span><span class="o">.</span><span class="n">field2bins</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="c1"># coordinates are u, v as dimensionless bin numbers</span> </span></span><span class="line"><span class="cl"><span class="n">result3</span> <span class="o">=</span> <span class="n">detector</span><span class="o">.</span><span class="n">field2angles</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="c1"># coordinates are phi_f, alpha_f in degrees</span> </span></span><span class="line"><span class="cl"><span class="n">result4</span> <span class="o">=</span> <span class="n">detector</span><span class="o">.</span><span class="n">field2q</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="c1"># coordinates are q_y, q_z in 1/nm</span> </span></span></code></pre></div><p>The transforming functions are members of class FlatDetector because they require knowledge of detector geometry and incident wave vector.</p>

# Babonneau2010

file:///usr/share/doc/bornagain/html/lit/babonneau2010.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/babonneau2010.html <p>D. Babonneau (2010):</p> <p>FitGISAXS: software package for modelling and analysis of GISAXS data using IGOR Pro.</p> <p><a href="https://doi.org/10.1107/S0021889810020352">J Appl Cryst 35, 406-421</a>.</p>

# Babonneau2013

file:///usr/share/doc/bornagain/html/lit/babonneau2013.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/babonneau2013.html <p>D. Babonneau (2013)</p> <p>FitGISAXS. Version 130531.</p> <p><a href="https://pprime.fr/wp-content/uploads/2020/01/FitGISAXS_130531.zip">https://pprime.fr/wp-content/uploads/2020/01/FitGISAXS_130531.zip</a></p>

# Bipyramid4

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/bipyramid4.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/bipyramid4.html <h3 id="bipyramid4">Bipyramid4</h3> <p>A compound of two truncated pyramids with a common square base and opposite orientations.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Bipyramid4.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Bipyramid4_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Bipyramid4_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Bipyramid4</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">r_H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, edge length of the shared quadratic base</li> <li>H, height of the bottom pyramid</li> <li>r_H, height ratio $r_{H}$ between the top and bottom pyramid</li> <li>alpha, dihedral angle $\alpha$ between the base and a side face.</li> </ul> <p>Constraint:</p> <p>$H \le \dfrac{\tan\alpha}{2} L \quad $ and $ \quad r_{H} H \le \dfrac{\tan\alpha}{2} L$</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p>

# Box

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/box.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/box.html <h3 id="box">Box</h3> <p>A rectangular cuboid.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Box.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Box_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Box_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Box</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length of the base</li> <li>W, width of the base</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Box</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as $$F(\mathbf{q})=LWH \space \exp\Big(iq_{z}\dfrac{H}{2}\Big) \space \text{sinc}\Big(q_{x}\dfrac{L}{2}\Big) \space \text{sinc}\Big(q_{y}\dfrac{W}{2}\Big) \space \text{sinc}\Big(q_{z}\dfrac{H}{2}\Big).$$</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$V=LWH.$$</p> <h4 id="related-shapes">Related shapes</h4> <p>More general:</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid2">Pyramid2</a> or <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid4">Pyramid4</a>, if sides are not vertical.</li> </ul> <p>More special:</p> <!--- [Bar](/ref/sample/particle/ff/ripples/bar), if elongated in L or W direction.--> <ul> <li>Bar, if elongated in L or W direction.</li> </ul> <p>Modified cubes:</p>

# CantellatedCube

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cantellatedcube.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cantellatedcube.html <h3 id="cantellatedcube">CantellatedCube</h3> <p>A cube with truncated edges and vertices as in Fig 7 of [<a href="file:///usr/share/doc/bornagain/html/lit/croset2017">Croset 2017</a>]. Can also be obtained by cantellating an octahedron. Also known as <a href="https://en.wikipedia.org/wiki/Rhombicuboctahedron">Rhombicuboctahedron</a>.</p> <img src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Rhombicuboctahedron_by_Cutting_Rhombic_Dodecahedron.svg" width="30%" > <!-- <img src="../cut/CantellatedCube_xy.svg" width="30%"> <img src="../cut/CantellatedCube_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">CantellatedCube</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length of the full cube</li> <li>t, side length of the birectangular prisms removed from the cube’s edges</li> </ul> <p>Constraint:</p> <p>$ t \le L/2 $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">CantellatedCube</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron with inversion symmetry provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p>

# Cone

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cone.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cone.html <h3 id="cone">Cone</h3> <p>A truncated cone (frustum) with circular base.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Cone.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Cone_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Cone_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Cone</span><span class="p">(</span><span class="n">R</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, radius</li> <li>H, height</li> <li>alpha, angle $\alpha$ between the base and a side.</li> </ul> <p>Constraint:</p> <p>$H \le R \tan\alpha$</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Cone.h">Cone</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Computation involves numerical integration in radial direction, $$F(\mathbf{q})=2\pi \exp(i \tilde{q_{z}} R) \tan\alpha \int_{R_H}^R d\rho\thinspace \rho^2 \frac{J_1(q_{\parallel}\rho)}{q_{\parallel}\rho} e^{-i\tilde{q}_z \rho},$$</p> <p>with notation $$\quad R_{H} := R-\dfrac{H}{\tan\alpha}, \quad q_{||} := \sqrt{q_{x}^2 + q_{y}^2}, \quad \tilde{q_{z}} := q_{z} \tan\alpha.$$</p>

# Croset2021

file:///usr/share/doc/bornagain/html/lit/croset2017.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/croset2017.html <p>Bernard Croset (2017):</p> <p>Form factor of any polyhedron: a general compact formula and its singularities.</p> <p><a href="https://doi.org/10.1107/S1600576717010147">J Appl Cryst 50, 1245-1255</a>.</p>

# Cylinder

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cylinder.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cylinder.html <h3 id="cylinder">Cylinder</h3> <p>An upright circular cylinder.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Cylinder.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Cylinder_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Cylinder_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Cylinder</span><span class="p">(</span><span class="n">R</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, radius</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Cylinder.h">Cylinder</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q})=2\pi R^2H \space \exp\Big(iq_z\dfrac{H}{2}\Big) \text{sinc}\Big(q_z\dfrac{H}{2}\Big) \dfrac{J_1(q_{\parallel}R)}{q_{\parallel}R} , $$ with the notation $$ q_{||} := \sqrt{q_x^2 + q_y^2}. $$</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$V=\pi R^2H.$$</p> <h4 id="related-shapes">Related shapes</h4> <p>More general:</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/cone">Cone</a>, if radius varies with z.</li> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/ellipsoidalcylinder">EllipsoidalCylinder</a>, if base is an ellipse.</li> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/horizontalcylinder">HorizontalCylinder</a>, if horizontal and truncated.</li> </ul> <h4 id="example">Example</h4> <p>Scattering by uncorrelated, oriented cylinders for horizontal incidence. Rotation around $y$ axis:</p>

# Dodecahedron

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/dodecahedron.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/dodecahedron.html <h3 id="dodecahedron">Dodecahedron</h3> <p>A regular dodecahedron.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Dodecahedron.png" width="30%"> <!-- <img src="../cut/Dodecahedron_xy.svg" width="30%"> <img src="../cut/Dodecahedron_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Dodecahedron</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>a, length of the edge</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Dodecahedron</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron with inversion symmetry provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V= \dfrac{1}{4}(15+7\sqrt{5})a^3 \approx 7.663 \space a^3. $$</p> <h4 id="related-shapes">Related shapes</h4> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/icosahedron">Icosahedron</a>, a regular icosahedron.</li> </ul> <h4 id="example">Example</h4> <p>Scattering by uncorrelated, oriented truncated dodecahedra for horizontal incidence:</p>

# EllipsoidalCylinder

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/ellipsoidalcylinder.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/ellipsoidalcylinder.html <h3 id="ellipsoidalcylinder">EllipsoidalCylinder</h3> <p>An upright cylinder whose cross section is an ellipse.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/EllipsoidalCylinder.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/EllipsoidalCylinder_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/EllipsoidalCylinder_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">EllipsoidalCylinder</span><span class="p">(</span><span class="n">R_a</span><span class="p">,</span> <span class="n">R_b</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R_a, radius $R_{a}$ in $x$ direction</li> <li>R_b, radius $R_{b}$ in $y$ direction</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/EllipsoidalCylinder.h">EllipsoidalCylinder</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q})=2\pi R_aR_b H \space \exp\Big(iq_z\dfrac{H}{2}\Big) \text{sinc}\Big(q_z\dfrac{H}{2}\Big) \dfrac{J_1(\gamma)}{\gamma} , $$ with the notation $$ \gamma := \sqrt{(q_xR_a)^2 + (q_yR_b)^2}. $$</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$V=\pi R_aR_bH.$$</p>

# FuzzySphere

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/soft/fuzzysphere.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/soft/fuzzysphere.html <h3 id="fuzzysphere">FuzzySphere</h3> <p>A sphere with a fuzzy surface.</p> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">FuzzySphere</span><span class="p">(</span><span class="n">R</span><span class="p">,</span> <span class="n">sigma</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, mean radius.</li> <li>sigma, fuzziness length.</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/SoftParticle/FuzzySphere.h">FuzzySphere</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>The form factor is computed as $$F(q)=F_{\rm sphere}(q) \exp(-\sigma^2 q^2 /2)$$ where $F_{\rm sphere}(q)$ is the form factor of a <a href="../hard/sphere">hard sphere</a>.</p> <h4 id="history">History</h4> <p>Previously named &ldquo;SphereGaussianRadius&rdquo;. In BornAgain 1.20 renamed and simplified to match the <a href="https://www.sasview.org/docs/user/models/fuzzy_sphere.html?highlight=fuzzy%20sphere">fuzzy_sphere</a> model of SasView.</p> <p>The SasView manual gives credit to M Stieger, J. S Pedersen, P Lindner, W Richtering, <a href="https://doi.org/10.1021/la049518x">Langmuir 20, 7283-7292 (2004)</a>.</p>

# Gauss

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/soft/gauss.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/soft/gauss.html <h3 id="gauss">Gauss</h3> <p>A soft particle with Gaussian density distribution $$n(\mathbf{r})=e^{-r^2/(2R^2)}.$$</p> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Gauss</span><span class="p">(</span><span class="n">R</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, mean radius.</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/SoftParticle/Gauss.h">Gauss</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>The form factor is computed as $$F(q)=R^3 \exp\left(-|q|^2R^2/(4\pi)\right).$$</p>

# HemiEllipsoid

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/hemiellipsoid.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/hemiellipsoid.html <h3 id="hemiellipsoid">HemiEllipsoid</h3> <p>An horizontally oriented ellipsoid, truncated at the central plane.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/HemiEllipsoid.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/HemiEllipsoid_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/HemiEllipsoid_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">HemiEllipsoid</span><span class="p">(</span><span class="n">R_x</span><span class="p">,</span> <span class="n">R_y</span><span class="p">,</span> <span class="n">R_z</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R_x, radius $R_{x}$ in $x$ direction</li> <li>R_y, radius $R_{y}$ in $y$ direction</li> <li>R_z, radius $R_{z}$ in $z$ direction</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/HemiEllipsoid.h">HemiEllipsoid</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Computation involves numerical integration in vertical direction,</p> <p>$$ F(\mathbf{q})=2\pi \int_{0}^{R_z} \text{d}z \space r_{x,z} r_{y,z} \frac{J_1(\gamma_{z})}{\gamma_{z}} \thinspace \exp(iq_z z) , $$</p> <p>with the notation</p> <p>$$ r_{x,z}:=R_{x}\sqrt{1-\Big( \dfrac{z}{R_z} \Big)^2}, \quad r_{y,z}:=R_{y}\sqrt{1-\Big( \dfrac{z}{R_z} \Big)^2}, $$</p>

# HorizontalCylinder

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/horizontalcylinder.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/horizontalcylinder.html <h3 id="horizontalcylinder">HorizontalCylinder</h3> <p>A horizontal truncated circular cylinder.</p> <!-- <img src="../3d/HorizontalCylinder.png" width="30%" > <img src="../cut/HorizontalCylinder_xy.svg" width="30%"> <img src="../cut/HorizontalCylinder_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <p>Full form ```python HorizontalCylinder(R, H, b, t)</p> <pre tabindex="0"><code>and short form ```python HorizontalCylinder(R, H) == HorizontalCylinder(R, H, -R, R) </code></pre><p>Parameters:</p> <ul> <li>R, radius</li> <li>H, height</li> <li>b, bottom boundary, relative to the center</li> <li>t, top boundary, relative to the center</li> </ul> <p>Constraint:</p> <p>$ -R \le b \le t \le R $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/HorizontalCylinder.h">HorizontalCylinder</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p>

# Icosahedron

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/icosahedron.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/icosahedron.html <h3 id="icosahedron">Icosahedron</h3> <p>A regular icosahedron.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Icosahedron.png" width="30%"> <!-- <img src="../cut/Icosahedron_xy.svg" width="30%"> <img src="../cut/Icosahedron_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Icosahedron</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>a, length of the edge</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Icosahedron</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron with inversion symmetry provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V= \dfrac{5}{12}(3+\sqrt{5})a^3 \approx 2.182 \space a^3. $$</p> <h4 id="related-shapes">Related shapes</h4> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/dodecahedron">Dodecahedron</a>, a regular dodecahedron.</li> </ul> <h4 id="example">Example</h4> <p>Scattering by uncorrelated, oriented truncated icosahedra for horizontal incidence:</p>

# Lazzari2002

file:///usr/share/doc/bornagain/html/lit/lazzari2002.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/lazzari2002.html <p>R. Lazzari (2002):</p> <p>IsGISAXS: a program for grazing-incidence small-angle X-ray scattering analysis of supported islands</p> <p><a href="https://doi.org/10.1107/S0021889802006088">J. Appl. Cryst. 35, 406-421</a>.</p>

# Lazzari2006

file:///usr/share/doc/bornagain/html/lit/lazzari2006.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/lazzari2006.html <p>R. Lazzari (2006):</p> <p>IsGISAXS manual. Version 2.6.</p> <!--http://www.insp.jussieu.fr/oxydes/IsGISAXS/isgisaxs.htm.--> <p><a href="http://www.insp.upmc.fr/oxydes/IsGISAXS/figures/doc/manual.html">http://www.insp.upmc.fr/oxydes/IsGISAXS/figures/doc/manual.html</a></p>

# PlatonicOctahedron

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/platonicoctahedron.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/platonicoctahedron.html <h3 id="platonicoctahedron">PlatonicOctahedron</h3> <p>A regular octahedron.</p> <img src="https://upload.wikimedia.org/wikipedia/commons/f/f1/Uniform_polyhedron-43-t2.png" width="30%" > <!-- <img src="../3d/PlatonicOctahedron.png" width="30%"> <img src="../cut/PlatonicOctahedron_xy.svg" width="30%"> <img src="../cut/PlatonicOctahedron_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">PlatonicOctahedron</span><span class="p">(</span><span class="n">L</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length of the edge</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">PlatonicOctahedron</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V= \dfrac{\sqrt{2}}{3}L^3. $$</p> <h4 id="related-shapes">Related shapes</h4> <p>More general:</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/bipyramid4">Bipyramid4</a>, if not regular and/or truncated.</li> </ul> <h4 id="example">Example</h4> <p>Scattering by uncorrelated, oriented octahedra for horizontal incidence:</p> <img src="file:///usr/share/doc/bornagain/html/img/auto/ff/PlatonicOctahedron.png"> <p>Generated by <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/ff/PlatonicOctahedron.py">Examples/ff/PlatonicOctahedron.py</a> .</p>

# PlatonicTetrahedron

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/platonictetrahedron.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/platonictetrahedron.html <h3 id="platonictetrahedron">PlatonicTetrahedron</h3> <p>A regular tetrahedron.</p> <img src="https://upload.wikimedia.org/wikipedia/commons/f/fc/Tetrahedron.svg" width="30%" > <!-- <img src="../3d/PlatonicTetrahedron.png" width="30%"> <img src="../cut/PlatonicTetrahedron_xy.svg" width="30%"> <img src="../cut/PlatonicTetrahedron_xz.svg" width="30%"> --> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">PlatonicTetrahedron</span><span class="p">(</span><span class="n">L</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length of the edge</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">PlatonicTetrahedron</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V= \dfrac{\sqrt{2}}{12}L^3. $$</p> <h4 id="related-shapes">Related shapes</h4> <p>More general:</p> <ul> <li><a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid3">Pyramid3</a>, if not regular and/or truncated.</li> </ul> <h4 id="example">Example</h4> <p>Scattering by uncorrelated, oriented tetrahedra for horizontal incidence:</p> <img src="file:///usr/share/doc/bornagain/html/img/auto/ff/PlatonicTetrahedron.png"> <p>Generated by <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/auto/Examples/ff/PlatonicTetrahedron.py">Examples/ff/PlatonicTetrahedron.py</a> .</p>

# Pospelov2020

file:///usr/share/doc/bornagain/html/lit/pospelov2020.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/pospelov2020.html <p>Gennady Pospelov, Walter Van Herck, Jan Burle, Juan M. Carmona Loaiza, Céline Durniak, Jonathan M. Fisher, Marina Ganeva, Dmitry Yurov and Joachim Wuttke (2020):</p> <p>BornAgain: software for simulating and fitting grazing-incidence small- angle scattering</p> <p><a href="https://doi.org/10.1107/S1600576719016789">J. Appl. Cryst. 53, 262–276</a>.</p> <p><i>This is the standard reference for BornAgain, see also <a href="file:///usr/share/doc/bornagain/html/howto/cite">how to cite</a>.</i></p>

# Prism3

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/prism3.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/prism3.html <h3 id="prism3">Prism3</h3> <p>A prism based on equlateral triangle.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Prism3.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Prism3_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Prism3_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Prism3</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, edge length of the trigonal base</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Prism3</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q})=H \space \exp\Big(iq_z\dfrac{H}{2}\Big) \space \text{sinc}\Big(q_z\dfrac{H}{2}\Big) \space F_{||}(\mathbf{q}_{||}) $$</p> <p>where the form factor $F_{||}(\mathbf{q}_{||}) $ computation is based on the generic form factor of a planar polygon provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V=\dfrac{\sqrt3}{4}HL^2. $$</p>

# Prism6

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/prism6.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/prism6.html <h3 id="prism6">Prism6</h3> <p>A prism based on regular hexagon.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Prism6.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Prism6_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Prism6_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Prism6</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">H</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, edge of the regular hexagonal base</li> <li>H, height</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Prism6</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q})=H \space \exp\Big(iq_z\dfrac{H}{2}\Big) \space \text{sinc}\Big(q_z\dfrac{H}{2}\Big) \space F_{||}(\mathbf{q}_{||}) $$</p> <p>where the form factor $F_{||}(\mathbf{q}_{||}) $ computation is based on the generic form factor of a planar polygon with two-fold symmetry $(S_2)$ provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p>

# Pyramid2

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid2.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid2.html <h3 id="pyramid2">Pyramid2</h3> <p>A truncated pyramid with rectangular base.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Pyramid2.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid2_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid2_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Pyramid2</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">W</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, edge length of the base</li> <li>W, edge width of the base</li> <li>H, height</li> <li>alpha, dihedral angle $\alpha$ between the base and a side face.</li> </ul> <p>Constraint:</p> <p>$H \le \dfrac{\tan\alpha}{2} min(L,W)$</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Pyramid2</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V=H\Big[LW-\dfrac{(L+W)H}{\tan\alpha}+\dfrac{4}{3}\dfrac{H^2}{\tan^2\alpha}\Big]. $$</p>

# Pyramid3

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid3.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid3.html <h3 id="pyramid3">Pyramid3</h3> <p>A truncated pyramid (frustum) with trigonal base.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Pyramid3.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid3_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid3_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Pyramid3</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, edge length of the trigonal base</li> <li>H, height</li> <li>alpha, dihedral angle $\alpha$ between the base and a side face.</li> </ul> <p>Constraint:</p> <p>$H \le \dfrac{\tan\alpha}{2\sqrt3} L$</p> <p>The orthographic projection also shows the angle $\beta$ between the base and a side edge. It is related to the dihedral angle through $\tan\alpha = 2\tan\beta$.</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Pyramid3</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p>

# Pyramid4

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid4.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid4.html <h3 id="pyramid4">Pyramid4</h3> <p>A truncated pyramid (frustum) with quadratic base.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Pyramid4.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid4_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid4_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Pyramid4</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, edge length of the quadratic base</li> <li>H, height</li> <li>alpha, dihedral angle $\alpha$ between the base and a side face.</li> </ul> <p>Constraint:</p> <p>$H \le \dfrac{\tan\alpha}{2} L$</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">Pyramid4</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V=\dfrac{L^3\tan\alpha}{6}\Big[1-\Big(1-\dfrac{2H}{L\tan\alpha}\Big)^3\Big]. $$</p>

# Pyramid6

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid6.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/pyramid6.html <h3 id="pyramid6">Pyramid6</h3> <p>A truncated pyramid (frustum) based on a regular hexagon.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Pyramid6.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid6_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Pyramid6_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Pyramid6</span><span class="p">(</span><span class="n">R</span><span class="p">,</span> <span class="n">H</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, edge of the regular hexagonal base</li> <li>H, height</li> <li>alpha, dihedral angle $\alpha$ between the base and a side face.</li> </ul> <p>Constraint:</p> <p>$H \le \dfrac{\sqrt3\tan\alpha}{2} R$</p> <p>Note that the orthographic projection does not show $\alpha$ but the angle $\beta$ between base and a side edge. They are related through $\sqrt3\tan\alpha = 2\tan\beta$.</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p>

# Renaud2009

file:///usr/share/doc/bornagain/html/lit/renaud2009.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/renaud2009.html <p>G. Renaud, R. Lazzari and F. Leroy (2009):</p> <p>Probing surface and interface morphology with Grazing Incidence Small Angle X-Ray Scattering.</p> <p><a href="https://doi.org/10.1016/j.surfrep.2009.07.002">Surf. Sci. Rep. 64, 255-380</a>.</p>

# Sears1992

file:///usr/share/doc/bornagain/html/lit/sears1992.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/sears1992.html <p>Varley F. Sears (1992):</p> <p>Neutron scattering lengths and cross sections.</p> <p><a href="https://doi.org/10.1080/10448639208218770">Neutron News 3, 26-37</a>.</p>

# Sphere

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/sphere.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/sphere.html <h3 id="sphere">Sphere</h3> <p>A full sphere.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/FullSphere.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Sphere_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Sphere_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Sphere</span><span class="p">(</span><span class="n">R</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>R, radius</li> </ul> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Sphere.h">Sphere</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <!--$$ F(\mathbf{q})=\dfrac{4\pi}{q^3} \exp(iq_z R)\left[\sin(qR) - qR \cos(qR)\right] , $$--> <p>$$ F(\mathbf{q})=4\pi R^3 \exp(iq_z R) \dfrac{\sin(qR) - qR \cos(qR)}{(qR)^3} , $$ with the notation $$ q := \sqrt{q_x^2 + q_y^2+ q_z^2}. $$</p> <p>Volume <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Tests/Unit/Sample/FormfactorBasicTest.cpp">has been validated</a> against $$ V=\dfrac{4\pi}{3} R^3. $$</p> <h4 id="related-shapes">Related shapes</h4> <p>More general:</p>

# SphericalSegment

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/sphericalsegment.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/sphericalsegment.html <h3 id="sphericalsegment">SphericalSegment</h3> <p>A spherical segment, obtained from a spherical ball by two parallel cuts.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/SphericalSegment.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SphericalSegment_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SphericalSegment_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">SphericalSegment</span><span class="p">(</span><span class="n">R</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>$ R $, radius</li> <li>$ t $, cut from top</li> <li>$ b $, cut from bottom</li> </ul> <p>Constraint:</p> <p>$ t+b \le 2R $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/SphericalSegment.h">SphericalSegment</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Computation involves numerical integration in vertical direction,</p> <p>$$ F(\mathbf{q})=2\pi \exp[iq_z(R-b)] \int_{-R+b}^{R-t} \text{d}z \space r_z^2 \frac{J_1(q_{||}r_z)}{q_{||}r_z} \exp(iq_z z), $$</p> <p>with the notation</p>

# Spheroid

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/spheroid.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/spheroid.html <h3 id="spheroid">Spheroid</h3> <p>A full spheroid, generated by rotating an ellipse around the vertical axis.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/Spheroid.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Spheroid_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/Spheroid_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">Spheroid</span><span class="p">(</span><span class="n">R_xy</span><span class="p">,</span> <span class="n">R_z</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>$R_{xy}$, horizontal radius</li> <li>$R_z$, vertical radius</li> </ul> <p><strong>Attention</strong> This has changed in BornAgain 22. Previously, the second argument was $H=2R_z$.</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Spheroid.h">Spheroid</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor is computed as</p> <p>$$ F(\mathbf{q})=4\pi R_{xy}^2R_z \exp(iq_zR_z) \dfrac{\sin(s) - s \cos(s)}{s^3} , $$ with the notation $$ s := \sqrt{(R_{xy}q_x)^2 + (R_{xy}q_y)^2+ (R_zq_z)^2}. $$</p>

# SpheroidalSegment

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/spheroidalsegment.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/spheroidalsegment.html <h3 id="spheroidalsegment">SpheroidalSegment</h3> <p>A vertically oriented, horizontally truncated spheroid.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/SpheroidalSegment.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SpheroidalSegment_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/SpheroidalSegment_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">SpheroidalSegment</span><span class="p">(</span><span class="n">R_xy</span><span class="p">,</span> <span class="n">R_z</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>$R_{xy}$, horizontal radius</li> <li>$R_z$, vertical radius</li> <li>$ t $, cut from top</li> <li>$ b $, cut from bottom</li> </ul> <p>Constraint:</p> <p>$ t+b \le 2R_z $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/SpheroidalSegment.h">SpheroidalSegment</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Computation involves numerical integration in vertical direction,</p> <p>$$ F(\mathbf{q})=2\pi \exp[iq_z(R_z-b)] \int_{-R_z+b}^{R_z-t} \text{d}z \space r_z^2 \frac{J_1(q_{||}r_z)}{q_{||}r_z} \exp(iq_z z), $$</p> <p>with the notation</p> <p>$$ q_{||} := \sqrt{q_x^2 + q_y^2}, \quad r_z:=R_{xy}\sqrt{1-z^2/R_z^2} $$</p>

# TruncatedCube

file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/truncatedcube.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/ref/sample/particle/ff/hard/truncatedcube.html <h3 id="truncatedcube">TruncatedCube</h3> <p>A cube whose eight vertices have been removed. The truncated part of each vertex is a trirectangular tetrahedron.</p> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/3d/TruncatedCube.png" width="30%" > <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/TruncatedCube_xy.svg" width="30%"> <img src="file:///usr/share/doc/bornagain/html/img/draw/ff/2d/TruncatedCube_xz.svg" width="30%"> <h4 id="constructor">Constructor</h4> <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">TruncatedCube</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> </span></span></code></pre></div><p>Parameters:</p> <ul> <li>L, length of the full cube</li> <li>t, side length of the trirectangular tetrahedron removed from the cube’s vertices</li> </ul> <p>Constraint:</p> <p>$ t \le L/2 $</p> <h4 id="usage">Usage</h4> <p>As for any other <a href="file:///usr/share/doc/bornagain/html/ref/sample/particle/ff">Form factor</a>.</p> <h4 id="implementation">Implementation</h4> <p>Class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/HardParticle/Polyhedra.h">TruncatedCube</a> inherits from the interface class <a href="https://jugit.fz-juelich.de/mlz/bornagain/-/tree/r23/Sample/Particle/IFormfactor.h">IFormfactor</a>.</p> <p>Form factor computation is based on the generic form factor of a polyhedron provided by <a href="https://jugit.fz-juelich.de/mlz/libformfactor">libformfactor</a> .</p>

# Wuttke2021

file:///usr/share/doc/bornagain/html/lit/wuttke2021.html Mon, 01 Jan 0001 00:00:00 +0000 file:///usr/share/doc/bornagain/html/lit/wuttke2021.html <p>Joachim Wuttke (2021):</p> <p>Numerically stable form factor of any polygon and polyhedron.</p> <p><a href="https://doi.org/10.1107/S1600576721001710">J Appl Cryst 54, 580-587</a>.</p>