Index: sansmodels/src/sans/models/c_models/CBarBellModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CBarBellModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_models/CBarBellModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,625 @@
+/**
+	This software was developed by the University of Tennessee as part of the
+	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+	project funded by the US National Science Foundation.
+
+	If you use DANSE applications to do scientific research that leads to
+	publication, we ask that you acknowledge the use of the software with the
+	following sentence:
+
+	"This work benefited from DANSE software developed under NSF award DMR-0520547."
+
+	copyright 2008, University of Tennessee
+ */
+
+/** CBarBellModel
+ *
+ * C extension 
+ *
+ * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
+ *          DO NOT MODIFY THIS FILE, MODIFY barbell.h
+ *          AND RE-RUN THE GENERATOR SCRIPT
+ *
+ */
+#define NO_IMPORT_ARRAY
+#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
+ 
+extern "C" {
+#include <Python.h>
+#include <arrayobject.h>
+#include "structmember.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+#include "barbell.h"
+}
+
+#include "models.hh"
+#include "dispersion_visitor.hh"
+
+/// Error object for raised exceptions
+static PyObject * CBarBellModelError = NULL;
+
+
+// Class definition
+typedef struct {
+    PyObject_HEAD
+    /// Parameters
+    PyObject * params;
+    /// Dispersion parameters
+    PyObject * dispersion;
+    /// Underlying model object
+    BarBellModel * model;
+    /// Log for unit testing
+    PyObject * log;
+} CBarBellModel;
+
+
+static void
+CBarBellModel_dealloc(CBarBellModel* self)
+{
+    Py_DECREF(self->params);
+    Py_DECREF(self->dispersion);
+    Py_DECREF(self->log);
+    delete self->model;
+    self->ob_type->tp_free((PyObject*)self);
+    
+
+}
+
+static PyObject *
+CBarBellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    CBarBellModel *self;
+    
+    self = (CBarBellModel *)type->tp_alloc(type, 0);
+   
+    return (PyObject *)self;
+}
+
+static int
+CBarBellModel_init(CBarBellModel *self, PyObject *args, PyObject *kwds)
+{
+    if (self != NULL) {
+    	
+    	// Create parameters
+        self->params = PyDict_New();
+        self->dispersion = PyDict_New();
+        self->model = new BarBellModel();
+        
+        // Initialize parameter dictionary
+        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"sld_barbell",Py_BuildValue("d",0.000001000000));
+        PyDict_SetItemString(self->params,"len_bar",Py_BuildValue("d",400.000000000000));
+        PyDict_SetItemString(self->params,"rad_bell",Py_BuildValue("d",40.000000000000));
+        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"rad_bar",Py_BuildValue("d",20.000000000000));
+        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000));
+        // Initialize dispersion / averaging parameter dict
+        DispersionVisitor* visitor = new DispersionVisitor();
+        PyObject * disp_dict;
+        disp_dict = PyDict_New();
+        self->model->rad_bar.dispersion->accept_as_source(visitor, self->model->rad_bar.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "rad_bar", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->len_bar.dispersion->accept_as_source(visitor, self->model->len_bar.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "len_bar", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->rad_bell.dispersion->accept_as_source(visitor, self->model->rad_bell.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "rad_bell", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
+
+
+         
+        // Create empty log
+        self->log = PyDict_New();
+        
+        
+
+    }
+    return 0;
+}
+
+static PyMemberDef CBarBellModel_members[] = {
+    {"params", T_OBJECT, offsetof(CBarBellModel, params), 0,
+     "Parameters"},
+	{"dispersion", T_OBJECT, offsetof(CBarBellModel, dispersion), 0,
+	  "Dispersion parameters"},     
+    {"log", T_OBJECT, offsetof(CBarBellModel, log), 0,
+     "Log"},
+    {NULL}  /* Sentinel */
+};
+
+/** Read double from PyObject
+    @param p PyObject
+    @return double
+*/
+double CBarBellModel_readDouble(PyObject *p) {
+    if (PyFloat_Check(p)==1) {
+        return (double)(((PyFloatObject *)(p))->ob_fval);
+    } else if (PyInt_Check(p)==1) {
+        return (double)(((PyIntObject *)(p))->ob_ival);
+    } else if (PyLong_Check(p)==1) {
+        return (double)PyLong_AsLong(p);
+    } else {
+        return 0.0;
+    }
+}
+/**
+ * Function to call to evaluate model
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
+ */
+ 
+static PyObject *evaluateOneDim(BarBellModel* model, PyArrayObject *q){
+    PyArrayObject *result;
+   
+    // Check validity of array q , q must be of dimension 1, an array of double
+    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
+    {
+        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
+        //PyErr_SetString(PyExc_ValueError , message);
+        return NULL;
+    }
+    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 
+										  PyArray_DOUBLE);
+	if (result == NULL) {
+        const char * message= "Could not create result ";
+        PyErr_SetString(PyExc_RuntimeError , message);
+		return NULL;
+	}
+	 for (int i = 0; i < q->dimensions[0]; i++){
+      double q_value  = *(double *)(q->data + i*q->strides[0]);
+      double *result_value = (double *)(result->data + i*result->strides[0]);
+      *result_value =(*model)(q_value);
+	}
+    return PyArray_Return(result); 
+ }
+
+ /**
+ * Function to call to evaluate model
+ * @param args: input numpy array  [x[],y[]]
+ * @return: numpy array object 
+ */
+ static PyObject * evaluateTwoDimXY( BarBellModel* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[1];
+    //check validity of input vectors
+    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[0] != x->dimensions[0]){
+        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
+        PyErr_SetString(PyExc_ValueError , message); 
+        return NULL;
+    }
+   
+	if (PyArray_Check(x) && PyArray_Check(y)) {
+		
+	    x_len = dims[0]= x->dimensions[0];
+        y_len = dims[0]= y->dimensions[0];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
+        if (result == NULL){
+	    const char * message= "Could not create result ";
+        PyErr_SetString(PyExc_RuntimeError , message);
+	    return NULL;
+	    }
+       
+        /* Do the calculation. */
+        for ( i=0; i< x_len; i++) {
+            double x_value = *(double *)(x->data + i*x->strides[0]);
+  		    double y_value = *(double *)(y->data + i*y->strides[0]);
+  			double *result_value = (double *)(result->data +
+  			      i*result->strides[0]);
+  			*result_value = (*model)(x_value, y_value);
+        }           
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CBarBellModelError, 
+                   "CBarBellModel.evaluateTwoDimXY couldn't run.");
+	        return NULL;
+		}      	
+}
+/**
+ *  evalDistribution function evaluate a model function with input vector
+ *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
+ *
+ */ 
+static PyObject * evalDistribution(CBarBellModel *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
+    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
+    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
+    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
+    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
+    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CBarBellModelError, 
+	    	"CBarBellModel.evalDistribution expects a q value.");
+		return NULL;
+	}
+    // Check params
+	
+    if(PyArray_Check(pars)==1) {
+		
+	    // Length of list should 1 or 2
+	    npars = pars->nd; 
+	    if(npars==1) {
+	        // input is a numpy array
+	        if (PyArray_Check(pars)) {
+		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
+		    }
+		}else{
+		    PyErr_SetString(CBarBellModelError, 
+                   "CBarBellModel.evalDistribution expect numpy array of one dimension.");
+	        return NULL;
+		}
+    }else if( PyList_Check(pars)==1) {
+    	// Length of list should be 2 for I(qx,qy)
+	    mpars = PyList_GET_SIZE(pars); 
+	    if(mpars!=2) {
+	    	PyErr_SetString(CBarBellModelError, 
+	    		"CBarBellModel.evalDistribution expects a list of dimension 2.");
+	    	return NULL;
+	    }
+	     qx = PyList_GET_ITEM(pars,0);
+	     qy = PyList_GET_ITEM(pars,1);
+	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
+	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
+		           (PyArrayObject*)qy);
+		 }else{
+		    PyErr_SetString(CBarBellModelError, 
+                   "CBarBellModel.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}
+	PyErr_SetString(CBarBellModelError, 
+                   "CBarBellModel.evalDistribution couln't be run.");
+	return NULL;
+	
+}
+
+/**
+ * Function to call to evaluate model
+ * @param args: input q or [q,phi]
+ * @return: function value
+ */
+static PyObject * run(CBarBellModel *self, PyObject *args) {
+	double q_value, phi_value;
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
+    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
+    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
+    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
+    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
+    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CBarBellModelError, 
+	    	"CBarBellModel.run expects a q value.");
+		return NULL;
+	}
+	  
+	// Check params
+	if( PyList_Check(pars)==1) {
+		
+		// Length of list should be 2 for I(q,phi)
+	    npars = PyList_GET_SIZE(pars); 
+	    if(npars!=2) {
+	    	PyErr_SetString(CBarBellModelError, 
+	    		"CBarBellModel.run expects a double or a list of dimension 2.");
+	    	return NULL;
+	    }
+	    // We have a vector q, get the q and phi values at which
+	    // to evaluate I(q,phi)
+	    q_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,0));
+	    phi_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,1));
+	    // Skip zero
+	    if (q_value==0) {
+	    	return Py_BuildValue("d",0.0);
+	    }
+		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
+
+	} else {
+
+		// We have a scalar q, we will evaluate I(q)
+		q_value = CBarBellModel_readDouble(pars);		
+		
+		return Py_BuildValue("d",(*(self->model))(q_value));
+	}	
+}
+/**
+ * Function to call to calculate_ER
+ * @return: effective radius value 
+ */
+static PyObject * calculate_ER(CBarBellModel *self) {
+
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
+    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
+    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
+    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
+    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
+    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+		
+	return Py_BuildValue("d",(*(self->model)).calculate_ER());
+
+}
+/**
+ * Function to call to evaluate model in cartesian coordinates
+ * @param args: input q or [qx, qy]]
+ * @return: function value
+ */
+static PyObject * runXY(CBarBellModel *self, PyObject *args) {
+	double qx_value, qy_value;
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sld_barbell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_barbell") );
+    self->model->len_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_bar") );
+    self->model->rad_bell = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bell") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_bar = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_bar") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bar");
+    self->model->rad_bar.dispersion->accept_as_destination(visitor, self->model->rad_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_bar");
+    self->model->len_bar.dispersion->accept_as_destination(visitor, self->model->len_bar.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_bell");
+    self->model->rad_bell.dispersion->accept_as_destination(visitor, self->model->rad_bell.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CBarBellModelError, 
+	    	"CBarBellModel.run expects a q value.");
+		return NULL;
+	}
+	  
+	// Check params
+	if( PyList_Check(pars)==1) {
+		
+		// Length of list should be 2 for I(qx, qy))
+	    npars = PyList_GET_SIZE(pars); 
+	    if(npars!=2) {
+	    	PyErr_SetString(CBarBellModelError, 
+	    		"CBarBellModel.run expects a double or a list of dimension 2.");
+	    	return NULL;
+	    }
+	    // We have a vector q, get the qx and qy values at which
+	    // to evaluate I(qx,qy)
+	    qx_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,0));
+	    qy_value = CBarBellModel_readDouble(PyList_GET_ITEM(pars,1));
+	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
+
+	} else {
+
+		// We have a scalar q, we will evaluate I(q)
+		qx_value = CBarBellModel_readDouble(pars);		
+		
+		return Py_BuildValue("d",(*(self->model))(qx_value));
+	}	
+}
+
+static PyObject * reset(CBarBellModel *self, PyObject *args) {
+    
+
+    return Py_BuildValue("d",0.0);
+}
+
+static PyObject * set_dispersion(CBarBellModel *self, PyObject *args) {
+	PyObject * disp;
+	const char * par_name;
+
+	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
+	    PyErr_SetString(CBarBellModelError,
+	    	"CBarBellModel.set_dispersion expects a DispersionModel object.");
+		return NULL;
+	}
+	void *temp = PyCObject_AsVoidPtr(disp);
+	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
+
+
+	// Ugliness necessary to go from python to C
+	    // TODO: refactor this
+    if (!strcmp(par_name, "rad_bar")) {
+        self->model->rad_bar.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "len_bar")) {
+        self->model->len_bar.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "rad_bell")) {
+        self->model->rad_bell.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "phi")) {
+        self->model->phi.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "theta")) {
+        self->model->theta.dispersion = dispersion;
+    } else {
+	    PyErr_SetString(CBarBellModelError,
+	    	"CBarBellModel.set_dispersion expects a valid parameter name.");
+		return NULL;
+	}
+
+	DispersionVisitor* visitor = new DispersionVisitor();
+	PyObject * disp_dict = PyDict_New();
+	dispersion->accept_as_source(visitor, dispersion, disp_dict);
+	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
+    return Py_BuildValue("i",1);
+}
+
+
+static PyMethodDef CBarBellModel_methods[] = {
+    {"run",      (PyCFunction)run     , METH_VARARGS,
+      "Evaluate the model at a given Q or Q, phi"},
+    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy"},
+    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
+      "Evaluate the model at a given Q or Q, phi"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
+    {"reset",    (PyCFunction)reset   , METH_VARARGS,
+      "Reset pair correlation"},
+    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
+      "Set the dispersion model for a given parameter"},
+   {NULL}
+};
+
+static PyTypeObject CBarBellModelType = {
+    PyObject_HEAD_INIT(NULL)
+    0,                         /*ob_size*/
+    "CBarBellModel",             /*tp_name*/
+    sizeof(CBarBellModel),             /*tp_basicsize*/
+    0,                         /*tp_itemsize*/
+    (destructor)CBarBellModel_dealloc, /*tp_dealloc*/
+    0,                         /*tp_print*/
+    0,                         /*tp_getattr*/
+    0,                         /*tp_setattr*/
+    0,                         /*tp_compare*/
+    0,                         /*tp_repr*/
+    0,                         /*tp_as_number*/
+    0,                         /*tp_as_sequence*/
+    0,                         /*tp_as_mapping*/
+    0,                         /*tp_hash */
+    0,                         /*tp_call*/
+    0,                         /*tp_str*/
+    0,                         /*tp_getattro*/
+    0,                         /*tp_setattro*/
+    0,                         /*tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+    "CBarBellModel objects",           /* tp_doc */
+    0,		               /* tp_traverse */
+    0,		               /* tp_clear */
+    0,		               /* tp_richcompare */
+    0,		               /* tp_weaklistoffset */
+    0,		               /* tp_iter */
+    0,		               /* tp_iternext */
+    CBarBellModel_methods,             /* tp_methods */
+    CBarBellModel_members,             /* tp_members */
+    0,                         /* tp_getset */
+    0,                         /* tp_base */
+    0,                         /* tp_dict */
+    0,                         /* tp_descr_get */
+    0,                         /* tp_descr_set */
+    0,                         /* tp_dictoffset */
+    (initproc)CBarBellModel_init,      /* tp_init */
+    0,                         /* tp_alloc */
+    CBarBellModel_new,                 /* tp_new */
+};
+
+
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
+
+/**
+ * Function used to add the model class to a module
+ * @param module: module to add the class to
+ */ 
+void addCBarBellModel(PyObject *module) {
+	PyObject *d;
+	
+    if (PyType_Ready(&CBarBellModelType) < 0)
+        return;
+
+    Py_INCREF(&CBarBellModelType);
+    PyModule_AddObject(module, "CBarBellModel", (PyObject *)&CBarBellModelType);
+    
+    d = PyModule_GetDict(module);
+    CBarBellModelError = PyErr_NewException("CBarBellModel.error", NULL, NULL);
+    PyDict_SetItemString(d, "CBarBellModelError", CBarBellModelError);
+}
+
Index: sansmodels/src/sans/models/c_models/CCappedCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCappedCylinderModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_models/CCappedCylinderModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,625 @@
+/**
+	This software was developed by the University of Tennessee as part of the
+	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+	project funded by the US National Science Foundation.
+
+	If you use DANSE applications to do scientific research that leads to
+	publication, we ask that you acknowledge the use of the software with the
+	following sentence:
+
+	"This work benefited from DANSE software developed under NSF award DMR-0520547."
+
+	copyright 2008, University of Tennessee
+ */
+
+/** CCappedCylinderModel
+ *
+ * C extension 
+ *
+ * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
+ *          DO NOT MODIFY THIS FILE, MODIFY capcyl.h
+ *          AND RE-RUN THE GENERATOR SCRIPT
+ *
+ */
+#define NO_IMPORT_ARRAY
+#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
+ 
+extern "C" {
+#include <Python.h>
+#include <arrayobject.h>
+#include "structmember.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+#include "capcyl.h"
+}
+
+#include "models.hh"
+#include "dispersion_visitor.hh"
+
+/// Error object for raised exceptions
+static PyObject * CCappedCylinderModelError = NULL;
+
+
+// Class definition
+typedef struct {
+    PyObject_HEAD
+    /// Parameters
+    PyObject * params;
+    /// Dispersion parameters
+    PyObject * dispersion;
+    /// Underlying model object
+    CappedCylinderModel * model;
+    /// Log for unit testing
+    PyObject * log;
+} CCappedCylinderModel;
+
+
+static void
+CCappedCylinderModel_dealloc(CCappedCylinderModel* self)
+{
+    Py_DECREF(self->params);
+    Py_DECREF(self->dispersion);
+    Py_DECREF(self->log);
+    delete self->model;
+    self->ob_type->tp_free((PyObject*)self);
+    
+
+}
+
+static PyObject *
+CCappedCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    CCappedCylinderModel *self;
+    
+    self = (CCappedCylinderModel *)type->tp_alloc(type, 0);
+   
+    return (PyObject *)self;
+}
+
+static int
+CCappedCylinderModel_init(CCappedCylinderModel *self, PyObject *args, PyObject *kwds)
+{
+    if (self != NULL) {
+    	
+    	// Create parameters
+        self->params = PyDict_New();
+        self->dispersion = PyDict_New();
+        self->model = new CappedCylinderModel();
+        
+        // Initialize parameter dictionary
+        PyDict_SetItemString(self->params,"phi",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"len_cyl",Py_BuildValue("d",400.000000000000));
+        PyDict_SetItemString(self->params,"sld_capcyl",Py_BuildValue("d",0.000001000000));
+        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"theta",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"rad_cap",Py_BuildValue("d",40.000000000000));
+        PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006300000));
+        PyDict_SetItemString(self->params,"rad_cyl",Py_BuildValue("d",20.000000000000));
+        // Initialize dispersion / averaging parameter dict
+        DispersionVisitor* visitor = new DispersionVisitor();
+        PyObject * disp_dict;
+        disp_dict = PyDict_New();
+        self->model->rad_cyl.dispersion->accept_as_source(visitor, self->model->rad_cyl.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "rad_cyl", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->len_cyl.dispersion->accept_as_source(visitor, self->model->len_cyl.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "len_cyl", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->rad_cap.dispersion->accept_as_source(visitor, self->model->rad_cap.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "rad_cap", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->phi.dispersion->accept_as_source(visitor, self->model->phi.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "phi", disp_dict);
+        disp_dict = PyDict_New();
+        self->model->theta.dispersion->accept_as_source(visitor, self->model->theta.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "theta", disp_dict);
+
+
+         
+        // Create empty log
+        self->log = PyDict_New();
+        
+        
+
+    }
+    return 0;
+}
+
+static PyMemberDef CCappedCylinderModel_members[] = {
+    {"params", T_OBJECT, offsetof(CCappedCylinderModel, params), 0,
+     "Parameters"},
+	{"dispersion", T_OBJECT, offsetof(CCappedCylinderModel, dispersion), 0,
+	  "Dispersion parameters"},     
+    {"log", T_OBJECT, offsetof(CCappedCylinderModel, log), 0,
+     "Log"},
+    {NULL}  /* Sentinel */
+};
+
+/** Read double from PyObject
+    @param p PyObject
+    @return double
+*/
+double CCappedCylinderModel_readDouble(PyObject *p) {
+    if (PyFloat_Check(p)==1) {
+        return (double)(((PyFloatObject *)(p))->ob_fval);
+    } else if (PyInt_Check(p)==1) {
+        return (double)(((PyIntObject *)(p))->ob_ival);
+    } else if (PyLong_Check(p)==1) {
+        return (double)PyLong_AsLong(p);
+    } else {
+        return 0.0;
+    }
+}
+/**
+ * Function to call to evaluate model
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
+ */
+ 
+static PyObject *evaluateOneDim(CappedCylinderModel* model, PyArrayObject *q){
+    PyArrayObject *result;
+   
+    // Check validity of array q , q must be of dimension 1, an array of double
+    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
+    {
+        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
+        //PyErr_SetString(PyExc_ValueError , message);
+        return NULL;
+    }
+    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 
+										  PyArray_DOUBLE);
+	if (result == NULL) {
+        const char * message= "Could not create result ";
+        PyErr_SetString(PyExc_RuntimeError , message);
+		return NULL;
+	}
+	 for (int i = 0; i < q->dimensions[0]; i++){
+      double q_value  = *(double *)(q->data + i*q->strides[0]);
+      double *result_value = (double *)(result->data + i*result->strides[0]);
+      *result_value =(*model)(q_value);
+	}
+    return PyArray_Return(result); 
+ }
+
+ /**
+ * Function to call to evaluate model
+ * @param args: input numpy array  [x[],y[]]
+ * @return: numpy array object 
+ */
+ static PyObject * evaluateTwoDimXY( CappedCylinderModel* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[1];
+    //check validity of input vectors
+    if (x->nd != 1 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 1 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[0] != x->dimensions[0]){
+        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
+        PyErr_SetString(PyExc_ValueError , message); 
+        return NULL;
+    }
+   
+	if (PyArray_Check(x) && PyArray_Check(y)) {
+		
+	    x_len = dims[0]= x->dimensions[0];
+        y_len = dims[0]= y->dimensions[0];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(1,dims,NPY_DOUBLE);
+        if (result == NULL){
+	    const char * message= "Could not create result ";
+        PyErr_SetString(PyExc_RuntimeError , message);
+	    return NULL;
+	    }
+       
+        /* Do the calculation. */
+        for ( i=0; i< x_len; i++) {
+            double x_value = *(double *)(x->data + i*x->strides[0]);
+  		    double y_value = *(double *)(y->data + i*y->strides[0]);
+  			double *result_value = (double *)(result->data +
+  			      i*result->strides[0]);
+  			*result_value = (*model)(x_value, y_value);
+        }           
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CCappedCylinderModelError, 
+                   "CCappedCylinderModel.evaluateTwoDimXY couldn't run.");
+	        return NULL;
+		}      	
+}
+/**
+ *  evalDistribution function evaluate a model function with input vector
+ *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
+ *
+ */ 
+static PyObject * evalDistribution(CCappedCylinderModel *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
+    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
+    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
+    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
+    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CCappedCylinderModelError, 
+	    	"CCappedCylinderModel.evalDistribution expects a q value.");
+		return NULL;
+	}
+    // Check params
+	
+    if(PyArray_Check(pars)==1) {
+		
+	    // Length of list should 1 or 2
+	    npars = pars->nd; 
+	    if(npars==1) {
+	        // input is a numpy array
+	        if (PyArray_Check(pars)) {
+		        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
+		    }
+		}else{
+		    PyErr_SetString(CCappedCylinderModelError, 
+                   "CCappedCylinderModel.evalDistribution expect numpy array of one dimension.");
+	        return NULL;
+		}
+    }else if( PyList_Check(pars)==1) {
+    	// Length of list should be 2 for I(qx,qy)
+	    mpars = PyList_GET_SIZE(pars); 
+	    if(mpars!=2) {
+	    	PyErr_SetString(CCappedCylinderModelError, 
+	    		"CCappedCylinderModel.evalDistribution expects a list of dimension 2.");
+	    	return NULL;
+	    }
+	     qx = PyList_GET_ITEM(pars,0);
+	     qy = PyList_GET_ITEM(pars,1);
+	     if (PyArray_Check(qx) && PyArray_Check(qy)) {
+	         return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
+		           (PyArrayObject*)qy);
+		 }else{
+		    PyErr_SetString(CCappedCylinderModelError, 
+                   "CCappedCylinderModel.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}
+	PyErr_SetString(CCappedCylinderModelError, 
+                   "CCappedCylinderModel.evalDistribution couln't be run.");
+	return NULL;
+	
+}
+
+/**
+ * Function to call to evaluate model
+ * @param args: input q or [q,phi]
+ * @return: function value
+ */
+static PyObject * run(CCappedCylinderModel *self, PyObject *args) {
+	double q_value, phi_value;
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
+    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
+    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
+    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
+    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CCappedCylinderModelError, 
+	    	"CCappedCylinderModel.run expects a q value.");
+		return NULL;
+	}
+	  
+	// Check params
+	if( PyList_Check(pars)==1) {
+		
+		// Length of list should be 2 for I(q,phi)
+	    npars = PyList_GET_SIZE(pars); 
+	    if(npars!=2) {
+	    	PyErr_SetString(CCappedCylinderModelError, 
+	    		"CCappedCylinderModel.run expects a double or a list of dimension 2.");
+	    	return NULL;
+	    }
+	    // We have a vector q, get the q and phi values at which
+	    // to evaluate I(q,phi)
+	    q_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
+	    phi_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
+	    // Skip zero
+	    if (q_value==0) {
+	    	return Py_BuildValue("d",0.0);
+	    }
+		return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
+
+	} else {
+
+		// We have a scalar q, we will evaluate I(q)
+		q_value = CCappedCylinderModel_readDouble(pars);		
+		
+		return Py_BuildValue("d",(*(self->model))(q_value));
+	}	
+}
+/**
+ * Function to call to calculate_ER
+ * @return: effective radius value 
+ */
+static PyObject * calculate_ER(CCappedCylinderModel *self) {
+
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
+    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
+    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
+    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
+    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+		
+	return Py_BuildValue("d",(*(self->model)).calculate_ER());
+
+}
+/**
+ * Function to call to evaluate model in cartesian coordinates
+ * @param args: input q or [qx, qy]]
+ * @return: function value
+ */
+static PyObject * runXY(CCappedCylinderModel *self, PyObject *args) {
+	double qx_value, qy_value;
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->phi = PyFloat_AsDouble( PyDict_GetItemString(self->params, "phi") );
+    self->model->len_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "len_cyl") );
+    self->model->sld_capcyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_capcyl") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->theta = PyFloat_AsDouble( PyDict_GetItemString(self->params, "theta") );
+    self->model->rad_cap = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cap") );
+    self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
+    self->model->rad_cyl = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_cyl") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cyl");
+    self->model->rad_cyl.dispersion->accept_as_destination(visitor, self->model->rad_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "len_cyl");
+    self->model->len_cyl.dispersion->accept_as_destination(visitor, self->model->len_cyl.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_cap");
+    self->model->rad_cap.dispersion->accept_as_destination(visitor, self->model->rad_cap.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "phi");
+    self->model->phi.dispersion->accept_as_destination(visitor, self->model->phi.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "theta");
+    self->model->theta.dispersion->accept_as_destination(visitor, self->model->theta.dispersion, disp_dict);
+
+	
+	// Get input and determine whether we have to supply a 1D or 2D return value.
+	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
+	    PyErr_SetString(CCappedCylinderModelError, 
+	    	"CCappedCylinderModel.run expects a q value.");
+		return NULL;
+	}
+	  
+	// Check params
+	if( PyList_Check(pars)==1) {
+		
+		// Length of list should be 2 for I(qx, qy))
+	    npars = PyList_GET_SIZE(pars); 
+	    if(npars!=2) {
+	    	PyErr_SetString(CCappedCylinderModelError, 
+	    		"CCappedCylinderModel.run expects a double or a list of dimension 2.");
+	    	return NULL;
+	    }
+	    // We have a vector q, get the qx and qy values at which
+	    // to evaluate I(qx,qy)
+	    qx_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
+	    qy_value = CCappedCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
+	    return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
+
+	} else {
+
+		// We have a scalar q, we will evaluate I(q)
+		qx_value = CCappedCylinderModel_readDouble(pars);		
+		
+		return Py_BuildValue("d",(*(self->model))(qx_value));
+	}	
+}
+
+static PyObject * reset(CCappedCylinderModel *self, PyObject *args) {
+    
+
+    return Py_BuildValue("d",0.0);
+}
+
+static PyObject * set_dispersion(CCappedCylinderModel *self, PyObject *args) {
+	PyObject * disp;
+	const char * par_name;
+
+	if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
+	    PyErr_SetString(CCappedCylinderModelError,
+	    	"CCappedCylinderModel.set_dispersion expects a DispersionModel object.");
+		return NULL;
+	}
+	void *temp = PyCObject_AsVoidPtr(disp);
+	DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
+
+
+	// Ugliness necessary to go from python to C
+	    // TODO: refactor this
+    if (!strcmp(par_name, "rad_cyl")) {
+        self->model->rad_cyl.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "len_cyl")) {
+        self->model->len_cyl.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "rad_cap")) {
+        self->model->rad_cap.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "phi")) {
+        self->model->phi.dispersion = dispersion;
+    } else    if (!strcmp(par_name, "theta")) {
+        self->model->theta.dispersion = dispersion;
+    } else {
+	    PyErr_SetString(CCappedCylinderModelError,
+	    	"CCappedCylinderModel.set_dispersion expects a valid parameter name.");
+		return NULL;
+	}
+
+	DispersionVisitor* visitor = new DispersionVisitor();
+	PyObject * disp_dict = PyDict_New();
+	dispersion->accept_as_source(visitor, dispersion, disp_dict);
+	PyDict_SetItemString(self->dispersion, par_name, disp_dict);
+    return Py_BuildValue("i",1);
+}
+
+
+static PyMethodDef CCappedCylinderModel_methods[] = {
+    {"run",      (PyCFunction)run     , METH_VARARGS,
+      "Evaluate the model at a given Q or Q, phi"},
+    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy"},
+    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
+      "Evaluate the model at a given Q or Q, phi"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
+    {"reset",    (PyCFunction)reset   , METH_VARARGS,
+      "Reset pair correlation"},
+    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
+      "Set the dispersion model for a given parameter"},
+   {NULL}
+};
+
+static PyTypeObject CCappedCylinderModelType = {
+    PyObject_HEAD_INIT(NULL)
+    0,                         /*ob_size*/
+    "CCappedCylinderModel",             /*tp_name*/
+    sizeof(CCappedCylinderModel),             /*tp_basicsize*/
+    0,                         /*tp_itemsize*/
+    (destructor)CCappedCylinderModel_dealloc, /*tp_dealloc*/
+    0,                         /*tp_print*/
+    0,                         /*tp_getattr*/
+    0,                         /*tp_setattr*/
+    0,                         /*tp_compare*/
+    0,                         /*tp_repr*/
+    0,                         /*tp_as_number*/
+    0,                         /*tp_as_sequence*/
+    0,                         /*tp_as_mapping*/
+    0,                         /*tp_hash */
+    0,                         /*tp_call*/
+    0,                         /*tp_str*/
+    0,                         /*tp_getattro*/
+    0,                         /*tp_setattro*/
+    0,                         /*tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+    "CCappedCylinderModel objects",           /* tp_doc */
+    0,		               /* tp_traverse */
+    0,		               /* tp_clear */
+    0,		               /* tp_richcompare */
+    0,		               /* tp_weaklistoffset */
+    0,		               /* tp_iter */
+    0,		               /* tp_iternext */
+    CCappedCylinderModel_methods,             /* tp_methods */
+    CCappedCylinderModel_members,             /* tp_members */
+    0,                         /* tp_getset */
+    0,                         /* tp_base */
+    0,                         /* tp_dict */
+    0,                         /* tp_descr_get */
+    0,                         /* tp_descr_set */
+    0,                         /* tp_dictoffset */
+    (initproc)CCappedCylinderModel_init,      /* tp_init */
+    0,                         /* tp_alloc */
+    CCappedCylinderModel_new,                 /* tp_new */
+};
+
+
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
+
+/**
+ * Function used to add the model class to a module
+ * @param module: module to add the class to
+ */ 
+void addCCappedCylinderModel(PyObject *module) {
+	PyObject *d;
+	
+    if (PyType_Ready(&CCappedCylinderModelType) < 0)
+        return;
+
+    Py_INCREF(&CCappedCylinderModelType);
+    PyModule_AddObject(module, "CCappedCylinderModel", (PyObject *)&CCappedCylinderModelType);
+    
+    d = PyModule_GetDict(module);
+    CCappedCylinderModelError = PyErr_NewException("CCappedCylinderModel.error", NULL, NULL);
+    PyDict_SetItemString(d, "CCappedCylinderModelError", CCappedCylinderModelError);
+}
+
Index: sansmodels/src/sans/models/c_models/CCoreFourShellModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCoreFourShellModel.cpp	(revision 35aface36aa7573475600ebbacb987f50386d5f8)
+++ sansmodels/src/sans/models/c_models/CCoreFourShellModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -97,8 +97,8 @@
         PyDict_SetItemString(self->params,"thick_shell2",Py_BuildValue("d",10.000000000000));
         PyDict_SetItemString(self->params,"sld_shell1",Py_BuildValue("d",0.000001000000));
