diff --git a/Doc/UserManual/Examples.tex b/Doc/UserManual/Examples.tex index 81dd0443ac3a87ffc44ea5e6b4ec5d5c209a4063..cb94d877563c936f3f6b402eeb2fd108519a25c9 100644 --- a/Doc/UserManual/Examples.tex +++ b/Doc/UserManual/Examples.tex @@ -7,8 +7,7 @@ A simulation of GISAXS using \BornAgain\ platform can be decomposed into the fol \begin{itemize} \item definition of the materials by specifying their names and their refractive indices, -\item definition of particles: shapes, sizes, refractive indices of - the constituting material, interference functions, +\item definition of particles: shapes, sizes, constituting materials, interference functions, \item definition of the layers: thicknesses, roughnesses, associations with the previously defined materials, \item inclusion of the particles in layers: density, positions, orientations, @@ -25,18 +24,17 @@ materials, \subsection{Geometry of the sample} -\noindent The geometry used to describe the sample is shown in -Fig.~\ref{fig:multil3d}. The $z$-axis is perpendicular to the sample's +\noindent The geometry used to describe the sample is shown in \reffig{multil3d}. The $z$-axis is perpendicular to the sample's surface and pointing upwards. The $x$-axis is perpendicular to the plane of the detector and the $y$-axis is along it. The input and the scattered output beams are each by two angles $\alpha_i$, $\phi_i$ and $\alpha_f$, $\phi_f$ respectively. Our choice of orientation for the -angles $\alpha_j$ is so that $\alpha_i$ and $\alpha_f$ shown in fig.~\ref{fig:multil3d} are positive. \\ +angles $\alpha_i$ and $\alpha_f$ is so that they are positive as shown in \reffig{multil3d}. \\ \noindent The layers are defined by their thicknesses (parallel to the $z$-direction), their possible -roughnesses (equal to 0 by default) and the refractive index of the -material. We do not define any dimensions in the $x$, $y$ +roughnesses (equal to 0 by default) and the +material they are made of. We do not define any dimensions in the $x$, $y$ directions. And, except for roughness, the layer's vertical boundaries are plane and perpendicular to the $z$-axis. There is also no limitation to the number of layers that could be defined in \BornAgain. Note that the @@ -47,13 +45,13 @@ When assembling the sample, the layers are defined from top to bottom. So in most cases the first layer will be the air layer.}\\ \noindent The particles are characterized by their form factors (\textit{i.e.} the Fourier transform of the shape function - see the list of form factors implemented - in \BornAgain) and -\textbf{the refractive index of the composing material}. The number of input parameters for the form + in \BornAgain) and the composing material. The number of input parameters for the form factor depends on the particle symmetry; it ranges from one parameter for a sphere (its radius) to three for an ellipsoid (its three main axis lengths).\\ By placing the particles -inside or on top of a layer, we impose their vertical positions. The in-plane distribution of particles is linked with the way the +inside or on top of a layer, we impose their vertical positions, whose +values corresponds to the bottoms of the particles. The in-plane distribution of particles is linked with the way the particles interfere with each other, which is therefore implemented when dealing with the interference function. \\ @@ -70,8 +68,7 @@ $\beta$ directly when we create a material using the function \texttt{getHomogen \begin{figure}[h] \centering \includegraphics[clip=, width=120mm]{multilayer3d3.eps} - \caption[Representation of the scattering geometry for multilayer - specular reflectivity.]{Representation of the scattering geometry. $n_j$ is + \caption[Representation of the scattering geometry.]{Representation of the scattering geometry. $n_j$ is the refractive index of layer $j$ and $\alpha_i$ and $\phi_i$ are the incident angle of the wave propagating. $\alpha_f$ is the exit angle with respect to the sample's surface and $\phi_f$ is the scattering angle with respect to the scattering @@ -83,10 +80,10 @@ plane. } spatial divergence.\\ %\textbf{polarization term?} \subsection{Units} -By default angles are expressed in radians and lengths are given in +By default the angles are expressed in radians and the lengths are given in nanometers. But it is possible to use other units by specifying them right after the value of the corresponding -parameter like, for example, \texttt{20.0*Units::micrometer} in C++. +parameter like, for example, \texttt{20.0*micrometer}. \subsection{Programs} @@ -112,15 +109,12 @@ the beginning of the description. But for the sake of completeness the full code at the end of this section (Listing~\ref{script_ex1}). \\ \noindent We start by importing different functions from external -modules (lines~\ref{import_begin}-\ref{import_end}). For example, -line~\ref{import_numpy} imports NumPy, which +modules (line~\ref{import_lib}), for example NumPy, which is a fundamental package for scientific computing with Python \cite{NumPyURL}. In particular, line~\ref{import_end} imports the features of \BornAgain\ software.\\ \begin{lstlisting}[language=python, style=eclipseboxed,name=ex1,nolol] -import sys@\label{import_begin}@ -import os -import numpy @\label{import_numpy}@ +import sys, os, numpy @\label{import_lib}@ from libBornAgainCore import * @\label{import_end}@ \end{lstlisting} @@ -128,19 +122,22 @@ from libBornAgainCore import * @\label{import_end}@ %%%%%%%%%%%%% \myparagraph{\underline{First step:} Defining materials} - + \begin{lstlisting}[language=python, style=eclipseboxed,name=ex1,nolol] def RunSimulation(): @\label{def_function}@ # defining materials @\label{material1}@ - mAmbience = MaterialManager.getHomogeneousMaterial("Air", 0.0, 0.0 ) @\label{material2}@ - mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 6e-6, 2e-8) @\label{material3}@ + mAmbience = MaterialManager.getHomogeneousMaterial("Air", 0.0, 0.0) @\label{material2}@ + mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", + 6e-6, 2e-8) @\label{material3}@ + mParticle = MaterialManager.getHomogeneousMaterial("Particle", 6e-4, + 2e-8 ) @\label{materialparticle}@ \end{lstlisting} \noindent Line~\ref{def_function} marks the beginning of the function to define and run the simulation. -\noindent Lines~\ref{material2} and \ref{material3} define two different +\noindent Lines~\ref{material2}, \ref{material3} and \ref{materialparticle} define different materials using function \texttt{getHomogeneousMaterial} from class \texttt{MaterialManager}. The general syntax is the following @@ -151,46 +148,45 @@ materials using function \texttt{getHomogeneousMaterial} from class \noindent where \texttt{name} is the name of the material associated with its complex refractive index n=1-\texttt{delta} +i \texttt{beta}. \texttt{<material\_name>} is later used when -referring to this particular material. The two defined materials in this example are \texttt{Air} with a refractive -index of 1 (\texttt{delta = beta =0}) and a \texttt{Substrate} associated with a complex refractive index -equal to $1-6\times 10^{-6} +i2\times 10^{-8} $. \\ +referring to this particular material. The three defined materials in this example are \texttt{Air} with a refractive +index of 1 (\texttt{delta = beta =0}), a \texttt{Substrate} associated with a complex refractive index +equal to $1-6\times 10^{-6} +i2\times 10^{-8} $, and the material of particles, whose refractive index is \texttt{n}$=1-6\times 10^{-4}+i2\times 10^{-8}$.\\\\ %\noindent \underline{Remark:} there is no condition on the choice of \texttt{name}. %%%%%%%%%%%%% \myparagraph{\underline{Second step:} Defining the particles} - \begin{lstlisting}[language=python,style=eclipseboxed,name=ex1,nolol] # collection of particles @\label{particles1}@ - n_particle = complex(1.-6e-4, 2e-8) @\label{complx_ref_index}@ cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer) @\label{particlescyl1}@ - cylinder = Particle(n_particle, cylinder_ff) @\label{particlescyl2}@ + cylinder = Particle(mParticle, cylinder_ff) @\label{particlescyl2}@ prism_ff = FormFactorPrism3(5*nanometer, 5*nanometer) @\label{particlesprism1}@ - prism = Particle(n_particle, prism_ff) @\label{particlesprism2}@ + prism = Particle(mParticle, prism_ff) @\label{particlesprism2}@ \end{lstlisting} \noindent We implement two different shapes of particles: cylinders and prisms (\textit{i.e.} elongated particles with a constant equilateral triangular cross section).\\ All particles implemented in \BornAgain\ are defined by their - form factors, their sizes \textbf{and the refractive index of the material - they are made of}. Here, for the + form factors, their sizes and the material + they are made of. Here, for the cylindrical particle, we input its radius and height. For the prism, the possible inputs are the length of one side of its equilateral triangular base and its height.\\ -\noindent In line~\ref{complx_ref_index}, we define the complex refractive index -associated with both particle shapes: \texttt{n}$=1-6\times 10^{-4}+i2\times 10^{-8}$.\\ +%\noindent In line~\ref{complx_ref_index}, we define the complex refractive index +%associated with both particle shapes: \texttt{n}$=1-6\times 10^{-4}+i2\times 10^{-8}$.\\ \noindent In order to define a particle, we proceed in two steps. For example for the cylindrical particle, we first specify the form factor of a cylinder with its radius and height, both equal to 5 nanometers in this particular case (see line~\ref{particlescyl1}). Then we associate this shape with -the refractive index of the constituting material as in line~\ref{particlescyl2}.\\ +the constituting material as in line~\ref{particlescyl2}.\\ \noindent The same procedure has been applied for the prism in lines~\ref{particlesprism1} and \ref{particlesprism2} respectively. %%%%%%%%%%%%% \myparagraph{\underline{Third step:} Characterizing the layers and assembling the sample} \noindent \textbf{Particle decoration} \\ + \begin{lstlisting}[language=python, style=eclipseboxed, name=ex1,nolol] particle_decoration = ParticleDecoration() @\label{particlesdecor1}@ @@ -200,17 +196,17 @@ the refractive index of the constituting material as in line~\ref{particlescyl2} particle_decoration.addInterferenceFunction(interference) @\label{particlesinterf}@ \end{lstlisting} -\noindent The object whcih holds the information about the positions and densities of particles +\noindent The object which holds the information about the positions and densities of particles in our sample is called ``particle decoration''. We use the function \texttt{ParticleDecoration()} (line~\ref{particlesdecor1}) and the associated \texttt{addParticle} for each particle shape (lines~\ref{particlesdecor2}, \ref{particlesdecor3}). The general syntax is \begin{lstlisting}[language=python, style=eclipse,numbers=none] -particledecoration.addParticle(particle_name, depth, abundance) +particledecoration.addParticle(<particle_name>, depth, abundance) \end{lstlisting} -\noindent where \texttt{particle\_name} is the name used to define the particles +\noindent where \texttt{<particle\_name>} is the name used to define the particles (lines~\ref{particlescyl2} and \ref{particlesprism2}), \texttt{depth} (default value =0) is the vertical position, expressed in nanometers, of the particles in a given layer (the @@ -223,8 +219,7 @@ and 50\% of prisms. \\ The vertical positions of particles in a layer are given in relative coordinates. For the top layer, the bottom corresponds to \texttt{depth}=0 and negative values would correspond to particles -floating above layer 1 since the vertical axis, shown in -fig.~\ref{fig:multil3d} is pointing upwards. But for all the other layers, it is the top of the +floating above layer 1 since the vertical axis, shown in \reffig{multil3d} is pointing upwards. But for all the other layers, it is the top of the layer which corresponds to \texttt{depth}=0.}\\ @@ -240,7 +235,7 @@ particles distribution (\textbf{see Theory}). On the contrary, the vertical posi imposed when we add the particles in a given layer by parameter \texttt{depth}, as shown in lines~\ref{particlesdecor2} and \ref{particlesdecor3}. \\ \noindent \textbf{Multilayer}\\ - + \begin{lstlisting}[language=python, style=eclipseboxed,name=ex1,nolol] # air layer with particles and substrate form multi layer @\label{sampleassembling}@ air_layer = Layer(mAmbience) @\label{airlayer}@ @@ -300,7 +295,7 @@ sample previously defined (line~\ref{runsample}). Finally we run the simulation (line~\ref{runsimul}). Those functions are part of the Simulation class. The different incident and exit angles are -shown in Fig.~\ref{fig:multil3d}. \\ +shown in \reffig{multil3d}. \\ \noindent The detector parameters are set using ranges of angles via the function:\\ @@ -345,11 +340,11 @@ previously defined setup. \end{lstlisting} -\noindent In line~\ref{outputdata} we record the simulated intensity +\noindent In line~\ref{outputdata} we obtain the simulated intensity as a function of outgoing angles $\alpha_f$ and $\phi_f$ for further uses (plots, fits,\ldots) as a NumPy array containing \texttt{n\_phi}$\times$\texttt{n\_alpha} -datapoints. Some options are provided by \BornAgain. For example, figure~\ref{fig:output_ex1} shows the two-dimensional +datapoints. Some options are provided by \BornAgain. For example, \reffig{output_ex1} shows the two-dimensional contourplot of the intensity as a function of $\alpha_f$ and $\phi_f$. @@ -377,9 +372,7 @@ is associated with the output intensity in arbitrary units. } framerule = 2mm , rulecolor = \color{lightgrey}, breaklines = true] -import sys -import os -import numpy +import sys, os, numpy sys.path.append(os.path.abspath(os.path.join(os.path.split(__file__)[0],'..', '..', '..', 'lib'))) @@ -388,13 +381,14 @@ from libBornAgainCore import * def RunSimulation(): # defining materials mAmbience = MaterialManager.getHomogeneousMaterial("Air", 0.0, 0.0 ) - mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 6e-6, 2e-8) + mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", + 6e-6, 2e-8) + mParticle = MaterialManager.getHomogeneousMaterial("Particle", 6e-4, 2e-8 ) # collection of particles - n_particle = complex(1.0-6e-4, 2e-8) cylinder_ff = FormFactorCylinder(5*nanometer, 5*nanometer) - cylinder = Particle(n_particle, cylinder_ff) + cylinder = Particle(mParticle, cylinder_ff) prism_ff = FormFactorPrism3(5*nanometer, 5*nanometer) - prism = Particle(n_particle, prism_ff) + prism = Particle(mParticle, prism_ff) particle_decoration = ParticleDecoration() particle_decoration.addParticle(cylinder, 0.0, 0.5) particle_decoration.addParticle(prism, 0.0, 0.5) @@ -420,8 +414,6 @@ def RunSimulation(): return GetOutputData(simulation) \end{lstlisting} - - % \newpage % \subsection{Hello, minted} % diff --git a/Doc/UserManual/Fitting.tex b/Doc/UserManual/Fitting.tex index c94220b72803a63aa4208d36f2ff708061364cd9..92123246e356d22b81f507c9c6a92435eff1d395 100644 --- a/Doc/UserManual/Fitting.tex +++ b/Doc/UserManual/Fitting.tex @@ -71,7 +71,7 @@ $m_i$. If these uncertainties are not known, and are simply left out of the calculation, then the fit may still have meaning, but not the quantitative values of the resulting parameter errors. If the $\sigma_i$ are all overestimated by a factor $\beta$, then the -resulting parameter errors from the fit will be overstimated by the +resulting parameter errors from the fit will be overestimated by the same factor $\beta$. %\url{http://seal.web.cern.ch/seal/MathLibs/Minuit2/html/} @@ -105,7 +105,7 @@ The fitting procedure deals with one reference (experimental) datafile. \begin{itemize} \item background noise, intensity threshold, beam intensity \item Fit using several experimental runs? -\textbf{ Software Scatter:} The program allows to automatically fit large number of data files such as files from timeresolved +\textbf{ Software Scatter:} The program allows to automatically fit large number of data files such as files from time-resolved studies. A requirement is that subsequent scattering curves do not differ too much, so that the fitted values of the first curve can be used as starting parameters for a fit to the next curve. Before starting a fit series, choose the first data file and perform a fit so that the @@ -587,6 +587,7 @@ After running the fit, whose script is shown in Listing~\ref{script_exfit1}, the text given in~\ref{output_exfit1} should be displayed on your screen (generated using \texttt{PrintResults}). + \begin{lstlisting}[caption={Python script of fitting example}, label=script_exfit1,captionpos=b,escapeinside={@}{@} ,language=python,style=eclipse, numbers= none,frame = leftline , framerule = 2mm , @@ -613,13 +614,14 @@ prism3_height = 5.0*nanometer def buildSample(): # defining materials mAmbience = MaterialManager.getHomogeneousMaterial("Air", 0.0, 0.0 ) - mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", 6e-6, 2e-8 ) + mSubstrate = MaterialManager.getHomogeneousMaterial("Substrate", + 6e-6, 2e-8 ) + mParticle = MaterialManager.getHomogeneousMaterial("Particle", 6e-4, 2e-8 ) # collection of particles - n_particle = complex(6e-4, 2e-8) cylinder_ff = FormFactorCylinder(cylinder_height, cylinder_radius) - cylinder = Particle(n_particle, cylinder_ff) + cylinder = Particle(mParticle, cylinder_ff) prism_ff = FormFactorPrism3(prism3_height, prism3_half_side) - prism = Particle(n_particle, prism_ff) + prism = Particle(mParticle, prism_ff) particle_decoration = ParticleDecoration() particle_decoration.addParticle(cylinder, 0.0, 0.5) particle_decoration.addParticle(prism,0.0, 0.5) @@ -627,10 +629,10 @@ def buildSample(): particle_decoration.addInterferenceFunction(interference) # air layer with particles and substrate form multi layer air_layer = Layer(mAmbience) - air_layer_decorator = LayerDecorator(air_layer, particle_decoration) + air_layer.setDecoration(particle_decoration) substrate_layer = Layer(mSubstrate, 0) multi_layer = MultiLayer() - multi_layer.addLayer(air_layer_decorator) + multi_layer.addLayer(air_layer) multi_layer.addLayer(substrate_layer) return multi_layer # ----------------------------------