Index: doc/ref/gpu/gpu_computations.rst
===================================================================
--- doc/ref/gpu/gpu_computations.rst	(revision 711f17e515fff416ab1aa15ae93c3d245ff21525)
+++ doc/ref/gpu/gpu_computations.rst	(revision 711f17e515fff416ab1aa15ae93c3d245ff21525)
@@ -0,0 +1,66 @@
+.. _models-computation:
+
+****************
+GPU Computations
+****************
+SasView model evaluations can run on your graphics card (GPU) or they can run
+on the processor (CPU).
+
+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 the environment, 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: doc/ref/gpu/opencl_installation.rst
===================================================================
--- doc/ref/gpu/opencl_installation.rst	(revision ec8b9a3e2841d6f1ececef27cda299f684cf8285)
+++ doc/ref/gpu/opencl_installation.rst	(revision ec8b9a3e2841d6f1ececef27cda299f684cf8285)
@@ -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: c/ref/gpu_computations.rst
===================================================================
--- doc/ref/gpu_computations.rst	(revision 886fa25dbb18c6bb0e504b4c4231771e0f26d910)
+++ 	(revision )
@@ -1,56 +1,0 @@
-.. _models-complitation:
-
-****************
-GPU Computations
-****************
-SasView model evaluations can run on your graphics card (GPU) or they can run
-on the processor (CPU).
-
-To run on the GPU, your computer must have OpenCL drivers installed.
-For information about OpenCL installation see the
-:ref:`opencl-installation` documentation
-
-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 models 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.
-
-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.
-
-It 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 the environment, 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*.
-
-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
-on the path so SasView can find it.
Index: doc/ref/index.rst
===================================================================
--- doc/ref/index.rst	(revision 886fa25dbb18c6bb0e504b4c4231771e0f26d910)
+++ doc/ref/index.rst	(revision c34a31f9923326734c823a9bf9c47652ff0475e7)
@@ -9,5 +9,7 @@
    intro.rst
    refs.rst
-   gpu_computations.rst
+   gpu/gpu_computations.rst
    magnetism/magnetism.rst
    sesans/sans_to_sesans.rst
+   sesans/sesans_fitting.rst
+   
Index: c/ref/opencl_installation.rst
===================================================================
--- doc/ref/opencl_installation.rst	(revision 886fa25dbb18c6bb0e504b4c4231771e0f26d910)
+++ 	(revision )
@@ -1,51 +1,0 @@
-.. _opencl-installation:
-
-*******************
-OpenCL Installation
-*******************
-
-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 -> 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 OSXs higher than 10.6 OpenCL is shipped along with the system.
-
-
-2. Installation
-===============
-
-Windows
-=========
-    Depeneding on the graphic card on 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
-
-
-.. note::
-    Note that Intel provides an OpenCL drivers for Intel processors:
-    https://software.intel.com/en-us/articles/opencl-drivers
-    This 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.
Index: doc/ref/sesans/sesans_fitting.rst
===================================================================
--- doc/ref/sesans/sesans_fitting.rst	(revision a655e270cf0fb7be68b8d5e62c7d5cb120a45cf6)
+++ doc/ref/sesans/sesans_fitting.rst	(revision a655e270cf0fb7be68b8d5e62c7d5cb120a45cf6)
@@ -0,0 +1,140 @@
+.. 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/generate.py
===================================================================
--- sasmodels/generate.py	(revision 2e49f9e859e8f4ca13fde7469af66ddd45ae0d5f)
+++ sasmodels/generate.py	(revision 462a115f2a030c6b417271399a8421130e3c21dc)
@@ -214,4 +214,7 @@
     "1/Ang": "|Ang^-1|",
     "1/Ang^2": "|Ang^-2|",
+    "Ang^3": "|Ang^3|",
+    "1e15/cm^3": "|1e15cm^3|",
+    "Ang^3/mol": "|Ang^3|/mol",
     "1e-6/Ang^2": "|1e-6Ang^-2|",
     "degrees": "degree",
