Software package SASfit for fitting small-angle scattering curves

SASfit has been written for analyzing and plotting small angle scattering data. It can calculate integral structural parameters like radius of gyration, scattering invariant, Porod constant. Furthermore it can fit size distributions together with several form factors including different structure factors. Additionally an algorithm has been implemented, which allows to simultaneously fit several scattering curves with a common set of (global) parameters. This last option is especially important in contrast variation experiments or measurements with polarised neutrons.

The global fit helps to determine fit parameters unambiguously which by analyzing a single curve would be otherwise strongly correlated. The program has been written to fulfill the needs at the small angle neutron scattering facility at PSI. The numerical routines have been written in C whereas the menu interface has been written in tcl/tk and the plotting routine with the extension blt.

Author Information:

by Joachim Kohlbrecher and Ingo Bressler

Laboratory for Neutron Scattering
Paul Scherrer Institut
5232 Villigen PSI

Telephone: +41 56 310 3165
Fax.: +41 56 310 20 87
SASfit is available for users analysing data taken at PSI.

SASfit has been developed at the Paul Scherrer Institute (PSI) and remains copyright of the PSI.

SASfit is provided for users of the PSI facilities.

SASfit is provided "as is" and with no warranty.

download SASfit package : (source, Windows binary , Linux binary, MacOS binary)


Manual with a jumble of formulas used by SASfit (pdf)

Video about "How to set up the build environment"
Video about "How to Create a New Plugin"

