Index: sansmodels/src/sans/models/BEPolyelectrolyte.py
===================================================================
--- sansmodels/src/sans/models/BEPolyelectrolyte.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/BEPolyelectrolyte.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+""" 
+    
+    Provide F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\
+                       *(q^(2)-(12*h*C/b^(2)))
+    BEPolyelectrolyte as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class BEPolyelectrolyte(BaseComponent):
+   
+    """
+        Class that evaluates a BEPolyelectrolyte.
+        
+        F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\
+                       *(q^(2)-(12*h*C/b^(2)))
+        
+        The model has Eight parameters: 
+            K        =  Constrast factor of the polymer
+            Lb       =  Bjerrum length
+            H        =  virial parameter
+            B        =  monomer length
+            Cs       =  Concentration of monovalent salt 
+            alpha    =  ionazation degree 
+            C        = polymer molar concentration
+            bkd      = background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "BEPolyelectrolyte"
+
+        ## Define parameters
+        self.params = {}
+        self.params['K']    = 10
+        self.params['Lb']   = 7.1
+        self.params['H']    = 12
+        self.params['B']    = 10
+        self.params['Cs']   = 0.0
+        self.params['alpha']= 0.05
+        self.params['C']    = 0.7
+        self.params['bkd']  = 0.001
+        
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['K']    = ['barns', None, None]
+        self.details['Lb'] = ['A', None, None]
+        self.details['H']   = ['A^{-3}', None, None]
+        self.details['B']    = ['A', None, None]
+        self.details['Cs'] = ['mol/L', None, None]
+        self.details['alpha']   = ['', None, None]
+        self.details['C']    = ['mol/L', None, None]
+        self.details['bkd'] = ['', None, None]
+       
+               
+    def _BEPoly(self, x):
+        """
+            Evaluate  
+            F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\
+                       *(q^(2)-(12*h*C/b^(2)))
+        
+            has 3 internal parameters :
+                   The inverse Debye Length: K2 = 4*pi*Lb*(2*Cs+alpha*C)
+                   r02 =1/alpha/Ca^(0.5)*(B/(48*pi*Lb)^(0.5))
+                   Ca = C*6.022136* exp(-4)
+        """
+        K2 = 4 * math.pi * self.params['Lb'] * (2*self.params['Cs'] + \
+                 self.params['alpha'] * self.params['C'])
+        
+        Ca = self.params['C'] * 6.022136 * math.exp(-4)
+        
+        r02 =1/(self.params['alpha'] * math.pow(Ca,0.5) * \
+                (self.params['B']/math.pow((48*math.pi *self.params['Lb']),0.5)))
+        
+        return ( self.params['K']/( ( 4 * math.pi *self.params['Lb']*\
+                (self.params['alpha']**2)*\
+                 ( x**2 + K2 )*( 1 + r02**2 ) * ( x**2 + K2 ) *\
+                 (x**2 - ( 12 * self.params['H'] * \
+                  self.params['C']/(self.params['B']**2) ))  )))+  self.params['bkd']
+        
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (debye value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._BEPoly(x[0]*math.cos(x[1]))*self._BEPoly(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._BEPoly(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: debye value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._BEPoly(x[0])*self._BEPoly(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._BEPolye(x)
Index: sansmodels/src/sans/models/DABModel.py
===================================================================
--- sansmodels/src/sans/models/DABModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/DABModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = scale/( 1 + (x*L)^2 )^(2)
+    DAB (Debye Anderson Brumberger) function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class DABModel(BaseComponent):
+   
+    """
+        Class that evaluates a DAB model.
+        
+        F(x) = scale/( 1 + (x*L)^2 )^(2) +bkd
+        
+        The model has three parameters: 
+            L     =  Correlation Length
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = " DAB_Model "
+
+        ## Define parameters
+        self.params = {}
+        self.params['L']     = 40.0
+        self.params['scale'] = 10.0
+        self.params['bkd']   = 0.0
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['L']    = ['A', None, None]
+        self.details['scale'] = ['', None, None]
+        self.details['bkd']   = ['cm^{-1}', None, None]
+               
+    def _DAB(self, x):
+        """
+            Evaluate  F(x) = scale/( 1 + (x*L)^2 )^(2) + bkd
+           
+        """
+        return self.params['scale']/math.pow(( 1 + math.pow(x * self.params['L'],2)),2) \
+         + self.params['bkd']
+       
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (DAB value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._DAB(x[0]*math.cos(x[1]))*self._DAB(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._DAB(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: DAB value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._DAB(x[0])*self._DAB(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._DAB(x)
Index: sansmodels/src/sans/models/DebyeModel.py
===================================================================
--- sansmodels/src/sans/models/DebyeModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/DebyeModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = 2( exp(-x)+x -1 )/x**2
+    Debye function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class DebyeModel(BaseComponent):
+   
+    """
+        Class that evaluates a Debye model.
+        
+        F(x) = 2( exp(-x)+x -1 )/x**2
+        
+        The model has three parameters: 
+            Rg     =  radius of gyration
+            scale  =  scale factor
+            bkd    =  Constant background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Debye"
+
+        ## Define parameters
+        self.params = {}
+        self.params['Rg']    = 50.0
+        self.params['scale'] = 1.0
+        self.params['bkd']   = 0.001
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['Rg']    = ['A', None, None]
+        self.details['scale'] = ['', None, None]
+        self.details['bkd']   = ['cm^{-1}', None, None]
+               
+    def _debye(self, x):
+        """
+            Evaluate F(x)= scale * D + bkd
+            has 2 internal parameters :
+                    D = 2 * (exp(-y) +x -1)/y**2 
+                    y = (x * Rg)^(2)
+        """
+        # prevent a value zero in the denominator 
+        if x != 0.0 :
+            y = math.pow((x * self.params['Rg']), 2)
+            D = 2*( math.exp(-y) + y -1 )/math.pow(y,2)
+            return self.params['scale']* D + self.params['bkd']
+        else: 
+            return False
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (debye value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._debye(x[0]*math.cos(x[1]))*self._debye(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._debye(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: debye value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._debye(x[0])*self._debye(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._debye(x)
Index: sansmodels/src/sans/models/FractalModel.py
===================================================================
--- sansmodels/src/sans/models/FractalModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/FractalModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+""" 
+    
+    Provide F(x)= P(x)*S(x) + bkd
+    Fractal as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+from scipy.special import gamma
+
+class FractalModel(BaseComponent):
+   
+    """
+        Class that evaluates a Fractal function.
+        
+        F(x)= P(x)*S(x) + bkd
+        The model has Seven parameters: 
+            scale   =  Volume fraction
+            Radius  =  Block radius
+            Fdim    =  Fractal dimension
+            L       =  correlation Length
+            SDLB    =  SDL block
+            SDLS    =  SDL solvent
+            bkd     =  background
+           
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Number Density Fractal"
+
+        ## Define parameters
+        self.params = {}
+        self.params['scale'] = 0.05
+        self.params['Radius']= 5
+        self.params['Fdim']  = 2
+        self.params['L']     = 100
+        self.params['SDLB']  = 2*math.exp(-6)
+        self.params['SDLS']  = 6.35*math.exp(-6)
+        self.params['bkd']   = 0.0
+        
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['scale']    = ['', None, None]
+        self.details['Radius']   = ['A', None, None]
+        self.details['Fdim']     = ['', None, None]
+        self.details['L']        = ['A', None, None]
+        self.details['SDLB']     = ['A^{-2}', None, None]
+        self.details['SDLS']     = ['A^{-2}', None, None]
+        self.details['bkd']      = ['cm^{-1} sr^{-1}', None, None]
+       
+               
+    def _Fractal(self, x):
+        """
+            Evaluate  
+            F(x) = p(x)* s(x)+bkd  
+        """
+        return self.params['bkd']+ self._scatterRanDom(x)* self._Block(x)
+    
+    def _Block(self,x):
+        
+        return 1 + (math.sin((self.params['Fdim']-1) * math.atan(x * self.params['L']))\
+             * self.params['Fdim'] * gamma(self.params['Fdim']-1))\
+           /( math.pow( (x*self.params['Radius']),self.params['Fdim'])*\
+           ( 1 + 1/math.pow(((x**2)*(self.params['L']**2)),(self.params['Fdim']-1)/2)))      
+           
+    def _Spherical(self,x):
+        """
+            F(x) = [sin(x)-xcos(x)]/3*(x**3)
+        """
+        if x !=0:
+            return (math.sin(x)-x*math.cos(x))/(3*math.pow(x,3))
+        else:
+            return false
+    def _scatterRanDom(self,x):
+        """
+             calculate p(x)= scale* V^(2)*delta^(2)* F(x*Radius)^(2)
+        """
+        V =(4/3)*math.pi* math.pow(self.params['Radius'],3) 
+        delta = self.params['SDLB']-self.params['SDLS']
+        
+        return self.params['scale']* (V**2)*(delta**2)*\
+                (self._Spherical(x*self.params['Radius'])**2)
+        
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (Fractal value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._Fractal(x[0]*math.cos(x[1]))*self._Fractal(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._Fractal(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: Fractal value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._Fractal(x[0])*self._Fractal(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._Fractal(x)
Index: sansmodels/src/sans/models/GuinierModel.py
===================================================================
--- sansmodels/src/sans/models/GuinierModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/GuinierModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+""" Provide y=exp (ax^(2)+b),Guinier function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class GuinierModel(BaseComponent):
+    """ Class that evaluates a Guinier model.
+    
+        Info about the model
+     
+        List of default parameters:
+         value           = 1.0 
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Guinier"
+
+        ## Define parameters
+        self.params = {}
+        self.params['A'] = 0.0
+        self.params['B'] = 0.0
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['A'] = ['', None, None]
+        self.details['B'] = ['', None, None]
+               
+    def _guinier(self, x):
+        return math.exp(self.params['A'] + self.params['B']* math.pow(x, 2))  
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (guinier value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._guinier(x[0]*math.cos(x[1]))*self._guinier(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._guinier(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: guinier value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._guinier(x[0])*self._guinier(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._guinier(x)
Index: sansmodels/src/sans/models/LorentzModel.py
===================================================================
--- sansmodels/src/sans/models/LorentzModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/LorentzModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd
+    Lorentz function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class LorentzModel(BaseComponent):
+   
+    """
+        Class that evaluates a Lorentz model.
+        
+        F(x) = scale/( 1 + (x*L)^2 ) + bkd
+        
+        The model has three parameters: 
+            L     =  screen Length
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Lorentz"
+
+        ## Define parameters
+        self.params = {}
+        self.params['L']     = 50.0
+        self.params['scale'] = 100.0
+        self.params['bkd']   = 1
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['L']    = ['A', None, None]
+        self.details['scale'] = ['', None, None]
+        self.details['bkd']   = ['cm^{-1}', None, None]
+               
+    def _lorentz(self, x):
+        """
+            Evaluate F(x) = scale/( 1 + (x*L)^2 ) + bkd
+           
+        """
+        return self.params['scale']/( 1 + math.pow((x * self.params['L']),2))\
+                + self.params['bkd']
+       
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (Lorentz value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._lorentz(x[0]*math.cos(x[1]))*self._lorentz(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._lorentz(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: Lorentz value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._lorentz(x[0])*self._lorentz(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._lorentz(x)
Index: sansmodels/src/sans/models/PorodModel.py
===================================================================
--- sansmodels/src/sans/models/PorodModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/PorodModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+""" Provide y=,Guinier function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class PorodModel(BaseComponent):
+    """ Class that evaluates a Porod model.
+    
+       F(x) = exp[ [C]/Q**4 ]
+        
+        The model has one parameter: C
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Porod Model"
+
+        ## Define parameters
+        self.params = {}
+        self.params['C'] = 0.0
+        
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['C'] = ['', None, None]
+      
+               
+    def _porod(self, x):
+        return math.exp(self.params['C']/ math.pow(x, 4))  
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (porod value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._porod(x[0]*math.cos(x[1]))*self._porod(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._porod(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: porod value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._porod(x[0])*self._porod(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._porod(x)
Index: sansmodels/src/sans/models/PowerLawModel.py
===================================================================
--- sansmodels/src/sans/models/PowerLawModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/PowerLawModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd
+    Lorentz function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class PowerLawModel(BaseComponent):
+   
+    """
+        Class that evaluates a Power_Law model.
+        
+        F(x) = scale* (x)^(m) + bkd
+        
+        The model has three parameters: 
+            m     =  power
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Power_Law"
+
+        ## Define parameters
+        self.params = {}
+        self.params['m']     = 50.0
+        self.params['scale'] = 100.0
+        self.params['bkd']   = 1
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['m']    = ['', None, None ]
+        self.details['scale'] = ['', None, None]
+        self.details['bkd']   = ['cm^{-1}', None, None]
+               
+    def _PowerLaw(self, x):
+        """
+            Evaluate  F(x) = scale* (x)^(m) + bkd
+           
+        """
+        return self.params['scale']*math.pow(x ,self.params['m'])\
+                + self.params['bkd']
+       
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (PowerLaw value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._PowerLaw(x[0]*math.cos(x[1]))*self._PowerLaw(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._PowerLaw(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: PowerLaw value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._PowerLaw(x[0])*self._PowerLaw(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._PowerLaw(x)
Index: sansmodels/src/sans/models/TeubnerStreyModel.py
===================================================================
--- sansmodels/src/sans/models/TeubnerStreyModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/TeubnerStreyModel.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = 1/( scale + c1*(x)^(2)+  c2*(x)^(4)) + bkd
+    Teubner-Strey function as a BaseComponent model
+    
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+
+class TeubnerStreyModel(BaseComponent):
+   
+    """
+        Class that evaluates  the TeubnerStrey model.
+        
+        F(x) = 1/( scale + c1*(x)^(2)+  c2*(x)^(4)) + bkd
+        
+        The model has Four parameters: 
+            scale  =  scale factor
+            c1     =  constant
+            c2     =  constant
+            bkd    =  incoherent background
+    """
+        
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = "Teubner Strey"
+
+        ## Define parameters
+        self.params = {}
+        self.params['c1']     = -30.0
+        self.params['c2']     = 5000.0
+        self.params['scale']  = 0.1
+        self.params['bkd']    = 0.1
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['c1']    = ['', None, None ]
+        self.details['c2']    = ['', None, None ]
+        self.details['scale'] = ['', None, None]
+        self.details['bkd']   = ['cm^{-1}', None, None]
+    
+               
+    def _TeubnerStrey(self, x):
+        """
+            Evaluate  F(x) = 1/( scale + c1*(x)^(2)+  c2*(x)^(4)) + bkd
+           
+        """
+        return 1/( self.params['scale']+ self.params['c1'] * math.pow(x ,2)\
+                + self.params['c2'] * math.pow(x ,4) ) + self.params['bkd']
+       
+   
+    def run(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: (PowerLaw value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._TeubnerStrey(x[0]*math.cos(x[1]))\
+             *self._TeubnerStrey(x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._TeubnerStrey(x)
+   
+    def runXY(self, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @return: PowerLaw value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._TeubnerStrey(x[0])*self._TeubnerStrey(x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._TeubnerStrey(x)
+        
+    def TeubnerStreyLengths(self):
+        """
+            Calculate the correlation length (L) 
+            @return L: the correlation distance 
+        """
+        if (self.params['c2'] !=0) and \
+        ((2*math.pow(self.params['scale'],1/2)+self.params['c1'])>= 0):
+            L =  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
+                            +(self.params['c1']/(4*self.params['c2'])),-1/2 )
+            return L
+        else:
+            return False
+    def TeubnerStreyDistance(self):
+        """
+            Calculate the quasi-periodic repeat distance (D/(2*pi)) 
+            @return D: quasi-periodic repeat distance
+        """
+        if (self.params['c2'] !=0) and \
+        ((2*math.pow(self.params['scale'],1/2)-self.params['c1'])>= 0):
+            D =  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
+                            -(self.params['c1']/(4*self.params['c2'])),-1/2 )
+            return D
+        else:
+            return False
Index: sansmodels/src/sans/models/UnifiedPowerLaw.py
===================================================================
--- sansmodels/src/sans/models/UnifiedPowerLaw.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
+++ sansmodels/src/sans/models/UnifiedPowerLaw.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+""" 
+    Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd
+    Lorentz function as a BaseComponent model
+"""
+
+from sans.models.BaseComponent import BaseComponent
+import math
+import matplotlib
+from scipy.special import erf
+class UnifiedPowerLawModel(BaseComponent):
+   
+    """
+        Class that evaluates a Unified Power_Law model.
+    
+        F(x) =  bkd + sum(G[i]*exp(-x**2 *Rg[i]**2 /3)) \
+          + [B[i]( erf(x*Rg[i]/math.sqrt(6)))** (3*p[i])]/x**p[i] )
+        
+        For each level four parameters must be chosen
+        The model has 5 parameters: 
+           Gi  = ?
+           Rgi = Guinier Radius
+           Pi  = power for each level
+           Bi  = ?
+        Four Levels can be used
+            i is each level 
+           
+    """
+   
+    def __init__(self):
+        """ Initialization """
+        
+        # Initialize BaseComponent first, then sphere
+        BaseComponent.__init__(self)
+        
+        ## Name of the model
+        self.name = " UnifiedPowerLaw " 
+        # default Number of levels 
+
+        self.LevelTotal =2
+
+        ## Define parameters
+        self.params = {}
+        
+        for i in xrange(self.LevelTotal):
+            self.params['G'+ str(i+1)]= 0.0
+            self.params['B'+ str(i+1)]= 0.0
+            self.params['Rg'+ str(i+1)]= 0.0
+            self.params['P'+ str(i+1)]= 0.0
+            
+        ## input Variables with default values for two levels
+        
+        self.params['G1']     = 400.0
+        self.params['G2']     = 3.0
+        
+        self.params['B1']     = 5 * math.exp(-6)
+        self.params['B2']     = 0.0006
+        
+        self.params['Rg1']    = 200.0
+        self.params['Rg2']    = 100.0
+        
+        self.params['P1']    = 4.0
+        self.params['P2']    = 2.0
+        
+        self.params['bkd']    = 0.0
+        
+        
+
+        ## Parameter details [units, min, max]
+        self.details = {}
+        self.details['G1']    = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['G2']    = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['B1']    = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['B2']    = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['Rg1']   = ['A', None, None ]
+        self.details['Rg2']   = ['A', None, None ]
+        self.details['P1']    = ['', None, None ]
+        self.details['P2']    = ['', None, None ]
+        self.details['bkd']   = ['cm^{-1} sr^{-1}', None, None]
+
+    def getValue(self, paramType,level):
+        
+        return self.getParam(str(paramType)+str(level))
+    
+    def setValueParam(self,level,Bvalue,Rgvalue,Gvalue,Pvalue):
+        """
+            set value of parameter given a level
+        """
+        self.params['G'+str(level)] = Gvalue
+        self.params['B'+str(level)] = Bvalue
+        self.params['Rg'+str(level)]= Rgvalue
+        self.params['P'+str(level)] = Pvalue
+        # set the number total of level for the sum
+        if self.LevelTotal < level:
+            self.LevelTotal = level
+            
+        # set parameter details
+        self.details['G'+str(level)]   = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['B'+str(level)]   = ['cm^{-1} sr^{-1}', None, None ]
+        self.details['Rg'+str(level)]  = ['A', None, None ]
+        self.details['P'+str(level)]   = ['', None, None ]
+ 
+
+    def _Sum(self,x):
+        """
+            Calculate the sum of Gi*exp(-x^(2)*Rgi^(2)/3)
+        """
+        sum =0
+        # the default level is 2 and we are using the default values
+        if (self.LevelTotal <= 2)and (self.LevelTotal > 1):
+            return self.params['G1']*math.exp(-(x**2)* (self.params['Rg1']**2)/3)+\
+                self.params['G2']*math.exp(-(x**2)* (self.params['Rg2']**2)/3)
+        # For level higher than 2 
+        else: 
+            for i in xrange(self.LevelTotal):
+                sum =sum +self.params['G'+str(i+1)]*math.exp(-(x**2)* (self.params['Rg'+str(i+1)]**2)/3)
+            return sum 
+                
+ 
+    def _UnifiedPow(self,level,x ):
+        """
+            Calculates the values of the Unified Power Law function
+            @param level: user should enters the level of computation else level =2 
+                will be used
+            @param x: a number
+        """
+       
+        return self.params['bkd']+self._Sum(x)+ (self.params['B'+str(level)]*\
+             math.pow(erf(x * self.params['Rg'+str(level)]/math.sqrt(6))\
+            ,3 * self.params['P'+str(level)]))/math.pow(x,self.params['P'+str(level)])
+       
+    def run(self, level,x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @param level : level of computation
+            @return: (Unified Power law value)
+        """
+        if x.__class__.__name__ == 'list':
+            return self._UnifiedPow(level, x[0]*math.cos(x[1]))*\
+                self.__UnifiedPow(level, x[0]*math.sin(x[1]))
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._UnifiedPow(level,x)
+   
+    def runXY(self,level, x = 0.0):
+        """ Evaluate the model
+            @param x: simple value
+            @param level : level of computation
+            @return: Unified Power law value
+        """
+        if x.__class__.__name__ == 'list':
+            return self._UnifiedPow(level, x[0])*self._UnifiedPow(level,x[1])
+        elif x.__class__.__name__ == 'tuple':
+            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+        else:
+            return self._UnifiedPow(level, x)
Index: sansmodels/src/sans/models/test/utest_nonshape.py
===================================================================
--- sansmodels/src/sans/models/test/utest_nonshape.py	(revision f03b027d69c01a1830b24e0ee8019031a93df7c8)
+++ sansmodels/src/sans/models/test/utest_nonshape.py	(revision 829eee9c87a25f8870f8613d915daf0cfa4c4d05)
@@ -5,4 +5,5 @@
 
 import unittest, time, math
+from scipy.special import erf,gamma
 
 # Disable "missing docstring" complaint
@@ -13,5 +14,5 @@
 # pylint: disable-msg=R0201
 
- 
+import scipy 
 class TestGuinier(unittest.TestCase):
     """
@@ -57,4 +58,6 @@
         #self.assertEqual(self.model.run([r, phi]), value)
         self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+        
 class TestPorod(unittest.TestCase):
     """
@@ -88,7 +91,424 @@
         
         value = self._func(2.0, 1.0)*self._func(2.0, 2.0)
-        
-        #self.assertEqual(self.model.run([r, phi]), value)
-        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+class TestDebye(unittest.TestCase):
+    """
+        Unit tests for Debye function
+        
+        F(x) = 2( exp(-x)+x -1 )/x**2
+        
+        The model has three parameters: 
+            Rg     =  radius of gyration
+            scale  =  scale factor
+            bkd    =  Constant background
+    """
+    def _func(self, Rg, scale, bkg, x):
+        y = (Rg * x)**2
+        return scale * (2*(math.exp(-y) + y -1)/y**2) + bkg
+    
+    def setUp(self):
+        from DebyeModel import DebyeModel
+        self.model= DebyeModel()
+        self.model.setParam('Rg', 50.0)    
+        self.model.setParam('scale',1.0) 
+        self.model.setParam('bkd',0.001)   
+        
+    def test1D(self):
+        value = self._func(50.0, 1.0, 0.001, 2.0)
+        self.assertEqual(self.model.run(2.0), value)
+        
+        #user enter zero as a value of x
+        self.assertEqual(self.model.run(0.0),False)
+       
+        
+    def test2D(self):
+        value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0)
+        self.assertEqual(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+        
+class TestLorentz(unittest.TestCase):
+    """
+        Unit tests for Lorentz function
+        
+         F(x) = scale/( 1 + (x*L)^2 ) + bkd
+        
+        The model has three parameters: 
+            L     =  screen Length
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+    def _func(self,scale,L,bkd,x):
+         return scale/( 1 + (x*L)**2 ) + bkd 
+    def setUp(self):
+        from LorentzModel import LorentzModel
+        self.model= LorentzModel()
+        
+    def test1D(self):
+        self.model.setParam('scale', 100.0)
+        self.model.setParam('L', 50.0)
+        self.model.setParam('bkd', 1.0)
+        
+        self.assertEqual(self.model.run(0.0), 101.0)
+        self.assertEqual(self.model.run(2.0), self._func(100.0, 50.0, 1.0, 2.0))
+        
+    def test2D(self):
+        self.model.setParam('scale', 100.0)
+        self.model.setParam('L', 50.0)
+        self.model.setParam('bkd', 1.0)
+        
+        value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0)    
+        self.assertEqual(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        self.model.setParam('scale', 100.0)
+        self.model.setParam('L', 50.0)
+        self.model.setParam('bkd', 1.0)
+        
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(100.0, 50.0, 1.0, x)*self._func(100.0, 50.0, 1.0, y)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+class TestDAB(unittest.TestCase):
+    """
+        Unit tests for DAB function
+        
+         F(x) = scale/( 1 + (x*L)^2 )^(2) + bkd
+        
+        The model has three parameters: 
+            L      =  Correlation Length
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+    def _func(self, a, b,c, x):
+        return a/(( 1 + ( x * b )**2 ))**2 + c
+    
+    def setUp(self):
+        from DABModel import DABModel
+        self.model= DABModel()
+        
+    def test1D(self):
+        self.model.setParam('scale', 10.0)
+        self.model.setParam('L', 40.0)
+        self.model.setParam('bkd', 0.0)
+        
+        self.assertEqual(self.model.run(0.0), 10.0)
+        self.assertEqual(self.model.run(2.0), self._func(10.0, 40.0, 0.0, 2.0))
+        
+    def test2D(self):
+        self.model.setParam('scale', 10.0)
+        self.model.setParam('L', 40.0)
+        self.model.setParam('bkd', 0.0)
+        
+        value = self._func(10.0, 40.0, 0.0, 1.0)*self._func(10.0, 40.0, 0.0, 2.0)    
+        self.assertEqual(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        self.model.setParam('scale', 10.0)
+        self.model.setParam('L', 40.0)
+        self.model.setParam('bkd', 0.0)
+        
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(10.0, 40.0, 0.0, x)*self._func(10.0, 40.0, 0.0, y)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+class TestPowerLaw(unittest.TestCase):
+    """
+        Unit tests for PowerLaw function
+
+        F(x) = scale* (x)^(m) + bkd
+        
+        The model has three parameters: 
+            m     =  power
+            scale  =  scale factor
+            bkd    =  incoherent background
+    """
+    def _func(self, a, m,c, x):
+        return a*(x )**m + c
+    
+    def setUp(self):
+        from PowerLawModel import PowerLawModel
+        self.model= PowerLawModel()
+        
+    def test1D(self):
+        self.model.setParam('scale', math.exp(-6))
+        self.model.setParam('m', 4.0)
+        self.model.setParam('bkd', 1.0)
+        
+        self.assertEqual(self.model.run(0.0), 1.0)
+        self.assertEqual(self.model.run(2.0), self._func(math.exp(-6), 4.0, 1.0, 2.0))
+        
+    def test2D(self):
+        self.model.setParam('scale', math.exp(-6))
+        self.model.setParam('m', 4.0)
+        self.model.setParam('bkd', 1.0)
+        
+        value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\
+        *self._func(math.exp(-6), 4.0, 1.0, 2.0)    
+        
+        self.assertEqual(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        self.model.setParam('scale', math.exp(-6))
+        self.model.setParam('m', 4.0)
+        self.model.setParam('bkd', 1.0)
+        
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(math.exp(-6), 4.0, 1.0, x)\
+        *self._func(math.exp(-6), 4.0, 1.0, y)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+                
+class TestTeubnerStrey(unittest.TestCase):
+    """
+        Unit tests for PowerLaw function
+
+        F(x) = 1/( scale + c1*(x)^(2)+  c2*(x)^(4)) + bkd
+        
+        The model has Four parameters: 
+            scale  =  scale factor
+            c1     =  constant
+            c2     =  constant
+            bkd    =  incoherent background
+    """
+    def _func(self, a,c1,c2,b, x):
+        return 1/( a + c1*(x)**(2)+  c2*(x)**(4)) + b
+    
+    def setUp(self):
+        from TeubnerStreyModel import TeubnerStreyModel
+        self.model= TeubnerStreyModel()
+        
+    def test1D(self):
+        
+        self.model.setParam('c1', -30.0) 
+        self.model.setParam('c2', 5000.0) 
+        self.model.setParam('scale', 0.1)
+        self.model.setParam('bkd', 0.1)
+        #self.assertEqual(1/(math.sqrt(4)), math.pow(4,-1/2))
+        self.assertEqual(self.model.TeubnerStreyLengths(),False )
+        
+        self.assertEqual(self.model.run(0.0), 10.1)
+        self.assertEqual(self.model.run(2.0), self._func(0.1,-30.0,5000.0,0.1,2.0))
+        
+    def test2D(self):
+        self.model.setParam('c1', -30.0) 
+        self.model.setParam('c2', 5000.0) 
+        self.model.setParam('scale', 0.1)
+        self.model.setParam('bkd', 0.1)
+        value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\
+        *self._func(0.1,-30.0,5000.0,0.1, 2.0)    
+        
+        self.assertEqual(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        self.model.setParam('c1', -30.0) 
+        self.model.setParam('c2', 5000.0) 
+        self.model.setParam('scale', 0.1)
+        self.model.setParam('bkd', 0.1)
+        
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(0.1,-30.0,5000.0,0.1, x)\
+        *self._func(0.1,-30.0,5000.0,0.1, y)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+class TestBEPolyelectrolyte(unittest.TestCase):
+    """
+        Unit tests for  BEPolyelectrolyte function
+        
+        F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\
+                       *(q^(2)-(12*h*C/b^(2)))
+        
+        The model has Eight parameters: 
+            K        =  Constrast factor of the polymer
+            Lb       =  Bjerrum length
+            H        =  virial parameter
+            B        =  monomer length
+            Cs       =  Concentration of monovalent salt 
+            alpha    =  ionazation degree 
+            C        = polymer molar concentration
+            bkd      = background
+    """
+    def _func(self, K, Lb, H, B, Cs, alpha, C, bkd, r02, k2,  x):
+        return (K /( (4*math.pi *Lb*(alpha**2)*(x**2 +k2)) *( (1 +(r02**2))  \
+                    *((x**2) + k2)*((x**2) -(12 * H * C/(B**2))) )))+ bkd
+    
+    def setUp(self):
+        from BEPolyelectrolyte import BEPolyelectrolyte
+        self.model= BEPolyelectrolyte()
+        
+    def test1D(self):
+        
+        self.model.setParam('K', 10.0) 
+        self.model.setParam('Lb', 7.1) 
+        self.model.setParam('H', 12)
+        self.model.setParam('B', 10)
+        self.model.setParam('Cs',0.0) 
+        self.model.setParam('alpha', 0.05) 
+        self.model.setParam('C', 0.7)
+        self.model.setParam('bkd', 0.001)
+        K2 = 4 * math.pi * 7.1 * (2*0.0 + 0.05*0.7)
+        Ca = 0.7 * 6.022136 * math.exp(-4)
+        r02 =1/(0.05 * math.pow(Ca,0.5)*(10/math.pow((48* math.pi *7.1),0.5)))
+ 
+        
+        self.assertEqual(self.model.run(0.0), self._func( 10.0, 7.1, 12,\
+                        10.0, 0.0,0.05,0.7,0.001, r02, K2,  0.0))
+        self.assertEqual(self.model.run(2.0),  self._func( 10.0, 7.1, 12,\
+                        10.0, 0.0,0.05,0.7,0.001, r02, K2,  2.0))
+        
+    def test2D(self):
+        self.model.setParam('K', 10.0) 
+        self.model.setParam('Lb', 7.1) 
+        self.model.setParam('H', 12)
+        self.model.setParam('B', 10)
+        self.model.setParam('Cs',0.0) 
+        self.model.setParam('alpha', 0.05) 
+        self.model.setParam('C', 0.7)
+        self.model.setParam('bkd', 0.001)
+        K2 = 4 * math.pi * 7.1 * (2*0.0 + 0.05*0.7)
+        Ca = 0.7 * 6.022136 * math.exp(-4)
+        r02 =1/(0.05 * math.pow(Ca,0.5)*(10/math.pow((48* math.pi *7.1),0.5)))
+ 
+        value = self._func(10.0, 7.1, 12, 10.0, 0.0,0.05,0.7,0.001, r02, K2,  1.0)\
+        *self._func(10.0, 7.1, 12,10.0, 0.0,0.05,0.7,0.001, r02, K2, 2.0)    
+        
+        self.assertAlmostEquals(self.model.runXY([1.0,2.0]), value)
+        
+    def test2Dphi(self):
+        self.model.setParam('K', 10.0) 
+        self.model.setParam('Lb', 7.1) 
+        self.model.setParam('H', 12)
+        self.model.setParam('B', 10)
+        self.model.setParam('Cs',0.0) 
+        self.model.setParam('alpha', 0.05) 
+        self.model.setParam('C', 0.7)
+        self.model.setParam('bkd', 0.001)
+        K2 = 4 * math.pi * 7.1 * (2*0.0 + 0.05*0.7)
+        Ca = 0.7 * 6.022136 * math.exp(-4)
+        r02 =1/(0.05 * math.pow(Ca,0.5)*(10/math.pow((48* math.pi *7.1),0.5)))
+        
+        x = 1.0
+        y = 2.0
+        r = math.sqrt(x**2 + y**2)
+        phi = math.atan2(y, x)
+        
+        value = self._func(10.0, 7.1, 12, 10.0, 0.0,0.05,0.7,0.001, r02, K2,  x)\
+        *self._func(10.0, 7.1, 12, 10.0, 0.0,0.05,0.7,0.001, r02, K2, y)
+        self.assertAlmostEquals(self.model.run([r, phi]), value,1)
+        
+class TestFractalModel(unittest.TestCase):
+    """
+        Unit tests for  Number Density Fractal function   
+        F(x)= P(x)*S(x) + bkd
+        The model has Seven parameters: 
+            scale   =  Volume fraction
+            Radius  =  Block radius
+            Fdim    =  Fractal dimension
+            L       =  correlation Length
+            SDLB    =  SDL block
+            SDLS    =  SDL solvent
+            bkd     =  background
+    """
+    def _func(self,p,s, bkd, x):
+        return p*s + bkd
+    
+    def setUp(self):
+        from FractalModel import FractalModel
+        self.model= FractalModel()
+        
+    def test1D(self):
+        
+        self.model.setParam('scale', 0.05) 
+        self.model.setParam('Radius',5) 
+        self.model.setParam('Fdim',2)
+        self.model.setParam('L', 100)
+        self.model.setParam('SDLB',2*math.exp(-6)) 
+        self.model.setParam('SDLS', 6.35*math.exp(-6)) 
+        self.model.setParam('bkd', 0.0)
+        
+        s= 1 + (math.sin((2 - 1) * math.atan(2.0*100))* 2 * gamma(2-1))\
+           /( math.pow( (2.0*5),2)*( 1 + 1/math.pow(((2.0**2)*(100**2)),(2-1)/2))) 
+        v= (4/3)*math.pi *math.pow(5, 3)
+        f= ( math.sin(2.0*5)-(2.0*5)*math.cos(2.0*5) )/(3*math.pow(2.0*5, 3))
+        p= 0.05 *(v**2)*(((2*math.exp(-6))-(6.35*math.exp(-6)))**2)*(f**2)
+       
+        self.assertEqual(self.model._scatterRanDom(2.0),p )
+        self.assertEqual(self.model._Block(2.0),s )
+        self.assertEqual(self.model.run(2.0),self._func(p,s ,0.0,2.0))
+        
+class TestUnifiedPowerLaw(unittest.TestCase):
+    """
+        Unit tests for Unified PowerLaw function
+
+        F(x) =  bkd + sum(G[i]*exp(-x**2 *Rg[i]**2 /3)) \
+          + [B[i]( erf(x*Rg[i]/math.sqrt(6)))** (3*p[i])]/x**p[i] )
+        
+    """
+  
+    def setUp(self):
+        from  UnifiedPowerLaw import  UnifiedPowerLawModel
+        self.model=  UnifiedPowerLawModel()
+        
+    def _func(self,level,B,Rg,G,Pow,bkd, x):
+        return bkd + (B * math.pow(erf(x *Rg/math.sqrt(6)),3 *Pow))/math.pow(x,Pow)
+    
+    def _Sum (self,level,x):
+        self.sum = 0
+        for i in xrange(level):
+            self.sum =self.sum +self.model.getParam('G'+str(i+1))*math.exp(-(x**2)*\
+                         (self.model.getParam('Rg'+str(i+1))**2)/3)
+        return self.sum
+    
+    def test1D(self):
+        
+
+        self.model.setParam('bkd', 0.0)
+        #setValueParam(self,level,Bvalue,Rgvalue,Gvalue,Pvalue)
+        self.model.setValueParam(1,2,1,2,5)
+        self.model.setValueParam(2,3,12,8,9)
+        self.model.setValueParam(3,0,2,3,2)
+        self.model.setValueParam(4,1,4,1,-1)
+        self.model.setValueParam(5,1,4,1,-2)
+        
+        self.assertEqual(self.model.getValue('P',1),5)
+        self.assertEqual(self.model.getValue('Rg',2),12)
+   
+        value1 = self._func(1,2,1,2,5,0.0,1.0)+self._Sum(5,1.0)
+        value2 = self._func(2,3,12,8,9,0.0,1.0)+self._Sum(5,1.0)
+        value3 = self._func(3,0,2,3,2,0.0,1.0)+self._Sum(5,1.0)
+        value4 = self._func(4,1,4,1,-1,0.0,1.0)+self._Sum(5,1.0)
+        value5 = self._func(5,1,4,1,-2,0.0,1.0)+self._Sum(5,1.0)
+        self.assertEqual(self.model.run(1,1.0), value1)
+        self.assertEqual(self.model.run(2,1.0), value2)
+        self.assertEqual(self.model.run(3,1.0), value3)
+        self.assertEqual(self.model.run(4,1.0), value4)
+        self.assertEqual(self.model.run(5,1.0), value5)
+        
+ 
+        
         
 if __name__ == '__main__':
