Changeset 6e7ba14 in sasmodels for sasmodels/kerneldll.py
- Timestamp:
- Aug 20, 2018 6:52:21 AM (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:
- aa44a6a
- Parents:
- bad3093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kerneldll.py
r2f8cbb9 r6e7ba14 315 315 316 316 # int, int, int, int*, double*, double*, double*, double*, double 317 argtypes = [ct.c_int32]*3 + [ct.c_void_p]*4 + [float_type ]317 argtypes = [ct.c_int32]*3 + [ct.c_void_p]*4 + [float_type, ct.c_int32] 318 318 names = [generate.kernel_name(self.info, variant) 319 319 for variant in ("Iq", "Iqxy", "Imagnetic")] … … 382 382 self.dim = '2d' if q_input.is_2d else '1d' 383 383 # leave room for f1/f2 results in case we need to compute beta for 1d models 384 n um_returns = 1 if self.dim == '2d' else 2 #385 # plus 1 for the normalization value386 self.result = np.empty( (q_input.nq+1)*num_returns, self.dtype)384 nout = 2 if self.info.have_Fq else 1 385 # plus 3 weight, volume, radius 386 self.result = np.empty(q_input.nq*nout + 3, self.dtype) 387 387 self.real = (np.float32 if self.q_input.dtype == generate.F32 388 388 else np.float64 if self.q_input.dtype == generate.F64 389 389 else np.float128) 390 390 391 def Iq(self, call_details, values, cutoff, magnetic): 392 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 393 self._call_kernel(call_details, values, cutoff, magnetic) 394 #print("returned",self.q_input.q, self.result) 395 pd_norm = self.result[self.q_input.nq] 396 scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 397 background = values[1] 398 #print("scale",scale,background) 399 return scale*self.result[:self.q_input.nq] + background 400 __call__ = Iq 401 402 def beta(self, call_details, values, cutoff, magnetic): 403 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 404 if self.dim == '2d': 405 raise NotImplementedError("beta not yet supported for 2D") 406 self._call_kernel(call_details, values, cutoff, magnetic) 407 w_norm = self.result[2*self.q_input.nq + 1] 408 pd_norm = self.result[self.q_input.nq] 409 if w_norm == 0.: 410 w_norm = 1. 411 F2 = self.result[:self.q_input.nq]/w_norm 412 F1 = self.result[self.q_input.nq+1:2*self.q_input.nq+1]/w_norm 413 volume_avg = pd_norm/w_norm 414 return F1, F2, volume_avg 415 416 def _call_kernel(self, call_details, values, cutoff, magnetic): 391 def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): 392 # type: (CallDetails, np.ndarray, np.ndarray, float, bool, int) -> np.ndarray 417 393 kernel = self.kernel[1 if magnetic else 0] 418 394 args = [ … … 425 401 self.result.ctypes.data, # results 426 402 self.real(cutoff), # cutoff 403 effective_radius_type, # cutoff 427 404 ] 428 405 #print("Calling DLL")
Note: See TracChangeset
for help on using the changeset viewer.