Changeset 39a06c9 in sasmodels for sasmodels/product.py
- Timestamp:
- Oct 25, 2018 5:58:26 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 81751c2
- Parents:
- 304c775
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/product.py
re44432d r39a06c9 61 61 return pars 62 62 63 # TODO: core_shell_sphere model has suppressed the volume ratio calculation64 # revert it after making VR and ER available at run time as constraints.65 63 def make_product_info(p_info, s_info): 66 64 # type: (ModelInfo, ModelInfo) -> ModelInfo … … 126 124 #model_info.tests = [] 127 125 #model_info.source = [] 128 # Iq, Iqxy, form_volume, ER, VR and sesans129 126 # Remember the component info blocks so we can build the model 130 127 model_info.composition = ('product', [p_info, s_info]) … … 331 328 #print("R_eff=%d:%g, volfrac=%g, volume ratio=%g"%(radius_type, effective_radius, volfrac, volume_ratio)) 332 329 if radius_type > 0: 333 # set the value to the model ERand set the weight to 1330 # set the value to the model R_eff and set the weight to 1 334 331 s_values[2] = s_values[2+s_npars+s_offset[0]] = effective_radius 335 332 s_values[2+s_npars+s_offset[0]+nweights] = 1.0 … … 366 363 self.p_kernel.release() 367 364 self.s_kernel.release() 368 369 370 def calc_er_vr(model_info, call_details, values):371 # type: (ModelInfo, ParameterSet) -> Tuple[float, float]372 373 if model_info.ER is None and model_info.VR is None:374 return 1.0, 1.0375 376 nvalues = model_info.parameters.nvalues377 value = values[nvalues:nvalues + call_details.num_weights]378 weight = values[nvalues + call_details.num_weights: nvalues + 2*call_details.num_weights]379 npars = model_info.parameters.npars380 # Note: changed from pairs ([v], [w]) to triples (p, [v], [w]), but the381 # dispersion mesh code doesn't actually care about the nominal parameter382 # value, p, so set it to None.383 pairs = [(None, value[offset:offset+length], weight[offset:offset+length])384 for p, offset, length385 in zip(model_info.parameters.call_parameters[2:2+npars],386 call_details.offset,387 call_details.length)388 if p.type == 'volume']389 value, weight = dispersion_mesh(model_info, pairs)390 391 if model_info.ER is not None:392 individual_radii = model_info.ER(*value)393 radius_effective = np.sum(weight*individual_radii) / np.sum(weight)394 else:395 radius_effective = 1.0396 397 if model_info.VR is not None:398 whole, part = model_info.VR(*value)399 volume_ratio = np.sum(weight*part)/np.sum(weight*whole)400 else:401 volume_ratio = 1.0402 403 return radius_effective, volume_ratio
Note: See TracChangeset
for help on using the changeset viewer.