Index: sasview/default_categories.json
===================================================================
--- sasview/default_categories.json	(revision d26dea03dc6672ee5b15cc43e77a7a352c6cbd25)
+++ sasview/default_categories.json	(revision db46d13d6ad925ea6da0c9aa178a62e3dc325cdb)
@@ -1,1 +1,1 @@
-{"Shapes": [["PearlNecklaceModel", true], ["HollowCylinderModel", true], ["CoreMultiShellModel", true], ["FCCrystalModel", true], ["CoreShellEllipsoidXTModel", true], ["FuzzySphereModel", true], ["CSParallelepipedModel", true], ["EllipticalCylinderModel", true], ["BCCrystalModel", true], ["LamellarFFHGModel", true], ["RectangularHollowPrismInfThinWallsModel", true], ["LamellarPCrystalModel", true], ["OnionExpShellModel", true], ["VesicleModel", true], ["MultiShellModel", true], ["RaspBerryModel", true], ["CoreShellEllipsoidModel", true], ["CappedCylinderModel", true], ["CylinderModel", true], ["SphericalSLDModel", true], ["StackedDisksModel", true], ["LamellarPSHGModel", true], ["CoreShellBicelleModel", true], ["RectangularHollowPrismModel", true], ["LamellarPSModel", true], ["EllipsoidModel", true], ["SphereModel", true], ["ParallelepipedModel", true], ["TriaxialEllipsoidModel", true], ["LamellarModel", true], ["PringlesModel", true], ["RectangularPrismModel", true], ["CoreShellCylinderModel", true], ["BinaryHSModel", true], ["FlexibleCylinderModel", true], ["SCCrystalModel", true], ["FlexCylEllipXModel", true], ["LinearPearlsModel", true], ["CoreShellModel", true]], "Structure Factor": [["SquareWellStructure", true], ["HayterMSAStructure", true], ["HardsphereStructure", true], ["StickyHSStructure", true]], "Shape-Independent": [["TwoPowerLawModel", true], ["GelFitModel", true], ["DABModel", true], ["PowerLawAbsModel", true], ["PorodModel", true], ["MassFractalModel", true], ["RPA10Model", true], ["TeubnerStreyModel", true], ["DebyeModel", true], ["MassSurfaceFractal", true], ["Core2ndMomentModel", true], ["TwoLorentzianModel", true], ["UnifiedPowerRgModel", true], ["PolymerExclVolume", true], ["BEPolyelectrolyte", true], ["GuinierModel", true], ["GuinierPorodModel", true], ["CorrLengthModel", true], ["StarPolymer", true], ["FractalModel", true], ["PeakLorentzModel", true], ["BroadPeakModel", true], ["PeakGaussModel", true], ["FractalCoreShellModel", true], ["Poly_GaussCoil", true], ["SurfaceFractalModel", true], ["GaussLorentzGelModel", true], ["LorentzModel", true]], "Uncategorized": [["ReflectivityModel", true], ["ReflectivityIIModel", true], ["LineModel", true], ["MicelleSphCoreModel", true]]}
+{"Shapes": [["BarBellModel", true], ["PearlNecklaceModel", true], ["HollowCylinderModel", true], ["CoreMultiShellModel", true], ["FCCrystalModel", true], ["ParallelepipedModel", true], ["FuzzySphereModel", true], ["CoreShellEllipsoidXTModel", true], ["LamellarPCrystalModel", true], ["BCCrystalModel", true], ["EllipticalCylinderModel", true], ["RectangularHollowPrismInfThinWallsModel", true], ["CSParallelepipedModel", true], ["OnionExpShellModel", true], ["MultiShellModel", true], ["RaspBerryModel", true], ["CoreShellEllipsoidModel", true], ["CappedCylinderModel", true], ["CylinderModel", true], ["SphericalSLDModel", true], ["SCCrystalModel", true], ["StackedDisksModel", true], ["LamellarPSHGModel", true], ["CoreShellBicelleModel", true], ["RectangularHollowPrismModel", true], ["LamellarPSModel", true], ["EllipsoidModel", true], ["SphereModel", true], ["VesicleModel", true], ["TriaxialEllipsoidModel", true], ["LamellarModel", true], ["PringlesModel", true], ["RectangularPrismModel", true], ["CoreShellCylinderModel", true], ["BinaryHSModel", true], ["FlexibleCylinderModel", true], ["LamellarFFHGModel", true], ["FlexCylEllipXModel", true], ["LinearPearlsModel", true], ["CoreShellModel", true]], "Structure Factor": [["SquareWellStructure", true], ["HayterMSAStructure", true], ["HardsphereStructure", true], ["StickyHSStructure", true]], "Shape-Independent": [["TwoPowerLawModel", true], ["GelFitModel", true], ["DABModel", true], ["PowerLawAbsModel", true], ["PorodModel", true], ["GuinierModel", true], ["RPA10Model", true], ["TeubnerStreyModel", true], ["StarPolymer", true], ["UnifiedPowerRgModel", true], ["MassSurfaceFractal", true], ["Core2ndMomentModel", true], ["TwoLorentzianModel", true], ["DebyeModel", true], ["MassFractalModel", true], ["GuinierPorodModel", true], ["CorrLengthModel", true], ["PolymerExclVolume", true], ["FractalModel", true], ["PeakLorentzModel", true], ["BroadPeakModel", true], ["FractalCoreShellModel", true], ["PeakGaussModel", true], ["BEPolyelectrolyte", true], ["Poly_GaussCoil", true], ["SurfaceFractalModel", true], ["GaussLorentzGelModel", true], ["LorentzModel", true]], "Uncategorized": [["ReflectivityModel", true], ["ReflectivityIIModel", true], ["LineModel", true], ["MicelleSphCoreModel", true]]}
Index: src/sas/models/c_extension/c_models/barbell.cpp
===================================================================
--- src/sas/models/c_extension/c_models/barbell.cpp	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/models/c_extension/c_models/barbell.cpp	(revision db46d13d6ad925ea6da0c9aa178a62e3dc325cdb)
@@ -30,4 +30,17 @@
 	#include "barbell.h"
 }
