Changeset a1c5758 in sasmodels for explore/precision.py


Ignore:
Timestamp:
Oct 23, 2017 10:25:27 AM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
34823bc
Parents:
ea60e08 (diff), 55d88b4 (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.
Message:

Merge branch 'master' into ticket-776-orientation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/precision.py

    r2a602c7 ra1c5758  
    107107        elif xrange == "linear": 
    108108            lin_min, lin_max, lin_steps = 1, 1000, 2000 
     109            lin_min, lin_max, lin_steps = 0.001, 2, 2000 
    109110        elif xrange == "log": 
    110111            log_min, log_max, log_steps = -3, 5, 400 
     
    354355    np_function=lambda x: np.fmod(x, 2*np.pi), 
    355356    ocl_function=make_ocl("return fmod(q, 2*M_PI);", "sas_fmod"), 
     357) 
     358add_function( 
     359    name="debye", 
     360    mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 
     361    np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 
     362    ocl_function=make_ocl(""" 
     363    const double qsq = q*q; 
     364    if (qsq < 1.0) { // Pade approximation 
     365        const double x = qsq; 
     366        if (0) { // 0.36 single 
     367            // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 4}] 
     368            return (x*x/180. + 1.)/((1./30.*x + 1./3.)*x + 1); 
     369        } else if (0) { // 1.0 for single 
     370            // padeapproximant[2*exp[-x^2] + x^2-1)/x^4, {x, 0, 6}] 
     371            const double A1=1./24., A2=1./84, A3=-1./3360; 
     372            const double B1=3./8., B2=3./56., B3=1./336.; 
     373            return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); 
     374        } else if (1) { // 1.0 for single, 0.25 for double 
     375            // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
     376            const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; 
     377            const double B1=2./5., B2=1./15., B3=1./180., B4=1./5040.; 
     378            return ((((A4*x + A3)*x + A2)*x + A1)*x + 1.) 
     379                  /((((B4*x + B3)*x + B2)*x + B1)*x + 1.); 
     380        } else { // 1.0 for single, 0.5 for double 
     381            // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
     382            const double A1=1./12., A2=2./99., A3=1./2640., A4=1./23760., A5=-1./1995840.; 
     383            const double B1=5./12., B2=5./66., B3=1./132., B4=1./2376., B5=1./95040.; 
     384            return (((((A5*x + A4)*x + A3)*x + A2)*x + A1)*x + 1.) 
     385                  /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 
     386        } 
     387    } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double 
     388        const double x = qsq; 
     389        const double C0 = +1.; 
     390        const double C1 = -1./3.; 
     391        const double C2 = +1./12.; 
     392        const double C3 = -1./60.; 
     393        const double C4 = +1./360.; 
     394        const double C5 = -1./2520.; 
     395        const double C6 = +1./20160.; 
     396        const double C7 = -1./181440.; 
     397        //return ((((C5*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     398        //return (((((C6*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     399        return ((((((C7*x + C6)*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
     400    } else { 
     401        return 2.*(expm1(-qsq) + qsq)/(qsq*qsq); 
     402    } 
     403    """, "sas_debye"), 
    356404) 
    357405 
Note: See TracChangeset for help on using the changeset viewer.