Changeset 208f0a4 in sasmodels


Ignore:
Timestamp:
Mar 20, 2016 1:19:04 PM (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:
b85be2d, 3a45c2c
Parents:
f35f1dd
Message:

throw in support for spherical correction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    rf35f1dd r208f0a4  
    4040           double sld_solvent 
    4141 
    42    PARAMETER_CALL(var) is the declaration of a call to the kernel. 
     42   CALL_IQ(q, nq, i, pars) is the declaration of a call to the kernel. 
    4343 
    4444       Cylinder: 
    4545 
    46            #define PARAMETER_CALL(var) \ 
     46           #define CALL_IQ(q, nq, i, var) \ 
     47           Iq(q[i], \ 
    4748           var.length, \ 
    4849           var.radius, \ 
    4950           var.sld, \ 
    50            var.sld_solvent 
     51           var.sld_solvent) 
    5152 
    5253       Multi-shell cylinder: 
    53            #define PARAMETER_CALL(var) \ 
     54           #define CALL_IQ(q, nq, i, var) \ 
     55           Iq(q[i], \ 
    5456           var.num_shells, \ 
    5557           var.length, \ 
    5658           var.radius, \ 
    5759           var.sld, \ 
    58            var.sld_solvent 
     60           var.sld_solvent) 
     61 
     62   CALL_VOLUME(var) is similar, but for calling the form volume. 
    5963 
    6064   INVALID is a test for model parameters in the correct range 
     
    104108        par_offset = {2, 3, 303, 313}  // parameter offsets 
    105109        par_coord = {0, 3, 2, 1} // bitmap of parameter dependencies 
     110        fast_coord_index = {5, 3, x, x} 
    106111        fast_coord_count = 2  // two parameters vary with *length* distribution 
    107         fast_coord_index = {5, 3, x, x, x, x} 
     112        theta_var = -1   // no spherical correction 
     113        fast_theta = 0   // spherical correction angle is not pd 1 
    108114    } 
    109115 
     
    197203Scale and background cannot be coordinated with other polydisperse parameters 
    198204 
     205Oriented objects in 2-D need a spherical correction on the angular variation 
     206in order to preserve the 'surface area' of the weight distribution. 
     207 
    199208TODO: cutoff 
    200209*/ 
     
    211220    int par_offset[NPARS];  // offset of par values in the par & weight vector 
    212221    int par_coord[NPARS];   // polydispersity coordination bitvector 
     222    int fast_coord_index[NPARS]; // index of the fast coordination parameters 
    213223    int fast_coord_count;   // number of parameters coordinated with pd 1 
    214     int fast_coord_index[NPARS]; // index of the fast coordination parameters 
     224    int theta_var;          // id of spherical correction variable 
     225    int fast_theta;         // true if spherical correction depends on pd 1 
    215226} ProblemDetails; 
    216227 
     
    300311  double weight = 1.0;        // set to 1 in case there are no weights 
    301312  double vol_weight = 1.0;    // set to 1 in case there are no vol weights 
     313  double spherical_correction = 1.0;  // correction for latitude variation 
    302314 
    303315  // Loop over the weights then loop over q, accumulating values 
     
    305317    // check if indices need to be updated 
    306318    if (pd_index[0] >= pd_length[0]) { 
     319 
     320      // RESET INDICES 
    307321      pd_index[0] = loop_index%pd_length[0]; 
    308322      partial_weight = 1.0; 
     
    314328        if (pd_isvol[k]) partial_volweight *= wi; 
    315329      } 
    316       weight = partial_weight * weights[pd_offset[0]+pd_index[0]] 
    317330      for (int k=0; k < NPARS; k++) { 
    318331        int coord = par_coord[k]; 
     
    329342        parvec[k] = pars[this_offset]; 
    330343      } 
     344      weight = partial_weight * weights[pd_offset[0]+pd_index[0]] 
     345      if (theta_var >= 0) { 
     346        spherical_correction = fabs(cos(M_PI_180*parvec[theta_var])); 
     347      } 
     348      if (!fast_theta) weight *= spherical_correction; 
     349 
    331350    } else { 
     351 
     352      // INCREMENT INDICES 
    332353      pd_index[0] += 1; 
    333354      const double wi = weights[pd_offset[0]+pd_index[0]]; 
     
    338359            = pars[offset[fast_coord_index[k]] + pd_index[0]]; 
    339360      } 
    340     } 
     361      if (fast_theta) weight *= fabs(cos(M_PI_180*parvec[theta_var])); 
     362 
     363    } 
     364 
    341365    #ifdef INVALID 
    342366    if (INVALID(local_pars)) continue; 
    343367    #endif 
     368 
    344369    if (weight > cutoff) { 
    345370      norm += weight; 
    346       vol += vol_weight * form_volume(VOLUME_PARAMETERS); 
     371      vol += vol_weight * CALL_VOLUME(local_pars); 
    347372      norm_vol += vol_weight; 
    348373 
     
    352377      for (int i=0; i < nq; i++) { 
    353378      { 
    354         const double scattering = IQ_FUNC(IQ_PARS, IQ_PARAMETERS); 
     379        const double scattering = CALL_IQ(q, nq, i, local_pars); 
    355380        //const double scattering = Iq(q[i], IQ_PARAMETERS); 
    356381        result[i] += weight*scattering; 
Note: See TracChangeset for help on using the changeset viewer.