Changeset 10ddb64 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 3:25:14 AM (9 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:
3a45c2c
Parents:
2e44ac7
Message:

continued refinement of new calculator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    r2e44ac7 r10ddb64  
    171171    ) 
    172172{ 
    173   // the location in the polydispersity calculation 
     173  // Storage for the current parameter values.  These will be updated as we 
     174  // walk the polydispersity cube. 
    174175  local ParameterBlock local_pars; 
    175176  const double *parvec = &local_pars;  // Alias named parameters with a vector 
     177 
     178  // Since we are no longer looping over the entire polydispersity hypercube 
     179  // for each q, we need to track the normalization values for each q in a 
     180  // separate work vector. 
     181  double *norm = work;   // contains sum over weights 
     182  double *vol = norm + (nq + padding); // contains sum over volume 
     183  double *norm_vol = vol + (nq + padding); 
    176184 
    177185  // Initialize the results to zero 
     
    188196  } 
    189197 
    190   // Force the index into a new state 
    191   local int pd_index[4]; 
     198  // Location in the polydispersity cube, one index per dimension. 
     199  // Set the initial index greater than its vector length in order to 
     200  // trigger the reset behaviour that happens at the end the fast loop. 
     201  local int pd_index[PD_MAX]; 
    192202  pd_index[0] = pd_length[0] 
    193203 
    194204  // Loop over the weights then loop over q, accumulating values 
     205  // par 
    195206  double partial_weight = NaN; 
    196207  for (int loop_index=pd_start; loop_index < pd_stop; loop_index++) { 
     
    224235      } 
    225236    } 
    226     #ifdef USE_OPENMP 
    227     #pragma omp parallel for 
    228     #endif 
    229     for (int i=0; i < Nq; i++) { 
    230     { 
    231       if (weight > cutoff) { 
    232           const double scattering = Iq(qi, IQ_PARAMETERS); 
    233           // allow kernels to exclude invalid regions by returning NaN 
    234           if (!isnan(scattering)) { 
    235             result[i] += weight*scattering; 
    236             norm[i] += weight; 
    237             const double vol_weight = VOLUME_WEIGHT_PRODUCT; 
    238             vol[i] += vol_weight*form_volume(VOLUME_PARAMETERS); 
    239             norm_vol[i] += vol_weight; 
    240       } 
     237    if (weight > cutoff) { 
     238      const double vol_weight = VOLUME_WEIGHT_PRODUCT; 
     239      const double weighted_vol = vol_weight*form_volume(VOLUME_PARAMTERS); 
     240      #ifdef USE_OPENMP 
     241      #pragma omp parallel for 
     242      #endif 
     243      for (int i=0; i < Nq; i++) { 
     244      { 
     245        const double scattering = Iq(qi, IQ_PARAMETERS); 
     246        // allow kernels to exclude invalid regions by returning NaN 
     247        if (!isnan(scattering)) { 
     248          result[i] += weight*scattering; 
     249          // can almost get away with only having one constant rather than 
     250          // one constant per q.  Maybe want a "is_valid" test? 
     251          norm[i] += weight; 
     252          vol[i] += weighted_vol; 
     253          norm_vol[i] += vol_weight; 
     254        } 
    241255    } 
    242256  } 
Note: See TracChangeset for help on using the changeset viewer.