Changeset e0c16ce in sasview
- Timestamp:
- Jul 26, 2015 4:44:06 PM (9 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:
- 1f5f206
- Parents:
- c95a1a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/models/CoreMultiShellModel.py
rac7be54 re0c16ce 53 53 ## parameters with orientation: can be removed since there is no orientational params 54 54 self._set_orientation_params() 55 56 55 57 56 def _clone(self, obj): 58 57 """ … … 67 66 68 67 return obj 69 70 68 71 69 def _set_dispersion(self): 72 70 """ 73 71 model dispersions 74 72 Polydispersion should not be applied to s_model 75 """ 76 ##set dispersion from model 73 """ 74 ##set dispersion from model 77 75 for name , value in self.model.dispersion.iteritems(): 78 76 nshell = 0 … … 82 80 if name.split('_')[-1] == 'shell%s' % str(nshell): 83 81 self.dispersion[name] = value 84 else: 82 else: 85 83 continue 86 84 else: 87 85 self.dispersion[name] = value 88 86 89 87 def _set_orientation_params(self): 90 88 """ 91 89 model orientation and magnetic parameters, same params for this model 92 """ 90 """ 93 91 ##set dispersion from model 94 92 for param in self.model.orientation_params: … … 104 102 self.orientation_params.append(param) 105 103 self.magnetic_params.append(param) 106 continue 104 continue 107 105 108 106 def _set_params(self): 109 107 """ 110 108 Concatenate the parameters of the model to create 111 this model parameters 109 this model parameters 112 110 """ 113 111 # rearrange the parameters for the given # of shells … … 128 126 else: 129 127 self.params[name]= value 130 128 131 129 # set constrained values for the original model params 132 self._set_xtra_model_param() 133 130 self._set_xtra_model_param() 131 134 132 def _set_details(self): 135 133 """ 136 134 Concatenate details of the original model to create 137 this model details 135 this model details 138 136 """ 139 137 for name ,detail in self.model.details.iteritems(): 140 138 if name in self.params.iterkeys(): 141 139 self.details[name]= detail 142 143 140 141 144 142 def _set_xtra_model_param(self): 145 143 """ … … 163 161 self.model.setParam(key, 0.0) 164 162 except: pass 165 163 166 164 167 165 def getProfile(self): 168 166 """ 169 Get SLD profile 170 171 : return: (r, beta) where r is a list of radius of the transition points 172 beta is a list of the corresponding SLD values173 : Note: This works only for func_shell num = 2.167 Get SLD profile 168 **Note:** This works only for func_shell num = 2. 169 170 :return: (r, beta) where r is a list of radius of the transition points\ 171 and beta is a list of the corresponding SLD values. 174 172 """ 175 173 r = [] … … 181 179 r.append(self.params['rad_core0']) 182 180 beta.append(self.params['sld_core0']) 183 181 184 182 # for shells 185 183 for n in range(1, self.n_shells+1): 186 184 # Left side of each shells 187 r0 = r[len(r)-1] 185 r0 = r[len(r)-1] 188 186 r.append(r0) 189 187 exec "beta.append(self.params['sld_shell%s'% str(n)])" … … 193 191 r.append(r0) 194 192 exec "beta.append(self.params['sld_shell%s'% str(n)])" 195 193 196 194 # for solvent 197 195 r0 = r[len(r)-1] … … 201 199 r.append(r_solv) 202 200 beta.append(self.params['sld_solv']) 203 201 204 202 return r, beta 205 203 206 204 def setParam(self, name, value): 207 """ 205 """ 208 206 Set the value of a model parameter 209 210 : 211 : 207 208 :param name: name of the parameter 209 :param value: value of the parameter 212 210 """ 213 211 # set param to new model 214 212 self._setParamHelper( name, value) 215 ## setParam to model 213 ## setParam to model 216 214 if name == 'sld_solv': 217 215 # the sld_*** model.params not in params must set to value of sld_solv … … 243 241 self.params[item] = value 244 242 return 245 246 243 #raise ValueError, "Model does not contain parameter %s" % name 247 248 244 245 249 246 def _set_fixed_params(self): 250 247 """ … … 252 249 """ 253 250 for item in self.model.fixed: 254 if item.split('.')[0] in self.params.keys(): 251 if item.split('.')[0] in self.params.keys(): 255 252 self.fixed.append(item) 256 253 257 254 self.fixed.sort() 258 255 259 256 def run(self, x = 0.0): 260 """ 257 """ 261 258 Evaluate the model 262 263 : 264 : 259 260 :param x: input q-value (float or [float, float] as [r, theta]) 261 :return: (DAB value) 265 262 """ 266 263 # set effective radius and scaling factor before run … … 269 266 270 267 def runXY(self, x = 0.0): 271 """ 268 """ 272 269 Evaluate the model 273 274 : 275 : 270 271 :param x: input q-value (float or [float, float] as [qx, qy]) 272 :return: DAB value 276 273 """ 277 274 # set effective radius and scaling factor before run 278 275 279 276 return self.model.runXY(x) 280 277 281 278 ## Now (May27,10) directly uses the model eval function 282 279 ## instead of the for-loop in Base Component. 283 280 def evalDistribution(self, x = []): 284 """ 281 """ 285 282 Evaluate the model in cartesian coordinates 286 287 : 288 : 283 284 :param x: input q[], or [qx[], qy[]] 285 :return: scattering function P(q[]) 289 286 """ 290 287 # set effective radius and scaling factor before run 291 288 return self.model.evalDistribution(x) 292 289 293 290 def calculate_ER(self): 294 """ 291 """ 295 292 Calculate the effective radius for P(q)*S(q) 296 293 297 294 :return: the value of the effective radius 298 299 """ 295 """ 300 296 return self.model.calculate_ER() 301 297 302 298 def calculate_VR(self): 303 """ 299 """ 304 300 Calculate the volf ratio for P(q)*S(q) 305 301 306 302 :return: the value of the volf ratio 307 308 """ 303 """ 309 304 return self.model.calculate_VR() 310 305 311 306 def set_dispersion(self, parameter, dispersion): 312 307 """ 313 308 Set the dispersion object for a model parameter 314 315 : 316 : dispersion: dispersion object of type DispersionModel309 310 :param parameter: name of the parameter [string] 311 :param dispersion: dispersion object of type DispersionModel 317 312 """ 318 313 value = None … … 323 318 return value 324 319 except: 325 raise 320 raise
Note: See TracChangeset
for help on using the changeset viewer.