Changeset 31f9d0c2 in sasview for sansmodels
- Timestamp:
- Apr 18, 2012 12:01:15 PM (13 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:
- 7fb69f26
- Parents:
- 7343319
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/FractalCoreShellModel.py
r18695bf r31f9d0c2 1 1 """ 2 Fractal Core-Shell model 3 """ 2 4 from sans.models.BaseComponent import BaseComponent 3 5 from sans.models.CoreShellModel import CoreShellModel 4 6 from scipy.special import gammaln 5 from math import exp, sin, atan 7 import math 6 8 from numpy import power 7 9 from copy import deepcopy … … 26 28 ## Setting model name model description 27 29 model = CoreShellModel() 28 self.description =model30 self.description = model 29 31 30 32 self.model = model 31 33 self.name = "FractalCoreShell" 32 self.description ="""Scattering from a fractal structure34 self.description = """Scattering from a fractal structure 33 35 with a primary building block of a spherical particle 34 36 with particle with a core-shell structure. … … 64 66 self._set_details() 65 67 66 ## parameters with orientation: can be removed since there is no orientational params68 ## parameters with orientation: 67 69 for item in self.model.orientation_params: 68 70 self.orientation_params.append(item) 69 71 70 def _fractalcore(self, x):72 def _fractalcore(self, x): 71 73 """ 72 74 Define model function … … 79 81 r0 = self.params['radius'] 80 82 #calculate S(q) 81 sq = Df* exp(gammaln(Df-1.0))*sin((Df-1.0)*atan(x*corr))82 sq /= power((x*r0), Df) * power((1.0 + 1.0/(x*corr*x*corr)),((Df-1)/2))83 sq = Df*math.exp(gammaln(Df-1.0))*math.sin((Df-1.0)*math.atan(x*corr)) 84 sq /= power((x*r0), Df) * power((1.0 + 1.0/(x*corr*x*corr)), ((Df-1)/2)) 83 85 sq += 1.0 84 86 return sq … … 103 105 ##set dispersion from model 104 106 for name , value in self.model.dispersion.iteritems(): 105 self.dispersion[name] = value107 self.dispersion[name] = value 106 108 107 109 def _set_params(self): … … 126 128 elif name == 'background': 127 129 value = 0.0 128 self.model.params[name] = value130 self.model.params[name] = value 129 131 if name == 'scale': 130 132 name = 'volfraction' … … 138 140 this model details 139 141 """ 140 for name ,detail in self.model.details.iteritems():142 for name, detail in self.model.details.iteritems(): 141 143 if name in self.params.iterkeys(): 142 144 if name == 'scale': 143 145 name = 'volfraction' 144 self.details[name] = detail146 self.details[name] = detail 145 147 self.details['frac_dim'] = ['', None, None] 146 148 self.details['cor_length'] = ['[A]', None, None] … … 201 203 #qx = math.fabs(x[0]*math.cos(x[1])) 202 204 #qy = math.fabs(x[0]*math.sin(x[1])) 203 return self.params['background']+self._fractalcore(x[0])*self.model.run(x) 205 return self.params['background']\ 206 +self._fractalcore(x[0])*self.model.run(x) 204 207 elif x.__class__.__name__ == 'tuple': 205 208 raise ValueError, "Tuples are not allowed as input to BaseComponent models" 206 209 else: 207 return self.params['background'] +self._fractalcore(x)*self.model.run(x)208 210 return self.params['background']\ 211 +self._fractalcore(x)*self.model.run(x) 209 212 210 213 return self.params['background']+self._fractalcore(x)*self.model.run(x) … … 233 236 :dispersion: dispersion object of type DispersionModel 234 237 """ 235 value = None238 value = None 236 239 try: 237 240 if parameter in self.model.dispersion.keys(): 238 value = self.model.set_dispersion(parameter, dispersion)241 value = self.model.set_dispersion(parameter, dispersion) 239 242 self._set_dispersion() 240 243 return value
Note: See TracChangeset
for help on using the changeset viewer.