Index: .gitignore
===================================================================
--- .gitignore	(revision 2a55a6f2f24f911b7394865b206431a89f96ead0)
+++ .gitignore	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -11,5 +11,5 @@
 /doc/api/
 /doc/model/
-/doc/ref/models
+/doc/guide/models
 .mplconfig
 /pylint_violations.txt
Index: doc/conf.py
===================================================================
--- doc/conf.py	(revision 40a87fa5096610e24c3ead10299f609e99f093f2)
+++ doc/conf.py	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -42,4 +42,7 @@
              ]
 
+# Redirect mathjax to a different CDN
+mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
Index: doc/genapi.py
===================================================================
--- doc/genapi.py	(revision a5b8477c53695e7df03ecec7346f0c1bd770d3f7)
+++ doc/genapi.py	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -2,5 +2,5 @@
 import os.path
 
-MODULE_TEMPLATE=""".. Autogenerated by genmods.py
+MODULE_TEMPLATE = """.. Autogenerated by genmods.py
 
 ******************************************************************************
@@ -19,5 +19,5 @@
 """
 
-INDEX_TEMPLATE=""".. Autogenerated by genmods.py
+INDEX_TEMPLATE = """.. Autogenerated by genmods.py
 
 .. _api-index:
@@ -46,17 +46,18 @@
         os.makedirs(dir)
 
-    for module,name in modules:
-        with open(os.path.join(dir,module+'.rst'), 'w') as f:
+    for module, name in modules:
+        with open(os.path.join(dir, module+'.rst'), 'w') as f:
             f.write(MODULE_TEMPLATE%locals())
 
-    rsts = "\n   ".join(module+'.rst' for module,name in modules)
-    with open(os.path.join(dir,'index.rst'),'w') as f:
+    rsts = "\n   ".join(module+'.rst' for module, name in modules)
+    with open(os.path.join(dir, 'index.rst'), 'w') as f:
         f.write(INDEX_TEMPLATE%locals())
 
 
-modules=[
-    #('__init__', 'Top level namespace'),
+modules = [
+    ('__init__', 'Top level namespace'),
     #('alignment', 'GPU data alignment [unused]'),
     ('bumps_model', 'Bumps interface'),
+    ('compare_many', 'Batch compare models on different compute engines'),
     ('compare', 'Compare models on different compute engines'),
     ('convert', 'Sasview to sasmodel converter'),
@@ -66,5 +67,4 @@
     ('direct_model', 'Simple interface'),
     ('exception', 'Annotate exceptions'),
-    #('frozendict', 'Freeze a dictionary to make it immutable'),
     ('generate', 'Model parser'),
     ('kernel', 'Evaluator type definitions'),
@@ -79,10 +79,10 @@
     ('resolution', '1-D resolution functions'),
     ('resolution2d', '2-D resolution functions'),
+    ('rst2html', 'Convert doc strings the web pages'),
     ('sasview_model', 'Sasview interface'),
     ('sesans', 'SESANS calculation routines'),
-    #('transition', 'Model stepper for automatic model selection'),
     ('weights', 'Distribution functions'),
 ]
-package='sasmodels'
-package_name='Reference'
+package = 'sasmodels'
+package_name = 'Reference'
 genfiles(package, package_name, modules)
Index: doc/gentoc.py
===================================================================
--- doc/gentoc.py	(revision 40a87fa5096610e24c3ead10299f609e99f093f2)
+++ doc/gentoc.py	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -16,5 +16,5 @@
     from sasmodels.modelinfo import ModelInfo
 
-TEMPLATE="""\
+TEMPLATE = """\
 ..
     Generated from doc/gentoc.py -- DO NOT EDIT --
@@ -30,5 +30,5 @@
 """
 
-MODEL_TOC_PATH = "ref/models"
+MODEL_TOC_PATH = "guide/models"
 
 def _make_category(category_name, label, title, parent=None):
@@ -65,15 +65,16 @@
         # assume model is in sasmodels/models/name.py, and ignore the full path
         model_name = basename(item)[:-3]
-        if model_name.startswith('_'): continue
+        if model_name.startswith('_'):
+            continue
         model_info = load_model_info(model_name)
         if model_info.category is None:
             print("Missing category for", item, file=sys.stderr)
         else:
-            category.setdefault(model_info.category,[]).append(model_name)
+            category.setdefault(model_info.category, []).append(model_name)
 
     # Check category names
-    for k,v in category.items():
+    for k, v in category.items():
         if len(v) == 1:
-            print("Category %s contains only %s"%(k,v[0]), file=sys.stderr)
+            print("Category %s contains only %s"%(k, v[0]), file=sys.stderr)
 
     # Generate category files for the table of contents.
@@ -86,16 +87,17 @@
     # alphabetical order before them.
 
-    if not exists(MODEL_TOC_PATH): mkdir(MODEL_TOC_PATH)
+    if not exists(MODEL_TOC_PATH):
+        mkdir(MODEL_TOC_PATH)
     model_toc = _make_category(
-        'index',  'Models', 'Model Functions')
+        'index', 'Models', 'Model Functions')
     #shape_toc = _make_category(
     #    'shape',  'Shapes', 'Shape Functions', model_toc)
     free_toc = _make_category(
-        'shape-independent',  'Shape-independent',
+        'shape-independent', 'Shape-independent',
         'Shape-Independent Functions')
     struct_toc = _make_category(
-        'structure-factor',  'Structure-factor', 'Structure Factors')
+        'structure-factor', 'Structure-factor', 'Structure Factors')
     custom_toc = _make_category(
-        'custom-models',  'Custom-models', 'Custom Models')
+        'custom-models', 'Custom-models', 'Custom Models')
 
     # remember to top level categories
@@ -109,12 +111,12 @@
 
     # Process the model lists
-    for k,v in sorted(category.items()):
+    for k, v in sorted(category.items()):
         if ':' in k:
-            cat,subcat = k.split(':')
+            cat, subcat = k.split(':')
             _maybe_make_category(cat, v, cat_files, model_toc)
             cat_file = cat_files[cat]
-            label = "-".join((cat,subcat))
+            label = "-".join((cat, subcat))
             filename = label
-            title = subcat.capitalize()+" Functions"
+            title = subcat.capitalize() + " Functions"
             sub_toc = _make_category(filename, label, title, cat_file)
             for model in sorted(v):
