Changeset 7ff3cf3 in sasmodels


Ignore:
Timestamp:
Mar 21, 2016 4:55:33 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
5cf3c33, 3a45c2c
Parents:
e1bdc7e
Message:

getting past hello…

Location:
sasmodels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r303d8d6 r7ff3cf3  
    226226        weights = np.array([1.0]) 
    227227        details = kernel.info['mono_details'] 
    228         return kernel(pars, weights, details, cutoff) 
     228        return kernel(details, pars, weights, cutoff) 
    229229    else: 
    230230        pairs = [get_weights(p, values) for p in kernel.info['parameters']] 
     
    232232        details = generate.poly_details(kernel.info, weights, pars) 
    233233        weights, pars = [np.hstack(v) for v in (weights, pars)] 
    234         return kernel(pars, weights, details, cutoff) 
     234        return kernel(details, pars, weights, cutoff) 
    235235 
    236236def call_ER_VR(model_info, vol_pars): 
  • sasmodels/generate.py

    r4a72d1a r7ff3cf3  
    650650    model_info['has_2d'] = par_type['orientation'] or par_type['magnetic'] 
    651651 
    652 def mono_details(max_pd, npars): 
     652def mono_details(model_info): 
     653    max_pd = model_info['max_pd'] 
     654    npars = len(model_info['parameters']) - 2 
    653655    p = 5*max_pd 
    654656    c = p + 3*npars 
    655657 
    656     mono = np.zeros(c + 3, 'i') 
    657     mono[0*max_pd:1*max_pd] = range(max_pd)       # pd_par: arbitrary order; use first 
    658     mono[1*max_pd:2*max_pd] = [1]*max_pd          # pd_length: only one element 
    659     mono[2*max_pd:3*max_pd] = range(2, max_pd+2)  # pd_offset: skip scale and background 
    660     mono[3*max_pd:4*max_pd] = [1]*max_pd          # pd_stride: vectors of length 1 
    661     mono[4*max_pd:5*max_pd] = [0]*max_pd          # pd_isvol: doens't matter if no norm 
    662     mono[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset 
    663     mono[p+1*npars:p+2*npars] = [0]*npars         # no coordination 
    664     #mono[p+npars] = 1 # par_coord[0] is coordinated with the first par? 
    665     mono[p+2*npars:p+3*npars] = 0 # fast coord with 0 
    666     mono[c]   = 1     # fast_coord_count: one fast index 
    667     mono[c+1] = -1  # theta_var: None 
    668     mono[c+2] = 0   # fast_theta: False 
    669     return mono 
    670  
    671 def poly_details(model_info, weights, pars, constraints=None): 
     658    details = np.zeros(c + 3, 'int32') 
     659    details[0*max_pd:1*max_pd] = range(max_pd)       # pd_par: arbitrary order; use first 
     660    details[1*max_pd:2*max_pd] = [1]*max_pd          # pd_length: only one element 
     661    details[2*max_pd:3*max_pd] = range(2, max_pd+2)  # pd_offset: skip scale and background 
     662    details[3*max_pd:4*max_pd] = [1]*max_pd          # pd_stride: vectors of length 1 
     663    details[4*max_pd:5*max_pd] = [0]*max_pd          # pd_isvol: doens't matter if no norm 
     664    details[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset 
     665    details[p+1*npars:p+2*npars] = [0]*npars         # no coordination 
     666    #details[p+npars] = 1 # par_coord[0] is coordinated with the first par? 
     667    details[p+2*npars:p+3*npars] = 0 # fast coord with 0 
     668    details[c]   = 1     # fast_coord_count: one fast index 
     669    details[c+1] = -1  # theta_var: None 
     670    details[c+2] = 0   # fast_theta: False 
     671    return details 
     672 
     673def poly_details(model_info, weights, constraints=None): 
    672674    if constraints is not None: 
    673675        # Need to find the independently varying pars and sort them 
     
    676678        # and weights, returning par blocks 
    677679        raise ValueError("Can't handle constraints yet") 
     680 
     681    max_pd = model_info['max_pd'] 
     682    npars = len(model_info['parameters']) - 2 
     683    p = 5*max_pd 
     684    c = p + 3*npars 
     685 
     686    # Decreasing list of polydispersity lengths 
     687    # Note: the reversing view, x[::-1], does not require a copy 
     688    idx = np.argsort([len(w) for w in weights])[::-1] 
     689    details = np.zeros(c + 3, 'int32') 
     690    details[0*max_pd:1*max_pd] = idx[:max_pd]        # pd_par: arbitrary order; use first 
     691    details[1*max_pd:2*max_pd] = [1]*max_pd          # pd_length: only one element 
     692    details[2*max_pd:3*max_pd] = range(2, max_pd+2)  # pd_offset: skip scale and background 
     693    details[3*max_pd:4*max_pd] = [1]*max_pd          # pd_stride: vectors of length 1 
     694    details[4*max_pd:5*max_pd] = [0]*max_pd          # pd_isvol: doens't matter if no norm 
     695    details[p+0*npars:p+1*npars] = range(2, npars+2) # par_offset 
     696    details[p+1*npars:p+2*npars] = [0]*npars         # no coordination 
     697    #details[p+npars] = 1 # par_coord[0] is coordinated with the first par? 
     698    details[p+2*npars:p+3*npars] = 0 # fast coord with 0 
     699    details[c]   = 1     # fast_coord_count: one fast index 
     700    details[c+1] = -1  # theta_var: None 
     701    details[c+2] = 0   # fast_theta: False 
     702    return details 
     703 
     704 
    678705 
    679706    raise ValueError("polydispersity not supported") 
     
    768795        oldpars=getattr(kernel_module, 'oldpars', {}), 
    769796        tests=getattr(kernel_module, 'tests', []), 
    770         mono_details = mono_details(MAX_PD, len(kernel_module.parameters)) 
    771797        ) 
    772798    process_parameters(model_info) 
     
    775801    model_info.update((k, getattr(kernel_module, k, None)) for k in functions) 
    776802    create_default_functions(model_info) 
     803    # Precalculate the monodisperse parameters 
     804    # TODO: make this a lazy evaluator 
     805    # make_model_info is called for every model on sasview startup 
     806    model_info['mono_details'] = mono_details(model_info) 
    777807    return model_info 
    778808 
  • sasmodels/kernel_iq.c

    re1bdc7e r7ff3cf3  
    5050    ) 
    5151{ 
    52 printf("aliasing\n"); 
    5352  // Storage for the current parameter values.  These will be updated as we 
    5453  // walk the polydispersity cube. 
     
    5655  double *pvec = (double *)(&local_pars);  // Alias named parameters with a vector 
    5756 
    58 printf("allocating\n"); 
    5957  local int offset[NPARS-2]; 
    6058 
    6159#if 1 // defined(USE_SHORTCUT_OPTIMIZATION) 
    62 printf("dereferencing %p as %d\n", problem, problem->pd_length[0]); 
    6360  if (problem->pd_length[0] == 1) { 
    6461    // Shouldn't need to copy!! 
  • sasmodels/kerneldll.py

    r4a72d1a r7ff3cf3  
    5050import tempfile 
    5151import ctypes as ct 
    52 from ctypes import c_void_p, c_int, c_longdouble, c_double, c_float 
     52from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float 
    5353 
    5454import numpy as np 
     
    205205 
    206206        # int, int, int, int*, double*, double*, double*, double*, double*, double 
    207         argtypes = [c_int]*3 + [c_void_p]*5 + [fp] 
     207        argtypes = [c_int32]*3 + [c_void_p]*5 + [fp] 
    208208        self.Iq = self.dll[generate.kernel_name(self.info, False)] 
    209209        self.Iqxy = self.dll[generate.kernel_name(self.info, True)] 
Note: See TracChangeset for help on using the changeset viewer.