-        PyDict_SetItemString(self->params,"rad_core",Py_BuildValue("d",60.000000000000));
-        PyDict_SetItemString(self->params,"sld_core",Py_BuildValue("d",0.000006400000));
+        PyDict_SetItemString(self->params,"thick_shell3",Py_BuildValue("d",10.000000000000));
+        PyDict_SetItemString(self->params,"sld_core0",Py_BuildValue("d",0.000006400000));
         PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000000000));
-        PyDict_SetItemString(self->params,"thick_shell3",Py_BuildValue("d",10.000000000000));
+        PyDict_SetItemString(self->params,"rad_core0",Py_BuildValue("d",60.000000000000));
         PyDict_SetItemString(self->params,"sld_solv",Py_BuildValue("d",0.000006400000));
         PyDict_SetItemString(self->params,"sld_shell3",Py_BuildValue("d",0.000003000000));
@@ -107,6 +107,6 @@
         PyObject * disp_dict;
         disp_dict = PyDict_New();
-        self->model->rad_core.dispersion->accept_as_source(visitor, self->model->rad_core.dispersion, disp_dict);
-        PyDict_SetItemString(self->dispersion, "rad_core", disp_dict);
+        self->model->rad_core0.dispersion->accept_as_source(visitor, self->model->rad_core0.dispersion, disp_dict);
+        PyDict_SetItemString(self->dispersion, "rad_core0", disp_dict);
         disp_dict = PyDict_New();
         self->model->thick_shell1.dispersion->accept_as_source(visitor, self->model->thick_shell1.dispersion, disp_dict);
