Changeset 56b0435 in sasmodels


Ignore:
Timestamp:
Dec 20, 2016 5:07:15 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
a0168e8
Parents:
abb6e4f
Message:

round to nearest Nlayers rather than truncate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/lamellar_stack_caille.c

    r0bef47b r56b0435  
    33*/ 
    44 
    5 double Iq(double qval, 
    6       double del, 
    7       double Nlayers,  
    8       double dd, 
    9           double Cp,  
    10       double sld, 
    11       double solvent_sld); 
    12  
    13 double Iq(double qval, 
    14       double del, 
    15       double Nlayers,  
    16       double dd, 
    17           double Cp,  
    18       double sld, 
    19       double solvent_sld) 
     5static double 
     6Iq(double qval, 
     7   double del, 
     8   double fp_Nlayers, 
     9   double dd, 
     10   double Cp, 
     11   double sld, 
     12   double solvent_sld) 
    2013{ 
    21   double contr,NN;   //local variables of coefficient wave 
     14  int Nlayers = (int)(fp_Nlayers+0.5);    //cast to an integer for the loop 
     15  double contr;   //local variables of coefficient wave 
    2216  double inten,Pq,Sq,alpha,temp,t2; 
    2317  //double dQ, dQDefault, t1, t3; 
    24   int ii,NNint; 
    2518  // from wikipedia 0.577215664901532860606512090082402431042159335 
    2619  const double Euler = 0.577215664901533;   // Euler's constant, increased sig figs for new models Feb 2015 
     
    2821  //dQ = dQDefault; // REMOVED UNUSED dQ calculations for new models Feb 2015 
    2922 
    30   NN = trunc(Nlayers);    //be sure that NN is an integer 
    31    
    3223  contr = sld - solvent_sld; 
    3324 
    3425  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del)); 
    3526 
    36   NNint = (int)NN;    //cast to an integer for the loop 
    37   ii=0; 
    3827  Sq = 0.0; 
    3928  // the vital "=" in ii<=  added March 2015 
    40   for(ii=1;ii<=(NNint-1);ii+=1) { 
     29  for (int ii=1; ii<=Nlayers-1; ii++) { 
    4130 
    4231    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015 
     
    4837    //t3 = dQ*dQ*dd*dd*ii*ii; 
    4938 
    50     temp = 1.0-ii/NN; 
     39    temp = 1.0 - (double)ii / (double)Nlayers; 
    5140    //temp *= cos(dd*qval*ii/(1.0+t1)); 
    5241    temp *= cos(dd*qval*ii); 
Note: See TracChangeset for help on using the changeset viewer.