Version information

  • SASfit 0.94.10 2018-03-20
    • The form factors "Ellipsoid i" "Ellipsoid ii" "EllipsoidalCoreShell", and "triaxEllShell1" have been disabled and replaced by a series of plug-in functions. Those replacements make use of a faster routine for multidimensional integrals (pcubature). Because of this an optional size distribution became part of the supplied plug-in form factors.
    • bug fix of unit conversion via clipboard
    • added a plug-in for a random flight structure factor
    • bug fix in the algorithm for calculating the resolution parameter in case of averaging neighboring data points
    • plug-in implementation of several variants of helices
    • plug-in for rectangular parallelepipeds have been extended so that it can have a size distribution of one, two or all three axis. The multiple integration is done by using the pcubature code from Steven G. Johnson
    • multi dimensional integration package "cubature" from Steven G. Johnson becomes generally available also in plug-ins (
  • SASfit 0.94.9 2017-08-16
    • changed scaling of SESANS correlation functions by factor 1/(2pi)^2
    • unit conversion for reading ASCII files corrected and extended
    • update to FFTW 3.3.6-pl2 did not work, went back to 3.3.5
    • updated to gsl 2.4
    • bug fix: resolution bar was not plotted properly
    • Uncertainties on x and y axis are now plotted symmetrically from x+-Delta_x and y+-Delta_y. Before they were plotted from x+-0.5*Delta_x and y+-0.5*Delta_y.
  • SASfit 0.94.8 2016-12-16
    • moved all peak functions into the plug-in area.
    • Added the possibility to apply after the summation of all scattering contributions a final operator. At the moment between three operator can be chosen:
      1. Unit operator which does not do anything with the data
      2. Taking the Hankel transform 2pi*H[I(Q)] for converting SAS model into a projected correlation function G(delta), which defines the SESANS signal
      3. Applying the operator from 2) and taking the exponential function of it exp(2pi*H[I(Q)]) to get SESANS signal
    • For the extension to SESANS also an option for reading SESANS data has been supplied. The format has been defined by TU Delft and has the default extension *.ses.
    • added a model for of a self-fine random density distribution (gDAB) both under non-particular structures as well as under SESANS as a correlation function.
    • added a SESANS correlation function for a generalized Gaussian chain for Flory exponents between nu ϵ (0,1/2)
    • updated to FFTW 3.3.5
    • updated to sundials 2.7.0
    • updated to gsl 2.3
    • supplying some alternative integration routines for integrating over the size distribution
    • bug fix of sasfit_integrate routine, which caused a crash when called from plug-in functions
    • first minimal routine for reading simple ASCII data from ALV-5000 with single correlation function for DLS-analysis
    • adding the PLHNC and RMSA closure to the OZ solver
    • fixed a bug in the scaling parameter of the Teubner-Strey model
    • bug fix in routine for reading data in BerSANS format
  • SASfit 0.94.7 2016-04-25
    • implementation of another cumulant formula for DLS
    • Bug-fix in the unit conversion routine
    • implementation of GMRES, Bi-CGStab, TFQMR and Andersen Accelarion for solving efficiently the Ornstein Zernicke fixpoint problem
    • bug fix: since version 0.94.4 the new interrupt option suppressed a proper error reporting to the GUI for undefined input values
    • removed some old structure factors, which were rarely used and theoretically not up to date
    • a first version of a plugin for ordered mesoscopic and nano structures. The plugin is providing a part of the structure factors available in the software package "scatter" from S. Förster.
    • plugin of a radial profile for a sphere resulting in a Porod law both below and above Q^-4
  • SASfit 0.94.6 2014-12-14
    • improved analysis of confidence intervals of fit parameters:
      • clickable correlation coefficients in the matrix highlight associated pair of fit parameters
      • covariance matrix elements are highlighted according to their correlation coefficient
      • highlighting and selection of correlated params improved
  • SASfit 0.94.5 2014-10-03
    • storing intensity and size distribution in batch processing routine
    • changed the width of the error bar, assuming that the supplied error is FWHM
    • changed the internal procedure for plotting error bars
    • resolution parameter can now also be plotted
    • changed the order of plotting the fit results in "integral structural parameters"
    • interruption of batch processing or series analysis implemented
  • SASfit 0.94.4 2014-09-03
    • a new interrupt button can stop now the intensity evaluation of fitting procedure after each q-value. Before the whole scattering curve needed to be calculated.
    • progress bar has been added to the GUI
    • bug fix in plotting error bars of multiple data sets.
    • implementation of another method for thinning out oversampled data sets. The new methods is performing an averaging of data points depending on a user-defined maximum allowed q-smearing and a user-defined maximum distance in intensity in units of the error bar of the data points, i.e. an averaging is only performed, if the intensities look similar with n-times the intensity error bars.
    • bug fix in GUI if one wants to forget old data and load a new data sets.
  • SASfit0.94.3 2014-07-02
    • bug fix in the plugin for parallel epiped
    • spelling errors in the menue interface
    • in case of slow convergence the OZ solver can be interupted now
  • SASfit 0.94.2 2014-06-02
    • new binding for zoom option, which works better for a mouse with one button (plot zoom by ctrl+left-mouse btn)
    • removed key binding for scattering contributions
    • Added several iteration schemes for finding the fixpoint of the OZ equation.
    • Added a tab for the total correlation function h(r)
    • Added also some root finding algorithms for solving OZ equation.
    • resolution parameter from file was not scaled during the change of units for Q
    • bug fix in calculation of xi for sq for wormlike structures (PS1 model)
    • wrong label for contrast in Teubner-Strey model
    • bug fix in SPHERE+R^-a_Nagg form factor in assignement of core volume
    • data export format set to scientific notation in the form x.yyyE?zz only
  • SASfit0.94.1 2014-02-05
    • added missing parameter label for Hamaker constant in DLVO potential
    • Penetrable Sphere Model was not properly assigned.
    • added all available plugins into the distribution binaries
  • SASfit 0.94.0
    • A new interface for solving the Ornstein Zernike equation for different closure relations and potentials (OZ-solver) has been added. The solutions of the OZ-solver can be used as a structure factor as a spline function without the possibility to fit a parameter of the potential at the moment.
    • manual has been extended for the ferrofluid plugin scattering functions
    • orientation of the 2D simulation was rotated by 90deg.
    • correction of the manual for Porod's approximation of cylinders.
    • minor bug fix for Porod's approximation of a long cylinders.
  • SASfit 0.93.5
    • implementation of a plugin for a form factor and correlation function for spin misalignment
    • bug fix for the scattering contribution of the individual chains in the form factors WORM*, ROD*, and DISC*
    • bug fix in the form factor MagneticShellCrossTerm
    • added some subfolders for form factor plugins
    • bug fix in the calculation of the scattering length density SLD(E) of x-rays
  • SASfit 0.93.4
    • In the menu for confidence interval the non-diagonal elements of correlation matrix are shown together with the confidence interval for the fitted parameters as diagonal elements.
    • added some additional parameters into the fit menu useful to evaluate the goodness of a fit
    • new plugin for Parallelepiped abc of dimension a*b*c to be found under [by plugins|anisotropic obj]
    • new plugin for generalized Guinier law to be found under [by plugins|non-particular structures]
    • Renamed HMI format into BerSANS format and did some debugging. Now also all masked data points (negative errors) are ignored.
    • added key bindings Home, End, PgUp, PgDn, Insert, Delete for going to first-last-next-previous entry or to add and remove an entry
    • adding plugin with a series of form factor for strongly anisotropic structures with local planar and local cylindrical shapes
    • adding a new plugin form factor for spheres with fuzzy interfaces. The existing form factors ExpShell, LinShell and LinShell2 have been moved to this plugin.
    • New plugin of FuzzySphere and CoreShellMicrogel. Also the related functions for calculating the corresponding radial proles have been added.
    • new section in the manual about absolute scale, molecular weight, etc.
    • for the form factors flat cylinder long cylinder, and Porod cylinder the limiting case q=0 is now treated properly
    • small bug fix in the peak function Gamma (Area) for checking validity of parameter
    • bug fix of the resolution parameter handling in case it will be read in from a data file
    • included under peak function the Maxwell distribution and the generalized Maxwell distribution
    • batch fitting
  • SASfit 0.93.3 (2011-05-4)
    • bug fix in the model "Stacked Discs". The structure factor describing the stacking order contained a bug.
    • extended plugin for stroboscopic measurements, especially for TISANE
    • plotting: ignore negative y values on log() and sqrt() scales
    • included Pcs_homogeneousCyl form factor
    • bug fix of ferrofluid plugin
    • added radial averaged form factor in ferrofluid plugin
    • extended the spline plugin to be used also as form factors. In case somebody wants to fit a spline function to e.g. a TEM size distribution, this function need to be available as a form factor and not only as a size distribution.
    • added configuration file 'config.ini' as replacement for deprecated sasfit_init_public.tcl
    • added switch for disabling 'about' popup at start time via config file
    • added checkbox (ascii options) for ignoring zero(0) intensity at the beginning of data
    • removed , as data column separator
    • added substitution of , => . for data columns (german decimal format to english format)
    • added interface function for covariance matrix output
    • covar matrix visualisation with parameter highlighting
    • added a chapter about particle number densities, volume fraction and absolute intensities in the manual.
    • LogNorm_fp size distribution is now plugin function. The new plugin is not backwards compatible. The manual explains a bit the difficulties in describing the size distribution in terms of a volume fraction.
    • added scrollbars for fit parameter window
  • SASfit 0.93.2 (2010-07-08)
    • bug fix in ferrofluid plugin
    • added radial averaged form factor. Included radial averaged form factors also for SAW model
    • Extended the spline plugin to be used also as form factors. In case somebody wants to fit a spline function to a size distribution, this function needs to be available as a form factor and not only as a size distribution.
    • forwarding intermediate linear Guinier approximation results to the plot window (green curve)
    • display of linear Guinier approximation results in ISP text output window
    • residuum window updated with linear Guinier approximation residuum
    • by default disabled, see checkbox in ISP window
    • fixed SLDCalculator in source package (missing data files)
    • added KNOWN_BUGS.txt (not complete)
    • optical(layout) GUI improvements:
      • removed thick margin around text boxes for ISP/analyt results
      • added resizeable file list in ISP window
      • added resizeable 'merge files' list when loading data files
    • added menu->tools->toggle console to show the console, it is hidden by default now
    • added 'OPTIM' parameter to src/CMakeLists.txt for optimized binary generation on the underlying hardware, use: 'cmake -DOPTIM=TRUE'
    • added configuration file 'config.ini' as (working) replacement for deprecated sasfit_init_public.tcl
    • added switch for disabling 'about' popup at start time via config file
    • added switch to set the default data directory
    • added checkbox (ascii options) for ignoring zero(0) intensity at the beginning of data
  • SASfit 0.93.1 (2010-05-13)
    • removed obsolete print menu entries and fix of textual output bug
  • SASfit 0.93.0 (2010-05-05)
    • copy&paste-able text output, as well as csv export (semicolon separated) for
      • integral structural parameters (ISP) data
      • parameters of contributions
      • moments of size distribution
    • improved/rewritten file selection GUI for ISP series fitting
    • new and improved plugins: Kratky Sphere, JuelichCoreShell (rewritten), Langevin
    • data is always plotted first, below the calculated lines
    • error bars are drawn behind data points
    • fixed wrong plotting of very large error bars
    • for log-plotting on the y-axis, negative data is ignored (not plotted, was abs() before)
    • fix to prevent the user from loading a SASfit project file as data
    • fix in Form-Factor Background (improved numerical stability)
    • bug fix for saving parameter files on windows
    • bug fix in gui when selecting form factor TwoAttachedSpheres
    • bug fix for "Singular Matrix" error (may still occur because of other reasons)
    • documentation update
  • SASfit 0.92.3 (2010-01-02)
    • implemented three different versions for worm like chains as described in Macromolecules 1996, 29, 7602-7612. They have been implemented as structure factors [anistropic obj|P'(Q):local cylindrical geometry], so that it can be combined with different cross-section form factors of local cylindrical objects [anisotropic obj.|Pcs(Q) for cylindrical obj.].
    • new form factor plugin for a sphere with 3 shells
    • new structure factor for a regular cluster up to maximal 5 particle (tetrahedron like)
    • correction of menue entry order for magnetic shell and superparamagnetic shell
    • new plugin for ferrofluid particles with a scheme similar to the one from J.S. Pedersen for Gaussian Chains attached to a spherical particle
    • bug fix in mMemberedTwistedRing
    • two more default plot: Guinier (rods) and Guinier (sheets)
    • bug fix in loglogistic peak
    • implementation of asymptotic limits for fractals, which require a numerical integration. The integration often fails for large q-values for which an asymptotic solution is available or has been constructed.
    • reprogrammed SquareWell1 structure factor for a squared well potential
    • replaced sasfit_qromb function by sasfit_integrate function in the form factor for the torus. The sasfit_qromb routine did not work for some unknown reason. This needs to be checked.
    • new structure factor for a thin square well potential
    • bug fix in BeaucageExpPowLaw2
    • bug fix for setting plot option Holtzer in multiple data set tab
    • public initialization file for setting the default working directory by the user to any path
  • SASfit 0.92.2 (2009-10-08)
    • data reduction without data loss, after loading a project file the data reduction can be reversed
    • info message about a guessed error bar is displayed only once when the ascii options are changed (not for every file)
    • added tooltip for complete filenames in merge window
    • color for selected fit region stays at dark grey after loading an old project file
    • removed unused help buttons in file open dialogs
    • fixed error loop when adding new data to previously loaded project file
    • fix for a homedir being e.g. 'U:\' at startup on Windows
    • minor correction in the routine to guess the error bar (normalization) when only two column are supplied
    • fix of rare error "form factor param out of range: -1"
  • SASfit 0.92.1 (13th of September)
    • fix for GUI problem with two plugin form factors (contribution updates). If there are two plugin model functions with a different number of parameters, you can't switch/cycle trough the contributions anymore (Next, Previous).
    • fix for saving a parameter file (file creation was disabled by accident in previous version)
  • SASfit 0.92.0 (8th of September)
    • data reduction when loading a data file: only a subset of data points can be loaded based on the overall point count or distance between points
    • default directory for file selection is the current users home directory now
    • documentation update
    • fixed doxygen documentation and latex issues
    • Holtzer and Debye-Bueche plot style added
    • fixed bessel function evaluation for large values for resolution calculation
    • fix for data file selection when error pops up and retry after input format correction
    • fixed names of resolution parameter labels
    • fixed error when loading default data file with sasfit installed in directory with spaces (again)
    • fixed bug with loading a 'new ..' data set when there were already some loaded: data structure maintenance issue
    • unified window titles
  • SASfit 0.91.1 (8th of July 2009)
    Since the previous version of SASfit (0.90.1, January 2009) there were a lot of changes to primarily improve the quality and portability of the code. Here is only a short summary of the larger changes done:
    • added detailed documentation on setup and installation of SASfit, as well as plugin development (how to add own model functions)
    • fixed some bugs in plugin framework
    • added automatic determination of available plugins at build time
    • enabled static building for plugins
    • increasing maximum number of model parameter in GUI
    • verified build compatibility for MacOS
    • Extended and improved Scattering Length Density (SLD) Calculator. Now the scattering length density for x-ray energies between 1keV and 24.9 keV can be calculated.
    • a few new form factor have been included: generalized Gaussian coil, generalized Gaussian coil 1, generalized Gaussian coil 2, ellCylShell1, ellCylShell2
  • SASfit 0.90.1 (12th of January 2009): bug-fix in plugin-GUI
  • SASfit 0.90 (5th January 2009): new release including full source code and binaries for windows and linux.
    Since the previous version of SASfit (0.87, March 2008) there were a lot of changes to primarily improve the quality and portability of the code. Here only a short summary of the 'big' changes done (as of Dec. 17th, 2008):
    • Structured the source code into the modules sasfit_common, sasfit_sd, sasfit_sq, sasfit_ff, sasfit_core.
    • Switched to CMake build environment for platform independence. Build and tested SASfit on Linux and Windows, 32bit as well as 64bit.
    • Replaced intensive string comparisons for model function selection in each interation step by more reasonable selection of functions pointers at initialization time and direct call of the according function at iteration time.
    • Fixed a lot of bugs and typos in the GUI (but there are still some)
    • Added flexible plugin system for external model functions. This way, all model functions can be provided as plugins and though move out of the core algorithms. Also enables easy customization. In the future the modules sasfit_sd, sasfit_sq, sasfit_ff and sasfit_peaks will be converted to external plugins.
    • Added sasfit_peaks, a new class of model functions containing peaks.
    • Added capability to ship SASfit as standalone executable, allows running on system without the need of external libraries (e.g. Tcl, BLT, ...)
  • 4.03.2008: (SASfit version 0.87) The last modification in the menu navigation still had bugs. Hopefully they are removed in this version.
  • 28.02.2008: (SASfit version 0.86) The menu navigation has been debugged and optimized. Corrected a bug in calculating the polydispersity index (PDI) in DLS cumulant analysis (PDI=Gamma2/Gamma1ˆ2)
  • 25.01.2008: (SASfit version 0.85) A bug for the form factors ROD+Rˆ-a* has been corrected. The implementation of the scaling approximation, partial structure factors and local monodisperse approach has been improved.
  • 09.01.2008: (SASfit version 0.84) Form factor for wormlike micelles (WORM+Chains(RW), WORM+Chains(RW)_Rc, WORM+Chains(RW)_Nagg) and for cluster aggregates (Mass Fractal (Exp(-x) Cut-Off), Fisher-Burford, MassFractExp, MassFractGauss, Mass Fractal (Exp(-xˆa) Cut-Off),   DLCAggregation, RLCAggregation, MassFractOverlappingSph) have
    been implemented. Furthermore a simple scheme for importing data from the clipboard has been implemented, which e.g. allows to copy/paste data from spread-sheets directly into SASfit.
  • 04.10.2007: (SASFit version 0.80) Next to the correction of some bugs a simulation option for multiple data sets has been implemented. Furthermore an option has been implemented to subtract a theoretical scattering contribution from the experimental data set, like e.g. a constant background signal. The format of the projects have up to now never been tested for compatibility. An attempt has been started to change this for the future versions.
  • 20.08.2007: A couple of form factors for spherical, elliptical, cylindrical and very long rod-like micelles consisting of a homogeneous core and which are either grafted with Gaussian chains "*(RW)*", or grafted with semi-flexible self-avoiding and interacting chains "*(SAW)*" or a corona with power-law decaying profile r^(-a)= "*(R^-a)*"   =have been implemented: =SPHERE+Chains(RW), SPHERE+Chains(RW)_Rc, SPHERE+Chains(RW)_Nagg, SPHERE+Chains(SAW), SPHERE+Chains(SAW)_Rc, SPHERE+Chains(SAW)_Nagg, SPHERE+Rˆ-a, SPHERE+Rˆ-a_Rc, SPHERE+Rˆ-a_Nagg, ELL+Chains(RW), ELL+Chains(RW)_Rc, ELL+Chains(RW)_Nagg, CYL+Chains(RW), CYL+Chains(RW)_Rc, CYL+Chains(RW)_Nagg, ROD+Chains(RW), ROD+Chains(RW)_Rc, ROD+Chains(RW)_nagg, ROD+Rˆ-a, ROD+Rˆ-a_Rc, ROD+Rˆ-a_nagg
  • 30.6.2007: Rudimental copy algorithm to copy plots or parameters into window-clipboard. Everything is copied in wmf-format and the option only works fine for information in non-scrolled widgets. Copy-option can be activated with right mouse button or double click of left mouse button. The form factor for a triaxial ellipsoidal ( triaxEllShell ) shell with semiaxis a, b, c and shell thickness t is available.
  • 4.6.2007: Implementation of form factors for cylindrical shells with circular cross-section and capped ends ( CylShell2 ) and without capped ends ( CylShell1 ) together with an approximation for very long cylindrical shells ( LongCylShell )
  • 27.3.2007: Implementation of form factor for bi-continuous systems ( TeubnerStrey and DAB)
  • 23.02.2007: Implementation of the structure factor for a system of charged, spheroidal objects in a dielectric medium according to the RMSA model of Hayter and Penfold
  • 11.11.2006: Implementation of a semiflexible polymer according to Kholodenko, some form factors with plane geometry, which are intended to be used with lamellar structure factors ( homogenousXSTwoInfinitelyThinPlates , LayeredCentroSymmetricXS , BiLayerGauss ), a sphere with Gaussian chains attached SphereWithGaussChains and a slightly different parametrised form factor named BlockCopolymerMicelle . An additional option for reading ASCII data files is now available, which allows to convert values for the scattering vector from nm^-1 into A^-1 and vice versa.
  • 23.10.2006: Implementation of a polydsiperse star PolydisperseStar and of flexible ring polymers FlexibleRingPolymer and mMemberedTwistedRing .
  • 22.10.2006: Implementation of the form factor of a flexible polymer with Gaussian statistics (in different parameterisations Gauss, Gauss2, Gauss3 ) for a polydisperse flexible polymer with Gaussian statistics ( GaussPoly ) and a flexible ring of polymer with Gaussian statistics ( FlexiblePolymerRing )
  • 12.10.2006: Under the menu option " Calc/DLS... " next to a cumulant fit also a double stretched exponential decay can be selected to fit dynamic light scattering data.
  • 5.10.2006: Implementation of a spherical shell with a diffuse (expontential) scattering length density profile inside the shell caused by solvent penetration into the shell
  • 13.9.2006: Implementation of a form factor for spheres with gaussian chains attached.
  • 19.7.2006: first release (current version: 0.71)
    at the moment only a windows version is available. The installation files for tcl/tlk and blt are included in the distribution file.