@@ -257,8 +257,8 @@
     self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
     self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->rad_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
+    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
     self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
     self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
@@ -266,6 +266,6 @@
     PyObject* disp_dict;
     DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core");
-    self->model->rad_core.dispersion->accept_as_destination(visitor, self->model->rad_core.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
+    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
     disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
     self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
@@ -345,8 +345,8 @@
     self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
     self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->rad_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
+    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
     self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
     self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
@@ -354,6 +354,6 @@
     PyObject* disp_dict;
     DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core");
-    self->model->rad_core.dispersion->accept_as_destination(visitor, self->model->rad_core.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
+    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
     disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
     self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
@@ -420,8 +420,8 @@
     self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
     self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->rad_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
+    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
     self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
     self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
@@ -429,6 +429,6 @@
     PyObject* disp_dict;
     DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core");
-    self->model->rad_core.dispersion->accept_as_destination(visitor, self->model->rad_core.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
+    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
     disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
     self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
@@ -464,8 +464,8 @@
     self->model->thick_shell2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell2") );
     self->model->sld_shell1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell1") );
-    self->model->rad_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core") );
-    self->model->sld_core = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core") );
+    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->sld_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_core0") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
-    self->model->thick_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_shell3") );
+    self->model->rad_core0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "rad_core0") );
     self->model->sld_solv = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solv") );
     self->model->sld_shell3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_shell3") );
@@ -473,6 +473,6 @@
     PyObject* disp_dict;
     DispersionVisitor* visitor = new DispersionVisitor();
-    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core");
-    self->model->rad_core.dispersion->accept_as_destination(visitor, self->model->rad_core.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "rad_core0");
+    self->model->rad_core0.dispersion->accept_as_destination(visitor, self->model->rad_core0.dispersion, disp_dict);
     disp_dict = PyDict_GetItemString(self->dispersion, "thick_shell1");
     self->model->thick_shell1.dispersion->accept_as_destination(visitor, self->model->thick_shell1.dispersion, disp_dict);
@@ -538,6 +538,6 @@
 	// Ugliness necessary to go from python to C
 	    // TODO: refactor this
-    if (!strcmp(par_name, "rad_core")) {
-        self->model->rad_core.dispersion = dispersion;
+    if (!strcmp(par_name, "rad_core0")) {
+        self->model->rad_core0.dispersion = dispersion;
     } else    if (!strcmp(par_name, "thick_shell1")) {
         self->model->thick_shell1.dispersion = dispersion;
Index: sansmodels/src/sans/models/c_models/CReflModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CReflModel.cpp	(revision 35aface36aa7573475600ebbacb987f50386d5f8)
+++ sansmodels/src/sans/models/c_models/CReflModel.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -90,6 +90,10 @@
         
         // Initialize parameter dictionary
+        PyDict_SetItemString(self->params,"sldIM_flat4",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"thick_flat8",Py_BuildValue("d",100.000000000000));
         PyDict_SetItemString(self->params,"thick_flat9",Py_BuildValue("d",100.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat7",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat10",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat5",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"thick_flat1",Py_BuildValue("d",10.000000000000));
         PyDict_SetItemString(self->params,"thick_flat3",Py_BuildValue("d",100.000000000000));
@@ -109,7 +113,10 @@
         PyDict_SetItemString(self->params,"thick_inter8",Py_BuildValue("d",1.000000000000));
         PyDict_SetItemString(self->params,"thick_inter9",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat1",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat2",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"func_inter9",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"thick_inter10",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat3",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"func_inter8",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"thick_flat2",Py_BuildValue("d",100.000000000000));
@@ -129,10 +136,15 @@
         PyDict_SetItemString(self->params,"sld_flat2",Py_BuildValue("d",0.000003500000));
         PyDict_SetItemString(self->params,"sld_flat3",Py_BuildValue("d",0.000004000000));
+        PyDict_SetItemString(self->params,"sldIM_flat8",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"sld_flat8",Py_BuildValue("d",0.000003500000));
         PyDict_SetItemString(self->params,"sld_flat9",Py_BuildValue("d",0.000004000000));
+        PyDict_SetItemString(self->params,"sldIM_flat9",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"func_inter1",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_sub0",Py_BuildValue("d",0.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_medium",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"sld_flat10",Py_BuildValue("d",0.000003500000));
         PyDict_SetItemString(self->params,"thick_inter0",Py_BuildValue("d",1.000000000000));
+        PyDict_SetItemString(self->params,"sldIM_flat6",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"func_inter4",Py_BuildValue("d",0.000000000000));
         PyDict_SetItemString(self->params,"func_inter10",Py_BuildValue("d",0.000000000000));
@@ -272,6 +284,10 @@
 	
 	    // Reader parameter dictionary
+    self->model->sldIM_flat4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat4") );
     self->model->thick_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat8") );
     self->model->thick_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat9") );
+    self->model->sldIM_flat7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat7") );
+    self->model->sldIM_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat10") );
+    self->model->sldIM_flat5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat5") );
     self->model->thick_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat1") );
     self->model->thick_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat3") );
@@ -291,7 +307,10 @@
     self->model->thick_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter8") );
     self->model->thick_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter9") );
+    self->model->sldIM_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat1") );
     self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sldIM_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat2") );
     self->model->func_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter9") );
     self->model->thick_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter10") );
+    self->model->sldIM_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat3") );
     self->model->func_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter8") );
     self->model->thick_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat2") );
@@ -311,10 +330,15 @@
     self->model->sld_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat2") );
     self->model->sld_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat3") );
+    self->model->sldIM_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat8") );
     self->model->sld_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat8") );
     self->model->sld_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat9") );
+    self->model->sldIM_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat9") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
     self->model->func_inter1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter1") );
+    self->model->sldIM_sub0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_sub0") );
+    self->model->sldIM_medium = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_medium") );
     self->model->sld_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat10") );
     self->model->thick_inter0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter0") );
+    self->model->sldIM_flat6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat6") );
     self->model->func_inter4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter4") );
     self->model->func_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter10") );
@@ -386,6 +410,10 @@
 	
 	    // Reader parameter dictionary
+    self->model->sldIM_flat4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat4") );
     self->model->thick_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat8") );
     self->model->thick_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat9") );
+    self->model->sldIM_flat7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat7") );
+    self->model->sldIM_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat10") );
+    self->model->sldIM_flat5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat5") );
     self->model->thick_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat1") );
     self->model->thick_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat3") );
@@ -405,7 +433,10 @@
     self->model->thick_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter8") );
     self->model->thick_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter9") );
+    self->model->sldIM_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat1") );
     self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sldIM_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat2") );
     self->model->func_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter9") );
     self->model->thick_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter10") );
+    self->model->sldIM_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat3") );
     self->model->func_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter8") );
     self->model->thick_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat2") );
@@ -425,10 +456,15 @@
     self->model->sld_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat2") );
     self->model->sld_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat3") );
+    self->model->sldIM_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat8") );
     self->model->sld_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat8") );
     self->model->sld_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat9") );
+    self->model->sldIM_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat9") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
     self->model->func_inter1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter1") );
+    self->model->sldIM_sub0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_sub0") );
+    self->model->sldIM_medium = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_medium") );
     self->model->sld_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat10") );
     self->model->thick_inter0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter0") );
+    self->model->sldIM_flat6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat6") );
     self->model->func_inter4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter4") );
     self->model->func_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter10") );
@@ -487,6 +523,10 @@
 	
 	    // Reader parameter dictionary
+    self->model->sldIM_flat4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat4") );
     self->model->thick_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat8") );
     self->model->thick_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat9") );
+    self->model->sldIM_flat7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat7") );
+    self->model->sldIM_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat10") );
+    self->model->sldIM_flat5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat5") );
     self->model->thick_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat1") );
     self->model->thick_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat3") );
@@ -506,7 +546,10 @@
     self->model->thick_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter8") );
     self->model->thick_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter9") );
+    self->model->sldIM_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat1") );
     self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sldIM_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat2") );
     self->model->func_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter9") );
     self->model->thick_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter10") );
+    self->model->sldIM_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat3") );
     self->model->func_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter8") );
     self->model->thick_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat2") );
@@ -526,10 +569,15 @@
     self->model->sld_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat2") );
     self->model->sld_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat3") );
+    self->model->sldIM_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat8") );
     self->model->sld_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat8") );
     self->model->sld_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat9") );
+    self->model->sldIM_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat9") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
     self->model->func_inter1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter1") );
+    self->model->sldIM_sub0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_sub0") );
+    self->model->sldIM_medium = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_medium") );
     self->model->sld_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat10") );
     self->model->thick_inter0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter0") );
+    self->model->sldIM_flat6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat6") );
     self->model->func_inter4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter4") );
     self->model->func_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter10") );
@@ -557,6 +605,10 @@
 	
 	    // Reader parameter dictionary
+    self->model->sldIM_flat4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat4") );
     self->model->thick_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat8") );
     self->model->thick_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat9") );
+    self->model->sldIM_flat7 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat7") );
+    self->model->sldIM_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat10") );
+    self->model->sldIM_flat5 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat5") );
     self->model->thick_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat1") );
     self->model->thick_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat3") );
@@ -576,7 +628,10 @@
     self->model->thick_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter8") );
     self->model->thick_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter9") );
+    self->model->sldIM_flat1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat1") );
     self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->sldIM_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat2") );
     self->model->func_inter9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter9") );
     self->model->thick_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter10") );
+    self->model->sldIM_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat3") );
     self->model->func_inter8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter8") );
     self->model->thick_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_flat2") );
@@ -596,10 +651,15 @@
     self->model->sld_flat2 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat2") );
     self->model->sld_flat3 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat3") );
+    self->model->sldIM_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat8") );
     self->model->sld_flat8 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat8") );
     self->model->sld_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat9") );
+    self->model->sldIM_flat9 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat9") );
     self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
     self->model->func_inter1 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter1") );
+    self->model->sldIM_sub0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_sub0") );
+    self->model->sldIM_medium = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_medium") );
     self->model->sld_flat10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_flat10") );
     self->model->thick_inter0 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thick_inter0") );
+    self->model->sldIM_flat6 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sldIM_flat6") );
     self->model->func_inter4 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter4") );
     self->model->func_inter10 = PyFloat_AsDouble( PyDict_GetItemString(self->params, "func_inter10") );
Index: sansmodels/src/sans/models/c_models/barbell.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/barbell.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_models/barbell.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,253 @@
+/**
+	This software was developed by the University of Tennessee as part of the
+	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+	project funded by the US National Science Foundation.
+
+	If you use DANSE applications to do scientific research that leads to
+	publication, we ask that you acknowledge the use of the software with the
+	following sentence:
+
+	"This work benefited from DANSE software developed under NSF award DMR-0520547."
+
+	copyright 2008, University of Tennessee
+ */
+
+/**
+ * Scattering model classes
+ * The classes use the IGOR library found in
+ *   sansmodels/src/libigor
+ *
+ */
+
+#include <math.h>
+#include "models.hh"
+#include "parameters.hh"
+#include <stdio.h>
+using namespace std;
+
+extern "C" {
+	#include "libCylinder.h"
+	#include "barbell.h"
+}
+
+BarBellModel :: BarBellModel() {
+	scale      = Parameter(1.0);
+	rad_bar		= Parameter(20.0);
+	rad_bar.set_min(0.0);
+	len_bar     = Parameter(400.0, true);
+	len_bar.set_min(0.0);
+	rad_bell = Parameter(40.0);
+	rad_bell.set_min(0.0);
+	sld_barbell   = Parameter(1.0e-6);
+	sld_solv   = Parameter(6.3e-6);
+	background = Parameter(0.0);
+	theta  = Parameter(0.0, true);
+	phi    = Parameter(0.0, true);
+}
+
+/**
+ * Function to evaluate 1D scattering function
+ * The NIST IGOR library is used for the actual calculation.
+ * @param q: q-value
+ * @return: function value
+ */
+double BarBellModel :: operator()(double q) {
+	double dp[7];
+
+	// Fill parameter array for IGOR library
+	// Add the background after averaging
+	dp[0] = scale();
+	dp[1] = rad_bar();
+	dp[2] = len_bar();
+	dp[3] = rad_bell();
+	dp[4] = sld_barbell();
+	dp[5] = sld_solv();
+	dp[6] = 0.0;
+
+	// Get the dispersion points for the rad_bar
+	vector<WeightPoint> weights_rad_bar;
+	rad_bar.get_weights(weights_rad_bar);
+	// Get the dispersion points for the len_bar
+	vector<WeightPoint> weights_len_bar;
+	len_bar.get_weights(weights_len_bar);
+	// Get the dispersion points for the rad_bell
+	vector<WeightPoint> weights_rad_bell;
+	rad_bell.get_weights(weights_rad_bell);
+
+	// Perform the computation, with all weight points
+	double sum = 0.0;
+	double norm = 0.0;
+	double vol = 0.0;
+	double pi,hDist,result;
+	double vol_i = 0.0;
+	pi = 4.0*atan(1.0);
+	// Loop over radius weight points
+	for(int i=0; i<weights_rad_bar.size(); i++) {
+		dp[1] = weights_rad_bar[i].value;
+		for(int j=0; j<weights_len_bar.size(); j++) {
+			dp[2] = weights_len_bar[j].value;
+			for(int k=0; k<weights_rad_bell.size(); k++) {
+				dp[3] = weights_rad_bell[k].value;
+
+				//Un-normalize SphereForm by volume
+				hDist = sqrt(fabs(dp[3]*dp[3]-dp[1]*dp[1]));
+				vol_i = pi*dp[1]*dp[1]*dp[2]+2.0*pi*(2.0*dp[3]*dp[3]*dp[3]/3.0
+								+dp[3]*dp[3]*hDist-hDist*hDist*hDist/3.0);
+				result =  Barbell(dp, q) * vol_i;
+				// This FIXES a singualrity the kernel in libigor.
+				if ( result == INFINITY || result == NAN){
+					result = 0.0;
+				}
+				sum += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight
+					* result;
+				//Find average volume
+				vol += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight
+					* vol_i;
+
+				norm += weights_rad_bar[i].weight*weights_len_bar[j].weight*weights_rad_bell[k].weight;
+			}
+		}
+	}
+
+	if (vol != 0.0 && norm != 0.0) {
+		//Re-normalize by avg volume
+		sum = sum/(vol/norm);}
+	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param q_x: value of Q along x
+ * @param q_y: value of Q along y
+ * @return: function value
+ */
+double BarBellModel :: operator()(double qx, double qy) {
+	BarBellParameters dp;
+
+	double q = sqrt(qx*qx + qy*qy);
+	dp.scale = scale();
+	dp.rad_bar = rad_bar();
+	dp.len_bar = len_bar();
+	dp.rad_bell = rad_bell();
+	dp.sld_barbell = sld_barbell();
+	dp.sld_solv = sld_solv();
+	dp.background = 0.0;
+	dp.theta  = theta();
+	dp.phi    = phi();
+
+
+	// Get the dispersion points for the rad_bar
+	vector<WeightPoint> weights_rad_bar;
+	rad_bar.get_weights(weights_rad_bar);
+
+	// Get the dispersion points for the len_bar
+	vector<WeightPoint> weights_len_bar;
+	len_bar.get_weights(weights_len_bar);
+
+	// Get the dispersion points for the rad_bell
+	vector<WeightPoint> weights_rad_bell;
+	rad_bell.get_weights(weights_rad_bell);
+
+	// Get angular averaging for theta
+	vector<WeightPoint> weights_theta;
+	theta.get_weights(weights_theta);
+
+	// Get angular averaging for phi
+	vector<WeightPoint> weights_phi;
+	phi.get_weights(weights_phi);
+
+
+	// Perform the computation, with all weight points
+	double sum = 0.0;
+	double norm = 0.0;
+	double norm_vol = 0.0;
+	double vol = 0.0;
+	double pi,hDist,result;
+	double vol_i = 0.0;
+	pi = 4.0*atan(1.0);
+
+	// Loop over radius weight points
+	for(int i=0; i<weights_rad_bar.size(); i++) {
+		dp.rad_bar = weights_rad_bar[i].value;
+		for(int j=0; j<weights_len_bar.size(); j++) {
+			dp.len_bar = weights_len_bar[j].value;
+			for(int k=0; k<weights_rad_bell.size(); k++) {
+				dp.rad_bell = weights_rad_bell[k].value;
+				// Average over theta distribution
+				for(int l=0; l< weights_theta.size(); l++) {
+					dp.theta = weights_theta[l].value;
+					// Average over phi distribution
+					for(int m=0; m< weights_phi.size(); m++) {
+						dp.phi = weights_phi[m].value;
+						//Un-normalize Form by volume
+						hDist = sqrt(fabs(dp.rad_bell*dp.rad_bell-dp.rad_bar*dp.rad_bar));
+						vol_i = pi*dp.rad_bar*dp.rad_bar*dp.len_bar+2.0*pi*(2.0*dp.rad_bell*dp.rad_bell*dp.rad_bell/3.0
+										+dp.rad_bell*dp.rad_bell*hDist-hDist*hDist*hDist/3.0);
+
+						double _ptvalue = weights_rad_bar[i].weight
+											* weights_len_bar[j].weight
+											* weights_rad_bell[k].weight
+											* weights_theta[l].weight
+											* weights_phi[m].weight
+											* vol_i
+											* barbell_analytical_2DXY(&dp, qx, qy);
+											//* pow(weights_rad[i].value,3.0);
+						// Consider when there is infinte or nan.
+						if ( _ptvalue == INFINITY || _ptvalue == NAN){
+							_ptvalue = 0.0;
+						}
+						if (weights_theta.size()>1) {
+							_ptvalue *= sin(weights_theta[l].value);
+						}
+						sum += _ptvalue;
+						// This model dose not need the volume of spheres correction!!!
+						//Find average volume
+						vol += weights_rad_bar[i].weight
+								* weights_len_bar[j].weight
+								* weights_rad_bell[k].weight
+								* vol_i;
+						//Find norm for volume
+						norm_vol += weights_rad_bar[i].weight
+								* weights_len_bar[j].weight
+								* weights_rad_bell[k].weight;
+
+						norm += weights_rad_bar[i].weight
+								* weights_len_bar[j].weight
+								* weights_rad_bell[k].weight
+								* weights_theta[l].weight
+								* weights_phi[m].weight;
+					}
+				}
+			}
+		}
+	}
+	// Averaging in theta needs an extra normalization
+	// factor to account for the sin(theta) term in the
+	// integration (see documentation).
+	if (weights_theta.size()>1) norm = norm / asin(1.0);
+
+	if (vol != 0.0 && norm_vol != 0.0) {
+		//Re-normalize by avg volume
+		sum = sum/(vol/norm_vol);}
+
+	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the SCCrystal
+ * @param q: q-value
+ * @param phi: angle phi
+ * @return: function value
+ */
+double BarBellModel :: evaluate_rphi(double q, double phi) {
+	return (*this).operator()(q);
+}
+
+/**
+ * Function to calculate effective radius
+ * @return: effective radius value
+ */
+double BarBellModel :: calculate_ER() {
+	//NOT implemented yet!!!
+}
Index: sansmodels/src/sans/models/c_models/capcyl.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/capcyl.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_models/capcyl.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,253 @@
+/**
+	This software was developed by the University of Tennessee as part of the
+	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+	project funded by the US National Science Foundation.
+
+	If you use DANSE applications to do scientific research that leads to
+	publication, we ask that you acknowledge the use of the software with the
+	following sentence:
+
+	"This work benefited from DANSE software developed under NSF award DMR-0520547."
+
+	copyright 2008, University of Tennessee
+ */
+
+/**
+ * Scattering model classes
+ * The classes use the IGOR library found in
+ *   sansmodels/src/libigor
+ *
+ */
+
+#include <math.h>
+#include "models.hh"
+#include "parameters.hh"
+#include <stdio.h>
+using namespace std;
+
+extern "C" {
+	#include "libCylinder.h"
+	#include "capcyl.h"
+}
+
+CappedCylinderModel :: CappedCylinderModel() {
+	scale      = Parameter(1.0);
+	rad_cyl		= Parameter(20.0);
+	rad_cyl.set_min(0.0);
+	len_cyl     = Parameter(400.0, true);
+	len_cyl.set_min(0.0);
+	rad_cap = Parameter(40.0);
+	rad_cap.set_min(0.0);
+	sld_capcyl  = Parameter(1.0e-6);
+	sld_solv   = Parameter(6.3e-6);
+	background = Parameter(0.0);
+	theta  = Parameter(0.0, true);
+	phi    = Parameter(0.0, true);
+}
+
+/**
+ * Function to evaluate 1D scattering function
+ * The NIST IGOR library is used for the actual calculation.
+ * @param q: q-value
+ * @return: function value
+ */
+double CappedCylinderModel :: operator()(double q) {
+	double dp[7];
+
+	// Fill parameter array for IGOR library
+	// Add the background after averaging
+	dp[0] = scale();
+	dp[1] = rad_cyl();
+	dp[2] = len_cyl();
+	dp[3] = rad_cap();
+	dp[4] = sld_capcyl();
+	dp[5] = sld_solv();
+	dp[6] = 0.0;
+
+	// Get the dispersion points for the rad_cyl
+	vector<WeightPoint> weights_rad_cyl;
+	rad_cyl.get_weights(weights_rad_cyl);
+	// Get the dispersion points for the len_cyl
+	vector<WeightPoint> weights_len_cyl;
+	len_cyl.get_weights(weights_len_cyl);
+	// Get the dispersion points for the rad_cap
+	vector<WeightPoint> weights_rad_cap;
+	rad_cap.get_weights(weights_rad_cap);
+
+	// Perform the computation, with all weight points
+	double sum = 0.0;
+	double norm = 0.0;
+	double vol = 0.0;
+	double pi,hDist,result;
+	double vol_i = 0.0;
+	pi = 4.0*atan(1.0);
+	// Loop over radius weight points
+	for(int i=0; i<weights_rad_cyl.size(); i++) {
+		dp[1] = weights_rad_cyl[i].value;
+		for(int j=0; j<weights_len_cyl.size(); j++) {
+			dp[2] = weights_len_cyl[j].value;
+			for(int k=0; k<weights_rad_cap.size(); k++) {
+				dp[3] = weights_rad_cap[k].value;
+
+				//Un-normalize SphereForm by volume
+				hDist = -1.0*sqrt(fabs(dp[3]*dp[3]-dp[1]*dp[1]));
+				vol_i = pi*dp[1]*dp[1]*dp[2]+2.0*pi/3.0*((dp[3]-hDist)*(dp[3]-hDist)*
+								(2.0*(dp[3]+hDist)));
+				result =  CappedCylinder(dp, q) * vol_i;
+				// This FIXES a singualrity the kernel in libigor.
+				if ( result == INFINITY || result == NAN){
+					result = 0.0;
+				}
+				sum += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight
+					* result;
+				//Find average volume
+				vol += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight
+					* vol_i;
+
+				norm += weights_rad_cyl[i].weight*weights_len_cyl[j].weight*weights_rad_cap[k].weight;
+			}
+		}
+	}
+
+	if (vol != 0.0 && norm != 0.0) {
+		//Re-normalize by avg volume
+		sum = sum/(vol/norm);}
+	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param q_x: value of Q along x
+ * @param q_y: value of Q along y
+ * @return: function value
+ */
+double CappedCylinderModel :: operator()(double qx, double qy) {
+	CapCylParameters dp;
+
+	double q = sqrt(qx*qx + qy*qy);
+	dp.scale = scale();
+	dp.rad_cyl = rad_cyl();
+	dp.len_cyl = len_cyl();
+	dp.rad_cap = rad_cap();
+	dp.sld_capcyl = sld_capcyl();
+	dp.sld_solv = sld_solv();
+	dp.background = 0.0;
+	dp.theta  = theta();
+	dp.phi    = phi();
+
+
+	// Get the dispersion points for the rad_bar
+	vector<WeightPoint> weights_rad_cyl;
+	rad_cyl.get_weights(weights_rad_cyl);
+
+	// Get the dispersion points for the len_bar
+	vector<WeightPoint> weights_len_cyl;
+	len_cyl.get_weights(weights_len_cyl);
+
+	// Get the dispersion points for the rad_bell
+	vector<WeightPoint> weights_rad_cap;
+	rad_cap.get_weights(weights_rad_cap);
+
+	// Get angular averaging for theta
+	vector<WeightPoint> weights_theta;
+	theta.get_weights(weights_theta);
+
+	// Get angular averaging for phi
+	vector<WeightPoint> weights_phi;
+	phi.get_weights(weights_phi);
+
+
+	// Perform the computation, with all weight points
+	double sum = 0.0;
+	double norm = 0.0;
+	double norm_vol = 0.0;
+	double vol = 0.0;
+	double pi,hDist,result;
+	double vol_i = 0.0;
+	pi = 4.0*atan(1.0);
+
+	// Loop over radius weight points
+	for(int i=0; i<weights_rad_cyl.size(); i++) {
+		dp.rad_cyl = weights_rad_cyl[i].value;
+		for(int j=0; j<weights_len_cyl.size(); j++) {
+			dp.len_cyl = weights_len_cyl[j].value;
+			for(int k=0; k<weights_rad_cap.size(); k++) {
+				dp.rad_cap = weights_rad_cap[k].value;
+				// Average over theta distribution
+				for(int l=0; l< weights_theta.size(); l++) {
+					dp.theta = weights_theta[l].value;
+					// Average over phi distribution
+					for(int m=0; m< weights_phi.size(); m++) {
+						dp.phi = weights_phi[m].value;
+						//Un-normalize Form by volume
+						hDist = -1.0*sqrt(fabs(dp.rad_cap*dp.rad_cap-dp.rad_cyl*dp.rad_cyl));
+						vol_i = pi*dp.rad_cyl*dp.rad_cyl*dp.len_cyl+2.0*pi/3.0*((dp.rad_cap-hDist)*(dp.rad_cap-hDist)*
+										(2*dp.rad_cap+hDist));
+
+						double _ptvalue = weights_rad_cyl[i].weight
+											* weights_len_cyl[j].weight
+											* weights_rad_cap[k].weight
+											* weights_theta[l].weight
+											* weights_phi[m].weight
+											* vol_i
+											* capcyl_analytical_2DXY(&dp, qx, qy);
+											//* pow(weights_rad[i].value,3.0);
+						// Consider when there is infinte or nan.
+						if ( _ptvalue == INFINITY || _ptvalue == NAN){
+							_ptvalue = 0.0;
+						}
+						if (weights_theta.size()>1) {
+							_ptvalue *= sin(weights_theta[l].value);
+						}
+						sum += _ptvalue;
+						// This model dose not need the volume of spheres correction!!!
+						//Find average volume
+						vol += weights_rad_cyl[i].weight
+								* weights_len_cyl[j].weight
+								* weights_rad_cap[k].weight
+								* vol_i;
+						//Find norm for volume
+						norm_vol += weights_rad_cyl[i].weight
+								* weights_len_cyl[j].weight
+								* weights_rad_cap[k].weight;
+
+						norm += weights_rad_cyl[i].weight
+								* weights_len_cyl[j].weight
+								* weights_rad_cap[k].weight
+								* weights_theta[l].weight
+								* weights_phi[m].weight;
+					}
+				}
+			}
+		}
+	}
+	// Averaging in theta needs an extra normalization
+	// factor to account for the sin(theta) term in the
+	// integration (see documentation).
+	if (weights_theta.size()>1) norm = norm / asin(1.0);
+
+	if (vol != 0.0 && norm_vol != 0.0) {
+		//Re-normalize by avg volume
+		sum = sum/(vol/norm_vol);}
+
+	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the SCCrystal
+ * @param q: q-value
+ * @param phi: angle phi
+ * @return: function value
+ */
+double CappedCylinderModel :: evaluate_rphi(double q, double phi) {
+	return (*this).operator()(q);
+}
+
+/**
+ * Function to calculate effective radius
+ * @return: effective radius value
+ */
+double CappedCylinderModel :: calculate_ER() {
+	//NOT implemented yet!!!
+}
Index: sansmodels/src/sans/models/c_models/corefourshell.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/corefourshell.cpp	(revision c724ccd87499a21402fee0d11d517066f99ddf9b)
+++ sansmodels/src/sans/models/c_models/corefourshell.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -33,7 +33,7 @@
 CoreFourShellModel :: CoreFourShellModel() {
 	scale      = Parameter(1.0);
-	rad_core     = Parameter(60.0, true);
-	rad_core.set_min(0.0);
-	sld_core   = Parameter(6.4e-6);
+	rad_core0     = Parameter(60.0, true);
+	rad_core0.set_min(0.0);
+	sld_core0   = Parameter(6.4e-6);
 	thick_shell1     = Parameter(10.0, true);
 	thick_shell1.set_min(0.0);
@@ -64,6 +64,6 @@
 	// Add the background after averaging
 	dp[0] = scale();
-	dp[1] = rad_core();
-	dp[2] = sld_core();
+	dp[1] = rad_core0();
+	dp[2] = sld_core0();
 	dp[3] = thick_shell1();
 	dp[4] = sld_shell1();
@@ -79,5 +79,5 @@
 	// Get the dispersion points for the radius
 	vector<WeightPoint> weights_rad;
-	rad_core.get_weights(weights_rad);
+	rad_core0.get_weights(weights_rad);
 
 	// Get the dispersion points for the thick 1
@@ -167,6 +167,6 @@
 
 	dp.scale = scale();
-	dp.rad_core = rad_core();
-	dp.sld_core = sld_core();
+	dp.rad_core0 = rad_core0();
+	dp.sld_core0 = sld_core0();
 	dp.thick_shell1 = thick_shell1();
 	dp.sld_shell1 = sld_shell1();
@@ -182,5 +182,5 @@
 	// Get the dispersion points for the radius
 	vector<WeightPoint> weights_rad;
-	rad_core.get_weights(weights_rad);
+	rad_core0.get_weights(weights_rad);
 
 	// Get the dispersion points for the thick 1
@@ -207,5 +207,5 @@
 	// Loop over radius weight points
 	for(int i=0; i<weights_rad.size(); i++) {
-		dp.rad_core = weights_rad[i].value;
+		dp.rad_core0 = weights_rad[i].value;
 		// Loop over radius weight points
 		for(int j=0; j<weights_s1.size(); j++) {
@@ -222,5 +222,5 @@
 						//Un-normalize FourShell by volume
 						sum += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight
-							* (dp.rad_core+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4);
+							* (dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4);
 						norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight*weights_s4[m].weight;
 					}
@@ -234,5 +234,5 @@
 	else{
 		//return normal value
-		rad_out = dp.rad_core+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4;}
+		rad_out = dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4;}
 
 	return rad_out;
Index: sansmodels/src/sans/models/c_models/lamellarPC.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/lamellarPC.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
+++ sansmodels/src/sans/models/c_models/lamellarPC.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -0,0 +1,120 @@
+/**
+	This software was developed by the University of Tennessee as part of the
+	Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+	project funded by the US National Science Foundation.
+
+	If you use DANSE applications to do scientific research that leads to
+	publication, we ask that you acknowledge the use of the software with the
+	following sentence:
+
+	"This work benefited from DANSE software developed under NSF award DMR-0520547."
+
+	copyright 2008, University of Tennessee
+ */
+
+/**
+ * Scattering model classes
+ * The classes use the IGOR library found in
+ *   sansmodels/src/libigor
+ */
+
+#include <math.h>
+#include "models.hh"
+#include "parameters.hh"
+#include <stdio.h>
+using namespace std;
+
+extern "C" {
+	#include "libCylinder.h"
+	#include "lamellarPC.h"
+}
+
+LamellarPCrystalModel :: LamellarPCrystalModel() {
+	scale      = Parameter(1.0);
+	thickness     = Parameter(33.0, true);
+	thickness.set_min(0.0);
+	Nlayers    = Parameter(20.0, true);
+	Nlayers.set_min(0.0);
+	spacing   = Parameter(250);
+	pd_spacing   = Parameter(0.0);
+	sld_layer  = Parameter(1.0e-6);
+	sld_solvent    = Parameter(6.34e-6);
+	background = Parameter(0.0);
+
+}
+
+/**
+ * Function to evaluate 1D scattering function
+ * The NIST IGOR library is used for the actual calculation.
+ * @param q: q-value
+ * @return: function value
+ */
+double LamellarPCrystalModel :: operator()(double q) {
+	double dp[8];
+
+	// Fill parameter array for IGOR library
+	// Add the background after averaging
+	dp[0] = scale();
+	dp[1] = thickness();
+	dp[2] = Nlayers();
+	dp[3] = spacing();
+	dp[4] = pd_spacing();
+	dp[5] = sld_layer();
+	dp[6] = sld_solvent();
+	dp[7] = 0.0; // Do not apply background here.
+
+	// Get the dispersion points for the head thickness
+	vector<WeightPoint> weights_thickness;
+	thickness.get_weights(weights_thickness);
+
+	// Let's provide from the func which is more accurate especially for small q region.
+	// Get the dispersion points for the tail length
+	//vector<WeightPoint> weights_spacing;
+	//spacing.get_weights(weights_spacing);
+
+	// Perform the computation, with all weight points
+	double sum = 0.0;
+	double norm = 0.0;
+
+	// Loop over thickness and spacing weight points
+	for(int i=0; i< (int)weights_thickness.size(); i++) {
+		dp[1] = weights_thickness[i].value;
+		//for (int j=0; j< (int)weights_spacing.size(); j++){
+			//dp[3] = weights_spacing[j].value;
+			sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q);
+			norm += weights_thickness[i].weight;
+		//}
+	}
+	//apply norm and background
+	return sum/norm + background();
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param q_x: value of Q along x
+ * @param q_y: value of Q along y
+ * @return: function value
+ */
+
+double LamellarPCrystalModel :: operator()(double qx, double qy) {
+	double q = sqrt(qx*qx + qy*qy);
+	return (*this).operator()(q);
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the lamellar
+ * @param q: q-value
+ * @param phi: angle phi
+ * @return: function value
+ */
+double LamellarPCrystalModel :: evaluate_rphi(double q, double phi) {
+	return (*this).operator()(q);
+}
+/**
+ * Function to calculate effective radius
+ * @return: effective radius value
+ */
+double LamellarPCrystalModel :: calculate_ER() {
+//NOT implemented yet!!!
+}
Index: sansmodels/src/sans/models/c_models/models.hh
===================================================================
--- sansmodels/src/sans/models/c_models/models.hh	(revision d5b6a9d7cd9e26b5f9e28e55e8cf848a40de6ae9)
+++ sansmodels/src/sans/models/c_models/models.hh	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -49,4 +49,51 @@
 };
 
+class BarBellModel{
+public:
+	// Model parameters
+	Parameter scale;
+	Parameter rad_bar;
+	Parameter len_bar;
+	Parameter rad_bell;
+	Parameter sld_barbell;
+	Parameter sld_solv;
+	Parameter background;
+	Parameter theta;
+	Parameter phi;
+
+	// Constructor
+	BarBellModel();
+
+	// Operators to get I(Q)
+	double operator()(double q);
+	double operator()(double qx, double qy);
+	double calculate_ER();
+	double evaluate_rphi(double q, double phi);
+};
+
+class CappedCylinderModel{
+public:
+	// Model parameters
+	Parameter scale;
+	Parameter rad_cyl;
+	Parameter len_cyl;
+	Parameter rad_cap;
+	Parameter sld_capcyl;
+	Parameter sld_solv;
+	Parameter background;
+	Parameter theta;
+	Parameter phi;
+
+	// Constructor
+	CappedCylinderModel();
+
+	// Operators to get I(Q)
+	double operator()(double q);
+	double operator()(double qx, double qy);
+	double calculate_ER();
+	double evaluate_rphi(double q, double phi);
+};
+
+
 class ParallelepipedModel{
 public:
@@ -80,6 +127,6 @@
 	Parameter n_shells;
 	Parameter scale;
-	Parameter rad_core;
-	Parameter sld_core;
+	Parameter rad_core0;
+	Parameter sld_core0;
 	Parameter sld_solv;
 	Parameter background;
@@ -256,4 +303,18 @@
 	Parameter func_inter10;
 
+	Parameter sldIM_flat1;
+	Parameter sldIM_flat2;
+	Parameter sldIM_flat3;
+	Parameter sldIM_flat4;
+	Parameter sldIM_flat5;
+	Parameter sldIM_flat6;
+	Parameter sldIM_flat7;
+	Parameter sldIM_flat8;
+	Parameter sldIM_flat9;
+	Parameter sldIM_flat10;
+
+	Parameter sldIM_sub0;
+	Parameter sldIM_medium;
+
 	// Constructor
 	ReflModel();
@@ -511,6 +572,6 @@
 	// Model parameters
 	Parameter scale;
-	Parameter rad_core;
-	Parameter sld_core;
+	Parameter rad_core0;
+	Parameter sld_core0;
 	Parameter thick_shell1;
 	Parameter sld_shell1;
Index: sansmodels/src/sans/models/c_models/onion.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/onion.cpp	(revision e096270047b0757e07e7187aa5de071c857a7e13)
+++ sansmodels/src/sans/models/c_models/onion.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -33,6 +33,6 @@
 	n_shells = Parameter(1.0);
 	scale = Parameter(1.0);
-	rad_core = Parameter(200.0);
-	sld_core = Parameter(1e-06);
+	rad_core0 = Parameter(200.0);
+	sld_core0 = Parameter(1e-06);
 	sld_solv = Parameter(6.4e-06);
     background = Parameter(0.0);
@@ -112,6 +112,6 @@
 	dp[0] = n_shells();
 	dp[1] = scale();
-	dp[2] = rad_core();
-	dp[3] = sld_core();
+	dp[2] = rad_core0();
+	dp[3] = sld_core0();
 	dp[4] = sld_solv();
 	dp[5] = 0.0;
@@ -175,5 +175,5 @@
 	// Get the dispersion points for the radius
 	vector<WeightPoint> weights_rad;
-	rad_core.get_weights(weights_rad);
+	rad_core0.get_weights(weights_rad);
 
 	// Get the dispersion points for the thick 1
@@ -313,5 +313,5 @@
 double OnionModel :: calculate_ER() {
 	OnionParameters dp;
-	dp.rad_core = rad_core();
+	dp.rad_core0 = rad_core0();
 	dp.thick_shell1 = thick_shell1();
 	dp.thick_shell2 = thick_shell2();
@@ -333,5 +333,5 @@
 	// Get the dispersion points for the radius
 	vector<WeightPoint> weights_rad;
-	rad_core.get_weights(weights_rad);
+	rad_core0.get_weights(weights_rad);
 
 	// Get the dispersion points for the thick 1
@@ -376,5 +376,5 @@
 	// Loop over radius weight points
 	for(int i=0; i<weights_rad.size(); i++) {
-		dp.rad_core = weights_rad[i].value;
+		dp.rad_core0 = weights_rad[i].value;
 		// Loop over radius weight points
 		for(int j=0; j<weights_s1.size(); j++) {
@@ -411,5 +411,5 @@
 													*weights_s5[n].weight*weights_s6[o].weight*weights_s7[p].weight*weights_s8[t].weight
 													*weights_s9[r].weight*weights_s10[s].weight
-													* (dp.rad_core+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4+dp.thick_shell5
+													* (dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4+dp.thick_shell5
 															+dp.thick_shell6+dp.thick_shell7+dp.thick_shell8+dp.thick_shell9+dp.thick_shell10);
 												norm += weights_rad[i].weight*weights_s1[j].weight*weights_s2[k].weight*weights_s3[l].weight
@@ -433,5 +433,5 @@
 	else{
 		//return normal value
-		rad_out = dp.rad_core+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4
+		rad_out = dp.rad_core0+dp.thick_shell1+dp.thick_shell2+dp.thick_shell3+dp.thick_shell4
 					+dp.thick_shell5+dp.thick_shell6+dp.thick_shell7+dp.thick_shell8+dp.thick_shell9+dp.thick_shell10;}
 	return rad_out;
Index: sansmodels/src/sans/models/c_models/refl.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/refl.cpp	(revision 35aface36aa7573475600ebbacb987f50386d5f8)
+++ sansmodels/src/sans/models/c_models/refl.cpp	(revision 339ce675656e3ab89eff7b84d8292a2e0ffe6109)
@@ -67,4 +67,17 @@
     func_inter10 = Parameter(0);
 
+    sldIM_flat1 = Parameter(0);
+    sldIM_flat2 = Parameter(0);
+    sldIM_flat3 = Parameter(0);
+    sldIM_flat4 = Parameter(0);
+    sldIM_flat5 = Parameter(0);
+    sldIM_flat6 = Parameter(0);
+    sldIM_flat7 = Parameter(0);
+    sldIM_flat8 = Parameter(0);
+    sldIM_flat9 = Parameter(0);
+    sldIM_flat10 = Parameter(0);
+
+    sldIM_sub0 = Parameter(0);
+    sldIM_medium = Parameter(0);
 }
 
@@ -75,5 +88,5 @@
  */
 double ReflModel :: operator()(double q) {
-	double dp[47];
+	double dp[59];
 	// Fill parameter array for IGOR library
 	// Add the background after averaging
@@ -130,4 +143,18 @@
 	dp[46] = func_inter10();
 
+	dp[47] = sldIM_flat1();
+	dp[48] = sldIM_flat2();
+	dp[49] = sldIM_flat3();
+	dp[50] = sldIM_flat4();
+	dp[51] = sldIM_flat5();
+	dp[52] = sldIM_flat6();
+	dp[53] = sldIM_flat7();
+	dp[54] = sldIM_flat8();
+	dp[55] = sldIM_flat9();
+	dp[56] = sldIM_flat10();
+
+	dp[57] = sldIM_sub0();
+	dp[58] = sldIM_medium();
+
 	// Get the dispersion points for the radius
 	//vector<WeightPoint> weights_thick;
