Changeset 1726b21 in sasmodels for Models/code_cylinder.py


Ignore:
Timestamp:
Aug 8, 2014 11:45:51 AM (10 years ago)
Author:
HMP1 <helen.park@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
ae7d639
Parents:
8cdb9f1
Message:

cylinder now MUCH faster!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Models/code_cylinder.py

    ra42fec0 r1726b21  
    66 
    77from weights import GaussianDispersion 
    8 from sasmodel import card, set_precision, set_precision_1d 
     8from sasmodel import card, set_precision, set_precision_1d, tic, toc 
    99 
    1010 
     
    3333    def eval(self, pars): 
    3434 
     35        tic() 
    3536        _ctx,queue = card() 
    3637        self.res[:] = 0 
     
    5556        for i in xrange(len(radius.weight)): 
    5657            for j in xrange(len(length.weight)): 
     58 
     59                vol += radius.weight[i]*length.weight[j]*pow(radius.value[i], 2)*length.value[j] 
     60                norm_vol += radius.weight[i]*length.weight[j] 
     61 
    5762                for k in xrange(len(cyl_theta.weight)): 
    5863                    for l in xrange(len(cyl_phi.weight)): 
     
    6368                                           np.uint32(self.qx.size), np.uint32(size)) 
    6469 
    65                         vol += radius.weight[i]*length.weight[j]*pow(radius.value[i], 2)*length.value[j] 
    66                         norm_vol += radius.weight[i]*length.weight[j] 
    6770                        norm += radius.weight[i]*length.weight[j]*cyl_theta.weight[k]*cyl_phi.weight[l] 
     71 
    6872 
    6973       # if size > 1: 
     
    7478            sum *= norm_vol/vol 
    7579 
     80        print toc()*1000, self.qx.shape[0] 
    7681        return sum/norm+pars['background'] 
    7782 
Note: See TracChangeset for help on using the changeset viewer.