Changeset 3db3895 in sasview for sansmodels/src
- Timestamp:
- Mar 25, 2008 11:05:04 AM (16 years ago)
- 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
- Location:
- sansmodels/src/sans/models
- Files:
-
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/AddComponent.py
rae3ce4e r3db3895 38 38 return self.operateOn.run(x) + self.other.run(x) 39 39 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 40 48 def setParam(self, name, value): 41 49 """ -
sansmodels/src/sans/models/BEPolyelectrolyte.py
r829eee9 r3db3895 2 2 """ 3 3 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)\ 5 5 *(q^(2)-(12*h*C/b^(2))) 6 6 BEPolyelectrolyte as a BaseComponent model … … 15 15 Class that evaluates a BEPolyelectrolyte. 16 16 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)\ 18 18 *(q^(2)-(12*h*C/b^(2))) 19 19 … … 40 40 ## Define parameters 41 41 self.params = {} 42 self.params[' K'] = 1043 self.params[' Lb'] = 7.144 self.params[' H'] = 1245 self.params[' B'] = 1046 self.params[' Cs'] = 0.042 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 47 47 self.params['alpha']= 0.05 48 self.params[' C'] = 0.749 self.params['b kd'] = 0.00148 self.params['c'] = 0.7 49 self.params['background'] = 0.0 50 50 51 51 52 52 ## Parameter details [units, min, max] 53 53 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] 59 59 self.details['alpha'] = ['', None, None] 60 self.details[' C'] = ['mol/L', None, None]61 self.details['b kd'] = ['', None, None]60 self.details['c'] = ['mol/L', None, None] 61 self.details['background'] = ['cm-1', None, None] 62 62 63 63 … … 65 65 """ 66 66 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)\ 68 68 *(q^(2)-(12*h*C/b^(2))) 69 69 … … 71 71 The inverse Debye Length: K2 = 4*pi*Lb*(2*Cs+alpha*C) 72 72 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 74 74 """ 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 77 76 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) 79 79 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']))) 82 82 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'] 88 88 89 89 90 90 def run(self, x = 0.0): 91 91 """ Evaluate the model 92 @param x: simple value92 @param x: input q-value (float or [float, float] as [r, theta]) 93 93 @return: (debye value) 94 94 """ … … 102 102 def runXY(self, x = 0.0): 103 103 """ Evaluate the model 104 @param x: simple value104 @param x: input q-value (float or [float, float] as [qx, qy]) 105 105 @return: debye value 106 106 """ … … 110 110 raise ValueError, "Tuples are not allowed as input to BaseComponent models" 111 111 else: 112 return self._BEPoly e(x)112 return self._BEPoly(x) -
sansmodels/src/sans/models/BaseComponent.py
rae3ce4e r3db3895 47 47 ## Parameters to be accessed by client 48 48 self.params = {} 49 self.details = {} 49 50 50 51 def __str__(self): … … 67 68 obj = copy.deepcopy(self) 68 69 obj.params = copy.deepcopy(self.params) 70 obj.details = copy.deepcopy(self.details) 69 71 70 72 # Check for standard data members of arithmetics sub-classes -
sansmodels/src/sans/models/DABModel.py
r829eee9 r3db3895 1 1 #!/usr/bin/env python 2 2 """ 3 Provide F(x) = scale/( 1 + (x*L)^2 )^(2) 3 Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 4 4 DAB (Debye Anderson Brumberger) function as a BaseComponent model 5 5 """ … … 13 13 Class that evaluates a DAB model. 14 14 15 F(x) = scale/( 1 + (x*L)^2 )^(2) + bkd15 F(x) = scale/( 1 + (x*L)^2 )^(2) + background 16 16 17 17 The model has three parameters: 18 L = Correlation Length19 scale = scale factor20 b kd = incoherent background18 L = Correlation Length 19 scale = scale factor 20 background = incoherent background 21 21 """ 22 22 … … 28 28 29 29 ## Name of the model 30 self.name = " DAB_Model"30 self.name = "DAB_Model" 31 31 32 32 ## Define parameters 33 33 self.params = {} 34 self.params[' L'] = 40.035 self.params['scale'] = 10.036 self.params['b kd']= 0.034 self.params['length'] = 50.0 35 self.params['scale'] = 1.0 36 self.params['background'] = 0.0 37 37 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} 40 self.details[' L'] = ['A', None, None]41 self.details['scale'] = ['', None, None]42 self.details['b kd'] = ['cm^{-1}', None, None]40 self.details['length'] = ['', None, None] 41 self.details['scale'] = ['', None, None] 42 self.details['background'] = ['', None, None] 43 43 44 44 def _DAB(self, x): 45 45 """ 46 Evaluate F(x) = scale/( 1 + (x*L)^2 )^(2) + b kd46 Evaluate F(x) = scale/( 1 + (x*L)^2 )^(2) + background 47 47 48 48 """ 49 return self.params['scale']/math.pow(( 1 + math.pow(x * self.params[' L'],2)),2) \50 + self.params['b kd']49 return self.params['scale']/math.pow(( 1 + math.pow(x * self.params['length'],2)),2) \ 50 + self.params['background'] 51 51 52 52 53 53 def run(self, x = 0.0): 54 54 """ Evaluate the model 55 @param x: simple value55 @param x: input q-value (float or [float, float] as [r, theta]) 56 56 @return: (DAB value) 57 57 """ … … 65 65 def runXY(self, x = 0.0): 66 66 """ Evaluate the model 67 @param x: simple value67 @param x: input q-value (float or [float, float] as [qx, qy]) 68 68 @return: DAB value 69 69 """ -
sansmodels/src/sans/models/DebyeModel.py
r829eee9 r3db3895 1 1 #!/usr/bin/env python 2 2 """ 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 4 6 Debye function as a BaseComponent model 5 7 """ … … 13 15 Class that evaluates a Debye model. 14 16 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 16 19 17 20 The model has three parameters: … … 32 35 ## Define parameters 33 36 self.params = {} 34 self.params[' Rg']= 50.035 self.params['scale'] = 1.036 self.params['b kd'] = 0.00137 self.params['rg'] = 50.0 38 self.params['scale'] = 1.0 39 self.params['background'] = 0.0 37 40 38 41 ## Parameter details [units, min, max] 39 42 self.details = {} 40 self.details[' Rg'] = ['A', None, None]41 self.details['scale'] = ['', None, None]42 self.details['b kd'] = ['cm^{-1}', None, None]43 self.details['rg'] = ['', None, None] 44 self.details['scale'] = ['', None, None] 45 self.details['background'] = ['', None, None] 43 46 44 47 def _debye(self, x): … … 46 49 Evaluate F(x)= scale * D + bkd 47 50 has 2 internal parameters : 48 D = 2 * (exp(-y) + x -1)/y**251 D = 2 * (exp(-y) + y - 1)/y**2 49 52 y = (x * Rg)^(2) 50 53 """ 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'] 58 59 59 60 def run(self, x = 0.0): 60 61 """ Evaluate the model 61 @param x: simple value62 @param x: input q-value (float or [float, float] as [r, theta]) 62 63 @return: (debye value) 63 64 """ … … 71 72 def runXY(self, x = 0.0): 72 73 """ Evaluate the model 73 @param x: simple value74 @param x: input q-value (float or [float, float] as [qx, qy]) 74 75 @return: debye value 75 76 """ -
sansmodels/src/sans/models/DivComponent.py
rae3ce4e r3db3895 38 38 return self.operateOn.run(x) / self.other.run(x) 39 39 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 40 48 def setParam(self, name, value): 41 49 """ -
sansmodels/src/sans/models/FractalModel.py
r829eee9 r3db3895 17 17 F(x)= P(x)*S(x) + bkd 18 18 The model has Seven parameters: 19 scale = Volume fraction20 Radius= Block radius21 Fdim= Fractal dimension22 L= correlation Length23 SDLB= SDL block24 SDLS= SDL solvent25 b kd= background19 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 26 26 27 27 """ … … 38 38 ## Define parameters 39 39 self.params = {} 40 self.params['scale'] = 0.0541 self.params[' Radius']= 542 self.params[' Fdim'] = 243 self.params[' L'] = 10044 self.params[' SDLB'] = 2*math.exp(-6)45 self.params[' SDLS'] = 6.35*math.exp(-6)46 self.params['b kd']= 0.040 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 47 47 48 48 49 49 ## Parameter details [units, min, max] 50 50 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['b kd'] = ['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] 58 58 59 59 … … 61 61 """ 62 62 Evaluate 63 F(x) = p(x) * s(x)+bkd63 F(x) = p(x) * s(x) + bkd 64 64 """ 65 return self.params['b kd']+ self._scatterRanDom(x)* self._Block(x)65 return self.params['background']+ self._scatterRanDom(x)* self._Block(x) 66 66 67 67 def _Block(self,x): 68 68 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)) 73 73 74 74 def _Spherical(self,x): … … 76 76 F(x) = [sin(x)-xcos(x)]/3*(x**3) 77 77 """ 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 82 80 def _scatterRanDom(self,x): 83 81 """ 84 82 calculate p(x)= scale* V^(2)*delta^(2)* F(x*Radius)^(2) 85 83 """ 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'] 88 86 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) 91 89 92 90 def run(self, x = 0.0): 93 91 """ Evaluate the model 94 @param x: simple value92 @param x: input q-value (float or [float, float] as [r, theta]) 95 93 @return: (Fractal value) 96 94 """ … … 104 102 def runXY(self, x = 0.0): 105 103 """ Evaluate the model 106 @param x: simple value104 @param x: input q-value (float or [float, float] as [qx, qy]) 107 105 @return: Fractal value 108 106 """ -
sansmodels/src/sans/models/GuinierModel.py
r829eee9 r3db3895 1 1 #!/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 3 5 """ 4 6 … … 7 9 8 10 class GuinierModel(BaseComponent): 9 """ Class that evaluates a Guinier model. 11 """ 12 Class that evaluates a Guinier model. 10 13 11 I nfo about the model14 I(q) = I_0 exp ( - R_g^2 q^2 / 3.0 ) 12 15 13 16 List of default parameters: 14 value = 1.0 17 I_0 = Scale 18 R_g = Radius of gyration 19 15 20 """ 16 21 … … 26 31 ## Define parameters 27 32 self.params = {} 28 self.params[' A'] = 0.029 self.params[' B'] = 0.033 self.params['scale'] = 1.0 34 self.params['rg'] = 0.1 30 35 31 36 ## Parameter details [units, min, max] 32 37 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] 35 40 36 41 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 ) 38 43 39 44 def run(self, x = 0.0): 40 45 """ Evaluate the model 41 @param x: simple value46 @param x: input q-value (float or [float, float] as [r, theta]) 42 47 @return: (guinier value) 43 48 """ … … 51 56 def runXY(self, x = 0.0): 52 57 """ Evaluate the model 53 @param x: simple value58 @param x: input q-value (float or [float, float] as [qx, qy]) 54 59 @return: guinier value 55 60 """ -
sansmodels/src/sans/models/LorentzModel.py
r829eee9 r3db3895 2 2 """ 3 3 Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd 4 Lorentz function as a BaseComponent model4 Lorentz (Ornstein-Zernicke) function as a BaseComponent model 5 5 """ 6 6 … … 11 11 12 12 """ 13 Class that evaluates a Lorentz model.13 Class that evaluates a Lorentz (Ornstein-Zernicke) model. 14 14 15 15 F(x) = scale/( 1 + (x*L)^2 ) + bkd … … 32 32 ## Define parameters 33 33 self.params = {} 34 self.params[' L']= 50.035 self.params['scale'] = 100.036 self.params['b kd'] = 134 self.params['length'] = 50.0 35 self.params['scale'] = 1.0 36 self.params['background'] = 0.0 37 37 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} 40 self.details[' L']= ['A', None, None]41 self.details['scale'] = ['', None, None]42 self.details['b kd'] = ['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] 43 43 44 44 def _lorentz(self, x): … … 47 47 48 48 """ 49 return self.params['scale']/( 1 + math.pow((x * self.params[' L']),2))\50 + self.params['b kd']49 return self.params['scale']/( 1 + math.pow((x * self.params['length']),2))\ 50 + self.params['background'] 51 51 52 52 53 53 def run(self, x = 0.0): 54 54 """ Evaluate the model 55 @param x: simple value55 @param x: input q-value (float or [float, float] as [r, theta]) 56 56 @return: (Lorentz value) 57 57 """ … … 65 65 def runXY(self, x = 0.0): 66 66 """ Evaluate the model 67 @param x: simple value67 @param x: input q-value (float or [float, float] as [qx, qy]) 68 68 @return: Lorentz value 69 69 """ -
sansmodels/src/sans/models/MulComponent.py
rae3ce4e r3db3895 38 38 return self.operateOn.run(x) * self.other.run(x) 39 39 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 40 48 def setParam(self, name, value): 41 49 """ -
sansmodels/src/sans/models/PorodModel.py
r829eee9 r3db3895 1 1 #!/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 3 5 """ 4 6 … … 9 11 """ Class that evaluates a Porod model. 10 12 11 F(x) = exp[ [C]/Q**4 ]13 I(q) = scale/q^4 12 14 13 The model has one parameter: C14 15 """ 15 16 … … 21 22 22 23 ## Name of the model 23 self.name = "Porod 24 self.name = "PorodModel" 24 25 25 26 ## Define parameters 26 27 self.params = {} 27 self.params[' C'] = 0.028 self.params['scale'] = 0.0 28 29 29 30 30 31 ## Parameter details [units, min, max] 31 32 self.details = {} 32 self.details[' C'] = ['', None, None]33 self.details['scale'] = ['', None, None] 33 34 34 35 35 36 def _porod(self, x): 36 return math.exp(self.params['C']/ math.pow(x, 4))37 return self.params['scale']/x**4.0 37 38 38 39 def run(self, x = 0.0): 39 40 """ Evaluate the model 40 @param x: simple value41 @param x: input q-value (float or [float, float] as [r, theta]) 41 42 @return: (porod value) 42 43 """ … … 50 51 def runXY(self, x = 0.0): 51 52 """ Evaluate the model 52 @param x: simple value53 @param x: input q-value (float or [float, float] as [qx, qy]) 53 54 @return: porod value 54 55 """ -
sansmodels/src/sans/models/PowerLawModel.py
r829eee9 r3db3895 1 1 #!/usr/bin/env python 2 2 """ 3 Provide F(x) = scale /( 1 + (x*L)^2) + bkd4 Lorentzfunction as a BaseComponent model3 Provide F(x) = scale* (x)^(-m) + bkd 4 Power law function as a BaseComponent model 5 5 """ 6 6 … … 13 13 Class that evaluates a Power_Law model. 14 14 15 F(x) = scale* (x)^( m) + bkd15 F(x) = scale* (x)^(-m) + bkd 16 16 17 17 The model has three parameters: … … 32 32 ## Define parameters 33 33 self.params = {} 34 self.params['m'] = 50.035 self.params['scale'] = 100.036 self.params['b kd'] = 134 self.params['m'] = 4.0 35 self.params['scale'] = 1.0 36 self.params['background'] = 0.0 37 37 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} 40 self.details['m'] = ['', None, None ]41 self.details['scale'] = ['', None, None]42 self.details['b kd'] = ['cm^{-1}', None, None]40 self.details['m'] = ['', None, None ] 41 self.details['scale'] = ['', None, None] 42 self.details['background'] = ['', None, None] 43 43 44 44 def _PowerLaw(self, x): 45 45 """ 46 Evaluate F(x) = scale* (x)^( m) + bkd46 Evaluate F(x) = scale* (x)^(-m) + bkd 47 47 48 48 """ 49 return self.params['scale']*math.pow(x , self.params['m'])\50 + self.params['b kd']49 return self.params['scale']*math.pow(x ,-self.params['m'])\ 50 + self.params['background'] 51 51 52 52 53 53 def run(self, x = 0.0): 54 54 """ Evaluate the model 55 @param x: simple value55 @param x: input q-value (float or [float, float] as [r, theta]) 56 56 @return: (PowerLaw value) 57 57 """ … … 65 65 def runXY(self, x = 0.0): 66 66 """ Evaluate the model 67 @param x: simple value67 @param x: input q-value (float or [float, float] as [qx, qy]) 68 68 @return: PowerLaw value 69 69 """ -
sansmodels/src/sans/models/SubComponent.py
rae3ce4e r3db3895 38 38 return self.operateOn.run(x) - self.other.run(x) 39 39 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 40 48 def setParam(self, name, value): 41 49 """ -
sansmodels/src/sans/models/TeubnerStreyModel.py
r829eee9 r3db3895 37 37 self.params['c2'] = 5000.0 38 38 self.params['scale'] = 0.1 39 self.params['b kd'] = 0.139 self.params['background'] = 0.0 40 40 41 41 ## Parameter details [units, min, max] … … 44 44 self.details['c2'] = ['', None, None ] 45 45 self.details['scale'] = ['', None, None] 46 self.details['b kd'] = ['cm^{-1}', None, None]46 self.details['background'] = ['', None, None] 47 47 48 48 … … 58 58 def run(self, x = 0.0): 59 59 """ Evaluate the model 60 @param x: simple value60 @param x: input q-value (float or [float, float] as [r, theta]) 61 61 @return: (PowerLaw value) 62 62 """ … … 71 71 def runXY(self, x = 0.0): 72 72 """ Evaluate the model 73 @param x: simple value73 @param x: input q-value (float or [float, float] as [qx, qy]) 74 74 @return: PowerLaw value 75 75 """ … … 81 81 return self._TeubnerStrey(x) 82 82 83 def TeubnerStreyLengths(self):83 def teubnerStreyLengths(self): 84 84 """ 85 85 Calculate the correlation length (L) 86 86 @return L: the correlation distance 87 87 """ 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 )\ 91 89 +(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): 96 91 """ 97 92 Calculate the quasi-periodic repeat distance (D/(2*pi)) 98 93 @return D: quasi-periodic repeat distance 99 94 """ 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 )\ 103 96 -(self.params['c1']/(4*self.params['c2'])),-1/2 ) 104 return D105 else:106 return False -
sansmodels/src/sans/models/prototypes/UnifiedPowerLaw.py
r829eee9 r3db3895 1 1 #!/usr/bin/env python 2 2 """ 3 Provide F(x) = scale/( 1 + (x*L)^2 ) + bkd 4 Lorentz function as a BaseComponent model 3 Failed attempt at a Beaucage model. 5 4 """ 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 6 8 7 9 from sans.models.BaseComponent import BaseComponent
Note: See TracChangeset
for help on using the changeset viewer.