Index: sasmodels/models/be_polyelectrolyte.py
===================================================================
--- sasmodels/models/be_polyelectrolyte.py	(revision b0c42719ac9096c35137bf644db59e1c5915b06b)
+++ sasmodels/models/be_polyelectrolyte.py	(revision 5df888c6540361f7d5cf02845ce9d6a422974042)
@@ -3,31 +3,53 @@
 ----------
 This model calculates the structure factor of a polyelectrolyte solution with
-the RPA expression derived by Borue and Erukhimovich\ [#Borue]_.  The scattering intensity
-$I(q)$ is calculated as
+the RPA expression derived by Borue and Erukhimovich\ [#Borue]_.  Note however
+that the fitting procedure here does not follow the notation in that reference
+as 's' and 't' are **not** decoupled. Instead the scattering intensity $I(q)$
+is calculated as
 
 .. math::
 
-    I(q) = K\frac{q^2+k^2}{4\pi L\alpha ^2}
+    I(q) = K\frac{q^2+k^2}{4\pi L_b\alpha ^2}
     \frac{1}{1+r_{0}^2(q^2+k^2)(q^2-12hC_a/b^2)} + background
 
-    k^2 = 4\pi L(2C_s + \alpha C_a)
+    k^2 = 4\pi L_b(2C_s + \alpha C_a)
 
     r_{0}^2 = \frac{1}{\alpha \sqrt{C_a} \left( b/\sqrt{48\pi L_b}\right)}
 
-where $K$ is the contrast factor for the polymer, $L_b$ is the Bjerrum length,
-$h$ is the virial parameter, $b$ is the monomer length,
-$C_s$ is the concentration of monovalent salt, $\alpha$ is the ionization
-degree, $C_a$ is the polymer molar concentration, and $background$ is the
-incoherent background.
+where 
+
+$K$ is the contrast factor for the polymer which is defined differently than in
+other models and is given in barns where $1 barn = 10^{-24} cm^2$.  $K$ is
+defined as:
+
+.. math::
+
+    K = a^2
+
+    a = b_p - (v_p/v_s) b_s
+    
+where $b_p$ and $b_s$ are sum of the scattering lengths of the atoms
+constituting the monomer of the polymer and the sum of the scattering lengths
+of the atoms constituting the solvent molecules respectively, and $v_p$ and
+$v_s$ are the partial molar volume of the polymer and the solvent respectively
+
+$L_b$ is the Bjerrum length(|Ang|) - **Note:** This parameter needs to be
+kept constant for a given solvent and temperature! 
+
+$h$ is the virial parameter (|Ang^3|/mol) - **Note:** See [#Borue]_ for the
+correct interpretation of this parameter.  It incorporates second and third
+virial coefficients and can be Negative.
+
+$b$ is the monomer length(|Ang|), $C_s$ is the concentration of monovalent
+salt(mol/L), $\alpha$ is the ionization degree (ionization degree : ratio of
+charged monomers  to total number of monomers), $C_a$ is the polymer molar
+concentration(mol/L), and $background$ is the incoherent background.
 
 For 2D data the scattering intensity is calculated in the same way as 1D,
-where the $q$ vector is defined as
+where the $\vec q$ vector is defined as
 
 .. math::
 
     q = \sqrt{q_x^2 + q_y^2}
-
-
-NB: $1 barn = 10^{-24} cm^2$
 
 References
@@ -69,5 +91,5 @@
     ["contrast_factor",       "barns",   10.0,  [-inf, inf], "", "Contrast factor of the polymer"],
     ["bjerrum_length",        "Ang",      7.1,  [0, inf],    "", "Bjerrum length"],
-    ["virial_param",          "1/Ang^2", 12.0,  [-inf, inf], "", "Virial parameter"],
+    ["virial_param",          "Ang^3/mol", 12.0,  [-inf, inf], "", "Virial parameter"],
     ["monomer_length",        "Ang",     10.0,  [0, inf],    "", "Monomer length"],
     ["salt_concentration",    "mol/L",    0.0,  [-inf, inf], "", "Concentration of monovalent salt"],
Index: sasmodels/models/broad_peak.py
===================================================================
--- sasmodels/models/broad_peak.py	(revision b0c42719ac9096c35137bf644db59e1c5915b06b)
+++ sasmodels/models/broad_peak.py	(revision 43fe34b36fb4d68e5cf894e939f88cc312c730be)
@@ -17,5 +17,5 @@
 .. math:: I(q) = \frac{A}{q^n} + \frac{C}{1 + (|q - q_0|\xi)^m} + B
 
-Here the peak position is related to the d-spacing as $q_o = 2\pi / d_o$.
+Here the peak position is related to the d-spacing as $q_0 = 2\pi / d_0$.
 
 $A$ is the Porod law scale factor, $n$ the Porod exponent, $C$ is the
Index: sasmodels/models/core_shell_bicelle.py
===================================================================
--- sasmodels/models/core_shell_bicelle.py	(revision adc753dbe4450955415a1427496ad3341a93896e)
+++ sasmodels/models/core_shell_bicelle.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -42,13 +42,14 @@
     I(Q,\alpha) = \frac{\text{scale}}{V} \cdot
         F(Q,\alpha)^2 + \text{background}
+
 where
 
 .. math::
 
-    \begin{align}    
-    F(Q,\alpha) = &\frac{1}{V_t} \bigg[ 
-    (\rho_c - \rho_f) V_c \frac{J_1(QRsin \alpha)}{QRsin\alpha}\frac{2 \cdot QLcos\alpha}{QLcos\alpha} \\
-    &+(\rho_f - \rho_r) V_{c+f} \frac{J_1(QRsin\alpha)}{QRsin\alpha}\frac{2 \cdot Q(L+t_f)cos\alpha}{Q(L+t_f)cos\alpha} \\
-    &+(\rho_r - \rho_s) V_t \frac{J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}\frac{2 \cdot Q(L+t_f)cos\alpha}{Q(L+t_f)cos\alpha}
+        \begin{align}    
+    F(Q,\alpha) = &\bigg[ 
+    (\rho_c - \rho_f) V_c \frac{J_1(QRsin \alpha)}{QRsin\alpha}\frac{2 \cdot sin(QLcos\alpha/2)}{QLcos\alpha} \\
+    &+(\rho_f - \rho_r) V_{c+f} \frac{J_1(QRsin\alpha)}{QRsin\alpha}\frac{2 \cdot sin(Q(L/2+t_f)cos\alpha)}{Q(L+2t_f)cos\alpha} \\
+    &+(\rho_r - \rho_s) V_t \frac{J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}\frac{2 \cdot sin(Q(L/2+t_f)cos\alpha)}{Q(L+2t_f)cos\alpha}
     \bigg]
     \end{align} 
@@ -130,8 +131,8 @@
 #             ["name", "units", default, [lower, upper], "type", "description"],
 parameters = [
-    ["radius",         "Ang",       20, [0, inf],    "volume",      "Cylinder core radius"],
+    ["radius",         "Ang",       80, [0, inf],    "volume",      "Cylinder core radius"],
     ["thick_rim",  "Ang",       10, [0, inf],    "volume",      "Rim shell thickness"],
     ["thick_face", "Ang",       10, [0, inf],    "volume",      "Cylinder face thickness"],
-    ["length",         "Ang",      400, [0, inf],    "volume",      "Cylinder length"],
+    ["length",         "Ang",      50, [0, inf],    "volume",      "Cylinder length"],
     ["sld_core",       "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder core scattering length density"],
     ["sld_face",       "1e-6/Ang^2", 4, [-inf, inf], "sld",         "Cylinder face scattering length density"],
Index: sasmodels/models/core_shell_ellipsoid.py
===================================================================
--- sasmodels/models/core_shell_ellipsoid.py	(revision b99734ab1282d49787c5367528b981556b211fbd)
+++ sasmodels/models/core_shell_ellipsoid.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -11,29 +11,13 @@
 .. figure:: img/core_shell_ellipsoid_geometry.png
 
-The geometric parameters of this model are
-
-*radius_equat_core =* equatorial core radius *= Rminor_core*
-
-*X_core = polar_core / radius_equat_core = Rmajor_core / Rminor_core*
-
-*Thick_shell = equat_outer - radius_equat_core = Rminor_outer - Rminor_core*
-
-*XpolarShell = Tpolar_shell / Thick_shell = (Rmajor_outer - Rmajor_core)/
-(Rminor_outer - Rminor_core)*
-
-In terms of the original radii
-
-*polar_core = radius_equat_core * X_core*
-
-*equat_shell = radius_equat_core + Thick_shell*
-
-*polar_shell = radius_equat_core * X_core + Thick_shell * XpolarShell*
-
-(where we note that "shell" perhaps confusingly, relates to the outer radius)
+The geometric parameters of this model are shown in the diagram above, which
+shows (a) a cut through at the circular equator and (b) a cross section through
+the poles, of a prolate ellipsoid.
+
 When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate.
 *X_core = 1* is a spherical core.
 
 For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness
-pro-rata with the radius *XpolarShell = X_core*.
+pro-rata with the radius set or constrain *XpolarShell = X_core*.
 
 When including an $S(q)$, the radius in $S(q)$ is calculated to be that of
@@ -41,5 +25,7 @@
 ellipsoid. This may have some undesirable effects if the aspect ratio of the
 ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$
-- which assumes spheres - will not in any case be valid.
+- which assumes spheres - will not in any case be valid.  Generating a 
+custom product model will enable separate effective volume fraction and effective 
+radius in the $S(q)$.
 
 If SAS data are in absolute units, and the SLDs are correct, then scale should
@@ -48,8 +34,60 @@
 or contain some other units conversion factor (for example, if you have SAXS data).
 
+The calculation of intensity follows that for the solid ellipsoid, but with separate
+terms for the core-shell and shell-solvent boundaries.
+
+.. math::
+
+    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}
+
+where
+
+.. math::
+    \begin{align}    
+    F(q,\alpha) = &f(q,radius\_equat\_core,radius\_equat\_core.x\_core,\alpha) \\
+    &+ f(q,radius\_equat\_core + thick\_shell,radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha)
+    \end{align} 
+
+where
+ 
+.. math::
+
+    f(q,R_e,R_p,\alpha) = \frac{3 \Delta \rho V (\sin[qr(R_p,R_e,\alpha)]
+                - \cos[qr(R_p,R_e,\alpha)])}
+                {[qr(R_p,R_e,\alpha)]^3}
+
+and
+
+.. math::
+
+    r(R_e,R_p,\alpha) = \left[ R_e^2 \sin^2 \alpha
+        + R_p^2 \cos^2 \alpha \right]^{1/2}
+
+
+$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$,
+$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the
+rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular
+to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the
+scattering length density difference, either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$.
+
+For randomly oriented particles:
+
+.. math::
+
+   F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}
+
+
 References
 ----------
-
-R K Heenan, 2015, reparametrised the core_shell_ellipsoid model
+see for example:
+Kotlarchyk, M.; Chen, S.-H. J. Chem. Phys., 1983, 79, 2461.
+Berr, S.  J. Phys. Chem., 1987, 91, 4760.
+
+Authorship and Verification
+----------------------------
+
+* **Author:** NIST IGOR/DANSE **Date:** pre 2010
+* **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015
+* **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016
 
 """
Index: sasmodels/models/cylinder.py
===================================================================
--- sasmodels/models/cylinder.py	(revision 551398cab5792d861989a698b28f224cd85ec263)
+++ sasmodels/models/cylinder.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -14,5 +14,5 @@
 .. math::
 
-    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q) + \text{background}
+    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}
 
 where
@@ -20,5 +20,5 @@
 .. math::
 
-    F(q) = 2 (\Delta \rho) V
+    F(q,\alpha) = 2 (\Delta \rho) V
            \frac{\sin \left(\tfrac12 qL\cos\alpha \right)}
                 {\tfrac12 qL \cos \alpha}
@@ -31,7 +31,14 @@
 first order Bessel function.
 
+For randomly oriented particles:
+
+.. math::
+
+    F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}
+
+
 To provide easy access to the orientation of the cylinder, we define the
 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles
-are defined in :numref:`cylinder-angle-definition`.
+are defined in :numref:`cylinder-angle-definition` .
 
 .. _cylinder-angle-definition:
Index: sasmodels/models/ellipsoid.py
===================================================================
--- sasmodels/models/ellipsoid.py	(revision a8072067ae8a224e45d23ba71f663aadbe1ba4a9)
+++ sasmodels/models/ellipsoid.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -35,4 +35,11 @@
 to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the
 scattering length density difference between the scatterer and the solvent.
+
+For randomly oriented particles:
+
+.. math::
+
+   F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}
+
 
 To provide easy access to the orientation of the ellipsoid, we define
Index: sasmodels/models/parallelepiped.py
===================================================================
--- sasmodels/models/parallelepiped.py	(revision a8072067ae8a224e45d23ba71f663aadbe1ba4a9)
+++ sasmodels/models/parallelepiped.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -10,5 +10,5 @@
 
 | This model calculates the scattering from a rectangular parallelepiped
-| (:numref:`parallelepiped-image`).
+| (\:numref:`parallelepiped-image`\).
 | If you need to apply polydispersity, see also :ref:`rectangular-prism`.
 
Index: sasmodels/models/polymer_micelle.py
===================================================================
--- sasmodels/models/polymer_micelle.py	(revision a8072067ae8a224e45d23ba71f663aadbe1ba4a9)
+++ sasmodels/models/polymer_micelle.py	(revision bba9361c45987d76f3673d7d0a4eb16d28a8b701)
@@ -11,10 +11,55 @@
 
 The 1D scattering intensity for this model is calculated according to
-the equations given by Pedersen (Pedersen, 2000).
+the equations given by Pedersen (Pedersen, 2000), summarised briefly here.
+
+The micelle core is imagined as $N\_aggreg$ polymer heads, each of volume $v\_core$,
+which then defines a micelle core of $radius\_core$, which is a separate parameter
+even though it could be directly determined.
+The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 
+distributed around the spherical core, centred at a distance $radius\_core + d\_penetration.rg$
+from the micelle centre, where $d\_penetration$ is of order unity.
+A volume $v\_corona$ is defined for each coil.
+The model in detail seems to separately parametrise the terms for the shape of I(Q) and the
+relative intensity of each term, so use with caution and check parameters for consistency.
+The spherical core is monodisperse, so it's intensity and the cross terms may have sharp
+oscillations (use q resolution smearing if needs be to help remove them).
+
+.. math::
+    P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q)
+    
+    \beta_s = v\_core(sld\_core - sld\_solvent)
+    
+    \beta_c = v\_corona(sld\_corona - sld\_solvent)
+
+where $N = n\_aggreg$, and for the spherical core of radius $R$ 
+
+.. math::   
+   \Phi(qR)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3}
+
+whilst for the Gaussian coils
+
+.. math::
+
+   P_c(q) &= 2 [\exp(-Z) + Z - 1] / Z^2
+
+   Z &= (q R_g)^2
+
+The sphere to coil ( core to corona) and coil to coil (corona to corona) cross terms are
+approximated by:
+
+.. math::
+   
+   S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)}
+   
+   S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2
+   
+   \psi(Z)=\frac{[1-exp^{-Z}]}{Z}
 
 Validation
 ----------
 
-This model has not yet been validated. Feb2015
+$P(q)$ above is multiplied by $ndensity$, and a units conversion of 10^{-13}, so $scale$
+is likely 1.0 if the scattering data is in absolute units. This model has not yet been 
+independently validated.
 
 
@@ -31,7 +76,12 @@
 title = "Polymer micelle model"
 description = """
-    This model provides an approximate form factor, P(q), for a micelle with
-    a spherical core with Gaussian polymer chains attached to the surface.
+This model provides the form factor, $P(q)$, for a micelle with a spherical
+core and Gaussian polymer chains attached to the surface, thus may be applied
+to block copolymer micelles. To work well the Gaussian chains must be much
+smaller than the core, which is often not the case.  Please study the
+reference to Pedersen and full documentation carefully. 
     """
+
+
 category = "shape:sphere"
 
Index: sasmodels/models/spinodal.py
===================================================================
--- sasmodels/models/spinodal.py	(revision bba9361c45987d76f3673d7d0a4eb16d28a8b701)
+++ sasmodels/models/spinodal.py	(revision bba9361c45987d76f3673d7d0a4eb16d28a8b701)
@@ -0,0 +1,73 @@
+r"""
+Definition
+----------
+
+This model calculates the SAS signal of a phase separating solution under spinodal decomposition. 
+The scattering intensity $I(q)$ is calculated as
+
+.. math:: 
+    I(q) = I_{max}\frac{(1+\gamma/2)x^2}{\gamma/2+x^{2+\gamma}}+B
+
+where $x=q/q_0$ and $B$ is a flat background. The characteristic structure length 
+scales with the correlation peak at $q_0$. The exponent $\gamma$ is equal to 
+$d+1$ with d the dimensionality of the off-critical concentration mixtures.
+A transition to $\gamma=2d$ is seen near the percolation threshold into the 
+critical concentration regime.
+
+References
+----------
+
+H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures: 
+Growth rates of droplets and scaling properties of autocorrelation functions. Physica A 123,497 (1984).
+
+Authorship and Verification
+----------------------------
+
+* **Author:** Dirk Honecker **Date:** Oct 7, 2016
+* **Last Modified by:** 
+* **Last Reviewed by:** 
+"""
+
+from numpy import inf, errstate
+
+name = "spinodal"
+title = "Spinodal decomposition model"
+description = """\
+      I(q) = scale ((1+gamma/2)x^2)/(gamma/2+x^(2+gamma))+background
+
+      List of default parameters:
+      scale = scaling
+      gamma = exponent
+      x = q/q_0
+      q_0 = correlation peak position [1/A]
+      background = Incoherent background"""
+category = "shape-independent"
+
+# pylint: disable=bad-whitespace, line-too-long
+#             ["name", "units", default, [lower, upper], "type", "description"],
+parameters = [["scale",    "",      1.0, [-inf, inf], "", "Scale factor"],
+              ["gamma",      "",    3.0, [-inf, inf], "", "Exponent"],
+              ["q_0",  "1/Ang",     0.1, [-inf, inf], "", "Correlation peak position"]
+             ]
+# pylint: enable=bad-whitespace, line-too-long
+
+def Iq(q,
+       scale=1.0,
+       gamma=3.0,
+       q_0=0.1):
+    """
+    :param q:              Input q-value
+    :param scale:          Scale factor
+    :param gamma:          Exponent
+    :param q_0:            Correlation peak position
+    :return:               Calculated intensity
+    """
+    
+    with errstate(divide='ignore'):
+        x = q/q_0
+        inten = scale * ((1 + gamma / 2) * x ** 2) / (gamma / 2 + x ** (2 + gamma)) 
+    return inten
+Iq.vectorized = True  # Iq accepts an array of q values
+
+demo = dict(scale=1, background=0,
+            gamma=1, q_0=0.1)
Index: sasmodels/models/triaxial_ellipsoid.py
===================================================================
--- sasmodels/models/triaxial_ellipsoid.py	(revision a8072067ae8a224e45d23ba71f663aadbe1ba4a9)
+++ sasmodels/models/triaxial_ellipsoid.py	(revision 416f5c7f5af38d5e5d926a5b6b140a94e7e60502)
@@ -36,5 +36,5 @@
 we define the axis of the cylinder using the angles $\theta$, $\phi$
 and $\psi$. These angles are defined on
-:numref:`triaxial-ellipsoid-angles`.
+:numref:`triaxial-ellipsoid-angles` .
 The angle $\psi$ is the rotational angle around its own $c$ axis
 against the $q$ plane. For example, $\psi = 0$ when the
Index: sasmodels/resolution.py
===================================================================
--- sasmodels/resolution.py	(revision 0444c0243e485f6169a58be535fb32ead6af9478)
+++ sasmodels/resolution.py	(revision 0444c0243e485f6169a58be535fb32ead6af9478)
@@ -55,4 +55,13 @@
         return theory
 
+
+class SESANS1D(Resolution):
+
+    def __init__(self, data, q_calc):
+        self.data = data
+        self.q_calc = q_calc
+
+    def apply(self, theory):
+        return sesans.transform(self.data, self.q_calc, theory, None, None)
 
 class Pinhole1D(Resolution):
@@ -306,5 +315,5 @@
             weights[i, :] = (in_x + abs_x) * np.diff(q_edges) / (2*h)
         else:
-            for k in range(-n_height, h_height+1):
+            for k in range(-n_height, n_height+1):
                 weights[i, :] += _q_perp_weights(q_edges, qi+k*h/n_height, w)
             weights[i, :] /= 2*n_height + 1