+
+// Convenience parameter structure
+typedef struct {
+    double scale;
+    double rad_bar;
+    double len_bar;
+    double rad_bell;
+    double sld_barbell;
+    double sld_solv;
+    double background;
+    double theta;
+    double phi;
+} BarBellParameters;
 
 BarBellModel :: BarBellModel() {
@@ -46,5 +59,5 @@
 }
 
-double bar2d_kernel(double dp[], double q, double alpha) {
+double barbell2d_kernel(double dp[], double q, double alpha) {
   int j;
   double Pi;
@@ -113,4 +126,75 @@
   return answer;
 }
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @param q_x: q_x / q
+ * @param q_y: q_y / q
+ * @return: function value
+ */
+static double barbell_analytical_2D_scaled(BarBellParameters *pars, double q, double q_x, double q_y) {
+  double cyl_x, cyl_y;//, cyl_z;
+  //double q_z;
+  double alpha, cos_val;
+  double answer;
+  double dp[7];
+  //convert angle degree to radian
+  double pi = 4.0*atan(1.0);
+  double theta = pars->theta * pi/180.0;
+  double phi = pars->phi * pi/180.0;
+
+  dp[0] = pars->scale;
+  dp[1] = pars->rad_bar;
+  dp[2] = pars->len_bar;
+  dp[3] = pars->rad_bell;
+  dp[4] = pars->sld_barbell;
+  dp[5] = pars->sld_solv;
+  dp[6] = pars->background;
+
+
+  //double Pi = 4.0*atan(1.0);
+    // Cylinder orientation
+    cyl_x = cos(theta) * cos(phi);
+    cyl_y = sin(theta);
+    //cyl_z = -cos(theta) * sin(phi);
+
+    // q vector
+    //q_z = 0;
+
+    // Compute the angle btw vector q and the
+    // axis of the cylinder
+    cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z;
+
+    // The following test should always pass
+    if (fabs(cos_val)>1.0) {
+      printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n");
+      return 0;
+    }
+
+    // Note: cos(alpha) = 0 and 1 will get an
+    // undefined value from CylKernel
+  alpha = acos( cos_val );
+
+  answer = barbell2d_kernel(dp, q, alpha);
+
+
+  return answer;
+
+}
+
+/**
+ * Function to evaluate 2D scattering function
+ * @param pars: parameters of the BarBell
+ * @param q: q-value
+ * @return: function value
+ */
+static double barbell_analytical_2DXY(BarBellParameters *pars, double qx, double qy){
+  double q;
+  q = sqrt(qx*qx+qy*qy);
+  return barbell_analytical_2D_scaled(pars, q, qx/q, qy/q);
+}
+
 /**
  * Function to evaluate 1D scattering function
@@ -190,18 +274,17 @@
  */
 double BarBellModel :: operator()(double qx, double qy) {
-  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;
-
-  double _theta = theta();
-  double _phi = phi();
+  BarBellParameters dp;
+
+	// Fill parameter array for IGOR library
+	// Add the background after averaging
+	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
@@ -237,44 +320,19 @@
 	// Loop over radius weight points
 	for(size_t i=0; i<weights_rad_bar.size(); i++) {
-		dp[1] = weights_rad_bar[i].value;
+		dp.rad_bar = weights_rad_bar[i].value;
 		for(size_t j=0; j<weights_len_bar.size(); j++) {
-			dp[2] = weights_len_bar[j].value;
+			dp.len_bar = weights_len_bar[j].value;
 			for(size_t k=0; k<weights_rad_bell.size(); k++) {
-				dp[3] = weights_rad_bell[k].value;
+				dp.rad_bell = weights_rad_bell[k].value;
 				// Average over theta distribution
 				for(size_t l=0; l< weights_theta.size(); l++) {
-					_theta = weights_theta[l].value;
+					dp.theta = weights_theta[l].value;
 					// Average over phi distribution
 					for(size_t m=0; m< weights_phi.size(); m++) {
-						_phi = weights_phi[m].value;
+						dp.phi = weights_phi[m].value;
 						//Un-normalize Form 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);
-
-					  const double q = sqrt(qx*qx+qy*qy);
-					  //convert angle degree to radian
-					  const double pi = 4.0*atan(1.0);
-
-					  // Cylinder orientation
-				    const double cyl_x = cos(_theta * pi/180.0) * cos(_phi * pi/180.0);
-				    const double cyl_y = sin(_theta * pi/180.0);
-
-				    // Compute the angle btw vector q and the
-				    // axis of the cylinder (assume qz = 0)
-				    const double cos_val = cyl_x*qx + cyl_y*qy;
-
-				    // The following test should always pass
-				    if (fabs(cos_val)>1.0) {
-				      return 0;
-				    }
-
-				    // Note: cos(alpha) = 0 and 1 will get an
-				    // undefined value from CylKernel
-				    const double alpha = acos( cos_val );
-
-            // Call the IGOR library function to get the kernel
-            const double output = bar2d_kernel(dp, q, alpha)/sin(alpha);
-
+						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/3.0*((dp.rad_bell-hDist)*(dp.rad_bell-hDist)*
+										(2*dp.rad_bell+hDist));
 						double _ptvalue = weights_rad_bar[i].weight
 											* weights_len_bar[j].weight
@@ -283,5 +341,6 @@
 											* weights_phi[m].weight
 											* vol_i
-											* output;
+											* barbell_analytical_2DXY(&dp, qx, qy);
+											//* output;
 											//* pow(weights_rad[i].value,3.0);
 
Index: src/sas/perspectives/fitting/models.py
===================================================================
--- src/sas/perspectives/fitting/models.py	(revision 415fb824f22c6e653a334cf7dae677b365067d1f)
+++ src/sas/perspectives/fitting/models.py	(revision db46d13d6ad925ea6da0c9aa178a62e3dc325cdb)
@@ -315,6 +315,6 @@
         # regular model names only
         base_message = "Unable to load model {0}"
-        try:
-            self.model_name_list = []
+        self.model_name_list = []
+        try:
             from sas.models.SphereModel import SphereModel
             self.model_dictionary[SphereModel.__name__] = SphereModel
@@ -529,4 +529,13 @@
         except:
             logging.error(base_message.format(EllipticalCylinderModel.__name__))
+
+        try:
+            from sas.models.BarBellModel import BarBellModel
+
+            self.model_dictionary[BarBellModel.__name__] = BarBellModel
+            #       self.shape_list.append(BarBellModel)
+            self.model_name_list.append(BarBellModel.__name__)
+        except:
+            logging.error(base_message.format(BarBellModel.__name__))
 
         try:
