Changeset 6e7ba14 in sasmodels for sasmodels/kernelcl.py


Ignore:
Timestamp:
Aug 20, 2018 8:52:21 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

allow for different forms of effective_radius

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelcl.py

    rc036ddb r6e7ba14  
    540540        # leave room for f1/f2 results in case we need to compute beta for 1d models 
    541541        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) 
    544544 
    545545        # Inputs and outputs for each kernel call 
     
    558558                     else np.float32)  # will never get here, so use np.float32 
    559559 
    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): 
    586561        # type: (CallDetails, np.ndarray, np.ndarray, float, bool) -> np.ndarray 
    587562        context = self.queue.context 
     
    597572            details_b, values_b, self.q_input.q_b, self.result_b, 
    598573            self.real(cutoff), 
     574            np.uint32(effective_radius_type), 
    599575        ] 
    600576        #print("Calling OpenCL") 
Note: See TracChangeset for help on using the changeset viewer.