Changeset 3db3895 in sasview


Ignore:
Timestamp:
Mar 25, 2008 11:05:04 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
f629e346
Parents:
829eee9
Message:

Fixed new models - still need validation

Location:
sansmodels/src/sans/models
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/AddComponent.py

    rae3ce4e r3db3895  
    3838        return self.operateOn.run(x) + self.other.run(x) 
    3939         
     40    def runXY(self, x=0): 
     41        """ 
     42            Evaluate each part of the component and sum the results 
     43            @param x: input parameter 
     44            @return: value of the model at x 
     45        """ 
     46        return self.operateOn.runXY(x) + self.other.runXY(x) 
     47         
    4048    def setParam(self, name, value): 
    4149        """  
  • sansmodels/src/sans/models/BEPolyelectrolyte.py

    r829eee9 r3db3895  
    22"""  
    33     
    4     Provide F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
     4    Provide F(x) = K*1/(4*pi*Lb*(alpha)^(2))*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
    55                       *(q^(2)-(12*h*C/b^(2))) 
    66    BEPolyelectrolyte as a BaseComponent model 
     
    1515        Class that evaluates a BEPolyelectrolyte. 
    1616         
    17         F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
     17        F(x) = K*1/(4*pi*Lb*(alpha)^(2))*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
    1818                       *(q^(2)-(12*h*C/b^(2))) 
    1919         
     
    4040        ## Define parameters 
    4141        self.params = {} 
    42         self.params['K']    = 10 
    43         self.params['Lb']   = 7.1 
    44         self.params['H']    = 12 
    45         self.params['B']    = 10 
    46         self.params['Cs']   = 0.0 
     42        self.params['k']    = 10 
     43        self.params['lb']   = 7.1 
     44        self.params['h']    = 12 
     45        self.params['b']    = 10 
     46        self.params['cs']   = 0.0 
    4747        self.params['alpha']= 0.05 
    48         self.params['C']    = 0.7 
    49         self.params['bkd']  = 0.001 
     48        self.params['c']    = 0.7 
     49        self.params['background']  = 0.0 
    5050         
    5151 
    5252        ## Parameter details [units, min, max] 
    5353        self.details = {} 
    54         self.details['K']    = ['barns', None, None] 
    55         self.details['Lb'] = ['A', None, None] 
    56         self.details['H']   = ['A^{-3}', None, None] 
    57         self.details['B']    = ['A', None, None] 
    58         self.details['Cs'] = ['mol/L', None, None] 
     54        self.details['k']    = ['barns', None, None] 
     55        self.details['lb'] = ['A', None, None] 
     56        self.details['h']   = ['A-3', None, None] 
     57        self.details['b']    = ['A', None, None] 
     58        self.details['cs'] = ['mol/L', None, None] 
    5959        self.details['alpha']   = ['', None, None] 
    60         self.details['C']    = ['mol/L', None, None] 
    61         self.details['bkd'] = ['', None, None] 
     60        self.details['c']    = ['mol/L', None, None] 
     61        self.details['background'] = ['cm-1', None, None] 
    6262        
    6363                
     
    6565        """ 
    6666            Evaluate   
    67             F(x) = K*1/(4*pi()*Lb*(alpha)^(2)*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
     67            F(x) = K*1/(4*pi*Lb*(alpha)^(2))*(q^(2)+k2)/(1+(r02)^(2))*(q^(2)+k2)\ 
    6868                       *(q^(2)-(12*h*C/b^(2))) 
    6969         
     
    7171                   The inverse Debye Length: K2 = 4*pi*Lb*(2*Cs+alpha*C) 
    7272                   r02 =1/alpha/Ca^(0.5)*(B/(48*pi*Lb)^(0.5)) 
    73                    Ca = C*6.022136* exp(-4) 
     73                   Ca = C*6.022136e-4 
    7474        """ 
    75         K2 = 4 * math.pi * self.params['Lb'] * (2*self.params['Cs'] + \ 
    76                  self.params['alpha'] * self.params['C']) 
     75        Ca = self.params['c'] * 6.022136e-4 
    7776         
    78         Ca = self.params['C'] * 6.022136 * math.exp(-4) 
     77        K2 = 4.0 * math.pi * self.params['lb'] * (2*self.params['cs'] + \ 
     78                 self.params['alpha'] * Ca) 
    7979         
    80         r02 =1/(self.params['alpha'] * math.pow(Ca,0.5) * \ 
    81                 (self.params['B']/math.pow((48*math.pi *self.params['Lb']),0.5))) 
     80        r02 = 1.0/self.params['alpha']/math.sqrt(Ca) * \ 
     81                (self.params['b']/math.sqrt((48.0*math.pi *self.params['lb']))) 
    8282         
    83         return ( self.params['K']/( ( 4 * math.pi *self.params['Lb']*\ 
    84                 (self.params['alpha']**2)*\ 
    85                  ( x**2 + K2 )*( 1 + r02**2 ) * ( x**2 + K2 ) *\ 
    86                  (x**2 - ( 12 * self.params['H'] * \ 
    87                   self.params['C']/(self.params['B']**2) ))  )))+  self.params['bkd'] 
     83        return self.params['k']/( 4.0 * math.pi * self.params['lb'] * self.params['alpha']**2 ) \ 
     84               * ( x**2 + K2 ) / ( 1.0 + r02**2 * ( x**2 + K2 ) \ 
     85                    * (x**2 - ( 12.0 * self.params['h'] \ 
     86                    * Ca/(self.params['b']**2) ))) \ 
     87                    + self.params['background'] 
    8888         
    8989    
    9090    def run(self, x = 0.0): 
    9191        """ Evaluate the model 
    92             @param x: simple value 
     92            @param x: input q-value (float or [float, float] as [r, theta]) 
    9393            @return: (debye value) 
    9494        """ 
     
    102102    def runXY(self, x = 0.0): 
    103103        """ Evaluate the model 
    104             @param x: simple value 
     104            @param x: input q-value (float or [float, float] as [qx, qy]) 
    105105            @return: debye value 
    106106        """ 
     
    110110            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
    111111        else: 
    112             return self._BEPolye(x) 
     112            return self._BEPoly(x) 
  • sansmodels/src/sans/models/BaseComponent.py

    rae3ce4e r3db3895  
    4747        ## Parameters to be accessed by client 
    4848        self.params = {} 
     49        self.details = {} 
    4950            
    5051    def __str__(self): 
     
    6768        obj = copy.deepcopy(self) 
    6869        obj.params = copy.deepcopy(self.params) 
     70        obj.details = copy.deepcopy(self.details) 
    6971     
    7072        # Check for standard data members of arithmetics sub-classes 
  • sansmodels/src/sans/models/DABModel.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    22"""  
    3     Provide F(x) = scale/( 1 + (x*L)^2 )^(2) 
     3    Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 
    44    DAB (Debye Anderson Brumberger) function as a BaseComponent model 
    55""" 
     
    1313        Class that evaluates a DAB model. 
    1414         
    15         F(x) = scale/( 1 + (x*L)^2 )^(2) +bkd 
     15        F(x) = scale/( 1 + (x*L)^2 )^(2) + background 
    1616         
    1717        The model has three parameters:  
    18             L     =  Correlation Length 
    19             scale  =  scale factor 
    20             bkd    =  incoherent background 
     18            L             =  Correlation Length 
     19            scale         =  scale factor 
     20            background    =  incoherent background 
    2121    """ 
    2222         
     
    2828         
    2929        ## Name of the model 
    30         self.name = " DAB_Model " 
     30        self.name = "DAB_Model" 
    3131 
    3232        ## Define parameters 
    3333        self.params = {} 
    34         self.params['L']     = 40.0 
    35         self.params['scale'] = 10.0 
    36         self.params['bkd']   = 0.0 
     34        self.params['length']             = 50.0 
     35        self.params['scale']              = 1.0 
     36        self.params['background']         = 0.0 
    3737 
    3838        ## Parameter details [units, min, max] 
    3939        self.details = {} 
    40         self.details['L']    = ['A', None, None] 
    41         self.details['scale'] = ['', None, None] 
    42         self.details['bkd']   = ['cm^{-1}', None, None] 
     40        self.details['length']            = ['', None, None] 
     41        self.details['scale']             = ['', None, None] 
     42        self.details['background']        = ['', None, None] 
    4343                
    4444    def _DAB(self, x): 
    4545        """ 
    46             Evaluate  F(x) = scale/( 1 + (x*L)^2 )^(2) + bkd 
     46            Evaluate  F(x) = scale/( 1 + (x*L)^2 )^(2) + background 
    4747            
    4848        """ 
    49         return self.params['scale']/math.pow(( 1 + math.pow(x * self.params['L'],2)),2) \ 
    50          + self.params['bkd'] 
     49        return self.params['scale']/math.pow(( 1 + math.pow(x * self.params['length'],2)),2) \ 
     50         + self.params['background'] 
    5151        
    5252    
    5353    def run(self, x = 0.0): 
    5454        """ Evaluate the model 
    55             @param x: simple value 
     55            @param x: input q-value (float or [float, float] as [r, theta]) 
    5656            @return: (DAB value) 
    5757        """ 
     
    6565    def runXY(self, x = 0.0): 
    6666        """ Evaluate the model 
    67             @param x: simple value 
     67            @param x: input q-value (float or [float, float] as [qx, qy]) 
    6868            @return: DAB value 
    6969        """ 
  • sansmodels/src/sans/models/DebyeModel.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    22"""  
    3     Provide F(x) = 2( exp(-x)+x -1 )/x**2 
     3    Provide F(x) = 2( exp(-x) + x - 1 )/x**2 
     4    with x = (q*R_g)**2 
     5     
    46    Debye function as a BaseComponent model 
    57""" 
     
    1315        Class that evaluates a Debye model. 
    1416         
    15         F(x) = 2( exp(-x)+x -1 )/x**2 
     17        F(x) = 2( exp(-x) + x - 1 )/x**2 
     18        with x = (q*R_g)**2 
    1619         
    1720        The model has three parameters:  
     
    3235        ## Define parameters 
    3336        self.params = {} 
    34         self.params['Rg']    = 50.0 
    35         self.params['scale'] = 1.0 
    36         self.params['bkd']   = 0.001 
     37        self.params['rg']          = 50.0 
     38        self.params['scale']       = 1.0 
     39        self.params['background']  = 0.0 
    3740 
    3841        ## Parameter details [units, min, max] 
    3942        self.details = {} 
    40         self.details['Rg']    = ['A', None, None] 
    41         self.details['scale'] = ['', None, None] 
    42         self.details['bkd']   = ['cm^{-1}', None, None] 
     43        self.details['rg']         = ['', None, None] 
     44        self.details['scale']      = ['', None, None] 
     45        self.details['background'] = ['', None, None] 
    4346                
    4447    def _debye(self, x): 
     
    4649            Evaluate F(x)= scale * D + bkd 
    4750            has 2 internal parameters : 
    48                     D = 2 * (exp(-y) +x -1)/y**2  
     51                    D = 2 * (exp(-y) + y - 1)/y**2  
    4952                    y = (x * Rg)^(2) 
    5053        """ 
    51         # prevent a value zero in the denominator  
    52         if x != 0.0 : 
    53             y = math.pow((x * self.params['Rg']), 2) 
    54             D = 2*( math.exp(-y) + y -1 )/math.pow(y,2) 
    55             return self.params['scale']* D + self.params['bkd'] 
    56         else:  
    57             return False 
     54        # Note that a zero denominator value will raise 
     55        # an exception 
     56        y = math.pow((x * self.params['rg']), 2) 
     57        D = 2*( math.exp(-y) + y -1 )/math.pow(y,2) 
     58        return self.params['scale']* D + self.params['background'] 
    5859    
    5960    def run(self, x = 0.0): 
    6061        """ Evaluate the model 
    61             @param x: simple value 
     62            @param x: input q-value (float or [float, float] as [r, theta]) 
    6263            @return: (debye value) 
    6364        """ 
     
    7172    def runXY(self, x = 0.0): 
    7273        """ Evaluate the model 
    73             @param x: simple value 
     74            @param x: input q-value (float or [float, float] as [qx, qy]) 
    7475            @return: debye value 
    7576        """ 
  • sansmodels/src/sans/models/DivComponent.py

    rae3ce4e r3db3895  
    3838        return self.operateOn.run(x) / self.other.run(x) 
    3939         
     40    def runXY(self, x=0): 
     41        """ 
     42            Evaluate each part of the component and sum the results 
     43            @param x: input parameter 
     44            @return: value of the model at x 
     45        """ 
     46        return self.operateOn.runXY(x) / self.other.runXY(x) 
     47         
    4048    def setParam(self, name, value): 
    4149        """  
  • sansmodels/src/sans/models/FractalModel.py

    r829eee9 r3db3895  
    1717        F(x)= P(x)*S(x) + bkd 
    1818        The model has Seven parameters:  
    19             scale   =  Volume fraction 
    20             Radius  =  Block radius 
    21             Fdim    =  Fractal dimension 
    22             L       =  correlation Length 
    23             SDLB    =  SDL block 
    24             SDLS    =  SDL solvent 
    25             bkd     =  background 
     19            scale        =  Volume fraction 
     20            radius       =  Block radius 
     21            fractal_dim  =  Fractal dimension 
     22            corr_length  =  correlation Length 
     23            block_sld    =  SDL block 
     24            solvent_sld  =  SDL solvent 
     25            background   =  background 
    2626            
    2727    """ 
     
    3838        ## Define parameters 
    3939        self.params = {} 
    40         self.params['scale'] = 0.05 
    41         self.params['Radius']= 5 
    42         self.params['Fdim']  = 2 
    43         self.params['L']     = 100 
    44         self.params['SDLB']  = 2*math.exp(-6) 
    45         self.params['SDLS']  = 6.35*math.exp(-6) 
    46         self.params['bkd']   = 0.0 
     40        self.params['scale']       = 0.05 
     41        self.params['radius']      = 5.0 
     42        self.params['fractal_dim'] = 2.0 
     43        self.params['corr_length'] = 100.0 
     44        self.params['block_sld']   = 2.0e-6 
     45        self.params['solvent_sld'] = 6.0e-6 
     46        self.params['background']  = 0.0 
    4747         
    4848 
    4949        ## Parameter details [units, min, max] 
    5050        self.details = {} 
    51         self.details['scale']    = ['', None, None] 
    52         self.details['Radius']   = ['A', None, None] 
    53         self.details['Fdim']    = ['', None, None] 
    54         self.details['L']        = ['A', None, None] 
    55         self.details['SDLB']     = ['A^{-2}', None, None] 
    56         self.details['SDLS']     = ['A^{-2}', None, None] 
    57         self.details['bkd']      = ['cm^{-1} sr^{-1}', None, None] 
     51        self.details['scale']       = ['', None, None] 
     52        self.details['radius']      = ['A', None, None] 
     53        self.details['fractal_dim'] = ['', None, None] 
     54        self.details['corr_length'] = ['A', None, None] 
     55        self.details['block_sld']   = ['A-2', None, None] 
     56        self.details['solvent_sld'] = ['A-2', None, None] 
     57        self.details['background']  = ['cm-1', None, None] 
    5858        
    5959                
     
    6161        """ 
    6262            Evaluate   
    63             F(x) = p(x)* s(x)+bkd   
     63            F(x) = p(x) * s(x) + bkd   
    6464        """ 
    65         return self.params['bkd']+ self._scatterRanDom(x)* self._Block(x) 
     65        return self.params['background']+ self._scatterRanDom(x)* self._Block(x) 
    6666     
    6767    def _Block(self,x): 
    6868         
    69         return 1 + (math.sin((self.params['Fdim']-1) * math.atan(x * self.params['L']))\ 
    70              * self.params['Fdim'] * gamma(self.params['Fdim']-1))\ 
    71            /( math.pow( (x*self.params['Radius']),self.params['Fdim'])*\ 
    72            ( 1 + 1/math.pow(((x**2)*(self.params['L']**2)),(self.params['Fdim']-1)/2)))       
     69        return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 
     70             * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 
     71           /( math.pow( (x*self.params['radius']),self.params['fractal_dim'])*\ 
     72           ( 1.0 + 1.0/((x**2)*(self.params['corr_length']**2)),(self.params['fractal_dim']-1.0)/2.0))       
    7373            
    7474    def _Spherical(self,x): 
     
    7676            F(x) = [sin(x)-xcos(x)]/3*(x**3) 
    7777        """ 
    78         if x !=0: 
    79             return (math.sin(x)-x*math.cos(x))/(3*math.pow(x,3)) 
    80         else: 
    81             return false 
     78        return (math.sin(x)-x*math.cos(x))/(3.0*math.pow(x,3.0)) 
     79         
    8280    def _scatterRanDom(self,x): 
    8381        """ 
    8482             calculate p(x)= scale* V^(2)*delta^(2)* F(x*Radius)^(2) 
    8583        """ 
    86         V =(4/3)*math.pi* math.pow(self.params['Radius'],3)  
    87         delta = self.params['SDLB']-self.params['SDLS'] 
     84        V =(4.0/3.0)*math.pi* math.pow(self.params['radius'],3.0)  
     85        delta = self.params['block_sld']-self.params['solvent_sld'] 
    8886         
    89         return self.params['scale']* (V**2)*(delta**2)*\ 
    90                 (self._Spherical(x*self.params['Radius'])**2) 
     87        return self.params['scale']* V *(delta**2)*\ 
     88                (self._Spherical(x*self.params['radius'])**2) 
    9189         
    9290    def run(self, x = 0.0): 
    9391        """ Evaluate the model 
    94             @param x: simple value 
     92            @param x: input q-value (float or [float, float] as [r, theta]) 
    9593            @return: (Fractal value) 
    9694        """ 
     
    104102    def runXY(self, x = 0.0): 
    105103        """ Evaluate the model 
    106             @param x: simple value 
     104            @param x: input q-value (float or [float, float] as [qx, qy]) 
    107105            @return: Fractal value 
    108106        """ 
  • sansmodels/src/sans/models/GuinierModel.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    2 """ Provide y=exp (ax^(2)+b),Guinier function as a BaseComponent model 
     2"""  
     3    Provide I(q) = I_0 exp ( - R_g^2 q^2 / 3.0) 
     4    Guinier function as a BaseComponent model 
    35""" 
    46 
     
    79 
    810class GuinierModel(BaseComponent): 
    9     """ Class that evaluates a Guinier model. 
     11    """  
     12        Class that evaluates a Guinier model. 
    1013     
    11         Info about the model 
     14        I(q) = I_0 exp ( - R_g^2 q^2 / 3.0 ) 
    1215      
    1316        List of default parameters: 
    14          value           = 1.0  
     17         I_0 = Scale 
     18         R_g = Radius of gyration 
     19           
    1520    """ 
    1621         
     
    2631        ## Define parameters 
    2732        self.params = {} 
    28         self.params['A'] = 0.0 
    29         self.params['B'] = 0.0 
     33        self.params['scale']  = 1.0 
     34        self.params['rg']     = 0.1 
    3035 
    3136        ## Parameter details [units, min, max] 
    3237        self.details = {} 
    33         self.details['A'] = ['', None, None] 
    34         self.details['B'] = ['', None, None] 
     38        self.details['scale'] = ['cm-1', None, None] 
     39        self.details['rg']    = ['A', None, None] 
    3540                
    3641    def _guinier(self, x): 
    37         return math.exp(self.params['A'] + self.params['B']* math.pow(x, 2) 
     42        return self.params['scale'] * math.exp( -(self.params['rg']*x)**2 / 3.0  
    3843    
    3944    def run(self, x = 0.0): 
    4045        """ Evaluate the model 
    41             @param x: simple value 
     46            @param x: input q-value (float or [float, float] as [r, theta]) 
    4247            @return: (guinier value) 
    4348        """ 
     
    5156    def runXY(self, x = 0.0): 
    5257        """ Evaluate the model 
    53             @param x: simple value 
     58            @param x: input q-value (float or [float, float] as [qx, qy]) 
    5459            @return: guinier value 
    5560        """ 
  • sansmodels/src/sans/models/LorentzModel.py

    r829eee9 r3db3895  
    22"""  
    33    Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd 
    4     Lorentz function as a BaseComponent model 
     4    Lorentz (Ornstein-Zernicke) function as a BaseComponent model 
    55""" 
    66 
     
    1111    
    1212    """ 
    13         Class that evaluates a Lorentz model. 
     13        Class that evaluates a Lorentz (Ornstein-Zernicke) model. 
    1414         
    1515        F(x) = scale/( 1 + (x*L)^2 ) + bkd 
     
    3232        ## Define parameters 
    3333        self.params = {} 
    34         self.params['L']     = 50.0 
    35         self.params['scale'] = 100.0 
    36         self.params['bkd']   = 1 
     34        self.params['length']      = 50.0 
     35        self.params['scale']       = 1.0 
     36        self.params['background']  = 0.0 
    3737 
    3838        ## Parameter details [units, min, max] 
    3939        self.details = {} 
    40         self.details['L']    = ['A', None, None] 
    41         self.details['scale'] = ['', None, None] 
    42         self.details['bkd']   = ['cm^{-1}', None, None] 
     40        self.details['length']     = ['A', None, None] 
     41        self.details['scale']      = ['', None, None] 
     42        self.details['background'] = ['cm-1', None, None] 
    4343                
    4444    def _lorentz(self, x): 
     
    4747            
    4848        """ 
    49         return self.params['scale']/( 1 + math.pow((x * self.params['L']),2))\ 
    50                 + self.params['bkd'] 
     49        return self.params['scale']/( 1 + math.pow((x * self.params['length']),2))\ 
     50                + self.params['background'] 
    5151        
    5252    
    5353    def run(self, x = 0.0): 
    5454        """ Evaluate the model 
    55             @param x: simple value 
     55            @param x: input q-value (float or [float, float] as [r, theta]) 
    5656            @return: (Lorentz value) 
    5757        """ 
     
    6565    def runXY(self, x = 0.0): 
    6666        """ Evaluate the model 
    67             @param x: simple value 
     67            @param x: input q-value (float or [float, float] as [qx, qy]) 
    6868            @return: Lorentz value 
    6969        """ 
  • sansmodels/src/sans/models/MulComponent.py

    rae3ce4e r3db3895  
    3838        return self.operateOn.run(x) * self.other.run(x) 
    3939         
     40    def runXY(self, x=0): 
     41        """ 
     42            Evaluate each part of the component and sum the results 
     43            @param x: input parameter 
     44            @return: value of the model at x 
     45        """ 
     46        return self.operateOn.runXY(x) * self.other.runXY(x) 
     47         
    4048    def setParam(self, name, value): 
    4149        """  
  • sansmodels/src/sans/models/PorodModel.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    2 """ Provide y=,Guinier function as a BaseComponent model 
     2"""  
     3    Provide I(q) = C/q^4, 
     4    Porod function as a BaseComponent model 
    35""" 
    46 
     
    911    """ Class that evaluates a Porod model. 
    1012     
    11        F(x) = exp[ [C]/Q**4 ] 
     13       I(q) = scale/q^4 
    1214         
    13         The model has one parameter: C 
    1415    """ 
    1516         
     
    2122         
    2223        ## Name of the model 
    23         self.name = "Porod Model" 
     24        self.name = "PorodModel" 
    2425 
    2526        ## Define parameters 
    2627        self.params = {} 
    27         self.params['C'] = 0.0 
     28        self.params['scale'] = 0.0 
    2829         
    2930 
    3031        ## Parameter details [units, min, max] 
    3132        self.details = {} 
    32         self.details['C'] = ['', None, None] 
     33        self.details['scale'] = ['', None, None] 
    3334       
    3435                
    3536    def _porod(self, x): 
    36         return math.exp(self.params['C']/ math.pow(x, 4))   
     37        return self.params['scale']/x**4.0 
    3738    
    3839    def run(self, x = 0.0): 
    3940        """ Evaluate the model 
    40             @param x: simple value 
     41            @param x: input q-value (float or [float, float] as [r, theta]) 
    4142            @return: (porod value) 
    4243        """ 
     
    5051    def runXY(self, x = 0.0): 
    5152        """ Evaluate the model 
    52             @param x: simple value 
     53            @param x: input q-value (float or [float, float] as [qx, qy]) 
    5354            @return: porod value 
    5455        """ 
  • sansmodels/src/sans/models/PowerLawModel.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    22"""  
    3     Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd 
    4     Lorentz function as a BaseComponent model 
     3    Provide F(x) = scale* (x)^(-m) + bkd 
     4    Power law function as a BaseComponent model 
    55""" 
    66 
     
    1313        Class that evaluates a Power_Law model. 
    1414         
    15         F(x) = scale* (x)^(m) + bkd 
     15        F(x) = scale* (x)^(-m) + bkd 
    1616         
    1717        The model has three parameters:  
     
    3232        ## Define parameters 
    3333        self.params = {} 
    34         self.params['m']     = 50.0 
    35         self.params['scale'] = 100.0 
    36         self.params['bkd']   = 1 
     34        self.params['m']            = 4.0 
     35        self.params['scale']        = 1.0 
     36        self.params['background']   = 0.0 
    3737 
    3838        ## Parameter details [units, min, max] 
    3939        self.details = {} 
    40         self.details['m']    = ['', None, None ] 
    41         self.details['scale'] = ['', None, None] 
    42         self.details['bkd']   = ['cm^{-1}', None, None] 
     40        self.details['m']           = ['', None, None ] 
     41        self.details['scale']       = ['', None, None] 
     42        self.details['background']  = ['', None, None] 
    4343                
    4444    def _PowerLaw(self, x): 
    4545        """ 
    46             Evaluate  F(x) = scale* (x)^(m) + bkd 
     46            Evaluate  F(x) = scale* (x)^(-m) + bkd 
    4747            
    4848        """ 
    49         return self.params['scale']*math.pow(x ,self.params['m'])\ 
    50                 + self.params['bkd'] 
     49        return self.params['scale']*math.pow(x ,-self.params['m'])\ 
     50                + self.params['background'] 
    5151        
    5252    
    5353    def run(self, x = 0.0): 
    5454        """ Evaluate the model 
    55             @param x: simple value 
     55            @param x: input q-value (float or [float, float] as [r, theta]) 
    5656            @return: (PowerLaw value) 
    5757        """ 
     
    6565    def runXY(self, x = 0.0): 
    6666        """ Evaluate the model 
    67             @param x: simple value 
     67            @param x: input q-value (float or [float, float] as [qx, qy]) 
    6868            @return: PowerLaw value 
    6969        """ 
  • sansmodels/src/sans/models/SubComponent.py

    rae3ce4e r3db3895  
    3838        return self.operateOn.run(x) - self.other.run(x) 
    3939         
     40    def runXY(self, x=0): 
     41        """ 
     42            Evaluate each part of the component and sum the results 
     43            @param x: input parameter 
     44            @return: value of the model at x 
     45        """ 
     46        return self.operateOn.runXY(x) - self.other.runXY(x) 
     47         
    4048    def setParam(self, name, value): 
    4149        """  
  • sansmodels/src/sans/models/TeubnerStreyModel.py

    r829eee9 r3db3895  
    3737        self.params['c2']     = 5000.0 
    3838        self.params['scale']  = 0.1 
    39         self.params['bkd']    = 0.1 
     39        self.params['background']    = 0.0 
    4040 
    4141        ## Parameter details [units, min, max] 
     
    4444        self.details['c2']    = ['', None, None ] 
    4545        self.details['scale'] = ['', None, None] 
    46         self.details['bkd']   = ['cm^{-1}', None, None] 
     46        self.details['background']   = ['', None, None] 
    4747     
    4848                
     
    5858    def run(self, x = 0.0): 
    5959        """ Evaluate the model 
    60             @param x: simple value 
     60            @param x: input q-value (float or [float, float] as [r, theta]) 
    6161            @return: (PowerLaw value) 
    6262        """ 
     
    7171    def runXY(self, x = 0.0): 
    7272        """ Evaluate the model 
    73             @param x: simple value 
     73            @param x: input q-value (float or [float, float] as [qx, qy]) 
    7474            @return: PowerLaw value 
    7575        """ 
     
    8181            return self._TeubnerStrey(x) 
    8282         
    83     def TeubnerStreyLengths(self): 
     83    def teubnerStreyLengths(self): 
    8484        """ 
    8585            Calculate the correlation length (L)  
    8686            @return L: the correlation distance  
    8787        """ 
    88         if (self.params['c2'] !=0) and \ 
    89         ((2*math.pow(self.params['scale'],1/2)+self.params['c1'])>= 0): 
    90             L =  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\ 
     88        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\ 
    9189                            +(self.params['c1']/(4*self.params['c2'])),-1/2 ) 
    92             return L 
    93         else: 
    94             return False 
    95     def TeubnerStreyDistance(self): 
     90    def teubnerStreyDistance(self): 
    9691        """ 
    9792            Calculate the quasi-periodic repeat distance (D/(2*pi))  
    9893            @return D: quasi-periodic repeat distance 
    9994        """ 
    100         if (self.params['c2'] !=0) and \ 
    101         ((2*math.pow(self.params['scale'],1/2)-self.params['c1'])>= 0): 
    102             D =  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\ 
     95        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\ 
    10396                            -(self.params['c1']/(4*self.params['c2'])),-1/2 ) 
    104             return D 
    105         else: 
    106             return False 
  • sansmodels/src/sans/models/prototypes/UnifiedPowerLaw.py

    r829eee9 r3db3895  
    11#!/usr/bin/env python 
    22"""  
    3     Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd 
    4     Lorentz function as a BaseComponent model 
     3    Failed attempt at a Beaucage model. 
    54""" 
     5#TODO: Clean this up 
     6#TODO: Remove setValueParam, which doesn't belong in this class! 
     7#      It totally breaks the philosophy of this class 
    68 
    79from sans.models.BaseComponent import BaseComponent 
Note: See TracChangeset for help on using the changeset viewer.