Index: doc/conf.py
===================================================================
--- doc/conf.py	(revision 22975f009849b1c0492f0dfb7402f0892dd11eed)
+++ doc/conf.py	(revision 39674a040d2b37f7704abd674b8a98b18ea42b4c)
@@ -56,5 +56,5 @@
 # General information about the project.
 project = 'SAS Models'
-copyright = '2014, sasview team'
+copyright = '2016, sasview team'
 
 # The version info for the project you're documenting, acts as replacement for
Index: smodels/models/_onion.py
===================================================================
--- sasmodels/models/_onion.py	(revision 5111921153c056b59ff03411e4b7b028d238ae26)
+++ 	(revision )
@@ -1,392 +1,0 @@
-r"""
-This model provides the form factor, $P(q)$, for a multi-shell sphere where
-the scattering length density (SLD) of the each shell is described by an
-exponential, linear, or constant function. The form factor is normalized by
-the volume of the sphere where the SLD is not identical to the SLD of the
-solvent. We currently provide up to 9 shells with this model.
-
-NB: *radius* represents the core radius $r_0$ and
-*thickness[k]* represents the thickness of the shell, $r_{k+1} - r_k$.
-
-Definition
-----------
-
-The 1D scattering intensity is calculated in the following way
-
-.. math::
-
-    P(q) &= [f]^2 / V_\text{particle}
-
-where
-
-.. math::
-
-    f    &= f_\text{core}
-            + \left(\sum_{\text{shell}=1}^N f_\text{shell}\right)
-            + f_\text{solvent}
-
-
-The shells are spherically symmetric with particle density $\rho(r)$ and
-constant SLD within the core and solvent, so
-
-.. math::
-
-    f_\text{core}
-        &= 4\pi\int_0^{r_\text{core}} \rho_\text{core}
-            \frac{\sin(qr)}{qr}\, r^2\,\mathrm{d}r
-        &= 3\rho_\text{core} V(r_\text{core})
-            \frac{j_1(qr_\text{core})}{qr_\text{core}} \\
-    f_\text{shell}
-        &= 4\pi\int_{r_{\text{shell}-1}}^{r_\text{shell}}
-            \rho_\text{shell}(r)\frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r \\
-    f_\text{solvent}
-        &= 4\pi\int_{r_N}^\infty
-            \rho_\text{solvent}\frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r
-        &= -3\rho_\text{solvent}V(r_N)\frac{j_1(q r_N)}{q r_N}
-
-where the spherical bessel function $j_1$ is
-
-.. math::
-
-    j_1(x) = \frac{\sin(x)}{x^2} - \frac{\cos(x)}{x}
-
-and the volume is $V(r) = \frac{4\pi}{3}r^3$. The volume of the particle
-is determined by the radius of the outer shell, so $V_\text{particle} = V(r_N)$.
-
-Now lets consider the SLD of a shell defined by
-
-.. math::
-
-    \rho_\text{shell}(r) = \begin{cases}
-        B\exp\left(A(r-r_{\text{shell}-1})/\Delta t_\text{shell}\right)
-            + C & \mbox{for } A \neq 0 \\
-        \rho_\text{in} = \text{constant} & \mbox{for } A = 0
-    \end{cases}
-
-An example of a possible SLD profile is shown below where
-$\rho_\text{in}$ and $\Delta t_\text{shell}$ stand for the
-SLD of the inner side of the $k^\text{th}$ shell and the
-thickness of the $k^\text{th}$ shell in the equation above, respectively.
-
-For $A \gt 0$,
-
-.. math::
-
-    f_\text{shell} &= 4 \pi \int_{r_{\text{shell}-1}}^{r_\text{shell}}
-        \left[ B\exp
-            \left(A (r - r_{\text{shell}-1}) / \Delta t_\text{shell} \right) + C
-        \right] \frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r \\
-    &= 3BV(r_\text{shell}) e^A h(\alpha_\text{out},\beta_\text{out})
-        - 3BV(r_{\text{shell}-1}) h(\alpha_\text{in},\beta_\text{in})
-        + 3CV(r_{\text{shell}}) \frac{j_1(\beta_\text{out})}{\beta_\text{out}}
-        - 3CV(r_{\text{shell}-1}) \frac{j_1(\beta_\text{in})}{\beta_\text{in}}
-
-for
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-    B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1}
-         &C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\
-    \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}}
-         &\alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\
-    \beta_\text{in} &= qr_{\text{shell}-1}
-        &\beta_\text{out} &= qr_\text{shell}
-    \end{align*}
-
-where $h$ is
-
- .. math::
-
-    h(x,y) = \frac{x \sin(y) - y\cos(y)}{(x^2+y^2)y}
-               - \frac{(x^2-y^2)\sin(y) - 2xy\cos(y)}{(x^2+y^2)^2y}
-
-
-For $A \sim 0$, e.g., $A = -0.0001$, this function converges to that of the
-linear SLD profile with
-$\rho_\text{shell}(r) \approx A(r-r_{\text{shell}-1})/\Delta t_\text{shell})+B$,
-so this case is equivalent to
-
-.. math::
-
-
-    f_\text{shell}
-    &=
-      3 V(r_\text{shell}) \frac{\Delta\rho_\text{shell}}{\Delta t_\text{shell}}
-        \left[\frac{
-                2 \cos(qr_\text{out})
-                    + qr_\text{out} \sin(qr_\text{out})
-            }{
-                (qr_\text{out})^4
-            }\right] \\
-     &{}
-      -3 V(r_\text{shell}) \frac{\Delta\rho_\text{shell}}{\Delta t_\text{shell}}
-        \left[\frac{
-                    2\cos(qr_\text{in})
-                +qr_\text{in}\sin(qr_\text{in})
-            }{
-                (qr_\text{in})^4
-            }\right] \\
-    &{}
-      +3\rho_\text{out}V(r_\text{shell}) \frac{j_1(qr_\text{out})}{qr_\text{out}}
-      -3\rho_\text{in}V(r_{\text{shell}-1}) \frac{j_1(qr_\text{in})}{qr_\text{in}}
-
-For $A = 0$, the exponential function has no dependence on the radius (so that
-$\rho_\text{out}$ is ignored this case) and becomes flat. We set the constant
-to $\rho_\text{in}$ for convenience, and thus the form factor contributed by
-the shells is
-
-.. math::
-
-    f_\text{shell} =
-        3\rho_\text{in}V(r_\text{shell})
-           \frac{j_1(qr_\text{out})}{qr_\text{out}}
-        - 3\rho_\text{in}V(r_{\text{shell}-1})
-            \frac{j_1(qr_\text{in})}{qr_\text{in}}
-
-.. figure:: img/onion_geometry.png
-
-    Example of an onion model profile.
-
-The 2D scattering intensity is the same as $P(q)$ above, regardless of the
-orientation of the $q$ vector which is defined as
-
-.. math::
-
-    q = \sqrt{q_x^2 + q_y^2}
-
-NB: The outer most radius is used as the effective radius for $S(q)$
-when $P(q) S(q)$ is applied.
-
-References
-----------
-
-L A Feigin and D I Svergun,
-*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*,
-Plenum Press, New York, 1987.
-"""
-
-#
-# Give a polynomial $\rho(r) = Ar^3 + Br^2 + Cr + D$ for density,
-#
-# .. math::
-#
-#    f = 4 \pi \int_a^b \rho(r) \sin(qr)/(qr) \mathrm{d}r  = h(b) - h(a)
-#
-# where
-#
-# .. math::
-#
-#    h(r) = \frac{4 \pi}{q^6}\left[
-#        (q^3(4Ar^3 + 3Br^2 + 2Cr + D) - q(24Ar + 6B)) \sin(qr)
-#      - (q^4(Ar^4 + Br^3 + Cr^2 + Dr) - q^2(12Ar^2 + 6Br + 2C) + 24A) \cos(qr)
-#    \right]
-#
-# Use the monotonic spline to get the polynomial coefficients for each shell.
-#
-# Order 0
-#
-# .. math::
-#
-#    h(r) = \frac{4 \pi}{q^3} \left[
-#       - \cos(qr) (Ar) q
-#       + \sin(qr) (A)
-#    \right]
-#
-# Order 1
-#
-# .. math::
-#
-#   h(r) = \frac{4 \pi}{q^4} \left[
-#       - \cos(qr) ( Ar^2 + Br) q^2
-#       + \sin(qr) ( Ar   + B ) q
-#       + \cos(qr) (2A        )
-#   \right]
-#
-# Order 2
-#
-# .. math::
-#  h(r) = \frac{4 \pi}{q^5} \left[
-#        - \cos(qr) ( Ar^3 +  Br^2 + Cr) q^3
-#        + \sin(qr) (3Ar^2 + 2Br   + C ) q^2
-#        + \cos(qr) (6Ar   + 2B        ) q
-#        - \sin(qr) (6A                )
-#
-# Order 3
-#
-#    h(r) = \frac{4 \pi}{q^6}\left[
-#      - \cos(qr) (  Ar^4 +  Br^3 +  Cr^2 + Dr) q^4
-#      + \sin(qr) ( 4Ar^3 + 3Br^2 + 2Cr   + D ) q^3
-#      + \cos(qr) (12Ar^2 + 6Br   + 2C        ) q^2
-#      - \sin(qr) (24Ar   + 6B                ) q
-#      - \cos(qr) (24A                        )
-#    \right]
-#
-# Order p
-#
-#    h(r) = \frac{4 \pi}{q^{2}}
-#      \sum_{k=0}^p -\frac{d^k\cos(qr)}{dr^k} \frac{d^k r\rho(r)}{dr^k} (qr)^{-k}
-#
-# Given the equation
-#
-#    f = sum_(k=0)^(n-1) h_k(r_(k+1)) - h_k(r_k)
-#
-# we can rearrange the terms so that
-#
-#    f = sum_0^(n-1) h_k(r_(k+1)) - sum_0^(n-1) h_k(r_k)
-#      = sum_1^n h_(k-1)(r_k) - sum_0^(n-1) h_k(r_k)
-#      = h_(n-1)(r_n) - h_0(r_0) + sum_1^(n-1) [h_(k-1)(r_k) - h_k(r_k)]
-#      = h_(n-1)(r_n) - h_0(r_0) - sum_1^(n-1) h_(Delta k)(r_k)
-#
-# where
-#
-#    h_(Delta k)(r) = h(Delta rho_k, r)
-#
-# for
-#
-#    Delta rho_k = (A_k-A_(k-1)) r^p + (B_k-B_(k-1)) r^(p-1) + ...
-#
-# Using l'H\^opital's Rule 6 times on the order 3 polynomial,
-#
-#   lim_(q->0) h(r) = (140D r^3 + 180C r^4 + 144B r^5 + 120A r^6)/720
-#
-
-
-from __future__ import division
-
-import numpy as np
-from numpy import inf, nan
-from math import fabs, exp, expm1
-
-name = "onion"
-title = "Onion shell model with constant, linear or exponential density"
-
-description = """\
-Form factor of mutishells normalized by the volume. Here each shell is
-described by an exponential function;
-
-	I) For A_shell != 0,
-		f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C
-	where
-		B=(sld_out-sld_in)/(exp(A_shell)-1)
-		C=sld_in-B.
-	Note that in the above case, the function becomes a linear function
-	as A_shell --> 0+ or 0-.
-
-	II) For the exact point of A_shell == 0,
-		f(r) = sld_in ,i.e., it crosses over flat function
-	Note that the 'sld_out' becaomes NULL in this case.
-
-	background:background,
-	rad_core0: radius of sphere(core)
-	thick_shell#:the thickness of the shell#
-	sld_core0: the SLD of the sphere
-	sld_solv: the SLD of the solvent
-	sld_shell: the SLD of the shell#
-	A_shell#: the coefficient in the exponential function
-"""
-
-category = "shape:sphere"
-
-
-#             ["name", "units", default, [lower, upper], "type","description"],
-parameters = [["core_sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
-               "Core scattering length density"],
-              ["core_radius", "Ang", 200., [0, inf], "",
-               "Radius of the core"],
-              ["solvent_sld", "1e-6/Ang^2", 6.4, [-inf, inf], "",
-               "Solvent scattering length density"],
-              ["n", "", 1, [0, 10], "volume",
-               "number of shells"],
-              ["in_sld[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "",
-               "scattering length density at the inner radius of shell k"],
-              ["out_sld[n]", "1e-6/Ang^2", 2.0, [-inf, inf], "",
-               "scattering length density at the outer radius of shell k"],
-              ["thickness[n]", "Ang", 40., [0, inf], "volume",
-               "Thickness of shell k"],
-              ["A[n]", "", 1.0, [-inf, inf], "",
-               "Decay rate of shell k"],
-              ]
-
-source = ["lib/sph_j1c.c", "onion.c"]
-
-
-def shape(core_sld, core_radius, solvent_sld, n, in_sld, out_sld, thickness, A):
-    """
-    SLD profile
-    """
-
-    total_radius = 1.25*(sum(thickness[:n]) + core_radius + 1)
-    dr = total_radius/400  # 400 points for a smooth plot
-
-    r = []
-    beta = []
-
-    # add in the core
-    r.append(0)
-    beta.append(core_sld)
-    r.append(core_radius)
-    beta.append(core_sld)
-
-    # add in the shells
-    for k in range(n):
-        # Left side of each shells
-        r0 = r[-1]
-        r.append(r0)
-        beta.append(in_sld[k])
-
-        if fabs(A[k]) < 1.0e-16:
-            # flat shell
-            r.append(r0 + thickness[k])
-            beta.append(out_sld[k])
-        else:
-            # exponential shell
-            # num_steps must be at least 1, so use floor()+1 rather than ceil
-            # to protect against a thickness0.
-            num_steps = np.floor(thickness[k]/dr) + 1
-            slope = (out_sld[k] - in_sld[k])/expm1(A[k])
-            const = (in_sld[k] - slope)
-            for rk in np.linspace(0, thickness[k], num_steps+1):
-                r.append(r0+rk)
-                beta.append(slope*exp(A[k]*rk/thickness[k]) + const)
-
-    # add in the solvent
-    r.append(r[-1])
-    beta.append(solvent_sld)
-    r.append(total_radius)
-    beta.append(solvent_sld)
-
-    return np.asarray(r), np.asarray(beta)
-
-def ER(core_radius, n, thickness):
-    return np.sum(thickness[:n], axis=0) + core_radius
-
-def VR(core_radius, n, thickness):
-    return 1.0
-
-demo = {
-    "solvent_sld": 2.2,
-    "core_sld": 1.0,
-    "core_radius": 100,
-    "n": 4,
-    "in_sld": [0.5, 1.5, 0.9, 2.0],
-    "out_sld": [nan, 0.9, 1.2, 1.6],
-    "thickness": [50, 75, 150, 75],
-    "A": [0, -1, 1e-4, 1],
-    # Could also specify them individually as
-    # "A[1]": 0, "A[2]": -1, "A[3]": 1e-4, "A[4]": 1,
-    }
-
-oldname = "OnionExpShellModel"
-oldpars = dict(
-    core_sld="sld_core0",
-    core_radius="rad_core0",
-    solvent_sld="sld_solv",
-    n="n_shells",
-    in_sld="sld_in_shell",
-    out_sld="sld_out_shell",
-    A="A_shell",
-    thickness="thick_shell",
-    # func_shell is always 2 in the user interface, so isn't included
-    )
Index: sasmodels/models/core_shell_ellipsoid.py
===================================================================
--- sasmodels/models/core_shell_ellipsoid.py	(revision 29172aa52f4fdcefe534e792b14ec43221514fe1)
+++ sasmodels/models/core_shell_ellipsoid.py	(revision 65bf704bd7e7c00248fb713302485bca120a040b)
@@ -117,4 +117,13 @@
 source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", "core_shell_ellipsoid.c"]
 
