SAXS: Bimodal silica particles

In this notebook we demonstrate modelling of small angle scattering data from bimodal silica particles. More details as well as experimental data you can find in the original paper from Applied Crystallography Journal

http://journals.iucr.org/j/issues/2015/05/00/vg5026/

This notebook is a demonstration of the core functionality of ESCAPE package.

The investigated population of silica nanoparticles consists of particles of two sizes: small particles of type "A" and large particles of type "B", each with its own Gaussian distribution of sizes with characteristic mean radii $R_A$, $R_B$ and their distribution widths $\sigma_A$ and $\sigma_B$.

The resulted intensity is calculated as a sum of the scattering intensity contributed by each scatterer, i.e. each assembly of particles as following

$I_{mod}(q)=\sum_c^N\left[\int_a^b P(q, x)f(x)dx\right]S(q)$

Each contribution $c$ consists of a form-factor $P(q, x)$ determining the shape of a scatterer, $f(x)$ - distribution of certain parameter of the form-factor in the case of disperse aspects. $S(q)$ is a structure factor for each contribution, which is not relevant for our case and is equal unity.

We start implementation of our model with definition of model parameters. In the comments below we give a short description of each parameter. For the details please have a look on the original publication.

Now we can implement form-factors for our model. These are standard form-factors for homegeneous particles with spherical shape.

$P_A$ and $P_B$ are the form-factors for the corresponding scatterers without taking into account the size distribution. Since ESCAPE operates mostly with simple functor-type objects, the user has the ability to look at and analyze the behavior of each object, before the final simulation. For example, to visually estimate the contribution of any part of the model or locate a calculation error.

After implementing of form-factors and checking their curves we are ready to finalize our model and to implement integration over size distribution. Here we had to reformulate the expressions, because in ESCAPE there is no Gaussian number-weighted size distribution. For that purposes we introduced expressions for $C_A$ and $C_B$ normalization constants which we will use as multipliers for the form-factor expressions.

We are ready now to perform fitting of experimental data. To do that we need to open the data file, which was taken from the supplementary material to the original article. To open the file we will use the numpy library and the loadtxt function. The data will be loaded into the arrays x, y, err. Then we create a data object Escape dobj. The next step is to create a model. Here everything is simple, we will use the function model. The arguments residuals_scale and weight_type are relevant to the calculation of the cost function. Weight_type set to "data" means that the data errors will be used for the weights.

It's a good time to create and run an optimizer. We will start by testing the well-known Levenberg-Marquardt optimizer by shaking out the initial parameter values beforehand.

The values of the parameters and their errors are very close to the values presented in the article, although there is some expected discrepancy. We try now Differential Evolution algorithm.

The results of LM and DE optimizers for the presented data are in a good agreement with results presented in the original paper.