@@ -130,9 +132,10 @@
     _add_subcategory('shape-independent', model_toc)
     _add_subcategory('structure-factor', model_toc)
-    _add_subcategory('custom-models', model_toc)
+    #_add_subcategory('custom-models', model_toc)
 
     # Close the top-level category files
     #model_toc.close()
-    for f in cat_files.values(): f.close()
+    for f in cat_files.values():
+        f.close()
 
 
Index: doc/guide/gpu/gpu_computations.rst
===================================================================
--- doc/guide/gpu/gpu_computations.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/gpu/gpu_computations.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,68 @@
+.. _models-computation:
+
+****************
+GPU Computations
+****************
+sasmodels evaluations can run on your graphics card (GPU) or they can run
+on the processor (CPU). In general, calculations performed on the GPU will run faster.
+
+To run on the GPU, your computer must have OpenCL drivers installed.
+For information about OpenCL installation see this
+:ref:`opencl-installation` guidance.
+
+Where the model is evaluated is a little bit complicated.
+If the model has the line *single=False* then it requires double precision.
+If the GPU is single precision only, then it will try running via OpenCL
+on the CPU.  If the OpenCL driver is not available for the CPU then
+it will run as a normal program on the CPU.
+
+For models with a large number of parameters or with a lot of code,
+the GPU may be too small to run the program effectively.
+In this case, you should try simplifying the model, maybe breaking it
+into several different modules so that you don't need *IF* statements in your code.
+If it is still too big, you can set *opencl=False* in the model file and
+the model will only run as a normal program on the CPU.
+This will not usually be necessary.
+
+Device Selection
+................
+If you have multiple GPU devices you can tell SasView which device to use.
+By default, SasView looks for one GPU and one CPU device
+from available OpenCL platforms.
+
+SasView prefers AMD or NVIDIA drivers for GPU, and prefers Intel or
+Apple drivers for CPU. Both GPU and CPU are included on the assumption that CPU
+is always available and supports double precision.
+
+The device order is important: GPU is checked before CPU on the assumption that
+it will be faster. By examining ~/sasview.log you can see which device SasView
+chose to run the model.
+
+**If you don't want to use OpenCL, you can set** *SAS_OPENCL=None*
+**in your environment settings, and it will only use normal programs.**
+
+If you want to use one of the other devices, you can run the following
+from the python console in SasView::
+
+    import pyopencl as cl
+    cl.create_some_context()
+
+This will provide a menu of different OpenCL drivers available.
+When one is selected, it will say "set PYOPENCL_CTX=..."
+Use that value as the value of *SAS_OPENCL*.
+
+Compiler Selection
+..................
+For models run as normal programs, you may need to specify a compiler.
+This is done using the SAS_COMPILER environment variable.
+Set it to *tinycc* for the tinycc compiler, *msvc* for the
+Microsoft Visual C compiler, or *mingw* for the MinGW compiler.
+TinyCC is provided with SasView so that is the default.
+If you want one of the other compilers, be sure to have it available
+in your *PATH* so SasView can find it!
+
+
+*Document History*
+
+| 2016-10-08 Steve King
+| 2017-05-07 Paul Kienzle
Index: doc/guide/gpu/opencl_installation.rst
===================================================================
--- doc/guide/gpu/opencl_installation.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/gpu/opencl_installation.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,59 @@
+.. _opencl-installation:
+
+*******************
+OpenCL Installation
+*******************
+*Warning! GPU devices do not in general offer the same level of memory protection as CPU devices. If your code attempts to write outside allocated memory buffers unpredicatable behaviour may result (eg, your video display may freeze, or your system may crash, etc). Do not install OpenCL drivers without first checking for known issues (eg, some computer manufacturers install modified graphics drivers so replacing these may not be a good idea!). If in doubt, seek advice from an IT professional before proceeding further.*
+
+1. Check if you have OpenCL already installed
+=============================================
+
+Windows
+.......
+    The following instructions are based on
+    http://web.engr.oregonstate.edu/~mjb/cs475/DoIHaveOpenCL.pdf
+
+    * Go to: Start -> Control Panel -> System & Security -> Administrative Tools
+    * Double Click on Computer Managment
+    * Click on Device Manager
+    * Click open Display Adapters
+    * Right-click on available adapter and select Properties
+    * Click on Driver
+    * Go to Driver Details
+    * Scroll down and see if OpenCL is installed (look for OpenCL*.dll files)
+
+Mac OSX
+.......
+    For OS X operating systems higher than 10.6 OpenCL is shipped along with the system.
+
+    However, OpenCL has had a rocky history on Macs. Apple provide a useful compatibility table at https://support.apple.com/en-us/HT202823
+
+
+2. Installation
+===============
+
+Windows
+.......
+    Depending on the graphic card in your system, drivers
+    can be obtained from different sources:
+
+    * NVIDIA: https://developer.nvidia.com/opencl
+    * AMD: http://developer.amd.com/tools-and-sdks/opencl-zone/
+
+Mac OSX
+.......
+    N/A
+	
+	You cannot download OpenCL driver updates for your Mac. They are packaged with the normal quarterly OS X updates from Apple. 
+
+
+.. note::
+    Intel provides OpenCL drivers for Intel processors at     https://software.intel.com/en-us/articles/opencl-drivers 
+    These can sometimes make use of special vector instructions across multiple
+    processors, so it is worth installing if the GPU does not support double
+    precision. You can install this driver alongside the GPU driver for NVIDIA
+    or AMD.
+
+	
+.. note::
+    This help document was last changed by Steve King, 08Oct2016
Index: doc/guide/index.rst
===================================================================
--- doc/guide/index.rst	(revision bb6f0f3f04f718187ac81a56563b8bb7a1d216af)
+++ doc/guide/index.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -1,38 +1,15 @@
-**********
-SAS Models
-**********
+****************
+SAS Models Guide
+****************
 
-Small angle X-ray and Neutron (SAXS and SANS) scattering examines the
-scattering patterns produced by a beam travelling through the sample
-and scattering at low angles.  The scattering is computed as a function
-of $q_x$ and $q_y$, which for a given beam wavelength corresponds to
-particular scattering angles. Each pixel on the detector corresponds to
-a different scattering angle. If the sample is unoriented, the scattering
-pattern will appear as rings on the detector.  In this case, a circular
-average can be taken with 1-dimension data at $q = \surd (q_x^2 + q_y^2)$
-compared to the orientationally averaged SAS scattering pattern.
+.. toctree::
+   :numbered: 4
+   :maxdepth: 4
 
