Changeset 7292e8a in sasview
- Timestamp:
- Feb 27, 2009 6:37:04 PM (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:
- 8dddbd4
- Parents:
- 09d8c94
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/FractalModel.py
r96672c0 r7292e8a 75 75 F(x) = p(x) * s(x) + bkd 76 76 """ 77 if x<0 and self.params['fractal_dim']>0: 78 raise ValueError, "negative number cannot be raised to a fractional power" 79 77 #if x<0 and self.params['fractal_dim']>0: 78 # raise ValueError, "negative number cannot be raised to a fractional power" 79 #if x==0 and self.params['fractal_dim']==0: 80 # return 1+self.params['background'] 81 #elif x<0 and self.params['fractal_dim']==0: 82 # return 1e+32 83 #else: 80 84 return self.params['background']+ self._scatterRanDom(x)* self._Block(x) 81 85 82 86 83 87 def _Block(self,x): 84 return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 85 * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 86 /( math.pow( (x*self.params['radius']), self.params['fractal_dim'])*\ 87 math.pow( 1.0 + 1.0/((x**2)*(self.params['corr_length']**2)),(self.params['fractal_dim']-1.0)/2.0)) 88 88 #if self.params['fractal_dim']<0: 89 # self.params['fractal_dim']=-self.params['fractal_dim'] 90 try: 91 if x<0: 92 x=-x 93 if self.params['radius']<0: 94 self.params['radius']=-self.params['radius'] 95 96 if x==0 or self.params['radius']==0 : 97 return 1e+32 98 elif self.params['fractal_dim']==0: 99 return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 100 * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 101 *( math.pow( 1.0 + 1.0/((x**2)*(self.params['corr_length']**2)),1/2.0)) 102 elif self.params['corr_length']==0 or self.params['fractal_dim']==1: 103 return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 104 * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 105 /( math.pow( (x*self.params['radius']), self.params['fractal_dim'])) 106 107 elif self.params['fractal_dim']<1: 108 return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 109 * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 110 /( math.pow( (x*self.params['radius']), self.params['fractal_dim']))*\ 111 math.pow( 1.0 + 1.0/((x**2)*(self.params['corr_length']**2)),(1-self.params['fractal_dim'])/2.0) 112 else: 113 return 1.0 + (math.sin((self.params['fractal_dim']-1.0) * math.atan(x * self.params['corr_length']))\ 114 * self.params['fractal_dim'] * gamma(self.params['fractal_dim']-1.0))\ 115 / math.pow( (x*self.params['radius']), self.params['fractal_dim'])\ 116 /math.pow( 1.0 + 1.0/((x**2)*(self.params['corr_length']**2)),(self.params['fractal_dim']-1.0)/2.0) 117 except: 118 return 1 # Need a real fix. 89 119 def _Spherical(self,x): 90 120 """ 91 121 F(x) = 3*[sin(x)-xcos(x)]/x**3 92 122 """ 93 return 3.0*(math.sin(x)-x*math.cos(x))/(math.pow(x,3.0)) 123 if x==0: 124 return 0 125 else: 126 return 3.0*(math.sin(x)-x*math.cos(x))/(math.pow(x,3.0)) 94 127 95 128 def _scatterRanDom(self,x):
Note: See TracChangeset
for help on using the changeset viewer.