+def ER(equat_shell, polar_shell):
+    """
+        Returns the effective radius used in the S*P calculation
+    """
+    import numpy as np
+    from .ellipsoid import ER as ellipsoid_ER
+    return ellipsoid_ER(rpolar, equat_shell)
+
+
 demo = dict(scale=1, background=0.001,
             equat_core=200.0,
Index: sasmodels/models/core_shell_ellipsoid_xt.py
===================================================================
--- sasmodels/models/core_shell_ellipsoid_xt.py	(revision 3556ad79872d55bd8cff8b5ca27db3a80f326f98)
+++ sasmodels/models/core_shell_ellipsoid_xt.py	(revision 65bf704bd7e7c00248fb713302485bca120a040b)
@@ -103,4 +103,13 @@
           "core_shell_ellipsoid_xt.c"]
 
+def ER(equat_core, x_core, t_shell, x_polar_shell):
+    """
+        Returns the effective radius used in the S*P calculation
+    """
+    import numpy as np
+    from .ellipsoid import ER as ellipsoid_ER
+    return ellipsoid_ER(equat_core*x_core + t_shell*x_polar_shell, equat_shell + t_shell)
+
+
 demo = dict(scale=0.05, background=0.001,
             equat_core=20.0,
Index: sasmodels/models/flexible_cylinder_elliptical.py
===================================================================
--- sasmodels/models/flexible_cylinder_elliptical.py	(revision b66d38efa49109d61182ada21c4f30e06f75d4cd)
+++ sasmodels/models/flexible_cylinder_elliptical.py	(revision 65bf704bd7e7c00248fb713302485bca120a040b)
@@ -85,5 +85,5 @@
 from numpy import inf
 
-name = "flexible_cylinder_ex"
+name = "flexible_cylinder_elliptical"
 title = "Flexible cylinder wth an elliptical cross section and a uniform " \
         "scattering length density."
Index: sasmodels/models/micelle_spherical_core.py
===================================================================
--- sasmodels/models/micelle_spherical_core.py	(revision 0d0aee160a94e4d66091b571a5117dc34ac0052a)
+++ sasmodels/models/micelle_spherical_core.py	(revision db74c47822e8b4c809499a9d9a0c2e0bfc7940ee)
@@ -2,5 +2,7 @@
 
 This model provides the form factor, $P(q)$, for a micelle with a spherical
-core and Gaussian polymer chains attached to the surface.
+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 carefully.
 
 Definition
@@ -16,6 +18,6 @@
 
 
-Reference
----------
+References
+----------
 
 J Pedersen, *J. Appl. Cryst.*, 33 (2000) 637-640
@@ -37,10 +39,10 @@
 parameters = [
     ["ndensity",      "1e15/cm^3",  8.94, [0.0, inf], "", "Number density of micelles"],
-    ["v_core",        "Ang^3",  62624.0,  [0.0, inf], "", "Core volume"],
+    ["v_core",        "Ang^3",  62624.0,  [0.0, inf], "", "Core volume "],
     ["v_corona",      "Ang^3",  61940.0,  [0.0, inf], "", "Corona volume"],
-    ["solvent_sld",   "1e-6/Ang^2", 6.4,  [0.0, inf], "", "Solvent scattering length density"],
-    ["core_sld",      "1e-6/Ang^2", 0.34, [0.0, inf], "", "Core scattering length density"],
-    ["corona_sld",    "1e-6/Ang^2", 0.8,  [0.0, inf], "", "Corona scattering length density"],
-    ["radius_core",   "Ang",       45.0,  [0.0, inf], "", "Radius of core"],
+    ["sld_solvent",   "1e-6/Ang^2", 6.4,  [0.0, inf], "", "Solvent scattering length density"],
+    ["sld_core",      "1e-6/Ang^2", 0.34, [0.0, inf], "", "Core scattering length density"],
+    ["sld_corona",    "1e-6/Ang^2", 0.8,  [0.0, inf], "", "Corona scattering length density"],
+    ["radius_core",   "Ang",       45.0,  [0.0, inf], "", "Radius of core ( must be >> radius_gyr )"],
     ["radius_gyr",    "Ang",       20.0,  [0.0, inf], "", "Radius of gyration of chains in corona"],
     ["d_penetration", "",           1.0,  [-inf, inf], "", "Factor to mimic non-penetration of Gaussian chains"],
@@ -55,7 +57,7 @@
             v_core=62624.0,
             v_corona=61940.0,
-            solvent_sld=6.4,
-            core_sld=0.34,
-            corona_sld=0.8,
+            sld_solvent=6.4,
+            sld_core=0.34,
+            sld_corona=0.8,
             radius_core=45.0,
             radius_gyr=20.0,
@@ -65,9 +67,10 @@
 
 oldname = 'MicelleSphCoreModel'
-oldpars = dict(solvent_sld='rho_solv',
-               core_sld='rho_core',
-               corona_sld='rho_corona')
+oldpars = dict(sld_solvent='rho_solv',
+               sld_core='rho_core',
+               sld_corona='rho_corona')
 
 tests = [
     [{}, 0.01, 15.3532],
     ]
+# RKH 20Mar2016 - need to check whether the core & corona volumes are per monomer ??? and how aggregation number works!
Index: sasmodels/models/onion.py
===================================================================
--- sasmodels/models/onion.py	(revision 6a8fdfe497ace4a16ba0ab4b8bb00a726a419103)
+++ sasmodels/models/onion.py	(revision 6a8fdfe497ace4a16ba0ab4b8bb00a726a419103)
@@ -0,0 +1,398 @@
+r"""
+This model provides the form factor, $P(q)$, for a multi-shell sphere where
+the scattering length density (SLD) of the each shell is described by an
+exponential, linear, or constant function. The form factor is normalized by
+the volume of the sphere where the SLD is not identical to the SLD of the
+solvent. We currently provide up to 9 shells with this model.
+
+NB: *radius* represents the core radius $r_0$ and
+*thickness[k]* represents the thickness of the shell, $r_{k+1} - r_k$.
+
+Definition
+----------
+
+The 1D scattering intensity is calculated in the following way
+
+.. math::
+
+    P(q) &= [f]^2 / V_\text{particle}
+
+where
+
+.. math::
+
+    f    &= f_\text{core}
+            + \left(\sum_{\text{shell}=1}^N f_\text{shell}\right)
+            + f_\text{solvent}
+
+
+The shells are spherically symmetric with particle density $\rho(r)$ and
+constant SLD within the core and solvent, so
+
+.. math::
+
+    f_\text{core}
+        &= 4\pi\int_0^{r_\text{core}} \rho_\text{core}
+            \frac{\sin(qr)}{qr}\, r^2\,\mathrm{d}r
+        &= 3\rho_\text{core} V(r_\text{core})
+            \frac{j_1(qr_\text{core})}{qr_\text{core}} \\
+    f_\text{shell}
+        &= 4\pi\int_{r_{\text{shell}-1}}^{r_\text{shell}}
+            \rho_\text{shell}(r)\frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r \\
+    f_\text{solvent}
+        &= 4\pi\int_{r_N}^\infty
+            \rho_\text{solvent}\frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r
+        &= -3\rho_\text{solvent}V(r_N)\frac{j_1(q r_N)}{q r_N}
+
+where the spherical bessel function $j_1$ is
+
+.. math::
+
+    j_1(x) = \frac{\sin(x)}{x^2} - \frac{\cos(x)}{x}
+
+and the volume is $V(r) = \frac{4\pi}{3}r^3$. The volume of the particle
+is determined by the radius of the outer shell, so $V_\text{particle} = V(r_N)$.
+
+Now lets consider the SLD of a shell defined by
+
+.. math::
+
+    \rho_\text{shell}(r) = \begin{cases}
+        B\exp\left(A(r-r_{\text{shell}-1})/\Delta t_\text{shell}\right)
+            + C & \mbox{for } A \neq 0 \\
+        \rho_\text{in} = \text{constant} & \mbox{for } A = 0
+    \end{cases}
+
+An example of a possible SLD profile is shown below where
+$\rho_\text{in}$ and $\Delta t_\text{shell}$ stand for the
+SLD of the inner side of the $k^\text{th}$ shell and the
+thickness of the $k^\text{th}$ shell in the equation above, respectively.
+
+For $A \gt 0$,
+
+.. math::
+
+    f_\text{shell} &= 4 \pi \int_{r_{\text{shell}-1}}^{r_\text{shell}}
+        \left[ B\exp
+            \left(A (r - r_{\text{shell}-1}) / \Delta t_\text{shell} \right) + C
+        \right] \frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r \\
+    &= 3BV(r_\text{shell}) e^A h(\alpha_\text{out},\beta_\text{out})
+        - 3BV(r_{\text{shell}-1}) h(\alpha_\text{in},\beta_\text{in})
+        + 3CV(r_{\text{shell}}) \frac{j_1(\beta_\text{out})}{\beta_\text{out}}
+        - 3CV(r_{\text{shell}-1}) \frac{j_1(\beta_\text{in})}{\beta_\text{in}}
+
+for
+
+.. math::
+    :nowrap:
+
+    \begin{align*}
+    B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1}
+         &C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\
+    \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}}
+         &\alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\
+    \beta_\text{in} &= qr_{\text{shell}-1}
+        &\beta_\text{out} &= qr_\text{shell}
+    \end{align*}
+
+where $h$ is
+
+ .. math::
+
+    h(x,y) = \frac{x \sin(y) - y\cos(y)}{(x^2+y^2)y}
+               - \frac{(x^2-y^2)\sin(y) - 2xy\cos(y)}{(x^2+y^2)^2y}
+
+
+For $A \sim 0$, e.g., $A = -0.0001$, this function converges to that of the
+linear SLD profile with
+$\rho_\text{shell}(r) \approx A(r-r_{\text{shell}-1})/\Delta t_\text{shell})+B$,
+so this case is equivalent to
+
+.. math::
+
+
+    f_\text{shell}
+    &=
+      3 V(r_\text{shell}) \frac{\Delta\rho_\text{shell}}{\Delta t_\text{shell}}
+        \left[\frac{
+                2 \cos(qr_\text{out})
+                    + qr_\text{out} \sin(qr_\text{out})
+            }{
+                (qr_\text{out})^4
+            }\right] \\
+     &{}
+      -3 V(r_\text{shell}) \frac{\Delta\rho_\text{shell}}{\Delta t_\text{shell}}
+        \left[\frac{
+                    2\cos(qr_\text{in})
+                +qr_\text{in}\sin(qr_\text{in})
+            }{
+                (qr_\text{in})^4
+            }\right] \\
+    &{}
+      +3\rho_\text{out}V(r_\text{shell}) \frac{j_1(qr_\text{out})}{qr_\text{out}}
+      -3\rho_\text{in}V(r_{\text{shell}-1}) \frac{j_1(qr_\text{in})}{qr_\text{in}}
+
+For $A = 0$, the exponential function has no dependence on the radius (so that
+$\rho_\text{out}$ is ignored this case) and becomes flat. We set the constant
+to $\rho_\text{in}$ for convenience, and thus the form factor contributed by
+the shells is
+
+.. math::
+
+    f_\text{shell} =
+        3\rho_\text{in}V(r_\text{shell})
+           \frac{j_1(qr_\text{out})}{qr_\text{out}}
+        - 3\rho_\text{in}V(r_{\text{shell}-1})
+            \frac{j_1(qr_\text{in})}{qr_\text{in}}
+
+.. figure:: img/onion_geometry.png
+
+    Example of an onion model profile.
+
+The 2D scattering intensity is the same as $P(q)$ above, regardless of the
+orientation of the $q$ vector which is defined as
+
+.. math::
+
+    q = \sqrt{q_x^2 + q_y^2}
+
+NB: The outer most radius is used as the effective radius for $S(q)$
+when $P(q) S(q)$ is applied.
+
+References
+----------
+
+L A Feigin and D I Svergun,
+*Structure Analysis by Small-Angle X-Ray and Neutron Scattering*,
+Plenum Press, New York, 1987.
+"""
+
+#
+# Give a polynomial $\rho(r) = Ar^3 + Br^2 + Cr + D$ for density,
+#
+# .. math::
+#
+#    f = 4 \pi \int_a^b \rho(r) \sin(qr)/(qr) \mathrm{d}r  = h(b) - h(a)
+#
+# where
+#
+# .. math::
+#
+#    h(r) = \frac{4 \pi}{q^6}\left[
+#        (q^3(4Ar^3 + 3Br^2 + 2Cr + D) - q(24Ar + 6B)) \sin(qr)
+#      - (q^4(Ar^4 + Br^3 + Cr^2 + Dr) - q^2(12Ar^2 + 6Br + 2C) + 24A) \cos(qr)
+#    \right]
+#
+# Use the monotonic spline to get the polynomial coefficients for each shell.
+#
+# Order 0
+#
+# .. math::
+#
+#    h(r) = \frac{4 \pi}{q^3} \left[
+#       - \cos(qr) (Ar) q
+#       + \sin(qr) (A)
+#    \right]
+#
+# Order 1
+#
+# .. math::
+#
+#   h(r) = \frac{4 \pi}{q^4} \left[
+#       - \cos(qr) ( Ar^2 + Br) q^2
+#       + \sin(qr) ( Ar   + B ) q
+#       + \cos(qr) (2A        )
+#   \right]
+#
+# Order 2
+#
+# .. math::
+#  h(r) = \frac{4 \pi}{q^5} \left[
+#        - \cos(qr) ( Ar^3 +  Br^2 + Cr) q^3
+#        + \sin(qr) (3Ar^2 + 2Br   + C ) q^2
+#        + \cos(qr) (6Ar   + 2B        ) q
+#        - \sin(qr) (6A                )
+#
+# Order 3
+#
+#    h(r) = \frac{4 \pi}{q^6}\left[
+#      - \cos(qr) (  Ar^4 +  Br^3 +  Cr^2 + Dr) q^4
+#      + \sin(qr) ( 4Ar^3 + 3Br^2 + 2Cr   + D ) q^3
+#      + \cos(qr) (12Ar^2 + 6Br   + 2C        ) q^2
+#      - \sin(qr) (24Ar   + 6B                ) q
+#      - \cos(qr) (24A                        )
+#    \right]
+#
+# Order p
+#
+#    h(r) = \frac{4 \pi}{q^{2}}
+#      \sum_{k=0}^p -\frac{d^k\cos(qr)}{dr^k} \frac{d^k r\rho(r)}{dr^k} (qr)^{-k}
+#
+# Given the equation
+#
+#    f = sum_(k=0)^(n-1) h_k(r_(k+1)) - h_k(r_k)
+#
+# we can rearrange the terms so that
+#
+#    f = sum_0^(n-1) h_k(r_(k+1)) - sum_0^(n-1) h_k(r_k)
+#      = sum_1^n h_(k-1)(r_k) - sum_0^(n-1) h_k(r_k)
+#      = h_(n-1)(r_n) - h_0(r_0) + sum_1^(n-1) [h_(k-1)(r_k) - h_k(r_k)]
+#      = h_(n-1)(r_n) - h_0(r_0) - sum_1^(n-1) h_(Delta k)(r_k)
+#
+# where
+#
+#    h_(Delta k)(r) = h(Delta rho_k, r)
+#
+# for
+#
+#    Delta rho_k = (A_k-A_(k-1)) r^p + (B_k-B_(k-1)) r^(p-1) + ...
+#
+# Using l'H\^opital's Rule 6 times on the order 3 polynomial,
+#
+#   lim_(q->0) h(r) = (140D r^3 + 180C r^4 + 144B r^5 + 120A r^6)/720
+#
+
+
+from __future__ import division
+
+import numpy as np
+from numpy import inf, nan
+from math import fabs, exp, expm1
+
+name = "onion"
+title = "Onion shell model with constant, linear or exponential density"
+
+description = """\
+Form factor of mutishells normalized by the volume. Here each shell is
+described by an exponential function;
+
+	I) For A_shell != 0,
+		f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C
+	where
+		B=(sld_out-sld_in)/(exp(A_shell)-1)
+		C=sld_in-B.
+	Note that in the above case, the function becomes a linear function
+	as A_shell --> 0+ or 0-.
+
+	II) For the exact point of A_shell == 0,
+		f(r) = sld_in ,i.e., it crosses over flat function
+	Note that the 'sld_out' becaomes NULL in this case.
+
+	background:background,
+	rad_core0: radius of sphere(core)
+	thick_shell#:the thickness of the shell#
+	sld_core0: the SLD of the sphere
+	sld_solv: the SLD of the solvent
+	sld_shell: the SLD of the shell#
+	A_shell#: the coefficient in the exponential function
+"""
+
+category = "shape:sphere"
+
+
+#             ["name", "units", default, [lower, upper], "type","description"],
+parameters = [["core_sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
+               "Core scattering length density"],
+              ["core_radius", "Ang", 200., [0, inf], "",
+               "Radius of the core"],
+              ["solvent_sld", "1e-6/Ang^2", 6.4, [-inf, inf], "",
+               "Solvent scattering length density"],
+              ["n", "", 1, [0, 10], "volume",
+               "number of shells"],
+              ["in_sld[n]", "1e-6/Ang^2", 1.7, [-inf, inf], "",
+               "scattering length density at the inner radius of shell k"],
+              ["out_sld[n]", "1e-6/Ang^2", 2.0, [-inf, inf], "",
+               "scattering length density at the outer radius of shell k"],
+              ["thickness[n]", "Ang", 40., [0, inf], "volume",
+               "Thickness of shell k"],
+              ["A[n]", "", 1.0, [-inf, inf], "",
+               "Decay rate of shell k"],
+              ]
+
+#source = ["lib/sph_j1c.c", "onion.c"]
+
+def Iq(q, *args, **kw):
+    return q
+
+def Iqxy(qx, *args, **kw):
+    return qx
+
+
+def shape(core_sld, core_radius, solvent_sld, n, in_sld, out_sld, thickness, A):
+    """
+    SLD profile
+    """
+
+    total_radius = 1.25*(sum(thickness[:n]) + core_radius + 1)
+    dr = total_radius/400  # 400 points for a smooth plot
+
+    r = []
+    beta = []
+
+    # add in the core
+    r.append(0)
+    beta.append(core_sld)
+    r.append(core_radius)
+    beta.append(core_sld)
+
+    # add in the shells
+    for k in range(n):
+        # Left side of each shells
+        r0 = r[-1]
+        r.append(r0)
+        beta.append(in_sld[k])
+
+        if fabs(A[k]) < 1.0e-16:
+            # flat shell
+            r.append(r0 + thickness[k])
+            beta.append(out_sld[k])
+        else:
+            # exponential shell
+            # num_steps must be at least 1, so use floor()+1 rather than ceil
+            # to protect against a thickness0.
+            num_steps = np.floor(thickness[k]/dr) + 1
+            slope = (out_sld[k] - in_sld[k])/expm1(A[k])
+            const = (in_sld[k] - slope)
+            for rk in np.linspace(0, thickness[k], num_steps+1):
+                r.append(r0+rk)
+                beta.append(slope*exp(A[k]*rk/thickness[k]) + const)
+
+    # add in the solvent
+    r.append(r[-1])
+    beta.append(solvent_sld)
+    r.append(total_radius)
+    beta.append(solvent_sld)
+
+    return np.asarray(r), np.asarray(beta)
+
+def ER(core_radius, n, thickness):
+    return np.sum(thickness[:n], axis=0) + core_radius
+
+def VR(core_radius, n, thickness):
+    return 1.0
+
+demo = {
+    "solvent_sld": 2.2,
+    "core_sld": 1.0,
+    "core_radius": 100,
+    "n": 4,
+    "in_sld": [0.5, 1.5, 0.9, 2.0],
+    "out_sld": [nan, 0.9, 1.2, 1.6],
+    "thickness": [50, 75, 150, 75],
+    "A": [0, -1, 1e-4, 1],
+    # Could also specify them individually as
+    # "A[1]": 0, "A[2]": -1, "A[3]": 1e-4, "A[4]": 1,
+    }
+
+oldname = "OnionExpShellModel"
+oldpars = dict(
+    core_sld="sld_core0",
+    core_radius="rad_core0",
+    solvent_sld="sld_solv",
+    n="n_shells",
+    in_sld="sld_in_shell",
+    out_sld="sld_out_shell",
+    A="A_shell",
+    thickness="thick_shell",
+    # func_shell is always 2 in the user interface, so isn't included
+    )
Index: sasmodels/models/pringle.py
===================================================================
--- sasmodels/models/pringle.py	(revision 1805a9e1634c4a831edc2938742a6e50061666eb)
+++ sasmodels/models/pringle.py	(revision af4da9073520cc02d19d5fd57ede5b6e48de322c)
@@ -43,5 +43,6 @@
 ---------
 
-S Alexandru Rautu, Private Communication.
+Stefan Alexandru Rautu, Private Communication. 2012.
+As of 2016: stefanar@ncbs.res.in
 
 """
Index: sasmodels/sesans.py
===================================================================
--- sasmodels/sesans.py	(revision a154ad16d63ac5a27901c7c6b1f82e588f89f154)
+++ sasmodels/sesans.py	(revision c94577f038b813ab23072f3ec552add5da36539e)
@@ -189,4 +189,5 @@
         integral = besselj(0, q*SElength_i)*Iq*q
         G[i] = np.sum(integral)
+    G0 = np.sum(Iq*q)
 
     # [m^-1] step size in q, needed for integration
@@ -195,6 +196,7 @@
     # integration step, convert q into [m**-1] and 2 pi circle integration
     G *= dq*1e10*2*pi
-
-    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G[0]))
+    G0 *= dq*1e10*2*pi
+
+    P = exp(thickness*wavelength**2/(4*pi**2)*(G-G0))
 
     return P
