Changeset 6e7ba14 in sasmodels for sasmodels/kernelcl.py
- Timestamp:
- Aug 20, 2018 8: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/kernelcl.py
rc036ddb r6e7ba14 540 540 # leave room for f1/f2 results in case we need to compute beta for 1d models 541 541 num_returns = 1 if self.dim == '2d' else 2 # 542 # plus 1 for the normalization value 543 self.result = np.empty((q_input.nq+ 1)*num_returns, dtype)542 # plus 1 for the normalization value, plus another for R_eff 543 self.result = np.empty((q_input.nq+2)*num_returns, dtype) 544 544 545 545 # Inputs and outputs for each kernel call … … 558 558 else np.float32) # will never get here, so use np.float32 559 559 560 def Iq(self, call_details, values, cutoff, magnetic): 561 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 562 self._call_kernel(call_details, values, cutoff, magnetic) 563 #print("returned",self.q_input.q, self.result) 564 pd_norm = self.result[self.q_input.nq] 565 scale = values[0]/(pd_norm if pd_norm != 0.0 else 1.0) 566 background = values[1] 567 #print("scale",scale,background) 568 return scale*self.result[:self.q_input.nq] + background 569 __call__ = Iq 570 571 def beta(self, call_details, values, cutoff, magnetic): 572 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 573 if self.dim == '2d': 574 raise NotImplementedError("beta not yet supported for 2D") 575 self._call_kernel(call_details, values, cutoff, magnetic) 576 w_norm = self.result[2*self.q_input.nq + 1] 577 pd_norm = self.result[self.q_input.nq] 578 if w_norm == 0.: 579 w_norm = 1. 580 F2 = self.result[:self.q_input.nq]/w_norm 581 F1 = self.result[self.q_input.nq+1:2*self.q_input.nq+1]/w_norm 582 volume_avg = pd_norm/w_norm 583 return F1, F2, volume_avg 584 585 def _call_kernel(self, call_details, values, cutoff, magnetic): 560 def _call_kernel(self, call_details, values, cutoff, magnetic, effective_radius_type): 586 561 # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 587 562 context = self.queue.context … … 597 572 details_b, values_b, self.q_input.q_b, self.result_b, 598 573 self.real(cutoff), 574 np.uint32(effective_radius_type), 599 575 ] 600 576 #print("Calling OpenCL")
Note: See TracChangeset
for help on using the changeset viewer.