Index: sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CBinaryHSModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -18,5 +18,5 @@
  *
  * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
- *          DO NOT MODIFY THIS FILE, MODIFY binaryHS.h
+ *          DO NOT MODIFY THIS FILE, MODIFY binaryHs.h
  *          AND RE-RUN THE GENERATOR SCRIPT
  *
@@ -33,5 +33,5 @@
 #include <math.h>
 #include <time.h>
-#include "binaryHS.h"
+#include "binaryHs.h"
 }
 
@@ -191,6 +191,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -205,8 +206,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -170,41 +170,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( BinaryHSPSF11Model* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -227,6 +191,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -241,8 +206,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CCoreShellCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCoreShellCylinderModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CCoreShellCylinderModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -181,41 +181,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( CoreShellCylinderModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -238,6 +202,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -252,8 +217,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CCoreShellEllipsoidModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCoreShellEllipsoidModel.cpp	(revision eddff027b43bf6dfb5f35d7d30e3a458f64c1c41)
+++ sansmodels/src/sans/models/c_models/CCoreShellEllipsoidModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -205,6 +205,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -219,8 +220,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CCoreShellModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCoreShellModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CCoreShellModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -169,41 +169,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( CoreShellModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -226,6 +190,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -240,8 +205,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CCylinderModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CCylinderModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -196,6 +196,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -210,8 +211,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CDiamCylFunc.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CDiamCylFunc.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CDiamCylFunc.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -164,41 +164,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( DiamCylFunc* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -221,6 +185,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -235,8 +200,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CDiamEllipFunc.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CDiamEllipFunc.cpp	(revision 63c209583a818ebb642b2b5cf6652f7b593ad755)
+++ sansmodels/src/sans/models/c_models/CDiamEllipFunc.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -22,7 +22,10 @@
  *
  */
+#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>
@@ -131,5 +134,155 @@
     }
 }
-
+/**
+ * Function to call to evaluate model
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
+ */
+ 
+static PyObject *evaluateOneDim(DiamEllipFunc* 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( DiamEllipFunc* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[2];
+    //check validity of input vectors
+    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[1] != 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[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(2,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++) {
+            for ( j=0; j< y_len; j++) {
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
+      			double *result_value = (double *)(result->data +
+      			      i*result->strides[1] + j*result->strides[0]);
+      			*result_value = (*model)(x_value, y_value);
+            }           
+        }
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CDiamEllipFuncError, 
+                   "CDiamEllipFunc.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(CDiamEllipFunc *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->radius_b = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_b") );
+    self->model->radius_a = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius_a") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "radius_a");
+    self->model->radius_a.dispersion->accept_as_destination(visitor, self->model->radius_a.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "radius_b");
+    self->model->radius_b.dispersion->accept_as_destination(visitor, self->model->radius_b.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(CDiamEllipFuncError, 
+	    	"CDiamEllipFunc.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(CDiamEllipFuncError, 
+                   "CDiamEllipFunc.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(CDiamEllipFuncError, 
+	    		"CDiamEllipFunc.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(CDiamEllipFuncError, 
+                   "CDiamEllipFunc.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}else{
+	    PyErr_SetString(CDiamEllipFuncError, 
+                   "CDiamEllipFunc.evalDistribution couln't be run.");
+	    return NULL;
+	}
+}
 
 /**
@@ -293,4 +446,7 @@
     {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
       "Evaluate the model at a given Q or Qx, Qy"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
     {"reset",    (PyCFunction)reset   , METH_VARARGS,
       "Reset pair correlation"},
@@ -343,7 +499,7 @@
 
 
-static PyMethodDef module_methods[] = {
-    {NULL} 
-};
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
 
 /**
Index: sansmodels/src/sans/models/c_models/CEllipsoidModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CEllipsoidModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CEllipsoidModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -196,6 +196,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -210,8 +211,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CEllipticalCylinderModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -204,6 +204,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -218,8 +219,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -171,41 +171,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( FlexibleCylinderModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -228,6 +192,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -242,8 +207,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CGaussian.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CGaussian.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CGaussian.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -159,41 +159,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( Gaussian* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -216,6 +180,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -230,8 +195,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CHardsphereStructure.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -161,41 +161,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( HardsphereStructure* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -218,6 +182,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -232,8 +197,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CHayterMSAStructure.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CHayterMSAStructure.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CHayterMSAStructure.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -165,41 +165,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( HayterMSAStructure* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -222,6 +186,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -236,8 +201,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CHollowCylinderModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -179,41 +179,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( HollowCylinderModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -236,6 +200,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -250,8 +215,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CLamellarFFHGModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLamellarFFHGModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CLamellarFFHGModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -169,41 +169,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( LamellarFFHGModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -226,6 +190,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -240,8 +205,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CLamellarModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLamellarModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CLamellarModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -185,6 +185,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -199,8 +200,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CLamellarPSHGModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLamellarPSHGModel.cpp	(revision 96b593847bbd8eb6072269e750a93261a4f743b3)
+++ sansmodels/src/sans/models/c_models/CLamellarPSHGModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -22,7 +22,10 @@
  *
  */
+#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>
@@ -142,15 +145,94 @@
     }
 }
-
-
 /**
  * Function to call to evaluate model
- * @param args: input q or [q,phi]
- * @return: function value
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
  */
-static PyObject * run(CLamellarPSHGModel *self, PyObject *args) {
-	double q_value, phi_value;
-	PyObject* pars;
-	int npars;
+ 
+static PyObject *evaluateOneDim(LamellarPSHGModel* 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( LamellarPSHGModel* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[2];
+    //check validity of input vectors
+    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[1] != 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[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(2,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++) {
+            for ( j=0; j< y_len; j++) {
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
+      			double *result_value = (double *)(result->data +
+      			      i*result->strides[1] + j*result->strides[0]);
+      			*result_value = (*model)(x_value, y_value);
+            }           
+        }
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CLamellarPSHGModelError, 
+                   "CLamellarPSHGModel.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(CLamellarPSHGModel *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
 	
 	// Get parameters
@@ -181,4 +263,85 @@
 	if ( !PyArg_ParseTuple(args,"O",&pars) ) {
 	    PyErr_SetString(CLamellarPSHGModelError, 
+	    	"CLamellarPSHGModel.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(CLamellarPSHGModelError, 
+                   "CLamellarPSHGModel.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(CLamellarPSHGModelError, 
+	    		"CLamellarPSHGModel.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(CLamellarPSHGModelError, 
+                   "CLamellarPSHGModel.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}else{
+	    PyErr_SetString(CLamellarPSHGModelError, 
+                   "CLamellarPSHGModel.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(CLamellarPSHGModel *self, PyObject *args) {
+	double q_value, phi_value;
+	PyObject* pars;
+	int npars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->n_plates = PyFloat_AsDouble( PyDict_GetItemString(self->params, "n_plates") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->deltaT = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaT") );
+    self->model->spacing = PyFloat_AsDouble( PyDict_GetItemString(self->params, "spacing") );
+    self->model->sld_tail = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_tail") );
+    self->model->sld_solvent = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_solvent") );
+    self->model->caille = PyFloat_AsDouble( PyDict_GetItemString(self->params, "caille") );
+    self->model->sld_head = PyFloat_AsDouble( PyDict_GetItemString(self->params, "sld_head") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->deltaH = PyFloat_AsDouble( PyDict_GetItemString(self->params, "deltaH") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "deltaT");
+    self->model->deltaT.dispersion->accept_as_destination(visitor, self->model->deltaT.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "deltaH");
+    self->model->deltaH.dispersion->accept_as_destination(visitor, self->model->deltaH.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "spacing");
+    self->model->spacing.dispersion->accept_as_destination(visitor, self->model->spacing.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(CLamellarPSHGModelError, 
 	    	"CLamellarPSHGModel.run expects a q value.");
 		return NULL;
@@ -326,4 +489,7 @@
     {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
       "Evaluate the model at a given Q or Qx, Qy"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
     {"reset",    (PyCFunction)reset   , METH_VARARGS,
       "Reset pair correlation"},
@@ -376,7 +542,7 @@
 
 
-static PyMethodDef module_methods[] = {
-    {NULL} 
-};
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
 
 /**
Index: sansmodels/src/sans/models/c_models/CLamellarPSModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLamellarPSModel.cpp	(revision c1c29b67c42e22e8ebe38ed7aacd5a53ec4f66bb)
+++ sansmodels/src/sans/models/c_models/CLamellarPSModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -190,6 +190,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -204,8 +205,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CLogNormal.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLogNormal.cpp	(revision 5b56b7a419ca88e2f199551aa0069d98e2caec4e)
+++ sansmodels/src/sans/models/c_models/CLogNormal.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -159,41 +159,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( LogNormal* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -216,6 +180,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -230,8 +195,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CLorentzian.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CLorentzian.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CLorentzian.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -159,41 +159,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( Lorentzian* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -216,6 +180,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -230,8 +195,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CMultiShellModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CMultiShellModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CMultiShellModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -173,41 +173,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( MultiShellModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -230,6 +194,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -244,8 +209,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/COblateModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/COblateModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/COblateModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -199,6 +199,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -213,8 +214,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CParallelepipedModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CParallelepipedModel.cpp	(revision 8e36cddc31aee946bb051c6a6d4eade849ca2ed4)
+++ sansmodels/src/sans/models/c_models/CParallelepipedModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -204,6 +204,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -218,8 +219,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CProlateModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CProlateModel.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CProlateModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -176,41 +176,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( ProlateModel* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -233,6 +197,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -247,8 +212,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CSphereModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CSphereModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CSphereModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -184,6 +184,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -198,8 +199,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CSquareWellStructure.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CSquareWellStructure.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CSquareWellStructure.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -163,41 +163,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( SquareWellStructure* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -220,6 +184,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -234,8 +199,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CStackedDisksModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CStackedDisksModel.cpp	(revision 975ec8e8211549489759b5a5ffe3b60607de065b)
+++ sansmodels/src/sans/models/c_models/CStackedDisksModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -204,6 +204,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -218,8 +219,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CStickyHSStructure.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CStickyHSStructure.cpp	(revision 9bd69098b443a3cbda08a1efa070cd1e2ead30ce)
+++ sansmodels/src/sans/models/c_models/CStickyHSStructure.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -163,41 +163,5 @@
     return PyArray_Return(result); 
  }
-/**
- * Function to call to evaluate model
- * @param args: input numpy array  [q[],phi[]]
- * @return: numpy array object 
- */
-static PyObject * evaluateTwoDim( StickyHSStructure* model, 
-                              PyArrayObject *q, PyArrayObject *phi)
- {
-    PyArrayObject *result;
-    //check validity of input vectors
-    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
-        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
-        || phi->dimensions[0] != q->dimensions[0]){
-     
-        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
-        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
-        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 phi_value = *(double *)(phi->data + i*phi->strides[0]);
-      double *result_value = (double *)(result->data + i*result->strides[0]);
-      if (q_value == 0)
-          *result_value = 0.0;
-      else
-          *result_value = model->evaluate_rphi(q_value, phi_value);
-    }
-    return PyArray_Return(result); 
- }
+
  /**
  * Function to call to evaluate model
@@ -220,6 +184,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -234,8 +199,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp	(revision 3c102d483d76eaaef80c6c9f1e39089cfbd6799b)
+++ sansmodels/src/sans/models/c_models/CTriaxialEllipsoidModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -195,6 +195,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -209,8 +210,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
Index: sansmodels/src/sans/models/c_models/CVesicleModel.cpp
===================================================================
--- sansmodels/src/sans/models/c_models/CVesicleModel.cpp	(revision 42f193aa18a9b086b81b4861e33abca433f0ba94)
+++ sansmodels/src/sans/models/c_models/CVesicleModel.cpp	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -22,7 +22,10 @@
  *
  */
+#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>
@@ -135,5 +138,159 @@
     }
 }
-
+/**
+ * Function to call to evaluate model
+ * @param args: input numpy array q[] 
+ * @return: numpy array object 
+ */
+ 
+static PyObject *evaluateOneDim(VesicleModel* 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( VesicleModel* model, 
+                              PyArrayObject *x, PyArrayObject *y)
+ {
+    PyArrayObject *result;
+    int i,j, x_len, y_len, dims[2];
+    //check validity of input vectors
+    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
+        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
+        || y->dimensions[1] != 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[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
+	    
+	    // Make a new double matrix of same dims
+        result=(PyArrayObject *) PyArray_FromDims(2,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++) {
+            for ( j=0; j< y_len; j++) {
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
+      			double *result_value = (double *)(result->data +
+      			      i*result->strides[1] + j*result->strides[0]);
+      			*result_value = (*model)(x_value, y_value);
+            }           
+        }
+        return PyArray_Return(result); 
+        
+        }else{
+		    PyErr_SetString(CVesicleModelError, 
+                   "CVesicleModel.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(CVesicleModel *self, PyObject *args){
+	PyObject *qx, *qy;
+	PyArrayObject * pars;
+	int npars ,mpars;
+	
+	// Get parameters
+	
+	    // Reader parameter dictionary
+    self->model->core_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_sld") );
+    self->model->core_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "core_radius") );
+    self->model->thickness = PyFloat_AsDouble( PyDict_GetItemString(self->params, "thickness") );
+    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
+    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
+    self->model->shell_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "shell_sld") );
+    // Read in dispersion parameters
+    PyObject* disp_dict;
+    DispersionVisitor* visitor = new DispersionVisitor();
+    disp_dict = PyDict_GetItemString(self->dispersion, "core_radius");
+    self->model->core_radius.dispersion->accept_as_destination(visitor, self->model->core_radius.dispersion, disp_dict);
+    disp_dict = PyDict_GetItemString(self->dispersion, "thickness");
+    self->model->thickness.dispersion->accept_as_destination(visitor, self->model->thickness.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(CVesicleModelError, 
+	    	"CVesicleModel.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(CVesicleModelError, 
+                   "CVesicleModel.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(CVesicleModelError, 
+	    		"CVesicleModel.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(CVesicleModelError, 
+                   "CVesicleModel.evalDistribution expect 2 numpy arrays in list.");
+	        return NULL;
+	     }
+	}else{
+	    PyErr_SetString(CVesicleModelError, 
+                   "CVesicleModel.evalDistribution couln't be run.");
+	    return NULL;
+	}
+}
 
 /**
@@ -305,4 +462,7 @@
     {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
       "Evaluate the model at a given Q or Qx, Qy"},
+      
+    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
+      "Evaluate the model at a given Q or Qx, Qy vector "},
     {"reset",    (PyCFunction)reset   , METH_VARARGS,
       "Reset pair correlation"},
@@ -355,7 +515,7 @@
 
 
-static PyMethodDef module_methods[] = {
-    {NULL} 
-};
+//static PyMethodDef module_methods[] = {
+//    {NULL} 
+//};
 
 /**
Index: sansmodels/src/sans/models/c_models/classTemplate.txt
===================================================================
--- sansmodels/src/sans/models/c_models/classTemplate.txt	(revision 26e4a247fb629283560bcebfc702766d91e89b16)
+++ sansmodels/src/sans/models/c_models/classTemplate.txt	(revision a8d6888a4aca60748f072915b7116a8daf50636b)
@@ -170,6 +170,7 @@
    
 	if (PyArray_Check(x) && PyArray_Check(y)) {
-	    x_len = dims[0]= x->dimensions[0];
-        y_len = dims[1]= y->dimensions[1];
+		
+	    x_len = dims[1]= x->dimensions[1];
+        y_len = dims[0]= y->dimensions[0];
 	    
 	    // Make a new double matrix of same dims
@@ -184,8 +185,8 @@
         for ( i=0; i< x_len; i++) {
             for ( j=0; j< y_len; j++) {
-                double x_value = *(double *)(x->data + i*x->strides[0]);
-      		    double y_value = *(double *)(y->data + j*y->strides[1]);
+                double x_value = *(double *)(x->data + i*x->strides[1]);
+      		    double y_value = *(double *)(y->data + j*y->strides[0]);
       			double *result_value = (double *)(result->data +
-      			      i*result->strides[0] + j*result->strides[1]);
+      			      i*result->strides[1] + j*result->strides[0]);
       			*result_value = (*model)(x_value, y_value);
             }           