-Models have certain features in common.
-
-Every model has a *scale* and a *background*.
-
-Talk about orientation, with diagrams for orientation so that we don't need
-a link on every model page?
-
-.. _orientation:
-
-.. figure: img/orientation1.jpg
-
-    Orientation in 3D
-
-.. figure: img/orientation2.jpg
-
-    Orientation cross sections
-
-Talk about polydispersity.
-
-Talk about magnetism, converting the magnetism help file to inline text here,
-with links so that models can point back to it.
-
-Need to talk about structure factors even though we don't have any
-implemented yet.
+   intro.rst
+   gpu/gpu_computations.rst
+   gpu/opencl_installation.rst
+   magnetism/magnetism.rst
+   sesans/sans_to_sesans.rst
+   sesans/sesans_fitting.rst
+   refs.rst
Index: doc/guide/intro.rst
===================================================================
--- doc/guide/intro.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/intro.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,59 @@
+
+.. _models-intro:
+
+************
+Introduction
+************
+
+This software provides form factors for various particle shapes and computes
+resolution, polydispersity and angular dispersion. After giving a mathematical
+definition of each model, we show the list of parameters available to the user.
+Validation plots for each model are also presented.
+
+To easily compare to the scattering intensity measured in experiments, we
+normalize the form factors by the volume of the particle
+
+.. math::
+
+    P(\vec q) = \frac{P_o(\vec q)}{V} = \frac{1}{V} F(\vec q) F^*(\vec q)
+
+with
+
+.. math::
+
+    F(\vec q) = \int\int\int dV\rho(\vec r) e^{-i\vec q \cdot \vec r}
+
+where $P_0(\vec q)$ is the un-normalized form factor, $\rho(\vec r)$ is
+the scattering length density at a given point in space and the integration
+is done over the volume $V$ of the scatterer.
+
+For systems without inter-particle interference, the form factors we provide
+can be related to the scattering intensity by the particle volume fraction
+
+.. math::
+
+    I(\vec q) = \Phi P(\vec q)
+
+Our so-called 1D scattering intensity functions provide $P(Q)$ for the case
+where the scatterer is randomly oriented. In that case, the scattering
+intensity only depends on the length of $Q$ . The intensity measured on
+the plane of the SAS detector will have an azimuthal symmetry around $Q=0$.
+
+Our so-called 2D scattering intensity functions provide $P(Q,\phi)$ for an
+oriented system as a function of a $q$ vector in the plane of the detector.
+We define the angle $\phi$ as the angle between the $q$ vector and the
+horizontal ($x$) axis of the plane of the detector.
+
+For information about polarised and magnetic scattering, see :ref:`magnetism`.
+
+The models are used within the SasView package.  Instructions on how to
+use SasView itself are available separately.
+
+Many of our models use the form factor calculations as implemented in the
+C-library provided by the NIST Center for Neutron Research and thus some
+content and figures in this document are originated from or shared with
+the NIST SANS Igor-based analysis package.
+
+*Document History*
+
+| 2017-05-07 Paul Kienzle
Index: doc/guide/magnetism/magnetism.rst
===================================================================
--- doc/guide/magnetism/magnetism.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/magnetism/magnetism.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,99 @@
+.. _magnetism:
+
+Polarisation/Magnetic Scattering
+=======================================================
+
+In earlier versions of SasView magnetic scattering was implemented in just five 
+(2D) models
+
+*  :ref:`sphere`
+*  :ref:`core-shell-sphere`
+*  :ref:`core-multi-shell`
+*  :ref:`cylinder`
+*  :ref:`parallelepiped`
+
+From SasView 4.x it is implemented on most models in the 'shape' category.
+
+In general, the scattering length density (SLD = $\beta$) in each region where the
+SLD is uniform, is a combination of the nuclear and magnetic SLDs and, for polarised
+neutrons, also depends on the spin states of the neutrons.
+
+For magnetic scattering, only the magnetization component $\mathbf{M_\perp}$
+perpendicular to the scattering vector $\mathbf{Q}$ contributes to the magnetic
+scattering length.
+
+
+.. figure::
+    mag_img/mag_vector.bmp
+
+The magnetic scattering length density is then
+
+.. math::
+    \beta_M = \dfrac{\gamma r_0}{2\mu_B}\sigma \cdot
+    \mathbf{M_\perp} = D_M\sigma \cdot \mathbf{M_\perp}
+
+where $\gamma = -1.913$ is the gyromagnetic ratio, $\mu_B$ is the
+Bohr magneton, $r_0$ is the classical radius of electron, and $\sigma$
+is the Pauli spin.
+
+Assuming that incident neutrons are polarized parallel (+) and anti-parallel (-)
+to the $x'$ axis, the possible spin states after the sample are then
+
+No spin-flips (+ +) and (- -)
+
+Spin-flips    (+ -) and (- +)
+
+.. figure::
+    mag_img/M_angles_pic.bmp
+
+If the angles of the $Q$ vector and the spin-axis $x'$ to the $x$ - axis are
+$\phi$ and $\theta_{up}$, respectively, then, depending on the spin state of the
+neutrons, the scattering length densities, including the nuclear scattering
+length density ($\beta{_N}$) are
+
+.. math::
+    \beta_{\pm\pm} =  \beta_N \mp D_M M_{\perp x'}
+    \text{ when there are no spin-flips}
+
+and
+
+.. math::
+    \beta_{\pm\mp} =  -D_M (M_{\perp y'} \pm iM_{\perp z'})
+    \text{ when there are}
+
+where
+
+.. math::
+    M_{\perp x'} = M_{0q_x}\cos(\theta_{up})+M_{0q_y}\sin(\theta_{up}) \\
+    M_{\perp y'} = M_{0q_y}\cos(\theta_{up})-M_{0q_x}\sin(\theta_{up}) \\
+    M_{\perp z'} = M_{0z} \\
+    M_{0q_x} = (M_{0x}\cos\phi - M_{0y}\sin\phi)\cos\phi \\
+    M_{0q_y} = (M_{0y}\sin\phi - M_{0x}\cos\phi)\sin\phi
+
+Here, $M_{0x}$, $M_{0x}$, $M_{0z}$ are the x, y and z components
+of the magnetization vector given in the laboratory xyz frame given by
+
+.. math::
+    M_{0x} = M_0\cos\theta_M\cos\phi_M \\
+    M_{0y} = M_0\sin\theta_M \\
+    M_{0z} = -M_0\cos\theta_M\sin\phi_M
+
+and the magnetization angles $\theta_M$ and $\phi_M$ are defined in
+the figure above.
+
+The user input parameters are:
+
+===========   ================================================================
+ M0_sld        = $D_M M_0$
+ Up_theta      = $\theta_{up}$
+ M_theta       = $\theta_M$
+ M_phi         = $\phi_M$
+ Up_frac_i     = (spin up)/(spin up + spin down) neutrons *before* the sample
+ Up_frac_f     = (spin up)/(spin up + spin down) neutrons *after* the sample
+===========   ================================================================
+
+.. note::
+    The values of the 'Up_frac_i' and 'Up_frac_f' must be in the range 0 to 1.
+
+.. note::
+    This help document was last changed by Steve King, 02May2015
Index: doc/guide/refs.rst
===================================================================
--- doc/guide/refs.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/refs.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,35 @@
+.. _models-refs:
+
+**********
+References
+**********
+
+*Small-Angle Scattering of X-Rays*
+A Guinier and G Fournet
+John Wiley & Sons, New York (1955)
+
+P Stckel, R May, I Strell, Z Cejka, W Hoppe, H Heumann, W Zillig and H Crespi
+*Eur. J. Biochem.*, 112, (1980), 411-417
+
+G Porod
+in *Small Angle X-ray Scattering*
+(editors) O Glatter and O Kratky
+Academic Press (1982)
+
+*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*
+L.A Feigin and D I Svergun
+Plenum Press, New York (1987)
+
+S Hansen
+*J. Appl. Cryst.* 23, (1990), 344-346
+
+S J Henderson
+*Biophys. J.* 70, (1996), 1618-1627
+
+B C McAlister and B P Grady
+*J. Appl. Cryst.* 31, (1998), 594-599
+
+S R Kline
+*J Appl. Cryst.* 39(6), (2006), 895
+
+**Also see the references at the end of the each model function descriptions.**
Index: doc/guide/sesans/sans_to_sesans.rst
===================================================================
--- doc/guide/sesans/sans_to_sesans.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/sesans/sans_to_sesans.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,31 @@
+.. currentmodule:: sasmodels
+.. Wim Bouwman, DUT, written at codecamp-V, Oct2016
+
+.. _SESANS:
+
+SANS to SESANS conversion
+=========================
+
+The conversion from SANS into SESANS in absolute units is a simple Hankel
+transformation when all the small-angle scattered neutrons are detected.
+First we calculate the Hankel transform including the absolute intensities by
+
+.. math:: G(\delta) = 2 \pi \int_0^{\infty} J_0(Q \delta) \frac{d \Sigma}{d \Omega} (Q) Q dQ \!,
+
+in which :math:`J_0` is the zeroth order Bessel function, :math:`\delta`
+the spin-echo length, :math:`Q` the wave vector transfer and :math:`\frac{d \Sigma}{d \Omega} (Q)`
+the scattering cross section in absolute units. This is a 1-dimensional
+integral, which can be rather fast. In the numerical calculation we integrate
+from :math:`Q_{min} = 0.1 \times 2 \pi / R_{max}` in which :math:`R_{max}`
+will be model dependent. We determined the factor 0.1 by varying its value
+until the value of the integral was stable. This happened at a value of 0.3.
+The have a safety margin of a factor of three we have choosen the value 0.1.
+For the solid sphere we took 3 times the radius for :math:`R_{max}`. The real
+integration is performed to :math:`Q_{max}` which is an instrumental parameter
+that is read in from the measurement file. From the equation above we can
+calculate the polarisation that we measure in a SESANS experiment:
+
+.. math:: P(\delta) = e^{t \left( \frac{ \lambda}{2 \pi} \right)^2 \left(G(\delta) - G(0) \right)} \!,
+
+in which :math:`t` is the thickness of the sample and :math:`\lambda` is
+the wavelength of the neutrons.
Index: doc/guide/sesans/sesans_fitting.rst
===================================================================
--- doc/guide/sesans/sesans_fitting.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
+++ doc/guide/sesans/sesans_fitting.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -0,0 +1,149 @@
+.. currentmodule:: sasmodels
+.. Wim Bouwman, DUT, written at codecamp-V, Oct2016
+
+.. _sesans_fitting:
+
+Fitting SESANS Data
+===================
+
+.. note::
+
+    A proper installation of the developers setup of SasView
+    (http://trac.sasview.org/wiki/AnacondaSetup) is a prerequisite for
+    using these instructions.
+
+It is possible to fit SESANS measurements from the command line in Python.
+
+Simple Fits
+...........
+In the folder sasmodels/example the file sesans_sphere_2micron.py gives
+an example of how to fit a shape to a measurement.
+
+The command::
+
+  >python fit_sesans.py sesans_sphere_2micron.py
+
+then results in a GUI from which you can control the fit.
+
+.. image:: sesans_img/SphereLineFitSasView.png
+
+All the parameters and names in sesans_sphere_2micron.py (shown below) can
+be adjusted to fit your own problem::
+
+  """
+  This is a data file  used to load in sesans data and fit it using the bumps engine
+  """
+  from bumps.names import *
+
+  import sesansfit
+
+  # Enter the model name to use
+  model_name = "sphere"
+
+  # DO NOT MODIFY THIS LINE
+  model = sesansfit.get_bumps_model(model_name)
+
+  # Enter any custom parameters
+  # name = Parameter(initial_value, name='name')
+  phi = Parameter(0.0855, name='phi')
+  # Add the parameters to this list that should be displayed in the fitting window
+  custom_params = {"phi" : phi}
+
+  # SESANS data file name
+  sesans_file = "spheres2micron.ses"
+
+  # Initial parameter values (if other than defaults)
+  # "model_parameter_name" : value
+  initial_vals = {
+    "sld" : 1.41,
+    "radius" : 10000,
+    "sld_solvent" : 2.70,
+  }
+
+  # Ranges for parameters if other than default
+  # "model_parameter_name" : [min, max]
+  param_range = {
+    "phi" : [0.001, 0.5],
+    "radius" : [100, 100000]
+  }
+
+  # Constraints
+  # model.param_name = f(other params)
+  # EXAMPLE: model.scale = model.radius*model.radius*(1 - phi) - where radius
+  # and scale are model functions and phi is a custom parameter
+  model.scale = phi*(1-phi)
+
+  # Send to the fitting engine
+  # DO NOT MODIFY THIS LINE
+  problem = sesansfit.sesans_fit(sesans_file, model, initial_vals, custom_params, param_range)
+
+Incorporating a Structure Factor
+................................
+An example of how to also include a structure factor can be seen in the
+following example taken from Washington et al., *Soft Matter*\, (2014), 10, 3016
+(dx.doi.org/10.1039/C3SM53027B). These are time-of-flight measurements, which
+is the reason that not the polarisation is plotted, but the
+:math:`\frac{log(P/P_0)}{\lambda^2}` . The sample is a dispersion of
+core-shell colloids at a high volume fraction with hard sphere interactions.
+
+The fit can be started by::
+
+ >python fit_sesans.py sesans_parameters_css-hs.py
+
+This yields after the fitting:
+
+.. image:: sesans_img/HardSphereLineFitSasView.png
+
+The code sesans_parameters_css-hs.py can then be used as a template for a
+fitting problem with a structure factor::
+
+ """
+ This is a data file  used to load in sesans data and fit it using the bumps engine
+ """
+ from bumps.names import *
+
+ import sesansfit
+
+ # Enter the model name to use
+ model_name = "core_shell_sphere*hardsphere"
+
+ # DO NOT MODIFY THIS LINE
+ model = sesansfit.get_bumps_model(model_name)
+
+ # Enter any custom parameters
+ phi = Parameter(0.45, name='phi')
+ pen = Parameter(0.95, name='solvent penetration')
+ custom_params = {"phi" : phi, "pen" : pen}
+
+ # SESANS data file
+ sesans_file = "core_shell.ses"
+
+ # Initial parameter values (if other than defaults)
+ initial_vals = {
+    "sld_core" : 1.05,
+    "sld_shell" : 2.88*pen-0.05*(1-pen),
+    "sld_solvent" : 2.88,
+    "radius" : 730,
+    "thickness" : 20,
+    "volfraction" : phi,
+    "scale" : (1-phi)
+ }
+
+ # Ranges for parameters if other than default
+ param_range = {
+    "phi" : [0.2, 0.5],
+    "pen" : [0,1],
+    "radius" : [500, 3000],
+    "thickness" : [0,200]
+ }
+
+ # Constraints
+ # model.param_name = f(other params)
+ # EXAMPLE: model.scale = model.radius*model.radius*(1 - phi) - where radius
+ # and scale are model functions and phi is a custom parameter
+ model.scale = phi*(1-phi)
+ model.volfraction = phi
+ model.shell_sld = pen*2.88
+
+ # Send to the fitting engine
+ problem = sesansfit.sesans_fit(sesans_file, model_name, initial_vals, custom_params, param_range)
Index: doc/index.rst
===================================================================
--- doc/index.rst	(revision 5e1d6b03bc600b110bbfd643b1751800e2c02a9e)
+++ doc/index.rst	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -1,6 +1,18 @@
-Introduction
-============
+sasmodels
+=========
+Small angle X-ray and Neutron scattering (SAXS and SANS) examines the
+scattering patterns produced by a beam travelling through the sample
+and scattering at low angles.  The scattering is computed as a function
+of reciprocal space $q$, which arises from a combination of beam wavelength
+and scattering angles. Each pixel on the detector corresponds to
+a different scattering angle, and has a distinct $q_x$ and $q_y$. If the
+sample is unoriented, the scattering pattern will appear as rings on the
+detector.  In this case, a circular average can be taken with 1-dimension
+data at $q = \surd (q_x^2 + q_y^2)$ compared to the orientationally
+averaged SAS scattering pattern.
+
 The sasmodels package provides theory functions for small angle scattering
-calculations.
+calculations for different shapes, including the effects of resolution,
+polydispersity and orientational dispersion.
 
 .. htmlonly::
@@ -15,7 +27,6 @@
 
    guide/index.rst
+   guide/models/index.rst
    developer/index.rst
-   ref/index.rst
-   ref/models/index.rst
    api/index.rst
 
@@ -28,8 +39,2 @@
 .. htmlonly::
   * :ref:`search`
-
-
-
-
-  
-
Index: c/ref/gpu/gpu_computations.rst
===================================================================
--- doc/ref/gpu/gpu_computations.rst	(revision 1a6cd57bd7b12db89d69b335e984c55413295845)
+++ 	(revision )
@@ -1,66 +1,0 @@
-.. _models-computation:
-
-****************
-GPU Computations
-****************
-SasView model evaluations can run on your graphics card (GPU) or they can run
-on the processor (CPU). In general, calculations performed on the GPU will run faster.
-
-To run on the GPU, your computer must have OpenCL drivers installed.
-For information about OpenCL installation see this
-:ref:`opencl-installation` guidance.
-
-Where the model is evaluated is a little bit complicated.
-If the model has the line *single=False* then it requires double precision.
-If the GPU is single precision only, then it will try running via OpenCL
-on the CPU.  If the OpenCL driver is not available for the CPU then
-it will run as a normal program on the CPU.
-
-For models with a large number of parameters or with a lot of code,
-the GPU may be too small to run the program effectively.
-In this case, you should try simplifying the model, maybe breaking it
-into several different modules so that you don't need *IF* statements in your code.
-If it is still too big, you can set *opencl=False* in the model file and
-the model will only run as a normal program on the CPU.
-This will not usually be necessary.
-
-Device Selection
-................
-If you have multiple GPU devices you can tell SasView which device to use.
-By default, SasView looks for one GPU and one CPU device
-from available OpenCL platforms.
-
-SasView prefers AMD or NVIDIA drivers for GPU, and prefers Intel or
-Apple drivers for CPU. Both GPU and CPU are included on the assumption that CPU 
-is always available and supports double precision.
-
-The device order is important: GPU is checked before CPU on the assumption that
-it will be faster. By examining ~/sasview.log you can see which device SasView
-chose to run the model.
-
-**If you don't want to use OpenCL, you can set** *SAS_OPENCL=None*
-**in your environment settings, and it will only use normal programs.**
-
-If you want to use one of the other devices, you can run the following
-from the python console in SasView::
-
-    import pyopencl as cl
-    cl.create_some_context()
-
-This will provide a menu of different OpenCL drivers available.
-When one is selected, it will say "set PYOPENCL_CTX=..."
-Use that value as the value of *SAS_OPENCL*.
-
-Compiler Selection
-..................
-For models run as normal programs, you may need to specify a compiler.
-This is done using the SAS_COMPILER environment variable.
-Set it to *tinycc* for the tinycc compiler, *msvc* for the
-Microsoft Visual C compiler, or *mingw* for the MinGW compiler.
-TinyCC is provided with SasView so that is the default.
-If you want one of the other compilers, be sure to have it available
-in your *PATH* so SasView can find it!
-
-
-.. note::
-    This help document was last changed by Steve King, 08Oct2016
Index: c/ref/gpu/opencl_installation.rst
===================================================================
--- doc/ref/gpu/opencl_installation.rst	(revision ec8b9a3e2841d6f1ececef27cda299f684cf8285)
+++ 	(revision )
@@ -1,59 +1,0 @@
-.. _opencl-installation:
-
-*******************
-OpenCL Installation
-*******************
-*Warning! GPU devices do not in general offer the same level of memory protection as CPU devices. If your code attempts to write outside allocated memory buffers unpredicatable behaviour may result (eg, your video display may freeze, or your system may crash, etc). Do not install OpenCL drivers without first checking for known issues (eg, some computer manufacturers install modified graphics drivers so replacing these may not be a good idea!). If in doubt, seek advice from an IT professional before proceeding further.*
-
-1. Check if you have OpenCL already installed
-=============================================
-
-Windows
-.......
-    The following instructions are based on
-    http://web.engr.oregonstate.edu/~mjb/cs475/DoIHaveOpenCL.pdf
-
-    * Go to: Start -> Control Panel -> System & Security -> Administrative Tools
-    * Double Click on Computer Managment
-    * Click on Device Manager
-    * Click open Display Adapters
-    * Right-click on available adapter and select Properties
-    * Click on Driver
-    * Go to Driver Details
-    * Scroll down and see if OpenCL is installed (look for OpenCL*.dll files)
-
-Mac OSX
-.......
-    For OS X operating systems higher than 10.6 OpenCL is shipped along with the system.
-
-    However, OpenCL has had a rocky history on Macs. Apple provide a useful compatibility table at https://support.apple.com/en-us/HT202823
-
-
-2. Installation
-===============
-
-Windows
-.......
-    Depending on the graphic card in your system, drivers
-    can be obtained from different sources:
-
-    * NVIDIA: https://developer.nvidia.com/opencl
-    * AMD: http://developer.amd.com/tools-and-sdks/opencl-zone/
-
-Mac OSX
-.......
-    N/A
-	
-	You cannot download OpenCL driver updates for your Mac. They are packaged with the normal quarterly OS X updates from Apple. 
-
-
-.. note::
-    Intel provides OpenCL drivers for Intel processors at     https://software.intel.com/en-us/articles/opencl-drivers 
-    These can sometimes make use of special vector instructions across multiple
-    processors, so it is worth installing if the GPU does not support double
-    precision. You can install this driver alongside the GPU driver for NVIDIA
-    or AMD.
-
-	
-.. note::
-    This help document was last changed by Steve King, 08Oct2016
Index: c/ref/index.rst
===================================================================
--- doc/ref/index.rst	(revision 9f12fbed66bab9196fec52997bd80899d65bc9a2)
+++ 	(revision )
@@ -1,16 +1,0 @@
-*******************
-SAS Model Reference
-*******************
-
-.. toctree::
-   :numbered: 4
-   :maxdepth: 4
-
-   intro.rst
-   refs.rst
-   gpu/gpu_computations.rst
-   gpu/opencl_installation.rst
-   magnetism/magnetism.rst
-   sesans/sans_to_sesans.rst
-   sesans/sesans_fitting.rst
-   
Index: c/ref/intro.rst
===================================================================
--- doc/ref/intro.rst	(revision 9f60c06d85ba919d831dd8784f26618e41931862)
+++ 	(revision )
@@ -1,47 +1,0 @@
-
-.. _models-intro:
-
-************
-Introduction
-************
-
-Many of our models use the form factor calculations implemented in a c-library provided by the NIST Center for Neutron
-Research and thus some content and figures in this document are originated from or shared with the NIST SANS Igor-based
-analysis package.
-
-This software provides form factors for various particle shapes. After giving a mathematical definition of each model,
-we show the list of parameters available to the user. Validation plots for each model are also presented.
-
-Instructions on how to use SasView itself are available separately.
-
-To easily compare to the scattering intensity measured in experiments, we normalize the form factors by the volume of
-the particle
-
-.. math::
-
-    P(\vec q) = \frac{P_o(\vec q)}{V} = \frac{1}{V} F(\vec q) F^*(\vec q)
-
-with
-
-    F(\vec q) = \int\int\int dV\rho(\vec r) e^{-i\vec q \cdot \vec r}
-
-where $P_0(\vec q)$ is the un-normalized form factor, $\rho(\vec r)$ is the scattering length density at a given
-point in space and the integration is done over the volume $V$ of the scatterer.
-
-For systems without inter-particle interference, the form factors we provide can be related to the scattering intensity
-by the particle volume fraction
-
-.. math::
-
-    I(\vec q) = \Phi P(\vec q)
-
-Our so-called 1D scattering intensity functions provide $P(Q)$ for the case where the scatterer is randomly oriented. In
-that case, the scattering intensity only depends on the length of $Q$ . The intensity measured on the plane of the SAS
-detector will have an azimuthal symmetry around $Q=0$.
-
-Our so-called 2D scattering intensity functions provide $P(Q,\phi)$ for an oriented system as a function of a
-$q$ vector in the plane of the detector. We define the angle $\phi$ as the angle between the $q$ vector and the horizontal
-($x$) axis of the plane of the detector.
-
-For information about polarised and magnetic scattering, see :ref:`magnetism`.
-
Index: c/ref/magnetism/magnetism.rst
===================================================================
--- doc/ref/magnetism/magnetism.rst	(revision deb854fa9e01c28c36f231466b343bb667d4e687)
+++ 	(revision )
@@ -1,99 +1,0 @@
-.. _magnetism:
-
-Polarisation/Magnetic Scattering
-=======================================================
-
-In earlier versions of SasView magnetic scattering was implemented in just five 
-(2D) models
-
-*  :ref:`sphere`
-*  :ref:`core-shell-sphere`
-*  :ref:`core-multi-shell`
-*  :ref:`cylinder`
-*  :ref:`parallelepiped`
-
-From SasView 4.x it is implemented on most models in the 'shape' category.
-
-In general, the scattering length density (SLD = $\beta$) in each region where the
-SLD is uniform, is a combination of the nuclear and magnetic SLDs and, for polarised
-neutrons, also depends on the spin states of the neutrons.
-
-For magnetic scattering, only the magnetization component $\mathbf{M_\perp}$
-perpendicular to the scattering vector $\mathbf{Q}$ contributes to the magnetic
-scattering length.
-
-
-.. figure::
-    mag_img/mag_vector.bmp
-
-The magnetic scattering length density is then
-
-.. math::
-    \beta_M = \dfrac{\gamma r_0}{2\mu_B}\sigma \cdot
-    \mathbf{M_\perp} = D_M\sigma \cdot \mathbf{M_\perp}
-
-where $\gamma = -1.913$ is the gyromagnetic ratio, $\mu_B$ is the
-Bohr magneton, $r_0$ is the classical radius of electron, and $\sigma$
-is the Pauli spin.
-
-Assuming that incident neutrons are polarized parallel (+) and anti-parallel (-)
-to the $x'$ axis, the possible spin states after the sample are then
-
-No spin-flips (+ +) and (- -)
-
-Spin-flips    (+ -) and (- +)
-
-.. figure::
-    mag_img/M_angles_pic.bmp
-
-If the angles of the $Q$ vector and the spin-axis $x'$ to the $x$ - axis are
-$\phi$ and $\theta_{up}$, respectively, then, depending on the spin state of the
-neutrons, the scattering length densities, including the nuclear scattering
-length density ($\beta{_N}$) are
-
-.. math::
-    \beta_{\pm\pm} =  \beta_N \mp D_M M_{\perp x'}
-    \text{ when there are no spin-flips}
-
-and
-
-.. math::
-    \beta_{\pm\mp} =  -D_M (M_{\perp y'} \pm iM_{\perp z'})
-    \text{ when there are}
-
-where
-
-.. math::
-    M_{\perp x'} = M_{0q_x}\cos(\theta_{up})+M_{0q_y}\sin(\theta_{up}) \\
-    M_{\perp y'} = M_{0q_y}\cos(\theta_{up})-M_{0q_x}\sin(\theta_{up}) \\
-    M_{\perp z'} = M_{0z} \\
-    M_{0q_x} = (M_{0x}\cos\phi - M_{0y}\sin\phi)\cos\phi \\
-    M_{0q_y} = (M_{0y}\sin\phi - M_{0x}\cos\phi)\sin\phi
-
-Here, $M_{0x}$, $M_{0x}$, $M_{0z}$ are the x, y and z components
-of the magnetization vector given in the laboratory xyz frame given by
-
-.. math::
-    M_{0x} = M_0\cos\theta_M\cos\phi_M \\
-    M_{0y} = M_0\sin\theta_M \\
-    M_{0z} = -M_0\cos\theta_M\sin\phi_M
-
-and the magnetization angles $\theta_M$ and $\phi_M$ are defined in
-the figure above.
-
-The user input parameters are:
-
-===========   ================================================================
- M0_sld        = $D_M M_0$
- Up_theta      = $\theta_{up}$
- M_theta       = $\theta_M$
- M_phi         = $\phi_M$
- Up_frac_i     = (spin up)/(spin up + spin down) neutrons *before* the sample
- Up_frac_f     = (spin up)/(spin up + spin down) neutrons *after* the sample
-===========   ================================================================
-
-.. note::
-    The values of the 'Up_frac_i' and 'Up_frac_f' must be in the range 0 to 1.
-
-.. note::
-    This help document was last changed by Steve King, 02May2015
Index: c/ref/refs.rst
===================================================================
--- doc/ref/refs.rst	(revision 61ba6233ec36e842d625c589deec77f689b2a9b6)
+++ 	(revision )
@@ -1,35 +1,0 @@
-.. _models-refs:
-
-**********
-References
-**********
-
-*Small-Angle Scattering of X-Rays*
-A Guinier and G Fournet
-John Wiley & Sons, New York (1955)
-
-P Stckel, R May, I Strell, Z Cejka, W Hoppe, H Heumann, W Zillig and H Crespi
-*Eur. J. Biochem.*, 112, (1980), 411-417
-
-G Porod
-in *Small Angle X-ray Scattering*
-(editors) O Glatter and O Kratky
-Academic Press (1982)
-
-*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*
-L.A Feigin and D I Svergun
-Plenum Press, New York (1987)
-
-S Hansen
-*J. Appl. Cryst.* 23, (1990), 344-346
-
-S J Henderson
-*Biophys. J.* 70, (1996), 1618-1627
-
-B C McAlister and B P Grady
-*J. Appl. Cryst.* 31, (1998), 594-599
-
-S R Kline
-*J Appl. Cryst.* 39(6), (2006), 895
-
-**Also see the references at the end of the each model function descriptions.**
Index: c/ref/sesans/sans_to_sesans.rst
===================================================================
--- doc/ref/sesans/sans_to_sesans.rst	(revision 3330bb44faf647c84e605c5a75bed3f385a25a52)
+++ 	(revision )
@@ -1,26 +1,0 @@
-.. currentmodule:: sasmodels
-.. Wim Bouwman, DUT, written at codecamp-V, Oct2016
-
-.. _SESANS:
-
-SANS to SESANS conversion
-=========================
-
-The conversion from SANS into SESANS in absolute units is a simple Hankel transformation when all the small-angle scattered neutrons are detected.
-First we calculate the Hankel transform including the absolute intensities by
-
-.. math:: G(\delta) = 2 \pi \int_0^{\infty} J_0(Q \delta) \frac{d \Sigma}{d \Omega} (Q) Q dQ \!,
-
-in which :math:`J_0` is the zeroth order Bessel function, :math:`\delta` the spin-echo length, :math:`Q` the wave vector transfer
-and :math:`\frac{d \Sigma}{d \Omega} (Q)` the scattering cross section in absolute units.
-This is a 1-dimensional integral, which can be rather fast.
-In the numerical calculation we integrate from :math:`Q_{min} = 0.1 \times 2 \pi / R_{max}` in which :math:`R_{max}` will be model dependent.
-We determined the factor 0.1 by varying its value until the value of the integral was stable.
-This happened at a value of 0.3.  The have a safety margin of a factor of three we have choosen the value 0.1.
-For the solid sphere we took 3 times the radius for :math:`R_{max}`.
-The real integration is performed to :math:`Q_{max}` which is an instrumental parameter that is read in from the measurement file.
-From the equation above we can calculate the polarisation that we measure in a SESANS experiment:
-
-.. math:: P(\delta) = e^{t \left( \frac{ \lambda}{2 \pi} \right)^2 \left(G(\delta) - G(0) \right)} \!,
-
-in which :math:`t` is the thickness of the sample and :math:`\lambda` is the wavelength of the neutrons.
Index: c/ref/sesans/sesans_fitting.rst
===================================================================
--- doc/ref/sesans/sesans_fitting.rst	(revision 3330bb44faf647c84e605c5a75bed3f385a25a52)
+++ 	(revision )
@@ -1,140 +1,0 @@
-.. currentmodule:: sasmodels
-.. Wim Bouwman, DUT, written at codecamp-V, Oct2016
-
-.. _sesans_fitting:
-
-Fitting SESANS Data
-===================
-
-.. note:: A proper installation of the developers setup of SasView (http://trac.sasview.org/wiki/AnacondaSetup) is a prerequisite for using these instructions.
-
-It is possible to fit SESANS measurements from the command line in Python.
-
-Simple Fits
-...........
-In the folder sasmodels/example the file sesans_sphere_2micron.py gives an example of how to fit a shape to a measurement.
-
-The command::
-
-  >python fit_sesans.py sesans_sphere_2micron.py
-
-then results in a GUI from which you can control the fit.
-
-.. image:: sesans_img/SphereLineFitSasView.png
-
-All the parameters and names in sesans_sphere_2micron.py (shown below) can be adjusted to fit your own problem::
-
-  """
-  This is a data file  used to load in sesans data and fit it using the bumps engine
-  """
-  from bumps.names import *
-
-  import sesansfit
-
-  # Enter the model name to use
-  model_name = "sphere"
-
-  # DO NOT MODIFY THIS LINE
-  model = sesansfit.get_bumps_model(model_name)
-
-  # Enter any custom parameters
-  # name = Parameter(initial_value, name='name')
-  phi = Parameter(0.0855, name='phi')
-  # Add the parameters to this list that should be displayed in the fitting window
-  custom_params = {"phi" : phi}
-
-  # SESANS data file name
-  sesans_file = "spheres2micron.ses"
-
-  # Initial parameter values (if other than defaults)
-  # "model_parameter_name" : value
-  initial_vals = {
-    "sld" : 1.41,
-    "radius" : 10000,
-    "sld_solvent" : 2.70,
-  }
-
-  # Ranges for parameters if other than default
-  # "model_parameter_name" : [min, max]
-  param_range = {
-    "phi" : [0.001, 0.5],
-    "radius" : [100, 100000]
-  }
-
-  # Constraints
-  # model.param_name = f(other params)
-  # EXAMPLE: model.scale = model.radius*model.radius*(1 - phi) - where radius and scale are model functions and phi is
-  # a custom parameter
-  model.scale = phi*(1-phi)
-
-  # Send to the fitting engine
-  # DO NOT MODIFY THIS LINE
-  problem = sesansfit.sesans_fit(sesans_file, model, initial_vals, custom_params, param_range)
-
-Incorporating a Structure Factor
-................................
-An example of how to also include a structure factor can be seen in the following example taken from Washington et al., 
-*Soft Matter*\, (2014), 10, 3016 (dx.doi.org/10.1039/C3SM53027B). These are time-of-flight measurements, which is the 
-reason that not the polarisation is plotted, but the :math:`\frac{log(P/P_0)}{\lambda^2}` . The sample is a dispersion 
-of core-shell colloids at a high volume fraction with hard sphere interactions.
-
-The fit can be started by::
-
- >python fit_sesans.py sesans_parameters_css-hs.py
-
-This yields after the fitting:
-
-.. image:: sesans_img/HardSphereLineFitSasView.png
-
-The code sesans_parameters_css-hs.py can then be used as a template for a fitting problem with a structure factor::
-
- """
- This is a data file  used to load in sesans data and fit it using the bumps engine
- """
- from bumps.names import *
-
- import sesansfit
-
- # Enter the model name to use
- model_name = "core_shell_sphere*hardsphere"
-
- # DO NOT MODIFY THIS LINE
- model = sesansfit.get_bumps_model(model_name)
-
- # Enter any custom parameters
- phi = Parameter(0.45, name='phi')
- pen = Parameter(0.95, name='solvent penetration')
- custom_params = {"phi" : phi, "pen" : pen}
-
- # SESANS data file
- sesans_file = "core_shell.ses"
-
- # Initial parameter values (if other than defaults)
- initial_vals = {
-    "sld_core" : 1.05,
-    "sld_shell" : 2.88*pen-0.05*(1-pen),
-    "sld_solvent" : 2.88,
-    "radius" : 730,
-    "thickness" : 20,
-    "volfraction" : phi,
-    "scale" : (1-phi)
- }
-
- # Ranges for parameters if other than default
- param_range = {
-    "phi" : [0.2, 0.5],
-    "pen" : [0,1],
-    "radius" : [500, 3000],
-    "thickness" : [0,200]
- }
-
- # Constraints
- # model.param_name = f(other params)
- # EXAMPLE: model.scale = model.radius*model.radius*(1 - phi) - where radius and scale are model functions and phi is
- # a custom parameter
- model.scale = phi*(1-phi)
- model.volfraction = phi
- model.shell_sld = pen*2.88
-
- # Send to the fitting engine
- problem = sesansfit.sesans_fit(sesans_file, model_name, initial_vals, custom_params, param_range)
Index: sasmodels/rst2html.py
===================================================================
--- sasmodels/rst2html.py	(revision f2f54137cf0be59060fcf77f0a416d0fce0de7ac)
+++ sasmodels/rst2html.py	(revision 8ae853293022b5081a1e1a8c26f74eaa2b3f8a13)
@@ -38,5 +38,5 @@
     - mathml
     - mathjax
-    See `http://docutils.sourceforge.net/docs/user/config.html#math-output`_
+    See `<http://docutils.sourceforge.net/docs/user/config.html#math-output>`_
     for details.
 
