Changeset d0462cf in sasmodels


Ignore:
Timestamp:
Nov 2, 2017 6:50:27 PM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c11d09f
Parents:
f475f90 (diff), 17db833 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (11/02/17 18:50:27)
git-committer:
GitHub <noreply@…> (11/02/17 18:50:27)
Message:

Merge branch 'ticket-776-orientation' into ticket-786

Location:
sasmodels
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/details.py

    r767dca8 rce99754  
    193193    #print("off:",offset) 
    194194 
    195     # Check that we arn't using too many polydispersity loops 
     195    # Check that we aren't using too many polydispersity loops 
    196196    num_active = np.sum(length > 1) 
    197197    max_pd = model_info.parameters.max_pd 
     
    318318    parameter set in the vector. 
    319319    """ 
    320     value, dispersity, weight = zip(*mesh) 
     320    _, dispersity, weight = zip(*mesh) 
    321321    #weight = [w if len(w)>0 else [1.] for w in weight] 
    322322    weight = np.vstack([v.flatten() for v in meshgrid(*weight)]) 
  • sasmodels/kernel_iq.c

    r4991048 r6aee3ab  
    1313// NOTE: the following macros are defined in generate.py: 
    1414// 
    15 //  MAX_PD : the maximum number of dispersity loops allowed 
     15//  MAX_PD : the maximum number of dispersity loops allowed for this model, 
     16//      which will be at most modelinfo.MAX_PD. 
    1617//  NUM_PARS : the number of parameters in the parameter table 
    1718//  NUM_VALUES : the number of values to skip at the start of the 
     
    282283#endif 
    283284 
    284   // Storage for the current parameter values.  These will be updated as we 
    285   // walk the dispersity mesh. 
     285  // ** Fill in the local values table ** 
     286  // Storage for the current parameter values. 
     287  // These will be updated as we walk the dispersity mesh. 
    286288  ParameterBlock local_values; 
    287  
     289  //   values[0] is scale 
     290  //   values[1] is background 
     291  #ifdef USE_OPENMP 
     292  #pragma omp parallel for 
     293  #endif 
     294  for (int i=0; i < NUM_PARS; i++) { 
     295    local_values.vector[i] = values[2+i]; 
     296    //if (q_index==0) printf("p%d = %g\n",i, local_values.vector[i]); 
     297  } 
     298  //if (q_index==0) printf("NUM_VALUES:%d  NUM_PARS:%d  MAX_PD:%d\n", NUM_VALUES, NUM_PARS, MAX_PD); 
     299  //if (q_index==0) printf("start:%d  stop:%d\n", pd_start, pd_stop); 
     300 
     301  // ** Precompute magnatism values ** 
    288302#if defined(MAGNETIC) && NUM_MAGNETIC>0 
    289303  // Location of the sld parameters in the parameter vector. 
     
    302316#endif // MAGNETIC 
    303317 
    304   // Fill in the initial variables 
    305   //   values[0] is scale 
    306   //   values[1] is background 
    307   #ifdef USE_OPENMP 
    308   #pragma omp parallel for 
    309   #endif 
    310   for (int i=0; i < NUM_PARS; i++) { 
    311     local_values.vector[i] = values[2+i]; 
    312 //if (q_index==0) printf("p%d = %g\n",i, local_values.vector[i]); 
    313   } 
    314 //if (q_index==0) printf("NUM_VALUES:%d  NUM_PARS:%d  MAX_PD:%d\n", NUM_VALUES, NUM_PARS, MAX_PD); 
    315 //if (q_index==0) printf("start:%d  stop:%d\n", pd_start, pd_stop); 
    316  
     318  // ** Fill in the initial results ** 
    317319  // If pd_start is zero that means that we are starting a new calculation, 
    318320  // and must initialize the result to zero.  Otherwise, we are restarting 
     
    336338      for (int q_index=0; q_index < nq; q_index++) result[q_index] = 0.0; 
    337339    } 
    338 //if (q_index==0) printf("start %d %g %g\n", pd_start, pd_norm, result[0]); 
     340    //if (q_index==0) printf("start %d %g %g\n", pd_start, pd_norm, result[0]); 
    339341#endif // !USE_OPENCL 
    340342 
     
    390392      PD_OPEN(0,1) 
    391393 
    392       ... main loop body ... 
     394      // ... main loop body ... 
     395      APPLY_PROJECTION    // convert jitter values to spherical coords 
     396      BUILD_ROTATION      // construct the rotation matrix qxy => qabc 
     397      for each q 
     398          FETCH_Q         // set qx,qy from the q input vector 
     399          APPLY_ROTATION  // convert qx,qy to qa,qb,qc 
     400          CALL_KERNEL     // scattering = Iqxy(qa, qb, qc, p1, p2, ...) 
    393401 
    394402      ++step;  // increment counter representing position in dispersity mesh 
     
    412420*/ 
    413421 
    414 // Define looping variables 
    415 #define PD_INIT(_LOOP) \ 
    416   const int n##_LOOP = details->pd_length[_LOOP]; \ 
    417   const int p##_LOOP = details->pd_par[_LOOP]; \ 
    418   global const double *v##_LOOP = pd_value + details->pd_offset[_LOOP]; \ 
    419   global const double *w##_LOOP = pd_weight + details->pd_offset[_LOOP]; \ 
    420   int i##_LOOP = (pd_start/details->pd_stride[_LOOP])%n##_LOOP; 
    421  
    422 // Jump into the middle of the dispersity loop 
    423 #define PD_OPEN(_LOOP,_OUTER) \ 
    424   while (i##_LOOP < n##_LOOP) { \ 
    425     local_values.vector[p##_LOOP] = v##_LOOP[i##_LOOP]; \ 
    426     const double weight##_LOOP = w##_LOOP[i##_LOOP] * weight##_OUTER; 
    427  
    428 // create the variable "weight#=1.0" where # is the outermost level+1 (=MAX_PD). 
    429 #define _PD_OUTERMOST_WEIGHT(_n) const double weight##_n = 1.0; 
    430 #define PD_OUTERMOST_WEIGHT(_n) _PD_OUTERMOST_WEIGHT(_n) 
    431  
    432 // Close out the loop 
    433 #define PD_CLOSE(_LOOP) \ 
    434     if (step >= pd_stop) break; \ 
    435     ++i##_LOOP; \ 
    436   } \ 
    437   i##_LOOP = 0; 
    438  
    439 // The main loop body is essentially: 
    440 // 
    441 //    BUILD_ROTATION      // construct the rotation matrix qxy => qabc 
    442 //    for each q 
    443 //        FETCH_Q         // set qx,qy from the q input vector 
    444 //        APPLY_ROTATION  // convert qx,qy to qa,qb,qc 
    445 //        CALL_KERNEL     // scattering = Iqxy(qa, qb, qc, p1, p2, ...) 
    446 // 
     422 
     423// ** prepare inner loops ** 
     424 
    447425// Depending on the shape type (radial, axial, triaxial), the variables 
    448 // and calling parameters will be slightly different.  These macros 
    449 // capture the differences in one spot so the rest of the code is easier 
    450 // to read. 
     426// and calling parameters in the loop body will be slightly different. 
     427// Macros capture the differences in one spot so the rest of the code 
     428// is easier to read. The code below both declares variables for the 
     429// inner loop and defines the macros that use them. 
    451430 
    452431#if defined(CALL_IQ) 
     
    486465  // psi and dpsi are only for IQ_ABC, so they are processed here. 
    487466  const double psi = values[details->theta_par+4]; 
     467  local_values.table.psi = 0.; 
    488468  #define BUILD_ROTATION() qabc_rotation(&rotation, theta, phi, psi, dtheta, dphi, local_values.table.psi) 
    489469  #define APPLY_ROTATION() qabc_apply(rotation, qx, qy, &qa, &qb, &qc) 
     
    501481  const double theta = values[details->theta_par+2]; 
    502482  const double phi = values[details->theta_par+3]; 
     483  // Make sure jitter angle defaults to zero if there is no jitter distribution 
     484  local_values.table.theta = 0.; 
     485  local_values.table.phi = 0.; 
    503486  // The "jitter" angles (dtheta, dphi, dpsi) are stored with the 
    504487  // dispersity values and copied to the local parameter table as 
     
    523506#endif // !spherosymmetric projection 
    524507 
     508// ** define looping macros ** 
     509 
     510// Define looping variables 
     511#define PD_INIT(_LOOP) \ 
     512  const int n##_LOOP = details->pd_length[_LOOP]; \ 
     513  const int p##_LOOP = details->pd_par[_LOOP]; \ 
     514  global const double *v##_LOOP = pd_value + details->pd_offset[_LOOP]; \ 
     515  global const double *w##_LOOP = pd_weight + details->pd_offset[_LOOP]; \ 
     516  int i##_LOOP = (pd_start/details->pd_stride[_LOOP])%n##_LOOP; 
     517 
     518// Jump into the middle of the dispersity loop 
     519#define PD_OPEN(_LOOP,_OUTER) \ 
     520  while (i##_LOOP < n##_LOOP) { \ 
     521    local_values.vector[p##_LOOP] = v##_LOOP[i##_LOOP]; \ 
     522    const double weight##_LOOP = w##_LOOP[i##_LOOP] * weight##_OUTER; 
     523 
     524// create the variable "weight#=1.0" where # is the outermost level+1 (=MAX_PD). 
     525#define _PD_OUTERMOST_WEIGHT(_n) const double weight##_n = 1.0; 
     526#define PD_OUTERMOST_WEIGHT(_n) _PD_OUTERMOST_WEIGHT(_n) 
     527 
     528// Close out the loop 
     529#define PD_CLOSE(_LOOP) \ 
     530    if (step >= pd_stop) break; \ 
     531    ++i##_LOOP; \ 
     532  } \ 
     533  i##_LOOP = 0; 
    525534 
    526535// ====== construct the loops ======= 
     
    537546int step = pd_start; 
    538547 
     548// *** define loops for each of 0, 1, 2, ..., modelinfo.MAX_PD-1 *** 
     549 
    539550// define looping variables 
    540551#if MAX_PD>4 
     
    571582  PD_OPEN(0,1) 
    572583#endif 
    573  
    574584 
    575585//if (q_index==0) {printf("step:%d of %d, pars:",step,pd_stop); for (int i=0; i < NUM_PARS; i++) printf("p%d=%g ",i, local_values.vector[i]); printf("\n");} 
     
    672682#endif // !USE_OPENCL 
    673683 
    674 // clear the macros in preparation for the next kernel 
     684// ** clear the macros in preparation for the next kernel ** 
    675685#undef PD_INIT 
    676686#undef PD_OPEN 
  • sasmodels/modelinfo.py

    re3571cb r6aee3ab  
    3030    TestCondition = Tuple[ParameterSetUser, TestInput, TestValue] 
    3131 
    32 MAX_PD = 4 #: Maximum number of simultaneously polydisperse parameters 
     32# If MAX_PD changes, need to change the loop macros in kernel_iq.c 
     33MAX_PD = 5 #: Maximum number of simultaneously polydisperse parameters 
    3334 
    3435# assumptions about common parameters exist throughout the code, such as: 
  • sasmodels/product.py

    r1f35235 rce99754  
    101101    model_info.composition = ('product', [p_info, s_info]) 
    102102    model_info.control = p_info.control 
     103    model_info.hidden = p_info.hidden 
     104    if getattr(p_info, 'profile', None) is not None: 
     105        profile_pars = set(p.id for p in p_info.parameters.kernel_parameters) 
     106        def profile(**kwargs): 
     107            # extract the profile args 
     108            kwargs = dict((k, v) for k, v in kwargs.items() if k in profile_pars) 
     109            return p_info.profile(**kwargs) 
     110    else: 
     111        profile = None 
     112    model_info.profile = profile 
     113    model_info.profile_axes = p_info.profile_axes 
     114 
    103115    # TODO: delegate random to p_info, s_info 
    104116    #model_info.random = lambda: {} 
     
    267279    weight = values[nvalues + call_details.num_weights: nvalues + 2*call_details.num_weights] 
    268280    npars = model_info.parameters.npars 
    269     pairs = [(value[offset:offset+length], weight[offset:offset+length]) 
     281    # Note: changed from pairs ([v], [w]) to triples (p, [v], [w]), but the 
     282    # dispersion mesh code doesn't actually care about the nominal parameter 
     283    # value, p, so set it to None. 
     284    pairs = [(None, value[offset:offset+length], weight[offset:offset+length]) 
    270285             for p, offset, length 
    271286             in zip(model_info.parameters.call_parameters[2:2+npars], 
  • sasmodels/sasview_model.py

    r904cd9c r17db833  
    205205                                           structure_factor._model_info) 
    206206    ConstructedModel = make_model_from_info(model_info) 
    207     return ConstructedModel(form_factor.multiplicity)     
     207    return ConstructedModel(form_factor.multiplicity) 
    208208 
    209209 
     
    673673        #call_details.show() 
    674674        #print("pairs", pairs) 
     675        #for k, p in enumerate(self._model_info.parameters.call_parameters): 
     676        #    print(k, p.name, *pairs[k]) 
    675677        #print("params", self.params) 
    676678        #print("values", values) 
     
    678680        result = calculator(call_details, values, cutoff=self.cutoff, 
    679681                            magnetic=is_magnetic) 
     682        #print("result", result) 
    680683        self._intermediate_results = getattr(calculator, 'results', None) 
    681684        calculator.release() 
     
    761764                return self.multiplicity, [self.multiplicity], [1.0] 
    762765            else: 
    763                 # For hidden parameters use the default value. 
     766                # For hidden parameters use default values.  This sets 
     767                # scale=1 and background=0 for structure factors 
    764768                default = self._model_info.parameters.defaults.get(par.name, np.NaN) 
    765                 return [default], [1.0] 
     769                return default, [default], [1.0] 
    766770        elif par.polydisperse: 
    767771            value = self.params[par.name] 
     
    776780        else: 
    777781            value = self.params[par.name] 
    778             return value, [value if par.relative_pd else 0.0], [1.0] 
     782            return value, [value], [1.0] 
    779783 
    780784def test_cylinder(): 
     
    794798    Model = _make_standard_model('hardsphere') 
    795799    model = Model() 
     800    value2d = model.evalDistribution([0.1, 0.1]) 
     801    value1d = model.evalDistribution(np.array([0.1*np.sqrt(2)])) 
     802    #print("hardsphere", value1d, value2d) 
     803    if np.isnan(value1d) or np.isnan(value2d): 
     804        raise ValueError("hardsphere returns nan") 
     805 
     806def test_product(): 
     807    # type: () -> float 
     808    """ 
     809    Test that 2-D hardsphere model runs and doesn't produce NaN. 
     810    """ 
     811    S = _make_standard_model('hayter_msa')() 
     812    P = _make_standard_model('cylinder')() 
     813    model = MultiplicationModel(P, S) 
    796814    value = model.evalDistribution([0.1, 0.1]) 
    797815    if np.isnan(value): 
    798         raise ValueError("hardsphere returns null") 
     816        raise ValueError("cylinder*hatyer_msa returns null") 
    799817 
    800818def test_rpa(): 
     
    850868if __name__ == "__main__": 
    851869    print("cylinder(0.1,0.1)=%g"%test_cylinder()) 
     870    #test_product() 
     871    #test_structure_factor() 
     872    #print("rpa:", test_rpa()) 
    852873    #test_empty_distribution() 
  • sasmodels/models/core_shell_parallelepiped.c

    r904cd9c r3a1fc7d  
    33    double thick_rim_a, double thick_rim_b, double thick_rim_c) 
    44{ 
    5     //return length_a * length_b * length_c; 
    65    return length_a * length_b * length_c + 
    76           2.0 * thick_rim_a * length_b * length_c + 
     
    2423    double thick_rim_c) 
    2524{ 
    26     // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c_scaled 
     25    // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c 
    2726    // Did not understand the code completely, it should be rechecked (Miguel Gonzalez) 
    2827    //Code is rewritten,the code is compliant with Diva Singhs thesis now (Dirk Honecker) 
     
    3029    const double mu = 0.5 * q * length_b; 
    3130 
    32     //calculate volume before rescaling (in original code, but not used) 
    33     //double vol = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); 
    34     //double vol = length_a * length_b * length_c + 
    35     //       2.0 * thick_rim_a * length_b * length_c + 
    36     //       2.0 * thick_rim_b * length_a * length_c + 
    37     //       2.0 * thick_rim_c * length_a * length_b; 
     31    // Scale sides by B 
     32    const double a_over_b = length_a / length_b; 
     33    const double c_over_b = length_c / length_b; 
    3834 
    39     // Scale sides by B 
    40     const double a_scaled = length_a / length_b; 
    41     const double c_scaled = length_c / length_b; 
    42  
    43     double ta = a_scaled + 2.0*thick_rim_a/length_b; // incorrect ta = (a_scaled + 2.0*thick_rim_a)/length_b; 
    44     double tb = 1+ 2.0*thick_rim_b/length_b; // incorrect tb = (a_scaled + 2.0*thick_rim_b)/length_b; 
    45     double tc = c_scaled + 2.0*thick_rim_c/length_b; //not present 
     35    double tA_over_b = a_over_b + 2.0*thick_rim_a/length_b; 
     36    double tB_over_b = 1+ 2.0*thick_rim_b/length_b; 
     37    double tC_over_b = c_over_b + 2.0*thick_rim_c/length_b; 
    4638 
    4739    double Vin = length_a * length_b * length_c; 
    48     //double Vot = (length_a * length_b * length_c + 
    49     //            2.0 * thick_rim_a * length_b * length_c + 
    50     //            2.0 * length_a * thick_rim_b * length_c + 
    51     //            2.0 * length_a * length_b * thick_rim_c); 
    52     double V1 = (2.0 * thick_rim_a * length_b * length_c);    // incorrect V1 (aa*bb*cc+2*ta*bb*cc) 
    53     double V2 = (2.0 * length_a * thick_rim_b * length_c);    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
    54     double V3 = (2.0 * length_a * length_b * thick_rim_c);    //not present 
     40    double VtA = (2.0 * thick_rim_a * length_b * length_c); 
     41    double VtB = (2.0 * length_a * thick_rim_b * length_c); 
     42    double VtC = (2.0 * length_a * length_b * thick_rim_c); 
    5543 
    5644    // Scale factors (note that drC is not used later) 
    57     const double drho0 = (core_sld-solvent_sld); 
    58     const double drhoA = (arim_sld-solvent_sld); 
    59     const double drhoB = (brim_sld-solvent_sld); 
    60     const double drhoC = (crim_sld-solvent_sld);  // incorrect const double drC_Vot = (crim_sld-solvent_sld)*Vot; 
    61  
     45    const double dr0 = (core_sld-solvent_sld); 
     46    const double drA = (arim_sld-solvent_sld); 
     47    const double drB = (brim_sld-solvent_sld); 
     48    const double drC = (crim_sld-solvent_sld); 
    6249 
    6350    // Precompute scale factors for combining cross terms from the shape 
    64     const double scale23 = drhoA*V1; 
    65     const double scale14 = drhoB*V2; 
    66     const double scale24 = drhoC*V3; 
    67     const double scale11 = drho0*Vin; 
    68     const double scale12 = drho0*Vin - scale23 - scale14 - scale24; 
     51    const double dr0_Vin = dr0*Vin; 
     52    const double drA_VtA = drA*VtA; 
     53    const double drB_VtB = drB*VtB; 
     54    const double drC_VtC = drC*VtC; 
     55    const double drV_delta = dr0_Vin - drA_VtA - drB_VtB - drC_VtC; 
     56 
     57    /*  *************** algorithm description ****************** 
     58 
     59    // Rewrite f as x*siC + y*siCt to move the siC/siCt calculation out 
     60    // of the inner loop.  That is: 
     61 
     62    f = (di-da-db-dc) sa sb sc + da sa' sb sc + db sa sb' sc + dc sa sb sc' 
     63      =  [ (di-da-db-dc) sa sb + da sa' sb + db sa sb' ] sc  + [dc sa sb] sc' 
     64      = x sc + y sc' 
     65 
     66    // where: 
     67    di = delta rho_core V_core 
     68    da = delta rho_rimA V_rimA 
     69    db = delta rho_rimB V_rimB 
     70    dc = delta rho_rimC V_rimC 
     71    sa = j_0 (q_a a/2)    // siA the code 
     72    sb = j_0 (q_b b/2) 
     73    sc = j_0 (q_c c/2) 
     74    sa' = j_0(q_a a_rim/2)  // siAt the code 
     75    sb' = j_0(q_b b_rim/2) 
     76    sc' = j_0(q_c c_rim/2) 
     77 
     78    // qa, qb, and qc are generated using polar coordinates, with the 
     79    // outer loop integrating over [0,1] after the u-substitution 
     80    //    sigma = cos(theta), sqrt(1-sigma^2) = sin(theta) 
     81    // and inner loop integrating over [0, pi/2] as 
     82    //    uu = phi 
     83 
     84    ************************************************************  */ 
    6985 
    7086    // outer integral (with gauss points), integration limits = 0, 1 
    71     double outer_total = 0; //initialize integral 
    72  
     87    double outer_sum = 0; //initialize integral 
    7388    for( int i=0; i<76; i++) { 
    7489        double sigma = 0.5 * ( Gauss76Z[i] + 1.0 ); 
    7590        double mu_proj = mu * sqrt(1.0-sigma*sigma); 
    7691 
    77         // inner integral (with gauss points), integration limits = 0, 1 
    78         double inner_total = 0.0; 
    79         double inner_total_crim = 0.0; 
     92        // inner integral (with gauss points), integration limits = 0, pi/2 
     93        const double siC = sas_sinx_x(mu * sigma * c_over_b); 
     94        const double siCt = sas_sinx_x(mu * sigma * tC_over_b); 
     95        double inner_sum = 0.0; 
    8096        for(int j=0; j<76; j++) { 
    8197            const double uu = 0.5 * ( Gauss76Z[j] + 1.0 ); 
    8298            double sin_uu, cos_uu; 
    8399            SINCOS(M_PI_2*uu, sin_uu, cos_uu); 
    84             const double si1 = sas_sinx_x(mu_proj * sin_uu * a_scaled); 
    85             const double si2 = sas_sinx_x(mu_proj * cos_uu ); 
    86             const double si3 = sas_sinx_x(mu_proj * sin_uu * ta); 
    87             const double si4 = sas_sinx_x(mu_proj * cos_uu * tb); 
     100            const double siA = sas_sinx_x(mu_proj * sin_uu * a_over_b); 
     101            const double siB = sas_sinx_x(mu_proj * cos_uu ); 
     102            const double siAt = sas_sinx_x(mu_proj * sin_uu * tA_over_b); 
     103            const double siBt = sas_sinx_x(mu_proj * cos_uu * tB_over_b); 
    88104 
    89             // Expression in libCylinder.c (neither drC nor Vot are used) 
    90             const double form = scale12*si1*si2 + scale23*si2*si3 + scale14*si1*si4; 
    91             const double form_crim = scale11*si1*si2; 
     105            const double x = drV_delta*siA*siB + drA_VtA*siB*siAt + drB_VtB*siA*siBt; 
     106            const double form = x*siC + drC_VtC*siA*siB*siCt; 
    92107 
    93             //  correct FF : sum of square of phase factors 
    94             inner_total += Gauss76Wt[j] * form * form; 
    95             inner_total_crim += Gauss76Wt[j] * form_crim * form_crim; 
     108            inner_sum += Gauss76Wt[j] * form * form; 
    96109        } 
    97         inner_total *= 0.5; 
    98         inner_total_crim *= 0.5; 
     110        inner_sum *= 0.5; 
    99111        // now sum up the outer integral 
    100         const double si = sas_sinx_x(mu * c_scaled * sigma); 
    101         const double si_crim = sas_sinx_x(mu * tc * sigma); 
    102         outer_total += Gauss76Wt[i] * (inner_total * si * si + inner_total_crim * si_crim * si_crim); 
     112        outer_sum += Gauss76Wt[i] * inner_sum; 
    103113    } 
    104     outer_total *= 0.5; 
     114    outer_sum *= 0.5; 
    105115 
    106116    //convert from [1e-12 A-1] to [cm-1] 
    107     return 1.0e-4 * outer_total; 
     117    return 1.0e-4 * outer_sum; 
    108118} 
    109119 
     
    129139 
    130140    double Vin = length_a * length_b * length_c; 
    131     double V1 = 2.0 * thick_rim_a * length_b * length_c;    // incorrect V1(aa*bb*cc+2*ta*bb*cc) 
    132     double V2 = 2.0 * length_a * thick_rim_b * length_c;    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
    133     double V3 = 2.0 * length_a * length_b * thick_rim_c; 
    134     // As for the 1D case, Vot is not used 
    135     //double Vot = (length_a * length_b * length_c + 
    136     //              2.0 * thick_rim_a * length_b * length_c + 
    137     //              2.0 * length_a * thick_rim_b * length_c + 
    138     //              2.0 * length_a * length_b * thick_rim_c); 
     141    double VtA = 2.0 * thick_rim_a * length_b * length_c; 
     142    double VtB = 2.0 * length_a * thick_rim_b * length_c; 
     143    double VtC = 2.0 * length_a * length_b * thick_rim_c; 
    139144 
    140145    // The definitions of ta, tb, tc are not the same as in the 1D case because there is no 
    141146    // the scaling by B. 
    142     double ta = length_a + 2.0*thick_rim_a; 
    143     double tb = length_b + 2.0*thick_rim_b; 
    144     double tc = length_c + 2.0*thick_rim_c; 
     147    double tA = length_a + 2.0*thick_rim_a; 
     148    double tB = length_b + 2.0*thick_rim_b; 
     149    double tC = length_c + 2.0*thick_rim_c; 
    145150    //handle arg=0 separately, as sin(t)/t -> 1 as t->0 
    146151    double siA = sas_sinx_x(0.5*length_a*qa); 
    147152    double siB = sas_sinx_x(0.5*length_b*qb); 
    148153    double siC = sas_sinx_x(0.5*length_c*qc); 
    149     double siAt = sas_sinx_x(0.5*ta*qa); 
    150     double siBt = sas_sinx_x(0.5*tb*qb); 
    151     double siCt = sas_sinx_x(0.5*tc*qc); 
     154    double siAt = sas_sinx_x(0.5*tA*qa); 
     155    double siBt = sas_sinx_x(0.5*tB*qb); 
     156    double siCt = sas_sinx_x(0.5*tC*qc); 
    152157 
    153158 
    154159    // f uses Vin, V1, V2, and V3 and it seems to have more sense than the value computed 
    155160    // in the 1D code, but should be checked! 
    156     double f = ( dr0*siA*siB*siC*Vin 
    157                + drA*(siAt-siA)*siB*siC*V1 
    158                + drB*siA*(siBt-siB)*siC*V2 
    159                + drC*siA*siB*(siCt-siC)*V3); 
     161    double f = ( dr0*Vin*siA*siB*siC 
     162               + drA*VtA*(siAt-siA)*siB*siC 
     163               + drB*VtB*siA*(siBt-siB)*siC 
     164               + drC*VtC*siA*siB*(siCt-siC)); 
    160165 
    161166    return 1.0e-4 * f * f; 
Note: See TracChangeset for help on using the changeset viewer.