Monte-Carlo Code

Hi all,

Herewith a preliminary release of the Monte-Carlo code for fitting SAXS patterns. Documentation will follow, as will a movie and more.

MCFit_sph.m

Check it out and let me know if you have any questions.

Share

“Perfect” 1D pattern generation software.

I have written some small, simple bits of Matlab software that can generate scattering patterns in the range you request for polydisperse, dilute spheres or ellipsoids. While nothing new per se, this implementation is guaranteed to produce correct scattering patterns irrespective of the width of the distribution. Allow me to quickly explain.

The normal way of calculating these patterns in fitting functions and the likes, is to choose an upper size limit (perhaps related to the width and mean of the distribution), and divide the size range between zero and this upper limit into perhaps 100 different sizes. Then the scattering pattern of each of these contributions is calculated, multiplied with their probability (obtained from the probability (or size) distribution function), multiplied with the square of the particle volume for that size, and then summed. In all, then, this is a numeric integration over the volume-square weighted size distribution.

The problem lies in the determination of the upper limit and the number of divisions required. In the past, I have tried using the cumulative distribution function to select “smart” divisions, or adjusting the width and mean to compensate for the volume-square weighting, but this often resulted in the appearance of oscillatory behaviour in the scattering patterns. An alternative solution was therefore required.

These functions are not necessarily fast enough for fitting purposes, but they can be used for checking the applicability of your fitting procedures. You should get out of your fitting functions what you put into these simulated patterns.

These functions work by random generation of a number of spheres or ellipsoids. A scattering pattern is calculated from an initial number of spheres or ellipsoids. Then, the scattering pattern is calculated of the original block with the addition of a new set of shapes. This is repeated until the effect of adding a new block on the scattering pattern no longer exceeds a certain threshold.

Included are the programs for generating scattering patterns using polydisperse distributions of spheres or ellipsoids. All distributions supported by the “statistics library”‘s RANDOM function are available. For ellipsoids, an additional distribution can be used for the aspect ratio. If the use is not clear, let me know and I will write some more extensive documentation.

The programs are: perfectpattern_spheres and perfectpattern_ellipsoids. Have fun!

Share