Index: smodels/models/lamellarCaille.py
===================================================================
--- sasmodels/models/lamellarCaille.py	(revision aa2edb2b2fb550caed0506dcf63bc7eac7e1779a)
+++ 	(revision )
@@ -1,129 +1,0 @@
-r"""
-This model provides the scattering intensity, $I(q) = P(q) S(q)$, for a
-lamellar phase where a random distribution in solution are assumed.
-Here a Caille $S(q)$ is used for the lamellar stacks.
-
-Definition
-----------
-
-The scattering intensity $I(q)$ is
-
-.. math::
-
-    I(q) = 2\pi \frac{P(q)S(q)}{\delta q^2}
-
-The form factor is
-
-.. math::
-
-    P(q) = \frac{2\Delta\rho^2}{q^2}\left(1-\cos q\delta \right)
-
-and the structure factor is
-
-.. math::
-
-    S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right)
-           \cos(qdn)\exp\left(-\frac{2q^2d^2\alpha(n)}{2}\right)
-
-where
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-    \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)
-              && \\
-    \gamma_E  &= 0.5772156649
-              && \text{Euler's constant} \\
-    \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}}
-              && \text{Caille constant}
-    \end{align*}
-
-Here $d$ = (repeat) spacing, $\delta$ = bilayer thickness,
-the contrast $\Delta\rho$ = SLD(headgroup) - SLD(solvent),
-$K$ = smectic bending elasticity, $B$ = compression modulus, and
-$N$ = number of lamellar plates (*n_plates*).
-
-NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the
-assumptions of the model are incorrect.** And due to a complication of the
-model function, users are responsible for making sure that all the assumptions
-are handled accurately (see the original reference below for more details).
-
-Non-integer numbers of stacks are calculated as a linear combination of
-results for the next lower and higher values.
-
-The 2D scattering intensity is calculated in the same way as 1D, where the
-$q$ vector is defined as
-
-.. math::
-
-    q = \sqrt{q_x^2 + q_y^2}
-
-
-References
-----------
-
-F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
-
-also in J. Phys. Chem. B, 105, (2001) 11081-11088
-"""
-from numpy import inf
-
-name = "lamellarPS"
-title = "Random lamellar sheet with Caille structure factor"
-description = """\
-    [Random lamellar phase with Caille  structure factor]
-    randomly oriented stacks of infinite sheets
-    with Caille S(Q), having polydisperse spacing.
-    sld = sheet scattering length density
-    sld_solvent = solvent scattering length density
-    background = incoherent background
-    scale = scale factor
-"""
-category = "shape:lamellae"
-
-single = False
-# pylint: disable=bad-whitespace, line-too-long
-#             ["name", "units", default, [lower, upper], "type","description"],
-parameters = [
-    ["thickness",        "Ang",      30.0,  [0, inf],   "volume", "sheet thickness"],
-    ["Nlayers",          "",          20,   [0, inf],   "",       "Number of layers"],
-    ["spacing",          "Ang",      400.,  [0.0,inf],  "volume", "d-spacing of Caille S(Q)"],
-    ["Caille_parameter", "1/Ang^2",    0.1, [0.0,0.8],  "",       "Caille parameter"],
-    ["sld",              "1e-6/Ang^2", 6.3, [-inf,inf], "",       "layer scattering length density"],
-    ["solvent_sld",      "1e-6/Ang^2", 1.0, [-inf,inf], "",       "Solvent scattering length density"],
-    ]
-# pylint: enable=bad-whitespace, line-too-long
-
-source = ["lamellarCaille_kernel.c"]
-
-# No volume normalization despite having a volume parameter
-# This should perhaps be volume normalized?
-form_volume = """
-    return 1.0;
-    """
-
-Iqxy = """
-    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
-    """
-
-# ER defaults to 0.0
-# VR defaults to 1.0
-
-demo = dict(scale=1, background=0,
-            thickness=67., Nlayers=3.75, spacing=200.,
-            Caille_parameter=0.268, sld=1.0, solvent_sld=6.34,
-            thickness_pd=0.1, thickness_pd_n=100,
-            spacing_pd=0.05, spacing_pd_n=40)
-
-oldname = 'LamellarPSModel'
-oldpars = dict(thickness='delta', Nlayers='N_plates',
-               Caille_parameter='caille',
-               sld='sld_bi', solvent_sld='sld_sol')
-#
-tests = [
-    [{'scale': 1.0, 'background': 0.0, 'thickness': 30., 'Nlayers': 20.0,
-      'spacing': 400., 'Caille_parameter': 0.1, 'sld': 6.3,
-      'solvent_sld': 1.0, 'thickness_pd': 0.0, 'spacing_pd': 0.0},
-     [0.001], [28895.13397]]
-    ]
Index: smodels/models/lamellarCailleHG.py
===================================================================
--- sasmodels/models/lamellarCailleHG.py	(revision aa2edb2b2fb550caed0506dcf63bc7eac7e1779a)
+++ 	(revision )
@@ -1,148 +1,0 @@
-# Note: model title and parameter table are inserted automatically
-r"""
-This model provides the scattering intensity, $I(q) = P(q)S(q)$, for a lamellar
-phase where a random distribution in solution are assumed. Here a Caille $S(q)$
-is used for the lamellar stacks.
-
-The scattering intensity $I(q)$ is
-
-.. math::
-
-    I(q) = 2 \pi \frac{P(q)S(q)}{\delta q^2}
-
-
-The form factor $P(q)$ is
-
-.. math::
-
-        P(q) = \frac{4}{q^2}\big\{
-        \Delta\rho_H \left[\sin[q(\delta_H + \delta_T)] - \sin(q\delta_T)\right]
-            + \Delta\rho_T\sin(q\delta_T)\big\}^2
-
-and the structure factor $S(q)$ is
-
-.. math::
-
-    S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right)
-        \cos(qdn)\exp\left(-\frac{2q^2d^2\alpha(n)}{2}\right)
-
-where
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-    \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)
-              &&  \\
-    \gamma_E  &= 0.5772156649
-              && \text{Euler's constant} \\
-    \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}}
-              && \text{Caille constant}
-    \end{align*}
-
-
-$\delta_T$ is the tail length (or *tail_length*), $\delta_H$ is the head
-thickness (or *head_length*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent),
-and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing,
-$K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the
-number of lamellar plates (*Nlayers*).
-
-NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the
-assumptions of the model are incorrect.**  And due to a complication of the
-model function, users are responsible for making sure that all the assumptions
-are handled accurately (see the original reference below for more details).
-
-Non-integer numbers of stacks are calculated as a linear combination of
-results for the next lower and higher values.
-
-The 2D scattering intensity is calculated in the same way as 1D, where
-the $q$ vector is defined as
-
-.. math::
-
-    q = \sqrt{q_x^2 + q_y^2}
-
-
-References
-----------
-
-F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
-
-also in J. Phys. Chem. B, 105, (2001) 11081-11088
-"""
-from numpy import inf
-
-name = "lamellarCailleHG"
-title = "Random lamellar sheet with Caille structure factor"
-description = """\
-    [Random lamellar phase with Caille  structure factor]
-        randomly oriented stacks of infinite sheets
-        with Caille S(Q), having polydisperse spacing.
-        layer thickness =(H+T+T+H) = 2(Head+Tail)
-        sld = Tail scattering length density
-        sld_head = Head scattering length density
-        sld_solvent = solvent scattering length density
-        background = incoherent background
-        scale = scale factor
-"""
-category = "shape:lamellae"
-
-single = False
-parameters = [
-    #   [ "name", "units", default, [lower, upper], "type",
-    #     "description" ],
-    ["tail_length", "Ang", 10, [0, inf], "volume",
-     "Tail thickness"],
-    ["head_length", "Ang", 2, [0, inf], "volume",
-     "head thickness"],
-    ["Nlayers", "", 30, [0, inf], "",
-     "Number of layers"],
-    ["spacing", "Ang", 40., [0.0, inf], "volume",
-     "d-spacing of Caille S(Q)"],
-    ["Caille_parameter", "", 0.001, [0.0, 0.8], "",
-     "Caille parameter"],
-    ["sld", "1e-6/Ang^2", 0.4, [-inf, inf], "",
-     "Tail scattering length density"],
-    ["head_sld", "1e-6/Ang^2", 2.0, [-inf, inf], "",
-     "Head scattering length density"],
-    ["solvent_sld", "1e-6/Ang^2", 6, [-inf, inf], "",
-     "Solvent scattering length density"],
-    ]
-
-source = ["lamellarCailleHG_kernel.c"]
-
-# No volume normalization despite having a volume parameter
-# This should perhaps be volume normalized?
-form_volume = """
-    return 1.0;
-    """
-
-Iqxy = """
-    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
-    """
-
-# ER defaults to 0.0
-# VR defaults to 1.0
-
-demo = dict(
-    scale=1, background=0,
-    Nlayers=20, spacing=200., Caille_parameter=0.05,
-    tail_length=15, head_length=10,
-    #sld=-1, head_sld=4.0, solvent_sld=6.0,
-    sld=-1, head_sld=4.1, solvent_sld=6.0,
-    tail_length_pd=0.1, tail_length_pd_n=20,
-    head_length_pd=0.05, head_length_pd_n=30,
-    spacing_pd=0.2, spacing_pd_n=40,
-    )
-
-oldname = 'LamellarPSHGModel'
-
-oldpars = dict(
-    tail_length='deltaT', head_length='deltaH', Nlayers='n_plates',
-    Caille_parameter='caille', sld='sld_tail', head_sld='sld_head',
-    solvent_sld='sld_solvent')
-#
-tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 10.0, 'head_length': 2.0,
-           'Nlayers': 30.0, 'spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4,
-           'head_sld': 2.0, 'solvent_sld': 6.0, 'tail_length_pd': 0.0,
-           'head_length_pd': 0.0, 'spacing_pd': 0.0}, [0.001], [6838238.571488]]]
Index: smodels/models/lamellarCailleHG_kernel.c
===================================================================
--- sasmodels/models/lamellarCailleHG_kernel.c	(revision 12c810f78dbf238faaad5e049615baec671280ae)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*	LamellarCailleHG kernel - allows for name changes of passed parameters ...
-    Maths identical to LamellarCaille apart from the line for P(Q)
-*/
-
-double Iq(double qval,
-      double tail_length,
-      double head_length,
-      double Nlayers, 
-      double dd,
-      double Cp,
-      double tail_sld,
-      double head_sld,
-      double solvent_sld);
-
-double Iq(double qval,
-      double tail_length,
-      double head_length,
-      double Nlayers, 
-      double dd,
-      double Cp,
-      double tail_sld,
-      double head_sld,
-      double solvent_sld)
-{
-  double NN;   //local variables of coefficient wave
-  double inten,Pq,Sq,alpha,temp,t2;
-  //double dQ, dQDefault, t1, t3;
-  int ii,NNint;
-  // from wikipedia 0.577215664901532860606512090082402431042159335
-  const double Euler = 0.577215664901533;   // Euler's constant, increased sig figs for new models Feb 2015
-  //dQDefault = 0.0;    //[=] 1/A, q-resolution, default value
-  //dQ = dQDefault; // REMOVED UNUSED dQ calculations for new models Feb 2015
-
-  NN = trunc(Nlayers);    //be sure that NN is an integer
-  
-  Pq = (head_sld-solvent_sld)*(sin(qval*(head_length+tail_length))-sin(qval*tail_length)) +
-              (tail_sld-solvent_sld)*sin(qval*tail_length);
-  Pq *= Pq;
-  Pq *= 4.0/(qval*qval);
-
-  NNint = (int)NN;    //cast to an integer for the loop
-  ii=0;
-  Sq = 0.0;
-  for(ii=1;ii<=(NNint-1);ii+=1) {
-
-    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015
-
-    temp = 0.0;
-    alpha = Cp/4.0/M_PI/M_PI*(log(M_PI*ii) + Euler);
-    //t1 = 2.0*dQ*dQ*dd*dd*alpha;
-    t2 = 2.0*qval*qval*dd*dd*alpha;
-    //t3 = dQ*dQ*dd*dd*ii*ii;
-
-    temp = 1.0-ii/NN;
-    //temp *= cos(dd*qval*ii/(1.0+t1));
-    temp *= cos(dd*qval*ii);
-    //if (temp < 0) printf("q=%g: ii=%d, cos(dd*q*ii)=cos(%g) < 0\n",qval,ii,dd*qval*ii);
-    //temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
-    temp *= exp(-t2/2.0 );
-    //temp /= sqrt(1.0+t1);
-
-    Sq += temp;
-  }
-
-  Sq *= 2.0;
-  Sq += 1.0;
-
-  //if (Sq < 0) printf("q=%g: S(q) =%g\n", qval, Sq);
-
-  inten = 2.0*M_PI*Pq*Sq/(dd*qval*qval);
-
-  inten *= 1.0e-04;   // 1/A to 1/cm
-  return(inten);
-}
-
Index: smodels/models/lamellarCaille_kernel.c
===================================================================
--- sasmodels/models/lamellarCaille_kernel.c	(revision 2e35a40faa66788cc99598aba7a610360b33e747)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*	LamellarCaille kernel - allows for name changes of passed parameters ...
-
-*/
-
-double Iq(double qval,
-      double del,
-      double Nlayers, 
-      double dd,
-	  double Cp, 
-      double sld,
-      double solvent_sld);
-
-double Iq(double qval,
-      double del,
-      double Nlayers, 
-      double dd,
-	  double Cp, 
-      double sld,
-      double solvent_sld)
-{
-  double contr,NN;   //local variables of coefficient wave
-  double inten,Pq,Sq,alpha,temp,t2;
-  //double dQ, dQDefault, t1, t3;
-  int ii,NNint;
-  // from wikipedia 0.577215664901532860606512090082402431042159335
-  const double Euler = 0.577215664901533;   // Euler's constant, increased sig figs for new models Feb 2015
-  //dQDefault = 0.0;    //[=] 1/A, q-resolution, default value
-  //dQ = dQDefault; // REMOVED UNUSED dQ calculations for new models Feb 2015
-
-  NN = trunc(Nlayers);    //be sure that NN is an integer
-  
-  contr = sld - solvent_sld;
-
-  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del));
-
-  NNint = (int)NN;    //cast to an integer for the loop
-  ii=0;
-  Sq = 0.0;
-  // the vital "=" in ii<=  added March 2015
-  for(ii=1;ii<=(NNint-1);ii+=1) {
-
-    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015
-
-    temp = 0.0;
-    alpha = Cp/4.0/M_PI/M_PI*(log(M_PI*ii) + Euler);
-    //t1 = 2.0*dQ*dQ*dd*dd*alpha;
-    t2 = 2.0*qval*qval*dd*dd*alpha;
-    //t3 = dQ*dQ*dd*dd*ii*ii;
-
-    temp = 1.0-ii/NN;
-    //temp *= cos(dd*qval*ii/(1.0+t1));
-    temp *= cos(dd*qval*ii);
-    //temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
-    temp *= exp(-t2/2.0 );
-    //temp /= sqrt(1.0+t1);
-
-    Sq += temp;
-  }
-
-  Sq *= 2.0;
-  Sq += 1.0;
-
-  inten = 2.0*M_PI*Pq*Sq/(dd*qval*qval);
-
-  inten *= 1.0e-04;   // 1/A to 1/cm
-
-  return(inten);
-}
-
Index: smodels/models/lamellarFFHG.py
===================================================================
--- sasmodels/models/lamellarFFHG.py	(revision aa2edb2b2fb550caed0506dcf63bc7eac7e1779a)
+++ 	(revision )
@@ -1,117 +1,0 @@
-# Note: model title and parameter table are inserted automatically
-r"""
-This model provides the scattering intensity, $I(q)$, for a lyotropic lamellar
-phase where a random distribution in solution are assumed. The SLD of the head
-region is taken to be different from the SLD of the tail region.
-
-Definition
-----------
-
-The scattering intensity $I(q)$ is
-
-.. math::
-
-   I(q) = 2\pi\frac{\text{scale}}{2(\delta_H + \delta_T)}  P(q) \frac{1}{q^2}
-
-The form factor $P(q)$ is
-
-.. math::
-
-    P(q) = \frac{4}{q^2}
-        \left\lbrace
-            \Delta \rho_H
-            \left[\sin[q(\delta_H + \delta_T)\ - \sin(q\delta_T)\right]
-            + \Delta\rho_T\sin(q\delta_T)
-        \right\rbrace^2
-
-where $\delta_T$ is *tail_length*, $\delta_H$ is *head_length*,
-$\Delta\rho_H$ is the head contrast (*head_sld* $-$ *solvent_sld*),
-and $\Delta\rho_T$ is tail contrast (*sld* $-$ *solvent_sld*).
-
-The 2D scattering intensity is calculated in the same way as 1D, where
-the $q$ vector is defined as
-
-.. math::
-
-    q = \sqrt{q_x^2 + q_y^2}
-
-
-References
-----------
-
-F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
-
-also in J. Phys. Chem. B, 105, (2001) 11081-11088
-
-*2014/04/17 - Description reviewed by S King and P Butler.*
-"""
-
-from numpy import inf
-
-name = "lamellar_FFHG"
-title = "Random lamellar phase with Head Groups"
-description = """\
-    [Random lamellar phase with Head Groups]
-        I(q)= 2*pi*P(q)/(2(H+T)*q^(2)), where
-        P(q)= see manual
-        layer thickness =(H+T+T+H) = 2(Head+Tail)
-        sld = Tail scattering length density
-        head_sld = Head scattering length density
-        solvent_sld = solvent scattering length density
-        background = incoherent background
-        scale = scale factor
-"""
-category = "shape:lamellae"
-
-# pylint: disable=bad-whitespace, line-too-long
-#             ["name", "units", default, [lower, upper], "type","description"],
-parameters = [["tail_length", "Ang",       15,   [0, inf],  "volume",  "Tail thickness"],
-              ["head_length", "Ang",       10,   [0, inf],  "volume",  "head thickness"],
-              ["sld",         "1e-6/Ang^2", 0.4, [-inf,inf], "",       "Tail scattering length density"],
-              ["head_sld",    "1e-6/Ang^2", 3.0, [-inf,inf], "",       "Head scattering length density"],
-              ["solvent_sld", "1e-6/Ang^2", 6,   [-inf,inf], "",       "Solvent scattering length density"]]
-# pylint: enable=bad-whitespace, line-too-long
-
-# No volume normalization despite having a volume parameter
-# This should perhaps be volume normalized?
-form_volume = """
-    return 1.0;
-    """
-
-Iq = """
-    const double qsq = q*q;
-    const double drh = head_sld - solvent_sld;
-    const double drt = sld - solvent_sld;    //correction 13FEB06 by L.Porcar
-    const double qT = q*tail_length;
-    double Pq, inten;
-    Pq = drh*(sin(q*(head_length+tail_length))-sin(qT)) + drt*sin(qT);
-    Pq *= Pq;
-    Pq *= 4.0/(qsq);
-
-    inten = 2.0e-4*M_PI*Pq/qsq;
-
-    // normalize by the bilayer thickness
-    inten /= 2.0*(head_length+tail_length);
-
-    return inten;
-    """
-
-Iqxy = """
-    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
-    """
-
-# ER defaults to 0.0
-# VR defaults to 1.0
-
-demo = dict(scale=1, background=0,
-            tail_length=15, head_length=10,
-            sld=0.4, head_sld=3.0, solvent_sld=6.0,
-            tail_length_pd=0.2, tail_length_pd_n=40,
-            head_length_pd=0.01, head_length_pd_n=40)
-
-oldname = 'LamellarFFHGModel'
-oldpars = dict(head_length='h_thickness', tail_length='t_length',
-               sld='sld_tail', head_sld='sld_head', solvent_sld='sld_solvent')
-#
-tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 15.0, 'head_length': 10.0,
-           'sld': 0.4, 'head_sld': 3.0, 'solvent_sld': 6.0}, [0.001], [653143.9209]]]
Index: smodels/models/lamellarPC.py
===================================================================
--- sasmodels/models/lamellarPC.py	(revision aa2edb2b2fb550caed0506dcf63bc7eac7e1779a)
+++ 	(revision )
@@ -1,153 +1,0 @@
-# Note: model title and parameter table are inserted automatically
-r"""
-This model calculates the scattering from a stack of repeating lamellar
-structures. The stacks of lamellae (infinite in lateral dimension) are
-treated as a paracrystal to account for the repeating spacing. The repeat
-distance is further characterized by a Gaussian polydispersity. **This model
-can be used for large multilamellar vesicles.**
-
-Definition
-----------
-
-In the equations below,
-
-- *scale* is used instead of the mass per area of the bilayer $\Gamma_m$
-  (this corresponds to the volume fraction of the material in the bilayer,
-  *not* the total excluded volume of the paracrystal),
-
-- *sld* $-$ *solvent_sld* is the contrast $\Delta \rho$,
-
-- *thickness* is the layer thickness $t$,
-
-- *Nlayers* is the number of layers $N$,
-
-- *spacing* is the average distance between adjacent layers
-  $\langle D \rangle$, and
-
-- *spacing_polydisp* is the relative standard deviation of the Gaussian
-  layer distance distribution $\sigma_D / \langle D \rangle$.
-
-
-The scattering intensity $I(q)$ is calculated as
-
-.. math::
-
-    I(q) = 2\pi\Delta\rho^2\Gamma_m\frac{P_\text{bil}(q)}{q^2} Z_N(q)
-
-The form factor of the bilayer is approximated as the cross section of an
-infinite, planar bilayer of thickness $t$
-
-.. math::
-
-    P_\text{bil}(q) = \left(\frac{\sin(qt/2)}{qt/2}\right)^2
-
-$Z_N(q)$ describes the interference effects for aggregates
-consisting of more than one bilayer. The equations used are (3-5)
-from the Bergstrom reference:
-
-.. math::
-
-
-    Z_N(q) = \frac{1 - w^2}{1 + w^2 - 2w \cos(q \langle D \rangle)}
-        + x_N S_N + (1 - x_N) S_{N+1}
-
-where
-
-.. math::
-
-    S_N(q) = \frac{a_N}{N}[1 + w^2 - 2 w \cos(q \langle D \rangle)]^2
-
-and
-
-.. math::
-
-    a_N &= 4w^2 - 2(w^3 + w) \cos(q \langle D \rangle) \\
-        &\quad - 4w^{N+2}\cos(Nq \langle D \rangle)
-        + 2 w^{N+3}\cos[(N-1)q \langle D \rangle]
-        + 2w^{N+1}\cos[(N+1)q \langle D \rangle]
-
-for the layer spacing distribution $w = \exp(-\sigma_D^2 q^2/2)$.
-
-Non-integer numbers of stacks are calculated as a linear combination of
-the lower and higher values
-
-.. math::
-
-    N_L = x_N N + (1 - x_N)(N+1)
-
-The 2D scattering intensity is the same as 1D, regardless of the orientation
-of the $q$ vector which is defined as
-
-.. math::
-
-    q = \sqrt{q_x^2 + q_y^2}
-
-
-Reference
----------
-
-M Bergstrom, J S Pedersen, P Schurtenberger, S U Egelhaaf,
-*J. Phys. Chem. B*, 103 (1999) 9888-9897
-
-"""
-
-from numpy import inf
-
-name = "lamellarPC"
-title = "Random lamellar sheet with paracrystal structure factor"
-description = """\
-    [Random lamellar phase with paracrystal structure factor]
-        randomly oriented stacks of infinite sheets
-        with paracrytal S(Q), having polydisperse spacing.
-        sld = sheet scattering length density
-        sld_solvent = solvent scattering length density
-        background = incoherent background
-        scale = scale factor
-"""
-category = "shape:lamellae"
-
-single = False
-
-#             ["name", "units", default, [lower, upper], "type","description"],
-parameters = [["thickness", "Ang", 33.0, [0, inf], "volume",
-               "sheet thickness"],
-              ["Nlayers", "", 20, [0, inf], "",
-               "Number of layers"],
-              ["spacing", "Ang", 250., [0.0, inf], "",
-               "d-spacing of paracrystal stack"],
-              ["spacing_polydisp", "Ang", 0.0, [0.0, inf], "",
-               "d-spacing polydispersity"],
-              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
-               "layer scattering length density"],
-              ["solvent_sld", "1e-6/Ang^2", 6.34, [-inf, inf], "",
-               "Solvent scattering length density"],
-             ]
-
-
-source = ["lamellarPC_kernel.c"]
-
-form_volume = """
-    return 1.0;
-    """
-
-Iqxy = """
-    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
-    """
-
-# ER defaults to 0.0
-# VR defaults to 1.0
-
-demo = dict(scale=1, background=0,
-            thickness=33, Nlayers=20, spacing=250, spacing_polydisp=0.2,
-            sld=1.0, solvent_sld=6.34,
-            thickness_pd=0.2, thickness_pd_n=40)
-
-oldname = 'LamellarPCrystalModel'
-oldpars = dict(spacing_polydisp='pd_spacing', sld='sld_layer',
-               solvent_sld='sld_solvent')
-#
-tests = [
-        [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 33.,'Nlayers' : 20.0, 'spacing' : 250., 'spacing_polydisp' : 0.2,
-            'sld' : 1.0, 'solvent_sld' : 6.34,
-            'thickness_pd' : 0.0, 'thickness_pd_n' : 40 }, [0.001, 0.215268], [21829.3, 0.00487686]]
-        ]
Index: smodels/models/lamellarPC_kernel.c
===================================================================
--- sasmodels/models/lamellarPC_kernel.c	(revision 319ab1478261080f41492caa7ea3b5e7f58409c8)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*	Lamellar_ParaCrystal - Pedersen's model
-
-*/
-double Iq(double qval,
-      double th,
-      double Nlayers, 
-	  double davg, 
-	  double pd,
-      double sld,
-      double solvent_sld);
-double paraCryst_sn(double ww, double qval, double davg, long Nlayers, double an);
-double paraCryst_an(double ww, double qval, double davg, long Nlayers);
-
-double Iq(double qval,
-      double th,
-      double Nlayers, 
-	  double davg, 
-	  double pd,
-      double sld,
-      double solvent_sld)
-{
-    
-	double inten,contr,xn;
-	double xi,ww,Pbil,Znq,Snq,an;
-	long n1,n2;
-	
-	contr = sld - solvent_sld;
-	//get the fractional part of Nlayers, to determine the "mixing" of N's
-	
-	n1 = (long)trunc(Nlayers);		//rounds towards zero
-	n2 = n1 + 1;
-	xn = (double)n2 - Nlayers;			//fractional contribution of n1
-	
-	ww = exp(-qval*qval*pd*pd*davg*davg/2.0);
-
-	//calculate the n1 contribution
-	an = paraCryst_an(ww,qval,davg,n1);
-	Snq = paraCryst_sn(ww,qval,davg,n1,an);
-	
-	Znq = xn*Snq;
-	
-	//calculate the n2 contribution
-	an = paraCryst_an(ww,qval,davg,n2);
-	Snq = paraCryst_sn(ww,qval,davg,n2,an);
-
-	Znq += (1.0-xn)*Snq;
-	
-	//and the independent contribution
-	Znq += (1.0-ww*ww)/(1.0+ww*ww-2.0*ww*cos(qval*davg));
-	
-	//the limit when Nlayers approaches infinity
-//	Zq = (1-ww^2)/(1+ww^2-2*ww*cos(qval*davg))
-	
-	xi = th/2.0;		//use 1/2 the bilayer thickness
-	Pbil = (sin(qval*xi)/(qval*xi))*(sin(qval*xi)/(qval*xi));
-	
-	inten = 2.0*M_PI*contr*contr*Pbil*Znq/(qval*qval);
-	inten *= 1.0e-04;
-//printf("q=%.7e wwm1=%g ww=%.5e an=% 12.5e Snq=% 12.5e Znq=% 12.5e Pbil=% 12.5e\n",qval,wwm1,ww,an,Snq,Znq,Pbil);
-	return(inten);
-}
-
-// functions for the lamellar paracrystal model
-double
-paraCryst_sn(double ww, double qval, double davg, long Nlayers, double an) {
-	
-	double Snq;
-
-	Snq = an/( (double)Nlayers*pow((1.0+ww*ww-2.0*ww*cos(qval*davg)),2) );
-	
-	return(Snq);
-}
-
-double
-paraCryst_an(double ww, double qval, double davg, long Nlayers) {
-	
-	double an;
-	
-	an = 4.0*ww*ww - 2.0*(ww*ww*ww+ww)*cos(qval*davg);
-	an -= 4.0*pow(ww,(Nlayers+2))*cos((double)Nlayers*qval*davg);
-	an += 2.0*pow(ww,(Nlayers+3))*cos((double)(Nlayers-1)*qval*davg);
-	an += 2.0*pow(ww,(Nlayers+1))*cos((double)(Nlayers+1)*qval*davg);
-	
-	return(an);
-}
-
Index: sasmodels/models/lamellar_hg.py
===================================================================
--- sasmodels/models/lamellar_hg.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_hg.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,118 @@
+# Note: model title and parameter table are inserted automatically
+r"""
+This model provides the scattering intensity, $I(q)$, for a lyotropic lamellar
+phase where a random distribution in solution are assumed. The SLD of the head
+region is taken to be different from the SLD of the tail region.
+
+Definition
+----------
+
+The scattering intensity $I(q)$ is
+
+.. math::
+
+   I(q) = 2\pi\frac{\text{scale}}{2(\delta_H + \delta_T)}  P(q) \frac{1}{q^2}
+
+The form factor $P(q)$ is
+
+.. math::
+
+    P(q) = \frac{4}{q^2}
+        \left\lbrace
+            \Delta \rho_H
+            \left[\sin[q(\delta_H + \delta_T)\ - \sin(q\delta_T)\right]
+            + \Delta\rho_T\sin(q\delta_T)
+        \right\rbrace^2
+
+where $\delta_T$ is *tail_length*, $\delta_H$ is *head_length*,
+$\Delta\rho_H$ is the head contrast (*sld_head* $-$ *sld_solvent*),
+and $\Delta\rho_T$ is tail contrast (*sld* $-$ *sld_solvent*).
+
+The 2D scattering intensity is calculated in the same way as 1D, where
+the $q$ vector is defined as
+
+.. math::
+
+    q = \sqrt{q_x^2 + q_y^2}
+
+
+References
+----------
+
+F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
+
+also in J. Phys. Chem. B, 105, (2001) 11081-11088
+
+*2014/04/17 - Description reviewed by S King and P Butler.*
+"""
+
+from numpy import inf
+
+name = "lamellar_hg"
+title = "Random lamellar phase with Head and Tail Groups"
+description = """\
+    [Random lamellar phase with Head and Tail Groups]
+        I(q)= 2*pi*P(q)/(2(H+T)*q^(2)), where
+        P(q)= see manual
+        layer thickness =(H+T+T+H) = 2(Head+Tail)
+        sld = Tail scattering length density
+        sld_head = Head scattering length density
+        sld_solvent = solvent scattering length density
+        background = incoherent background
+        scale = scale factor
+"""
+category = "shape:lamellae"
+
+# pylint: disable=bad-whitespace, line-too-long
+#             ["name", "units", default, [lower, upper], "type","description"],
+parameters = [["tail_length", "Ang",       15,   [0, inf],  "volume",  "Tail thickness ( total = H+T+T+H)"],
+              ["head_length", "Ang",       10,   [0, inf],  "volume",  "Head thickness"],
+              ["sld",         "1e-6/Ang^2", 0.4, [-inf,inf], "",       "Tail scattering length density"],
+              ["sld_head",    "1e-6/Ang^2", 3.0, [-inf,inf], "",       "Head scattering length density"],
+              ["sld_solvent", "1e-6/Ang^2", 6,   [-inf,inf], "",       "Solvent scattering length density"]]
+# pylint: enable=bad-whitespace, line-too-long
+
+# No volume normalization despite having a volume parameter
+# This should perhaps be volume normalized?
+form_volume = """
+    return 1.0;
+    """
+
+Iq = """
+    const double qsq = q*q;
+    const double drh = sld_head - sld_solvent;
+    const double drt = sld - sld_solvent;    //correction 13FEB06 by L.Porcar
+    const double qT = q*tail_length;
+    double Pq, inten;
+    Pq = drh*(sin(q*(head_length+tail_length))-sin(qT)) + drt*sin(qT);
+    Pq *= Pq;
+    Pq *= 4.0/(qsq);
+
+    inten = 2.0e-4*M_PI*Pq/qsq;
+
+    // normalize by the bilayer thickness
+    inten /= 2.0*(head_length+tail_length);
+
+    return inten;
+    """
+
+Iqxy = """
+    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
+    """
+
+# ER defaults to 0.0
+# VR defaults to 1.0
+
+demo = dict(scale=1, background=0,
+            tail_length=15, head_length=10,
+            sld=0.4, sld_head=3.0, sld_solvent=6.0,
+            tail_length_pd=0.2, tail_length_pd_n=40,
+            head_length_pd=0.01, head_length_pd_n=40)
+
+oldname = 'LamellarFFHGModel'
+oldpars = dict(head_length='h_thickness', tail_length='t_length',
+               sld='sld_tail', sld_head='sld_head', sld_solvent='sld_solvent')
+#
+tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 15.0, 'head_length': 10.0,
+           'sld': 0.4, 'sld_head': 3.0, 'sld_solvent': 6.0}, [0.001], [653143.9209]]]
+# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs
Index: sasmodels/models/lamellar_hg_stack_caille.py
===================================================================
--- sasmodels/models/lamellar_hg_stack_caille.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_hg_stack_caille.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,151 @@
+# Note: model title and parameter table are inserted automatically
+r"""
+This model provides the scattering intensity, $I(q) = P(q)S(q)$, for a lamellar
+phase where a random distribution in solution are assumed. Here a Caille $S(q)$
+is used for the lamellar stacks.
+
+The scattering intensity $I(q)$ is
+
+.. math::
+
+    I(q) = 2 \pi \frac{P(q)S(q)}{q^2\delta }
+
+
+The form factor $P(q)$ is
+
+.. math::
+
+        P(q) = \frac{4}{q^2}\big\{
+        \Delta\rho_H \left[\sin[q(\delta_H + \delta_T)] - \sin(q\delta_T)\right]
+            + \Delta\rho_T\sin(q\delta_T)\big\}^2
+
+and the structure factor $S(q)$ is
+
+.. math::
+
+    S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right)
+        \cos(qdn)\exp\left(-\frac{2q^2d^2\alpha(n)}{2}\right)
+
+where
+
+.. math::
+    :nowrap:
+
+    \begin{align*}
+    \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)
+              &&  \\
+    \gamma_E  &= 0.5772156649
+              && \text{Euler's constant} \\
+    \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}}
+              && \text{Caille constant}
+    \end{align*}
+
+
+$\delta_T$ is the tail length (or *tail_length*), $\delta_H$ is the head
+thickness (or *head_length*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent),
+and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing,
+$K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the
+number of lamellar plates (*Nlayers*).
+
+NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the
+assumptions of the model are incorrect.**  And due to a complication of the
+model function, users are responsible for making sure that all the assumptions
+are handled accurately (see the original reference below for more details).
+
+Non-integer numbers of stacks are calculated as a linear combination of
+results for the next lower and higher values.
+
+Be aware that the computations may be very slow.
+
+The 2D scattering intensity is calculated in the same way as 1D, where
+the $q$ vector is defined as
+
+.. math::
+
+    q = \sqrt{q_x^2 + q_y^2}
+
+
+References
+----------
+
+F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
+
+also in J. Phys. Chem. B, 105, (2001) 11081-11088
+"""
+from numpy import inf
+
+name = "lamellar_hg_stack_caille"
+title = "Random lamellar head/tail/tail/head sheet with Caille structure factor"
+description = """\
+    [Random lamellar phase with Caille  structure factor]
+        randomly oriented stacks of infinite sheets
+        with Caille S(Q), having polydisperse spacing.
+        layer thickness =(H+T+T+H) = 2(Head+Tail)
+        sld = Tail scattering length density
+        sld_head = Head scattering length density
+        sld_solvent = solvent scattering length density
+        background = incoherent background
+        scale = scale factor
+"""
+category = "shape:lamellae"
+
+single = False
+parameters = [
+    #   [ "name", "units", default, [lower, upper], "type",
+    #     "description" ],
+    ["tail_length", "Ang", 10, [0, inf], "volume",
+     "Tail thickness"],
+    ["head_length", "Ang", 2, [0, inf], "volume",
+     "head thickness"],
+    ["Nlayers", "", 30, [0, inf], "",
+     "Number of layers"],
+    ["spacing", "Ang", 40., [0.0, inf], "volume",
+     "d-spacing of Caille S(Q)"],
+    ["Caille_parameter", "", 0.001, [0.0, 0.8], "",
+     "Caille parameter"],
+    ["sld", "1e-6/Ang^2", 0.4, [-inf, inf], "",
+     "Tail scattering length density"],
+    ["sld_head", "1e-6/Ang^2", 2.0, [-inf, inf], "",
+     "Head scattering length density"],
+    ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "",
+     "Solvent scattering length density"],
+    ]
+
+source = ["lamellar_hg_stack_caille_kernel.c"]
+
+# No volume normalization despite having a volume parameter
+# This should perhaps be volume normalized?
+form_volume = """
+    return 1.0;
+    """
+
+Iqxy = """
+    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
+    """
+
+# ER defaults to 0.0
+# VR defaults to 1.0
+
+demo = dict(
+    scale=1, background=0,
+    Nlayers=20, spacing=200., Caille_parameter=0.05,
+    tail_length=15, head_length=10,
+    #sld=-1, sld_head=4.0, sld_solvent=6.0,
+    sld=-1, sld_head=4.1, sld_solvent=6.0,
+    tail_length_pd=0.1, tail_length_pd_n=20,
+    head_length_pd=0.05, head_length_pd_n=30,
+    spacing_pd=0.2, spacing_pd_n=40,
+    )
+
+oldname = 'LamellarPSHGModel'
+
+oldpars = dict(
+    tail_length='deltaT', head_length='deltaH', Nlayers='n_plates',
+    Caille_parameter='caille', sld='sld_tail', sld_head='sld_head',
+    sld_solvent='sld_solvent')
+#
+tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 10.0, 'head_length': 2.0,
+           'Nlayers': 30.0, 'spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4,
+           'sld_head': 2.0, 'sld_solvent': 6.0, 'tail_length_pd': 0.0,
+           'head_length_pd': 0.0, 'spacing_pd': 0.0}, [0.001], [6838238.571488]]]
+# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs
Index: sasmodels/models/lamellar_hg_stack_caille_kernel.c
===================================================================
--- sasmodels/models/lamellar_hg_stack_caille_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_hg_stack_caille_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,75 @@
+/*	LamellarCailleHG kernel - allows for name changes of passed parameters ...
+    Maths identical to LamellarCaille apart from the line for P(Q)
+*/
+
+double Iq(double qval,
+      double tail_length,
+      double head_length,
+      double Nlayers, 
+      double dd,
+      double Cp,
+      double tail_sld,
+      double head_sld,
+      double solvent_sld);
+
+double Iq(double qval,
+      double tail_length,
+      double head_length,
+      double Nlayers, 
+      double dd,
+      double Cp,
+      double tail_sld,
+      double head_sld,
+      double solvent_sld)
+{
+  double NN;   //local variables of coefficient wave
+  double inten,Pq,Sq,alpha,temp,t2;
+  //double dQ, dQDefault, t1, t3;
+  int ii,NNint;
+  // from wikipedia 0.577215664901532860606512090082402431042159335
+  const double Euler = 0.577215664901533;   // Euler's constant, increased sig figs for new models Feb 2015
+  //dQDefault = 0.0;    //[=] 1/A, q-resolution, default value
+  //dQ = dQDefault; // REMOVED UNUSED dQ calculations for new models Feb 2015
+
+  NN = trunc(Nlayers);    //be sure that NN is an integer
+  
+  Pq = (head_sld-solvent_sld)*(sin(qval*(head_length+tail_length))-sin(qval*tail_length)) +
+              (tail_sld-solvent_sld)*sin(qval*tail_length);
+  Pq *= Pq;
+  Pq *= 4.0/(qval*qval);
+
+  NNint = (int)NN;    //cast to an integer for the loop
+  ii=0;
+  Sq = 0.0;
+  for(ii=1;ii<=(NNint-1);ii+=1) {
+
+    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015
+
+    temp = 0.0;
+    alpha = Cp/4.0/M_PI/M_PI*(log(M_PI*ii) + Euler);
+    //t1 = 2.0*dQ*dQ*dd*dd*alpha;
+    t2 = 2.0*qval*qval*dd*dd*alpha;
+    //t3 = dQ*dQ*dd*dd*ii*ii;
+
+    temp = 1.0-ii/NN;
+    //temp *= cos(dd*qval*ii/(1.0+t1));
+    temp *= cos(dd*qval*ii);
+    //if (temp < 0) printf("q=%g: ii=%d, cos(dd*q*ii)=cos(%g) < 0\n",qval,ii,dd*qval*ii);
+    //temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
+    temp *= exp(-t2/2.0 );
+    //temp /= sqrt(1.0+t1);
+
+    Sq += temp;
+  }
+
+  Sq *= 2.0;
+  Sq += 1.0;
+
+  //if (Sq < 0) printf("q=%g: S(q) =%g\n", qval, Sq);
+
+  inten = 2.0*M_PI*Pq*Sq/(dd*qval*qval);
+
+  inten *= 1.0e-04;   // 1/A to 1/cm
+  return(inten);
+}
+
Index: sasmodels/models/lamellar_stack_caille.py
===================================================================
--- sasmodels/models/lamellar_stack_caille.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_stack_caille.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,130 @@
+r"""
+This model provides the scattering intensity, $I(q) = P(q) S(q)$, for a
+lamellar phase where a random distribution in solution are assumed.
+Here a Caille $S(q)$ is used for the lamellar stacks.
+
+Definition
+----------
+
+The scattering intensity $I(q)$ is
+
+.. math::
+
+    I(q) = 2\pi \frac{P(q)S(q)}{q^2\delta }
+
+The form factor is
+
+.. math::
+
+    P(q) = \frac{2\Delta\rho^2}{q^2}\left(1-\cos q\delta \right)
+
+and the structure factor is
+
+.. math::
+
+    S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right)
+           \cos(qdn)\exp\left(-\frac{2q^2d^2\alpha(n)}{2}\right)
+
+where
+
+.. math::
+    :nowrap:
+
+    \begin{align*}
+    \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)
+              && \\
+    \gamma_E  &= 0.5772156649
+              && \text{Euler's constant} \\
+    \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}}
+              && \text{Caille constant}
+    \end{align*}
+
+Here $d$ = (repeat) spacing, $\delta$ = bilayer thickness,
+the contrast $\Delta\rho$ = SLD(headgroup) - SLD(solvent),
+$K$ = smectic bending elasticity, $B$ = compression modulus, and
+$N$ = number of lamellar plates (*n_plates*).
+
+NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the
+assumptions of the model are incorrect.** And due to a complication of the
+model function, users are responsible for making sure that all the assumptions
+are handled accurately (see the original reference below for more details).
+
+Non-integer numbers of stacks are calculated as a linear combination of
+results for the next lower and higher values.
+
+The 2D scattering intensity is calculated in the same way as 1D, where the
+$q$ vector is defined as
+
+.. math::
+
+    q = \sqrt{q_x^2 + q_y^2}
+
+
+References
+----------
+
+F Nallet, R Laversanne, and D Roux, J. Phys. II France, 3, (1993) 487-502
+
+also in J. Phys. Chem. B, 105, (2001) 11081-11088
+"""
+from numpy import inf
+
+name = "lamellar_stack_caille"
+title = "Random lamellar sheet with Caille structure factor"
+description = """\
+    [Random lamellar phase with Caille  structure factor]
+    randomly oriented stacks of infinite sheets
+    with Caille S(Q), having polydisperse spacing.
+    sld = sheet scattering length density
+    sld_solvent = solvent scattering length density
+    background = incoherent background
+    scale = scale factor
+"""
+category = "shape:lamellae"
+
+single = False
+# pylint: disable=bad-whitespace, line-too-long
+#             ["name", "units", default, [lower, upper], "type","description"],
+parameters = [
+    ["thickness",        "Ang",      30.0,  [0, inf],   "volume", "sheet thickness"],
+    ["Nlayers",          "",          20,   [0, inf],   "",       "Number of layers"],
+    ["spacing",          "Ang",      400.,  [0.0,inf],  "volume", "d-spacing of Caille S(Q)"],
+    ["Caille_parameter", "1/Ang^2",    0.1, [0.0,0.8],  "",       "Caille parameter"],
+    ["sld",              "1e-6/Ang^2", 6.3, [-inf,inf], "",       "layer scattering length density"],
+    ["sld_solvent",      "1e-6/Ang^2", 1.0, [-inf,inf], "",       "Solvent scattering length density"],
+    ]
+# pylint: enable=bad-whitespace, line-too-long
+
+source = ["lamellar_stack_caille_kernel.c"]
+
+# No volume normalization despite having a volume parameter
+# This should perhaps be volume normalized?
+form_volume = """
+    return 1.0;
+    """
+
+Iqxy = """
+    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
+    """
+
+# ER defaults to 0.0
+# VR defaults to 1.0
+
+demo = dict(scale=1, background=0,
+            thickness=67., Nlayers=3.75, spacing=200.,
+            Caille_parameter=0.268, sld=1.0, sld_solvent=6.34,
+            thickness_pd=0.1, thickness_pd_n=100,
+            spacing_pd=0.05, spacing_pd_n=40)
+
+oldname = 'LamellarPSModel'
+oldpars = dict(thickness='delta', Nlayers='N_plates',
+               Caille_parameter='caille',
+               sld='sld_bi', sld_solvent='sld_sol')
+#
+tests = [
+    [{'scale': 1.0, 'background': 0.0, 'thickness': 30., 'Nlayers': 20.0,
+      'spacing': 400., 'Caille_parameter': 0.1, 'sld': 6.3,
+      'sld_solvent': 1.0, 'thickness_pd': 0.0, 'spacing_pd': 0.0},
+     [0.001], [28895.13397]]
+    ]
+# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs
Index: sasmodels/models/lamellar_stack_caille_kernel.c
===================================================================
--- sasmodels/models/lamellar_stack_caille_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_stack_caille_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,69 @@
+/*	LamellarCaille kernel - allows for name changes of passed parameters ...
+
+*/
+
+double Iq(double qval,
+      double del,
+      double Nlayers, 
+      double dd,
+	  double Cp, 
+      double sld,
+      double solvent_sld);
+
+double Iq(double qval,
+      double del,
+      double Nlayers, 
+      double dd,
+	  double Cp, 
+      double sld,
+      double solvent_sld)
+{
+  double contr,NN;   //local variables of coefficient wave
+  double inten,Pq,Sq,alpha,temp,t2;
+  //double dQ, dQDefault, t1, t3;
+  int ii,NNint;
+  // from wikipedia 0.577215664901532860606512090082402431042159335
+  const double Euler = 0.577215664901533;   // Euler's constant, increased sig figs for new models Feb 2015
+  //dQDefault = 0.0;    //[=] 1/A, q-resolution, default value
+  //dQ = dQDefault; // REMOVED UNUSED dQ calculations for new models Feb 2015
+
+  NN = trunc(Nlayers);    //be sure that NN is an integer
+  
+  contr = sld - solvent_sld;
+
+  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del));
+
+  NNint = (int)NN;    //cast to an integer for the loop
+  ii=0;
+  Sq = 0.0;
+  // the vital "=" in ii<=  added March 2015
+  for(ii=1;ii<=(NNint-1);ii+=1) {
+
+    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015
+
+    temp = 0.0;
+    alpha = Cp/4.0/M_PI/M_PI*(log(M_PI*ii) + Euler);
+    //t1 = 2.0*dQ*dQ*dd*dd*alpha;
+    t2 = 2.0*qval*qval*dd*dd*alpha;
+    //t3 = dQ*dQ*dd*dd*ii*ii;
+
+    temp = 1.0-ii/NN;
+    //temp *= cos(dd*qval*ii/(1.0+t1));
+    temp *= cos(dd*qval*ii);
+    //temp *= exp(-1.0*(t2 + t3)/(2.0*(1.0+t1)) );
+    temp *= exp(-t2/2.0 );
+    //temp /= sqrt(1.0+t1);
+
+    Sq += temp;
+  }
+
+  Sq *= 2.0;
+  Sq += 1.0;
+
+  inten = 2.0*M_PI*Pq*Sq/(dd*qval*qval);
+
+  inten *= 1.0e-04;   // 1/A to 1/cm
+
+  return(inten);
+}
+
Index: sasmodels/models/lamellar_stack_paracrystal.py
===================================================================
--- sasmodels/models/lamellar_stack_paracrystal.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_stack_paracrystal.py	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,155 @@
+# Note: model title and parameter table are inserted automatically
+r"""
+This model calculates the scattering from a stack of repeating lamellar
+structures. The stacks of lamellae (infinite in lateral dimension) are
+treated as a paracrystal to account for the repeating spacing. The repeat
+distance is further characterized by a Gaussian polydispersity. **This model
+can be used for large multilamellar vesicles.**
+
+Definition
+----------
+
+In the equations below,
+
+- *scale* is used instead of the mass per area of the bilayer $\Gamma_m$
+  (this corresponds to the volume fraction of the material in the bilayer,
+  *not* the total excluded volume of the paracrystal),
+
+- *sld* $-$ *sld_solvent* is the contrast $\Delta \rho$,
+
+- *thickness* is the layer thickness $t$,
+
+- *Nlayers* is the number of layers $N$,
+
+- *spacing* is the average distance between adjacent layers
+  $\langle D \rangle$, and
+
+- *spacing_polydisp* is the relative standard deviation of the Gaussian
+  layer distance distribution $\sigma_D / \langle D \rangle$.
+
+
+The scattering intensity $I(q)$ is calculated as
+
+.. math::
+
+    I(q) = 2\pi\Delta\rho^2\Gamma_m\frac{P_\text{bil}(q)}{q^2} Z_N(q)
+
+The form factor of the bilayer is approximated as the cross section of an
+infinite, planar bilayer of thickness $t$ (compare the equations for the
+lamellar model).
+
+.. math::
+
+    P_\text{bil}(q) = \left(\frac{\sin(qt/2)}{qt/2}\right)^2
+
+$Z_N(q)$ describes the interference effects for aggregates
+consisting of more than one bilayer. The equations used are (3-5)
+from the Bergstrom reference:
+
+.. math::
+
+
+    Z_N(q) = \frac{1 - w^2}{1 + w^2 - 2w \cos(q \langle D \rangle)}
+        + x_N S_N + (1 - x_N) S_{N+1}
+
+where
+
+.. math::
+
+    S_N(q) = \frac{a_N}{N}[1 + w^2 - 2 w \cos(q \langle D \rangle)]^2
+
+and
+
+.. math::
+
+    a_N &= 4w^2 - 2(w^3 + w) \cos(q \langle D \rangle) \\
+        &\quad - 4w^{N+2}\cos(Nq \langle D \rangle)
+        + 2 w^{N+3}\cos[(N-1)q \langle D \rangle]
+        + 2w^{N+1}\cos[(N+1)q \langle D \rangle]
+
+for the layer spacing distribution $w = \exp(-\sigma_D^2 q^2/2)$.
+
+Non-integer numbers of stacks are calculated as a linear combination of
+the lower and higher values
+
+.. math::
+
+    N_L = x_N N + (1 - x_N)(N+1)
+
+The 2D scattering intensity is the same as 1D, regardless of the orientation
+of the $q$ vector which is defined as
+
+.. math::
+
+    q = \sqrt{q_x^2 + q_y^2}
+
+
+Reference
+---------
+
+M Bergstrom, J S Pedersen, P Schurtenberger, S U Egelhaaf,
+*J. Phys. Chem. B*, 103 (1999) 9888-9897
+
+"""
+
+from numpy import inf
+
+name = "lamellar_stack_paracrystal"
+title = "Random lamellar sheet with paracrystal structure factor"
+description = """\
+    [Random lamellar phase with paracrystal structure factor]
+        randomly oriented stacks of infinite sheets
+        with paracrytal S(Q), having polydisperse spacing.
+        sld = sheet scattering length density
+        sld_solvent = solvent scattering length density
+        background = incoherent background
+        scale = scale factor
+"""
+category = "shape:lamellae"
+
+single = False
+
+#             ["name", "units", default, [lower, upper], "type","description"],
+parameters = [["thickness", "Ang", 33.0, [0, inf], "volume",
+               "sheet thickness"],
+              ["Nlayers", "", 20, [0, inf], "",
+               "Number of layers"],
+              ["spacing", "Ang", 250., [0.0, inf], "",
+               "d-spacing of paracrystal stack"],
+              ["spacing_polydisp", "Ang", 0.0, [0.0, inf], "",
+               "d-spacing polydispersity"],
+              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "",
+               "layer scattering length density"],
+              ["sld_solvent", "1e-6/Ang^2", 6.34, [-inf, inf], "",
+               "Solvent scattering length density"],
+             ]
+
+
+source = ["lamellar_stack_paracrystal_kernel.c"]
+
+form_volume = """
+    return 1.0;
+    """
+
+Iqxy = """
+    return Iq(sqrt(qx*qx+qy*qy), IQ_PARAMETERS);
+    """
+
+# ER defaults to 0.0
+# VR defaults to 1.0
+
+demo = dict(scale=1, background=0,
+            thickness=33, Nlayers=20, spacing=250, spacing_polydisp=0.2,
+            sld=1.0, sld_solvent=6.34,
+            thickness_pd=0.2, thickness_pd_n=40)
+
+oldname = 'LamellarPCrystalModel'
+oldpars = dict(spacing_polydisp='pd_spacing', sld='sld_layer',
+               sld_solvent='sld_solvent')
+#
+tests = [
+        [ {'scale': 1.0, 'background' : 0.0, 'thickness' : 33.,'Nlayers' : 20.0, 'spacing' : 250., 'spacing_polydisp' : 0.2,
+            'sld' : 1.0, 'sld_solvent' : 6.34,
+            'thickness_pd' : 0.0, 'thickness_pd_n' : 40 }, [0.001, 0.215268], [21829.3, 0.00487686]]
+        ]
+# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs
Index: sasmodels/models/lamellar_stack_paracrystal_kernel.c
===================================================================
--- sasmodels/models/lamellar_stack_paracrystal_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
+++ sasmodels/models/lamellar_stack_paracrystal_kernel.c	(revision 6ab4ed8677894e77dfd90dc3fdd5bdac2df2eff8)
@@ -0,0 +1,86 @@
+/*	Lamellar_ParaCrystal - Pedersen's model
+
+*/
+double Iq(double qval,
+      double th,
+      double Nlayers, 
+	  double davg, 
+	  double pd,
+      double sld,
+      double solvent_sld);
+double paraCryst_sn(double ww, double qval, double davg, long Nlayers, double an);
+double paraCryst_an(double ww, double qval, double davg, long Nlayers);
+
+double Iq(double qval,
+      double th,
+      double Nlayers, 
+	  double davg, 
+	  double pd,
+      double sld,
+      double solvent_sld)
+{
+    
+	double inten,contr,xn;
+	double xi,ww,Pbil,Znq,Snq,an;
+	long n1,n2;
+	
+	contr = sld - solvent_sld;
+	//get the fractional part of Nlayers, to determine the "mixing" of N's
+	
+	n1 = (long)trunc(Nlayers);		//rounds towards zero
+	n2 = n1 + 1;
+	xn = (double)n2 - Nlayers;			//fractional contribution of n1
+	
+	ww = exp(-qval*qval*pd*pd*davg*davg/2.0);
+
+	//calculate the n1 contribution
+	an = paraCryst_an(ww,qval,davg,n1);
+	Snq = paraCryst_sn(ww,qval,davg,n1,an);
+	
+	Znq = xn*Snq;
+	
+	//calculate the n2 contribution
+	an = paraCryst_an(ww,qval,davg,n2);
+	Snq = paraCryst_sn(ww,qval,davg,n2,an);
+
+	Znq += (1.0-xn)*Snq;
+	
+	//and the independent contribution
+	Znq += (1.0-ww*ww)/(1.0+ww*ww-2.0*ww*cos(qval*davg));
+	
+	//the limit when Nlayers approaches infinity
+//	Zq = (1-ww^2)/(1+ww^2-2*ww*cos(qval*davg))
+	
+	xi = th/2.0;		//use 1/2 the bilayer thickness
+	Pbil = (sin(qval*xi)/(qval*xi))*(sin(qval*xi)/(qval*xi));
+	
+	inten = 2.0*M_PI*contr*contr*Pbil*Znq/(qval*qval);
+	inten *= 1.0e-04;
+//printf("q=%.7e wwm1=%g ww=%.5e an=% 12.5e Snq=% 12.5e Znq=% 12.5e Pbil=% 12.5e\n",qval,wwm1,ww,an,Snq,Znq,Pbil);
+	return(inten);
+}
+
+// functions for the lamellar paracrystal model
+double
+paraCryst_sn(double ww, double qval, double davg, long Nlayers, double an) {
+	
+	double Snq;
+
+	Snq = an/( (double)Nlayers*pow((1.0+ww*ww-2.0*ww*cos(qval*davg)),2) );
+	
+	return(Snq);
+}
+
+double
+paraCryst_an(double ww, double qval, double davg, long Nlayers) {
+	
+	double an;
+	
+	an = 4.0*ww*ww - 2.0*(ww*ww*ww+ww)*cos(qval*davg);
+	an -= 4.0*pow(ww,(Nlayers+2))*cos((double)Nlayers*qval*davg);
+	an += 2.0*pow(ww,(Nlayers+3))*cos((double)(Nlayers-1)*qval*davg);
+	an += 2.0*pow(ww,(Nlayers+1))*cos((double)(Nlayers+1)*qval*davg);
+	
+	return(an);
+}
+
