Changeset 6e72989 in sasmodels for explore/precision.py


Ignore:
Timestamp:
Oct 3, 2017 9:21:07 AM (7 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:
3a220e6
Parents:
b76191e
Message:

clean up flexible cylinder; allow code to run on Intel HD 6000; improve precision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/precision.py

    r487e695 r6e72989  
    321321    np_function=lambda x: np.fmod(x, 2*np.pi), 
    322322    ocl_function=make_ocl("return fmod(q, 2*M_PI);", "sas_fmod"), 
     323) 
     324add_function( 
     325    name="debye", 
     326    mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 
     327    np_function=lambda x: 2*(np.exp(-x**2) + x**2 - 1)/x**4, 
     328    ocl_function=make_ocl(""" 
     329    const double qsq = q*q; 
     330    if (qsq < 0.1) { 
     331        const double x = qsq; 
     332        const double C0 = +1.; 
     333        const double C1 = -1./3.; 
     334        const double C2 = +1./12.; 
     335        const double C3 = -1./60.; 
     336        const double C4 = +1./360.; 
     337        const double C5 = -1./2520.; 
     338        const double C6 = +1./20160.; 
     339        const double C7 = -1./181440.; 
     340        //return ((((C5*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     341        return (((((C6*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     342        //return ((((((C7*x + C6)*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     343    } /* else if (qsq < 1.0) { 
     344        // taylor series around q^2 = 0.5 
     345        const double x = qsq - 0.5; 
     346        const double sqrt_e = sqrt(M_E); 
     347        const double C0 = 8./sqrt_e - 4.; 
     348        const double C1 = 24. - 40./sqrt_e; 
     349        const double C2 = 132./sqrt_e - 80.; 
     350        const double C3 = 224. - 1108./(3.*sqrt_e); 
     351        const double C4 = 2849./(3.*sqrt_e) - 576.; 
     352        const double C5 = 1408 - 11607./(5.*sqrt_e); 
     353        return ((((C5*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     354    } */ else { 
     355        return 2.*(exp(-qsq) + qsq - 1.)/(qsq*qsq); 
     356    } 
     357    """, "sas_debye"), 
    323358) 
    324359 
Note: See TracChangeset for help on using the changeset viewer.