Changeset 38d8774 in sasmodels


Ignore:
Timestamp:
Nov 25, 2015 1:09:28 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:
319ab14
Parents:
82d239a
Message:

improve single precision accuracy using 2sin2(x/2) = 1-cos(x)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/lamellar.py

    r3e428ec r38d8774  
    8181    const double sub = sld - solvent_sld; 
    8282    const double qsq = q*q; 
    83     return 4.0e-4*M_PI*sub*sub/qsq * (1.0-cos(q*thickness)) 
    84         / (thickness*qsq); 
     83    // Original expression 
     84    //return 4.0e-4*M_PI*sub*sub/qsq * (1.0-cos(q*thickness)) / (thickness*qsq); 
     85    // const double alpha = fmod(q*thickness+0.1, 2.0*M_PI)-0.1; 
     86    // Use small angle fix 1-cos(theta) = 2 sin^2(theta/2) 
     87    const double sinq2 = sin(0.5*q*thickness); 
     88    return 4.0e-4*M_PI*sub*sub/qsq * 2.0*sinq2*sinq2 / (thickness*qsq); 
    8589    """ 
    8690 
Note: See TracChangeset for help on using the changeset viewer.