Changeset fe8ff99 in sasmodels


Ignore:
Timestamp:
Feb 7, 2017 2:04:05 PM (4 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c, 1105286
Parents:
66ca2a6 (diff), 07c8d46 (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@…> (02/07/17 14:04:05)
git-committer:
GitHub <noreply@…> (02/07/17 14:04:05)
Message:

Merge pull request #14 from SasView?/ticket-795

Ticket 795

Location:
sasmodels
Files:
2 added
76 edited
2 moved

Legend:

Unmodified
Added
Removed
  • sasmodels/conversion_table.py

    rfa6d6fc r790b16bb  
    55names for each parameter in sasmodels.  This is used by :mod:`convert` to 
    66determine the equivalent parameter set when comparing a sasmodels model to 
    7 the models defined in SasView 3.1. 
     7the models defined in previous versions of SasView and sasmodels. This is now 
     8versioned based on the version number of SasView. 
     9 
     10When any sasmodels parameter or model name is changed, this must be modified to 
     11account for that. 
     12 
     13Usage: 
     14<old_Sasview_version> : { 
     15    <new_model_name> : [ 
     16        <old_model_name> , 
     17        { 
     18            <new_param_name_1> : <old_param_name_1>, 
     19            ... 
     20            <new_param_name_n> : <old_param_name_n> 
     21        } 
     22    ] 
     23} 
     24 
     25Any future parameter and model name changes can and should be given in this 
     26table for future compatibility. 
    827""" 
    928 
    10  
    1129CONVERSION_TABLE = { 
     30    (3,1,2) : { 
    1231    "adsorbed_layer": [ 
    1332        "Core2ndMomentModel", 
     
    211230    ], 
    212231    "correlation_length": [ 
    213         "CorrLengthModel", 
     232        "CorrLength", 
    214233        { 
    215234            "porod_scale": "scale_p", 
     
    218237            "lorentz_exp": "exponent_l", 
    219238            "cor_length": "length_l" 
    220         } 
     239        }, 
     240        "CorrLengthModel" 
    221241    ], 
    222242    "cylinder": [ 
     
    299319    ], 
    300320    "fractal_core_shell": [ 
    301         "FractalCoreShellModel", 
     321        "FractalCoreShell", 
    302322        { 
    303323            "sld_core": "core_sld", 
     
    309329            "cor_length": "cor_length", 
    310330            "volfraction": "volfraction", 
    311         } 
     331        }, 
     332        "FractalCoreShellModel" 
    312333    ], 
    313334    "fuzzy_sphere": [ 
     
    321342    ], 
    322343    "gauss_lorentz_gel": [ 
    323         "GaussLorentzGelModel", 
     344        "GaussLorentzGel", 
    324345        { 
    325346            "gauss_scale": "scale_g", 
     
    328349            "background": "background", 
    329350            "lorentz_scale": "scale_l" 
    330         } 
     351        }, 
     352        "GaussLorentzGelModel" 
    331353    ], 
    332354    "gaussian_peak": [ 
    333         "PeakGaussModel", 
     355        "Peak Gauss Model", 
    334356        { 
    335357            "peak_pos": "q0", 
    336358            "sigma": "B", 
    337         } 
     359        }, 
     360        "PeakGaussModel", 
    338361    ], 
    339362    "gel_fit": [ 
     
    343366            "lorentz_scale": "lScale", 
    344367            "guinier_scale": "gScale", 
    345             "fractal_dim": "scale", 
     368            "fractal_dim": "FractalExp", 
    346369            "cor_length": "zeta", 
    347370        } 
    348371    ], 
    349372    "guinier": [ 
     373        "Guinier", 
     374        { 
     375            "rg": "rg" 
     376        }, 
    350377        "GuinierModel", 
    351         { 
    352             "rg": "rg" 
    353         } 
    354378    ], 
    355379    "guinier_porod": [ 
    356         "GuinierPorodModel", 
     380        "GuinierPorod", 
    357381        { 
    358382            "s": "dim", 
     
    361385            "scale": "scale", 
    362386            "background": "background" 
    363         } 
     387        }, 
     388        "GuinierPorodModel", 
    364389    ], 
    365390    "hardsphere": [ 
     
    454479            "d_spacing": "spacing", 
    455480            "Caille_parameter": "caille", 
    456             "Nlayers": "N_plates", 
     481            "Nlayers": "n_plates", 
    457482        } 
    458483    ], 
     
    486511    ], 
    487512    "lorentz": [ 
     513        "Lorentz", 
     514        { 
     515            "cor_length": "length" 
     516        }, 
    488517        "LorentzModel", 
    489         { 
    490             "cor_length": "length" 
    491         } 
    492518    ], 
    493519    "mass_fractal": [ 
     
    510536    ], 
    511537    "mono_gauss_coil": [ 
    512         "DebyeModel", 
     538        "Debye", 
    513539        { 
    514540            "rg": "rg", 
    515541            "i_zero": "scale", 
    516542            "background": "background", 
    517         } 
     543        }, 
     544        "DebyeModel", 
    518545    ], 
    519546    "multilayer_vesicle": [ 
     
    564591    ], 
    565592    "peak_lorentz": [ 
    566         "PeakLorentzModel", 
     593        "Peak Lorentz Model", 
    567594        { 
    568595            "peak_pos": "q0", 
    569596            "peak_hwhm": "B" 
    570         } 
     597        }, 
     598        "PeakLorentzModel", 
    571599    ], 
    572600    "pearl_necklace": [ 
     
    802830    ], 
    803831    "two_lorentzian": [ 
    804         "TwoLorentzianModel", 
     832        "TwoLorentzian", 
    805833        { 
    806834            "lorentz_scale_1": "scale_1", 
     
    811839            "lorentz_length_1": "length_1", 
    812840            "background": "background" 
    813         } 
     841        }, 
     842        "TwoLorentzianModel", 
    814843    ], 
    815844    "two_power_law": [ 
    816         "TwoPowerLawModel", 
     845        "TwoPowerLaw", 
    817846        { 
    818847            "coefficent_1": "coef_A", 
     
    821850            "background": "background", 
    822851            "crossover": "qc" 
    823         } 
     852        }, 
     853        "TwoPowerLawModel", 
    824854    ], 
    825855    "unified_power_Rg": [ 
     856        "UnifiedPowerRg", 
     857        dict(((field_new+str(index), field_old+str(index)) 
     858              for field_new, field_old in [("rg", "Rg"), 
     859                                           ("power", "power"), 
     860                                           ("G", "G"), 
     861                                           ("B", "B"),] 
     862              for index in range(11)), 
     863             **{ 
     864                   "background": "background", 
     865                   "scale": "scale", 
     866               }), 
    826867        "UnifiedPowerRgModel", 
    827         { 
    828         } 
    829868    ], 
    830869    "vesicle": [ 
     
    835874        } 
    836875    ] 
     876    } 
    837877} 
  • sasmodels/convert.py

    rf80f334 r07c8d46  
    5353    ("_pd_nsigma", ".nsigmas"), 
    5454    ("_pd_type", ".type"), 
     55    (".lower", ".lower"), 
     56    (".upper", ".upper"), 
     57    (".fittable", ".fittable"), 
     58    (".std", ".std"), 
     59    (".units", ".units"), 
     60    ("", "") 
    5561    ] 
    5662 
     
    6470    if id.startswith('M0:'): 
    6571        return True 
    66     if id.startswith('volfraction') or id.startswith('radius_effective'): 
    67         return False 
    6872    if '_pd' in id or '.' in id: 
    6973        return False 
     
    7579        if p.id == id: 
    7680            return p.type == 'sld' 
    77     raise ValueError("unknown parameter %r in conversion"%id) 
     81    return False 
    7882 
    7983def _rescale_sld(model_info, pars, scale): 
     
    8892 
    8993 
    90 def _get_translation_table(model_info): 
    91     _, translation = CONVERSION_TABLE.get(model_info.id, [None, {}]) 
    92     translation = translation.copy() 
     94def _get_translation_table(model_info, version=(3,1,2)): 
     95    conv_param = CONVERSION_TABLE.get(version, {}).get(model_info.id, [None, {}]) 
     96    translation = conv_param[1].copy() 
    9397    for p in model_info.parameters.kernel_parameters: 
    9498        if p.length > 1: 
     
    119123def _pd_to_underscores(pars): 
    120124    return dict((_dot_pd_to_underscore_pd(k), v) for k, v in pars.items()) 
    121  
    122 def _convert_name(conv_dict, pars): 
    123     """ 
    124     Renames parameter values (upper, lower, etc) to v4.0 names 
    125     :param conv_dict: conversion dictionary mapping new name : old name 
    126     :param pars: parameters to convert 
    127     :return: 
    128     """ 
    129     new_pars = {} 
    130     i = 0 
    131     j = 0 
    132     for key_par, value_par in pars.iteritems(): 
    133         j += 1 
    134         for key_conv, value_conv in conv_dict.iteritems(): 
    135             if re.search(value_conv, key_par): 
    136                 new_pars[key_par.replace(value_conv, key_conv)] = value_par 
    137                 i += 1 
    138                 break 
    139             elif re.search("background", key_par) or re.search("scale", key_par): 
    140                 new_pars[key_par] = value_par 
    141                 i += 1 
    142                 break 
    143         if i != j: 
    144             new_pars[key_par] = value_par 
    145             i += 1 
    146     return new_pars 
    147125 
    148126def _convert_pars(pars, mapping): 
     
    167145    return newpars 
    168146 
    169  
    170 def _conversion_target(model_name): 
     147def _conversion_target(model_name, version=(3,1,2)): 
    171148    """ 
    172149    Find the sasmodel name which translates into the sasview name. 
     
    176153    two variants in sasview. 
    177154    """ 
    178     for sasmodels_name, [sasview_name, _] in CONVERSION_TABLE.items(): 
    179         if sasview_name == model_name: 
     155    for sasmodels_name, sasview_dict in \ 
     156            CONVERSION_TABLE.get(version, {}).items(): 
     157        if sasview_dict[0] == model_name: 
    180158            return sasmodels_name 
    181159    return None 
    182160 
    183  
    184 def _hand_convert(name, oldpars): 
     161def _hand_convert(name, oldpars, version=(3,1,2)): 
     162    if version == (3,1,2): 
     163        oldpars = _hand_convert_3_1_2_to_4_1(name, oldpars) 
     164    return oldpars 
     165 
     166def _hand_convert_3_1_2_to_4_1(name, oldpars): 
    185167    if name == 'core_shell_parallelepiped': 
    186168        # Make sure pd on rim parameters defaults to zero 
     
    215197            pd = oldpars['radius.width']*oldpars['radius']/thickness 
    216198            oldpars['radius.width'] = pd 
     199    elif name == 'multilayer_vesicle': 
     200        if 'scale' in oldpars: 
     201            oldpars['volfraction'] = oldpars['scale'] 
     202            oldpars['scale'] = 1.0 
     203        if 'scale.lower' in oldpars: 
     204            oldpars['volfraction.lower'] = oldpars['scale.lower'] 
     205        if 'scale.upper' in oldpars: 
     206            oldpars['volfraction.upper'] = oldpars['scale.upper'] 
     207        if 'scale.fittable' in oldpars: 
     208            oldpars['volfraction.fittable'] = oldpars['scale.fittable'] 
     209        if 'scale.std' in oldpars: 
     210            oldpars['volfraction.std'] = oldpars['scale.std'] 
     211        if 'scale.units' in oldpars: 
     212            oldpars['volfraction.units'] = oldpars['scale.units'] 
    217213    elif name == 'pearl_necklace': 
    218214        pass 
     
    236232                oldpars[p + ".upper"] /= 1e-13 
    237233    elif name == 'spherical_sld': 
    238         oldpars["CONTROL"] += 1 
     234        j = 0 
     235        while "func_inter" + str(j) in oldpars: 
     236            name = "func_inter" + str(j) 
     237            new_name = "shape" + str(j + 1) 
     238            if oldpars[name] == 'Erf(|nu|*z)': 
     239                oldpars[new_name] = int(0) 
     240            elif oldpars[name] == 'RPower(z^|nu|)': 
     241                oldpars[new_name] = int(1) 
     242            elif oldpars[name] == 'LPower(z^|nu|)': 
     243                oldpars[new_name] = int(2) 
     244            elif oldpars[name] == 'RExp(-|nu|*z)': 
     245                oldpars[new_name] = int(3) 
     246            elif oldpars[name] == 'LExp(-|nu|*z)': 
     247                oldpars[new_name] = int(4) 
     248            else: 
     249                oldpars[new_name] = int(0) 
     250            oldpars.pop(name) 
     251            oldpars['n_shells'] = str(j + 1) 
     252            j += 1 
    239253    elif name == 'teubner_strey': 
    240254        # basically undoing the entire Teubner-Strey calculations here. 
     
    281295    return oldpars 
    282296 
    283 def convert_model(name, pars, use_underscore=False): 
     297def convert_model(name, pars, use_underscore=False, model_version=(3,1,2)): 
    284298    """ 
    285299    Convert model from old style parameter names to new style. 
    286300    """ 
    287     newname = _conversion_target(name) 
    288     if newname is None: 
    289         return name, pars 
    290     if ':' in newname:   # core_shell_ellipsoid:1 
    291         model_info = load_model_info(newname[:-2]) 
    292         # Know that the table exists and isn't multiplicity so grab it directly 
    293         # Can't use _get_translation_table since that will return the 'bare' 
    294         # version. 
    295         translation = CONVERSION_TABLE[newname][1] 
    296     else: 
    297         model_info = load_model_info(newname) 
    298         translation = _get_translation_table(model_info) 
    299     newpars = _hand_convert(newname, pars.copy()) 
    300     newpars = _convert_name(translation, newpars) 
    301     newpars = _convert_pars(newpars, translation) 
    302     if not model_info.structure_factor: 
    303         newpars = _rescale_sld(model_info, newpars, 1e6) 
    304     newpars.setdefault('scale', 1.0) 
    305     newpars.setdefault('background', 0.0) 
    306     if use_underscore: 
    307         newpars = _pd_to_underscores(newpars) 
     301    newpars = pars 
     302    keys = sorted(CONVERSION_TABLE.keys()) 
     303    for i, version in enumerate(keys): 
     304        # Don't allow indices outside list 
     305        next_i = i + 1 
     306        if next_i == len(keys): 
     307            next_i = i 
     308        # If the save state is from a later version, skip the check 
     309        if model_version <= keys[next_i]: 
     310            newname = _conversion_target(name, version) 
     311        else: 
     312            newname = None 
     313        # If no conversion is found, move on 
     314        if newname is None: 
     315            newname = name 
     316            continue 
     317        if ':' in newname:   # core_shell_ellipsoid:1 
     318            model_info = load_model_info(newname[:-2]) 
     319            # Know the table exists and isn't multiplicity so grab it directly 
     320            # Can't use _get_translation_table since that will return the 'bare' 
     321            # version. 
     322            translation = CONVERSION_TABLE.get(version, {})[newname][1] 
     323        else: 
     324            model_info = load_model_info(newname) 
     325            translation = _get_translation_table(model_info, version) 
     326        newpars = _hand_convert(newname, newpars, version) 
     327        newpars = _convert_pars(newpars, translation) 
     328        # TODO: Still not convinced this is the best check 
     329        if not model_info.structure_factor and version == (3,1,2): 
     330            newpars = _rescale_sld(model_info, newpars, 1e6) 
     331        newpars.setdefault('scale', 1.0) 
     332        newpars.setdefault('background', 0.0) 
     333        if use_underscore: 
     334            newpars = _pd_to_underscores(newpars) 
     335        name = newname 
    308336    return newname, newpars 
    309  
    310337 
    311338# ========= BACKWARD CONVERSION sasmodels => sasview 3.x =========== 
  • sasmodels/sasview_model.py

    r64614ad rfe8ff99  
    5757    import sas.models 
    5858    from sasmodels.conversion_table import CONVERSION_TABLE 
    59     for new_name, conversion in CONVERSION_TABLE.items(): 
     59    for new_name, conversion in CONVERSION_TABLE.get((3,1,2), {}).items(): 
    6060        # CoreShellEllipsoidModel => core_shell_ellipsoid:1 
    6161        new_name = new_name.split(':')[0] 
    62         old_name = conversion[0] 
     62        old_name = conversion[0] if len(conversion) < 3 else conversion[2] 
    6363        module_attrs = {old_name: find_model(new_name)} 
    6464        ConstructedModule = type(old_name, (), module_attrs) 
  • sasmodels/generate.py

    r7fcdc9f r1e7b0db0  
    139139    square(x) = x*x 
    140140    cube(x) = x*x*x 
    141     sinc(x) = sin(x)/x, with sin(0)/0 -> 1 
     141    sas_sinx_x(x) = sin(x)/x, with sin(0)/0 -> 1 
    142142    all double precision constants must include the decimal point 
    143143    all double declarations may be converted to half, float, or long double 
  • sasmodels/kernel_header.c

    r218cdbc rdaeef4c  
    146146inline double square(double x) { return x*x; } 
    147147inline double cube(double x) { return x*x*x; } 
    148 inline double sinc(double x) { return x==0 ? 1.0 : sin(x)/x; } 
     148inline double sas_sinx_x(double x) { return x==0 ? 1.0 : sin(x)/x; } 
    149149 
    150 #if 0 
     150#if 1 
     151//think cos(theta) should be sin(theta) in new coords, RKH 11Jan2017 
    151152#define ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sn, cn) do { \ 
    152153    SINCOS(phi*M_PI_180, sn, cn); \ 
    153154    q = sqrt(qx*qx + qy*qy); \ 
    154     cn  = (q==0. ? 1.0 : (cn*qx + sn*qy)/q * cos(theta*M_PI_180));  \ 
     155    cn  = (q==0. ? 1.0 : (cn*qx + sn*qy)/q * sin(theta*M_PI_180));  \ 
    155156    sn = sqrt(1 - cn*cn); \ 
    156157    } while (0) 
  • sasmodels/kernel_template.c

    r0d6e865 r1e7b0db0  
    133133inline double square(double x) { return x*x; } 
    134134inline double cube(double x) { return x*x*x; } 
    135 inline double sinc(double x) { return x==0 ? 1.0 : sin(x)/x; } 
     135inline double sas_sinx_x(double x) { return x==0 ? 1.0 : sin(x)/x; } 
    136136 
    137137 
  • sasmodels/models/barbell.c

    r3a48772 r592343f  
    3333        const double t = Gauss76Z[i]*zm + zb; 
    3434        const double radical = 1.0 - t*t; 
    35         const double bj = sas_J1c(qrst*sqrt(radical)); 
     35        const double bj = sas_2J1x_x(qrst*sqrt(radical)); 
    3636        const double Fq = cos(m*t + b) * radical * bj; 
    3737        total += Gauss76Wt[i] * Fq; 
     
    4949{ 
    5050    const double bell_fq = _bell_kernel(q, h, radius_bell, half_length, sin_alpha, cos_alpha); 
    51     const double bj = sas_J1c(q*radius*sin_alpha); 
    52     const double si = sinc(q*half_length*cos_alpha); 
     51    const double bj = sas_2J1x_x(q*radius*sin_alpha); 
     52    const double si = sas_sinx_x(q*half_length*cos_alpha); 
    5353    const double cyl_fq = 2.0*M_PI*radius*radius*half_length*bj*si; 
    5454    const double Aq = bell_fq + cyl_fq; 
  • sasmodels/models/barbell.py

    r0d6e865 rfcb33e4  
    2020.. math:: 
    2121 
    22     I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 
     22    I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 
    2323 
    24 where the amplitude $A(q)$ is given as 
     24where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 
    2525 
    2626.. math:: 
    2727 
    2828    A(q) =&\ \pi r^2L 
    29         \frac{\sin\left(\tfrac12 qL\cos\theta\right)} 
    30              {\tfrac12 qL\cos\theta} 
    31         \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\ 
     29        \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 
     30             {\tfrac12 qL\cos\alpha} 
     31        \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 
    3232        &\ + 4 \pi R^3 \int_{-h/R}^1 dt 
    33         \cos\left[ q\cos\theta 
     33        \cos\left[ q\cos\alpha 
    3434            \left(Rt + h + {\tfrac12} L\right)\right] 
    3535        \times (1-t^2) 
    36         \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]} 
    37              {qR\sin\theta \left(1-t^2\right)^{1/2}} 
     36        \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 
     37             {qR\sin\alpha \left(1-t^2\right)^{1/2}} 
    3838 
    3939The $\left<\ldots\right>$ brackets denote an average of the structure over 
    40 all orientations. $\left<A^2(q)\right>$ is then the form factor, $P(q)$. 
     40all orientations. $\left<A^2(q,\alpha)\right>$ is then the form factor, $P(q)$. 
    4141The scale factor is equivalent to the volume fraction of cylinders, each of 
    4242volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length 
     
    8585* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8686* **Last Modified by:** Paul Butler **Date:** March 20, 2016 
    87 * **Last Reviewed by:** Paul Butler **Date:** March 20, 2016 
     87* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
    8888""" 
    8989from numpy import inf 
  • sasmodels/models/bcc_paracrystal.py

    rb0c4271 r925ad6e  
    128128# pylint: enable=bad-whitespace, line-too-long 
    129129 
    130 source = ["lib/sph_j1c.c", "lib/gauss150.c", "lib/sphere_form.c", "bcc_paracrystal.c"] 
     130source = ["lib/sas_3j1x_x.c", "lib/gauss150.c", "lib/sphere_form.c", "bcc_paracrystal.c"] 
    131131 
    132132# parameters for demo 
  • sasmodels/models/binary_hard_sphere.c

    r4f79d94 r925ad6e  
    5858    qr2 = r2*q; 
    5959 
    60     sc1 = sph_j1c(qr1); 
    61     sc2 = sph_j1c(qr2); 
     60    sc1 = sas_3j1x_x(qr1); 
     61    sc2 = sas_3j1x_x(qr2); 
    6262    b1 = r1*r1*r1*(rho1-rhos)*M_4PI_3*sc1; 
    6363    b2 = r2*r2*r2*(rho2-rhos)*M_4PI_3*sc2; 
  • sasmodels/models/binary_hard_sphere.py

    rb0c4271 r925ad6e  
    108108             ] 
    109109 
    110 source = ["lib/sph_j1c.c", "binary_hard_sphere.c"] 
     110source = ["lib/sas_3j1x_x.c", "binary_hard_sphere.c"] 
    111111 
    112112# parameters for demo and documentation 
  • sasmodels/models/capped_cylinder.c

    r3a48772 r592343f  
    3939        const double t = Gauss76Z[i]*zm + zb; 
    4040        const double radical = 1.0 - t*t; 
    41         const double bj = sas_J1c(qrst*sqrt(radical)); 
     41        const double bj = sas_2J1x_x(qrst*sqrt(radical)); 
    4242        const double Fq = cos(m*t + b) * radical * bj; 
    4343        total += Gauss76Wt[i] * Fq; 
     
    5454{ 
    5555    const double cap_Fq = _cap_kernel(q, h, radius_cap, half_length, sin_alpha, cos_alpha); 
    56     const double bj = sas_J1c(q*radius*sin_alpha); 
    57     const double si = sinc(q*half_length*cos_alpha); 
     56    const double bj = sas_2J1x_x(q*radius*sin_alpha); 
     57    const double si = sas_sinx_x(q*half_length*cos_alpha); 
    5858    const double cyl_Fq = 2.0*M_PI*radius*radius*half_length*bj*si; 
    5959    const double Aq = cap_Fq + cyl_Fq; 
  • sasmodels/models/capped_cylinder.py

    r0d6e865 rfcb33e4  
    2121.. math:: 
    2222 
    23     I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q)\right> 
     23    I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 
    2424 
    25 where the amplitude $A(q)$ is given as 
     25where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 
    2626 
    2727.. math:: 
    2828 
    2929    A(q) =&\ \pi r^2L 
    30         \frac{\sin\left(\tfrac12 qL\cos\theta\right)} 
    31             {\tfrac12 qL\cos\theta} 
    32         \frac{2 J_1(qr\sin\theta)}{qr\sin\theta} \\ 
     30        \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 
     31            {\tfrac12 qL\cos\alpha} 
     32        \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 
    3333        &\ + 4 \pi R^3 \int_{-h/R}^1 dt 
    34         \cos\left[ q\cos\theta 
     34        \cos\left[ q\cos\alpha 
    3535            \left(Rt + h + {\tfrac12} L\right)\right] 
    3636        \times (1-t^2) 
    37         \frac{J_1\left[qR\sin\theta \left(1-t^2\right)^{1/2}\right]} 
    38              {qR\sin\theta \left(1-t^2\right)^{1/2}} 
     37        \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 
     38             {qR\sin\alpha \left(1-t^2\right)^{1/2}} 
    3939 
    4040The $\left<\ldots\right>$ brackets denote an average of the structure over 
     
    8888* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8989* **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    90 * **Last Reviewed by:** Richard Heenan **Date:** March 19, 2016 
     90* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
     91 
    9192""" 
    9293from numpy import inf 
  • sasmodels/models/core_multi_shell.c

    rc5ac2b2 r925ad6e  
    33f_constant(double q, double r, double sld) 
    44{ 
    5   const double bes = sph_j1c(q * r); 
     5  const double bes = sas_3j1x_x(q * r); 
    66  const double vol = M_4PI_3 * cube(r); 
    77  return sld * vol * bes; 
     
    3333  f = 0.; 
    3434  for (int i=0; i<n; i++) { 
    35     f += M_4PI_3 * cube(r) * (sld[i] - last_sld) * sph_j1c(q*r); 
     35    f += M_4PI_3 * cube(r) * (sld[i] - last_sld) * sas_3j1x_x(q*r); 
    3636    last_sld = sld[i]; 
    3737    r += thickness[i]; 
    3838  } 
    39   f += M_4PI_3 * cube(r) * (solvent_sld - last_sld) * sph_j1c(q*r); 
     39  f += M_4PI_3 * cube(r) * (solvent_sld - last_sld) * sas_3j1x_x(q*r); 
    4040  return f * f * 1.0e-4; 
    4141} 
  • sasmodels/models/core_multi_shell.py

    r2d73a53 r925ad6e  
    101101             ] 
    102102 
    103 source = ["lib/sph_j1c.c", "core_multi_shell.c"] 
     103source = ["lib/sas_3j1x_x.c", "core_multi_shell.c"] 
    104104 
    105105def profile(sld_core, radius, sld_solvent, n, sld, thickness): 
  • sasmodels/models/core_shell_bicelle.c

    r5bddd89 r592343f  
    5555    double sinarg2 = qq*(length+facthick)*cos_alpha; 
    5656 
    57     be1 = sas_J1c(besarg1); 
    58     be2 = sas_J1c(besarg2); 
    59     si1 = sinc(sinarg1); 
    60     si2 = sinc(sinarg2); 
     57    be1 = sas_2J1x_x(besarg1); 
     58    be2 = sas_2J1x_x(besarg2); 
     59    si1 = sas_sinx_x(sinarg1); 
     60    si2 = sas_sinx_x(sinarg2); 
    6161 
    6262    const double t = vol1*dr1*si1*be1 + 
  • sasmodels/models/core_shell_bicelle.py

    ra23639a r3b9a526  
    4141 
    4242    I(Q,\alpha) = \frac{\text{scale}}{V_t} \cdot 
    43         F(Q,\alpha)^2 + \text{background} 
     43        F(Q,\alpha)^2.sin(\alpha) + \text{background} 
    4444 
    4545where 
     
    8585* **Author:** NIST IGOR/DANSE **Date:** pre 2010 
    8686* **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    87 * **Last Reviewed by:** Richard Heenan **Date:** October 5, 2016 
     87* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
    8888""" 
    8989 
     
    141141# pylint: enable=bad-whitespace, line-too-long 
    142142 
    143 source = ["lib/Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 
     143source = ["lib/sas_Si.c", "lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", 
    144144          "core_shell_bicelle.c"] 
    145145 
     
    156156            phi=0) 
    157157 
    158 qx, qy = 0.4 * cos(90), 0.5 * sin(0) 
     158#qx, qy = 0.4 * cos(pi/2.0), 0.5 * sin(0) 
  • sasmodels/models/core_shell_cylinder.c

    r9aa4881 r592343f  
    1111double _cyl(double vd, double besarg, double siarg) 
    1212{ 
    13     return vd * sinc(siarg) * sas_J1c(besarg); 
     13    return vd * sas_sinx_x(siarg) * sas_2J1x_x(besarg); 
    1414} 
    1515 
  • sasmodels/models/core_shell_cylinder.py

    r755ecc2 rfcb33e4  
    99.. math:: 
    1010 
    11     I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q) + \text{background} 
     11    I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background} 
    1212 
    1313where 
     
    1515.. math:: 
    1616 
    17     F(q) = &\ (\rho_c - \rho_s) V_c 
     17    F(q,\alpha) = &\ (\rho_c - \rho_s) V_c 
    1818           \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} 
    1919                {q \tfrac12 L\cos\alpha} 
  • sasmodels/models/core_shell_ellipsoid.py

    r73e08ae rdaeef4c  
    137137# pylint: enable=bad-whitespace, line-too-long 
    138138 
    139 source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", 
     139source = ["lib/sas_3j1x_x.c", "lib/gfn.c", "lib/gauss76.c", 
    140140          "core_shell_ellipsoid.c"] 
    141141 
     
    162162 
    163163q = 0.1 
    164 phi = pi/6 
    165 qx = q*cos(phi) 
    166 qy = q*sin(phi) 
    167 # After redefinition of angles find new reasonable values for unit test 
    168 #tests = [ 
    169 #    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
    170 #    [{'radius_equat_core': 200.0, 
    171 #      'x_core': 0.1, 
    172 #      'thick_shell': 50.0, 
    173 #      'x_polar_shell': 0.2, 
    174 #      'sld_core': 2.0, 
    175 #      'sld_shell': 1.0, 
    176 #      'sld_solvent': 6.3, 
    177 #      'background': 0.001, 
    178 #      'scale': 1.0, 
    179 #     }, 1.0, 0.00189402], 
     164# tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 
     165qx = q*cos(pi/6.0) 
     166qy = q*sin(pi/6.0) 
     167# 11Jan2017 RKH sorted tests after redefinition of angles 
     168tests = [ 
     169     # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
     170    [{'radius_equat_core': 200.0, 
     171      'x_core': 0.1, 
     172      'thick_shell': 50.0, 
     173      'x_polar_shell': 0.2, 
     174      'sld_core': 2.0, 
     175      'sld_shell': 1.0, 
     176      'sld_solvent': 6.3, 
     177      'background': 0.001, 
     178      'scale': 1.0, 
     179     }, 1.0, 0.00189402], 
    180180 
    181181    # Additional tests with larger range of parameters 
    182 #    [{'background': 0.01}, 0.1, 11.6915], 
    183  
    184 #    [{'radius_equat_core': 20.0, 
    185 #      'x_core': 200.0, 
    186 #      'thick_shell': 54.0, 
    187 #      'x_polar_shell': 3.0, 
    188 #      'sld_core': 20.0, 
    189 #      'sld_shell': 10.0, 
    190 #      'sld_solvent': 6.0, 
    191 #      'background': 0.0, 
    192 #      'scale': 1.0, 
    193 #     }, 0.01, 8688.53], 
    194  
    195 #   [{'background': 0.001}, (0.4, 0.5), 0.00690673], 
    196  
    197 #   [{'radius_equat_core': 20.0, 
    198 #      'x_core': 200.0, 
    199 #      'thick_shell': 54.0, 
    200 #      'x_polar_shell': 3.0, 
    201 #      'sld_core': 20.0, 
    202 #      'sld_shell': 10.0, 
    203 #      'sld_solvent': 6.0, 
    204 #      'background': 0.01, 
    205 #      'scale': 0.01, 
    206 #     }, (qx, qy), 0.0100002], 
    207 #    ] 
     182    [{'background': 0.01}, 0.1, 11.6915], 
     183 
     184    [{'radius_equat_core': 20.0, 
     185      'x_core': 200.0, 
     186      'thick_shell': 54.0, 
     187      'x_polar_shell': 3.0, 
     188      'sld_core': 20.0, 
     189      'sld_shell': 10.0, 
     190      'sld_solvent': 6.0, 
     191      'background': 0.0, 
     192      'scale': 1.0, 
     193     }, 0.01, 8688.53], 
     194 
     195   # 2D tests 
     196   [{'background': 0.001, 
     197     'theta': 90.0, 
     198     'phi': 0.0, 
     199     }, (0.4, 0.5), 0.00690673], 
     200 
     201   [{'radius_equat_core': 20.0, 
     202      'x_core': 200.0, 
     203      'thick_shell': 54.0, 
     204      'x_polar_shell': 3.0, 
     205      'sld_core': 20.0, 
     206      'sld_shell': 10.0, 
     207      'sld_solvent': 6.0, 
     208      'background': 0.01, 
     209      'scale': 0.01, 
     210      'theta': 90.0, 
     211      'phi': 0.0, 
     212     }, (qx, qy), 0.01000025], 
     213    ] 
  • sasmodels/models/core_shell_parallelepiped.c

    r14838a3 r1e7b0db0  
    8787            double sin_uu, cos_uu; 
    8888            SINCOS(M_PI_2*uu, sin_uu, cos_uu); 
    89             const double si1 = sinc(mu_proj * sin_uu * a_scaled); 
    90             const double si2 = sinc(mu_proj * cos_uu); 
    91             const double si3 = sinc(mu_proj * sin_uu * ta); 
    92             const double si4 = sinc(mu_proj * cos_uu * tb); 
     89            const double si1 = sas_sinx_x(mu_proj * sin_uu * a_scaled); 
     90            const double si2 = sas_sinx_x(mu_proj * cos_uu); 
     91            const double si3 = sas_sinx_x(mu_proj * sin_uu * ta); 
     92            const double si4 = sas_sinx_x(mu_proj * cos_uu * tb); 
    9393 
    9494            // Expression in libCylinder.c (neither drC nor Vot are used) 
     
    109109 
    110110        // now sum up the outer integral 
    111         const double si = sinc(mu * c_scaled * sigma); 
     111        const double si = sas_sinx_x(mu * c_scaled * sigma); 
    112112        outer_total += Gauss76Wt[i] * inner_total * si * si; 
    113113    } 
     
    160160    double tc = length_a + 2.0*thick_rim_c; 
    161161    //handle arg=0 separately, as sin(t)/t -> 1 as t->0 
    162     double siA = sinc(0.5*q*length_a*cos_val_a); 
    163     double siB = sinc(0.5*q*length_b*cos_val_b); 
    164     double siC = sinc(0.5*q*length_c*cos_val_c); 
    165     double siAt = sinc(0.5*q*ta*cos_val_a); 
    166     double siBt = sinc(0.5*q*tb*cos_val_b); 
    167     double siCt = sinc(0.5*q*tc*cos_val_c); 
     162    double siA = sas_sinx_x(0.5*q*length_a*cos_val_a); 
     163    double siB = sas_sinx_x(0.5*q*length_b*cos_val_b); 
     164    double siC = sas_sinx_x(0.5*q*length_c*cos_val_c); 
     165    double siAt = sas_sinx_x(0.5*q*ta*cos_val_a); 
     166    double siBt = sas_sinx_x(0.5*q*tb*cos_val_b); 
     167    double siCt = sas_sinx_x(0.5*q*tc*cos_val_c); 
    168168     
    169169 
  • sasmodels/models/core_shell_sphere.py

    r4962519 r925ad6e  
    7575# pylint: enable=bad-whitespace, line-too-long 
    7676 
    77 source = ["lib/sph_j1c.c", "lib/core_shell.c", "core_shell_sphere.c"] 
     77source = ["lib/sas_3j1x_x.c", "lib/core_shell.c", "core_shell_sphere.c"] 
    7878 
    7979demo = dict(scale=1, background=0, radius=60, thickness=10, 
  • sasmodels/models/cylinder.c

    rb829b16 r592343f  
    1818    const double qr = q*radius; 
    1919    const double qh = q*0.5*length;  
    20     return sas_J1c(qr*sn) * sinc(qh*cn); 
     20    return sas_2J1x_x(qr*sn) * sas_sinx_x(qh*cn); 
    2121} 
    2222 
  • sasmodels/models/cylinder.py

    r4cdd0cc rb7e8b94  
    22# Note: model title and parameter table are inserted automatically 
    33r""" 
    4 The form factor is normalized by the particle volume V = \piR^2L. 
     4 
    55For information about polarised and magnetic scattering, see 
    66the :ref:`magnetism` documentation. 
     
    1414.. math:: 
    1515 
    16     P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background} 
     16    P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha).sin(\alpha) + \text{background} 
    1717 
    1818where 
     
    2525           \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} 
    2626 
    27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V$ 
     27and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V =\pi R^2L$ 
    2828is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the 
    2929radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length 
     
    3535.. math:: 
    3636 
    37     F^2(q)=\int_{0}^{\pi/2}{F^2(q,\theta)\sin(\theta)d\theta} 
     37    F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}=\int_{0}^{1}{F^2(q,u)du} 
    3838 
    3939 
    40 To provide easy access to the orientation of the cylinder, we define the 
    41 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 
     40Numerical integration is simplified by a change of variable to $u = cos(\alpha)$ with  
     41$sin(\alpha)=\sqrt{1-u^2}$.  
     42 
     43The output of the 1D scattering intensity function for randomly oriented 
     44cylinders is thus given by 
     45 
     46.. math:: 
     47 
     48    P(q) = \frac{\text{scale}}{V} 
     49        \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 
     50 
     51 
     52NB: The 2nd virial coefficient of the cylinder is calculated based on the 
     53radius and length values, and used as the effective radius for $S(q)$ 
     54when $P(q) \cdot S(q)$ is applied. 
     55 
     56For oriented cylinders, we define the direction of the 
     57axis of the cylinder using two angles $\theta$ (note this is not the 
     58same as the scattering angle used in q) and $\phi$. Those angles 
    4259are defined in :numref:`cylinder-angle-definition` . 
    4360 
     
    4865    Definition of the angles for oriented cylinders. 
    4966 
    50  
    51 NB: The 2nd virial coefficient of the cylinder is calculated based on the 
    52 radius and length values, and used as the effective radius for $S(q)$ 
    53 when $P(q) \cdot S(q)$ is applied. 
    54  
    55 The output of the 1D scattering intensity function for randomly oriented 
    56 cylinders is then given by 
    57  
    58 .. math:: 
    59  
    60     P(q) = \frac{\text{scale}}{V} 
    61         \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 
    62  
    63 The $\theta$ and $\phi$ parameters are not used for the 1D output. 
     67The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 
    6468 
    6569Validation 
     
    7478 
    7579    P(q) = \int_0^{\pi/2} d\phi 
    76         \int_0^\pi p(\alpha) P_0(q,\alpha) \sin \alpha\ d\alpha 
     80        \int_0^\pi p(\theta) P_0(q,\theta) \sin \theta\ d\theta 
    7781 
    7882 
    7983where $p(\theta,\phi) = 1$ is the probability distribution for the orientation 
    80 and $P_0(q,\alpha)$ is the scattering intensity for the fully oriented 
     84and $P_0(q,\theta)$ is the scattering intensity for the fully oriented 
    8185system, and then comparing to the 1D result. 
    8286 
     
    145149 
    146150qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    147 # After redefinition of angles, find new tests values  
    148 #tests = [[{}, 0.2, 0.042761386790780453], 
    149 #         [{}, [0.2], [0.042761386790780453]], 
    150 #         [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
    151 #         [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
    152 #        ] 
     151# After redefinition of angles, find new tests values.  Was 10 10 in old coords 
     152tests = [[{}, 0.2, 0.042761386790780453], 
     153        [{}, [0.2], [0.042761386790780453]], 
     154#  new coords     
     155        [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
     156        [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
     157# old coords   [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
     158#              [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
     159        ] 
    153160del qx, qy  # not necessary to delete, but cleaner 
    154161# ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc 
  • sasmodels/models/ellipsoid.c

    r73e08ae r925ad6e  
    1818    const double r = radius_equatorial 
    1919                     * sqrt(1.0 + sin_alpha*sin_alpha*(ratio*ratio - 1.0)); 
    20     const double f = sph_j1c(q*r); 
     20    const double f = sas_3j1x_x(q*r); 
    2121 
    2222    return f*f; 
  • sasmodels/models/ellipsoid.py

    r0d6e865 r925ad6e  
    135135             ] 
    136136 
    137 source = ["lib/sph_j1c.c", "lib/gauss76.c", "ellipsoid.c"] 
     137source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "ellipsoid.c"] 
    138138 
    139139def ER(radius_polar, radius_equatorial): 
  • sasmodels/models/elliptical_cylinder.c

    r251f54b r592343f  
    3939            const double theta = ( Gauss20Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 
    4040            const double r = sin_val*sqrt(rA - rB*cos(theta)); 
    41             const double be = sas_J1c(q*r); 
     41            const double be = sas_2J1x_x(q*r); 
    4242            inner_sum += Gauss20Wt[j] * be * be; 
    4343        } 
     
    4646 
    4747        //now calculate outer integral 
    48         const double si = sinc(q*0.5*length*cos_val); 
     48        const double si = sas_sinx_x(q*0.5*length*cos_val); 
    4949        outer_sum += Gauss76Wt[i] * inner_sum * si * si; 
    5050    } 
     
    7373    // Given:    radius_major = r_ratio * radius_minor 
    7474    const double r = radius_minor*sqrt(square(r_ratio*cos_nu) + cos_mu*cos_mu); 
    75     const double be = sas_J1c(q*r); 
    76     const double si = sinc(q*0.5*length*cos_val); 
     75    const double be = sas_2J1x_x(q*r); 
     76    const double si = sas_sinx_x(q*0.5*length*cos_val); 
    7777    const double Aq = be * si; 
    7878    const double delrho = sld - solvent_sld; 
  • sasmodels/models/elliptical_cylinder.py

    ra807206 rfcb33e4  
    2020 
    2121    I(\vec q)=\frac{1}{V_\text{cyl}}\int{d\psi}\int{d\phi}\int{ 
    22         p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\theta)d\theta} 
     22        p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\alpha)d\alpha} 
    2323 
    2424with the functions 
     
    2626.. math:: 
    2727 
    28     F(\vec q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
     28    F(q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 
    2929 
    3030where 
     
    3232.. math:: 
    3333 
    34     a &= \vec q\sin(\alpha)\left[ 
    35         r^2_\text{major}\sin^2(\psi)+r^2_\text{minor}\cos(\psi) \right]^{1/2} 
     34    a = qr'\sin(\alpha) 
     35     
     36    b = q\frac{L}{2}\cos(\alpha) 
     37     
     38    r'=\frac{r_{minor}}{\sqrt{2}}\sqrt{(1+\nu^{2}) + (1-\nu^{2})cos(\psi)} 
    3639 
    37     b &= \vec q\frac{L}{2}\cos(\alpha) 
    3840 
    39 and the angle $\Psi$ is defined as the orientation of the major axis of the 
     41and the angle $\psi$ is defined as the orientation of the major axis of the 
    4042ellipse with respect to the vector $\vec q$. The angle $\alpha$ is the angle 
    4143between the axis of the cylinder and $\vec q$. 
     
    9597 
    9698L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    97 Neutron Scattering*, Plenum, New York, (1987) 
     99Neutron Scattering*, Plenum, New York, (1987) [see table 3.4] 
     100 
     101Authorship and Verification 
     102---------------------------- 
     103 
     104* **Author:** 
     105* **Last Modified by:**  
     106* **Last Reviewed by:**  Richard Heenan - corrected equation in docs **Date:** December 21, 2016 
     107 
    98108""" 
    99109 
  • sasmodels/models/fcc_paracrystal.py

    r0bef47b r925ad6e  
    116116# pylint: enable=bad-whitespace, line-too-long 
    117117 
    118 source = ["lib/sph_j1c.c", "lib/gauss150.c", "lib/sphere_form.c", "fcc_paracrystal.c"] 
     118source = ["lib/sas_3j1x_x.c", "lib/gauss150.c", "lib/sphere_form.c", "fcc_paracrystal.c"] 
    119119 
    120120# parameters for demo 
  • sasmodels/models/flexible_cylinder.c

    r4937980 r592343f  
    1414{ 
    1515    const double contrast = sld - solvent_sld; 
    16     const double cross_section = sas_J1c(q*radius); 
     16    const double cross_section = sas_2J1x_x(q*radius); 
    1717    const double volume = M_PI*radius*radius*length; 
    1818    const double flex = Sk_WR(q, length, kuhn_length); 
  • sasmodels/models/flexible_cylinder_elliptical.c

    r92ce163 r592343f  
    2222        SINCOS(zi, sn, cn); 
    2323        const double arg = q*sqrt(a*a*sn*sn + b*b*cn*cn); 
    24         const double yyy = sas_J1c(arg); 
     24        const double yyy = sas_2J1x_x(arg); 
    2525        sum += Gauss76Wt[i] * yyy * yyy; 
    2626    } 
  • sasmodels/models/fractal.c

    r217590b r925ad6e  
    1414    //calculate P(q) for the spherical subunits 
    1515    const double V = M_4PI_3*cube(radius); 
    16     const double pq = V * square((sld_block-sld_solvent)*sph_j1c(q*radius)); 
     16    const double pq = V * square((sld_block-sld_solvent)*sas_3j1x_x(q*radius)); 
    1717 
    1818    // scale to units cm-1 sr-1 (assuming data on absolute scale) 
  • sasmodels/models/fractal.py

    rfef353f r925ad6e  
    9797# pylint: enable=bad-whitespace, line-too-long 
    9898 
    99 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/fractal_sq.c", "fractal.c"] 
     99source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/fractal_sq.c", "fractal.c"] 
    100100 
    101101demo = dict(volfraction=0.05, 
  • sasmodels/models/fractal_core_shell.py

    rd6f60c3 r925ad6e  
    9595# pylint: enable=bad-whitespace, line-too-long 
    9696 
    97 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "lib/core_shell.c", 
     97source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "lib/core_shell.c", 
    9898          "lib/fractal_sq.c", "fractal_core_shell.c"] 
    9999 
  • sasmodels/models/fuzzy_sphere.py

    r3a48772 r925ad6e  
    8181# pylint: enable=bad-whitespace,line-too-long 
    8282 
    83 source = ["lib/sph_j1c.c"] 
     83source = ["lib/sas_3j1x_x.c"] 
    8484 
    8585# No volume normalization despite having a volume parameter 
     
    9191Iq = """ 
    9292    const double qr = q*radius; 
    93     const double bes = sph_j1c(qr); 
     93    const double bes = sas_3j1x_x(qr); 
    9494    const double qf = q*fuzziness; 
    9595    const double fq = bes * (sld - sld_solvent) * form_volume(radius) * exp(-0.5*qf*qf); 
  • sasmodels/models/guinier_porod.py

    ra807206 rcdcebf1  
    44and dimensionality of scattering objects, including asymmetric objects 
    55such as rods or platelets, and shapes intermediate between spheres 
    6 and rods or between rods and platelets. 
     6and rods or between rods and platelets, and overcomes some of the  
     7deficiencies of the (Beaucage) Unified_Power_Rg model (see Hammouda, 2010). 
    78 
    89Definition 
     
    5960--------- 
    6061 
    61 A Guinier, G Fournet, *Small-Angle Scattering of X-Rays*, 
    62 John Wiley and Sons, New York, (1955) 
     62B Hammouda, *A new Guinier-Porod model, J. Appl. Cryst.*, (2010), 43, 716-719 
    6363 
    64 O Glatter, O Kratky, *Small-Angle X-Ray Scattering*, Academic Press (1982) 
    65 Check out Chapter 4 on Data Treatment, pages 155-156. 
     64B Hammouda, *Analysis of the Beaucage model, J. Appl. Cryst.*, (2010), 43, 1474-1478 
     65 
    6666""" 
    6767 
  • sasmodels/models/hollow_cylinder.c

    rf8f0991 r592343f  
    2020{ 
    2121    const double qs = q*sin_val; 
    22     const double lam1 = sas_J1c((radius+thickness)*qs); 
    23     const double lam2 = sas_J1c(radius*qs); 
     22    const double lam1 = sas_2J1x_x((radius+thickness)*qs); 
     23    const double lam2 = sas_2J1x_x(radius*qs); 
    2424    const double gamma_sq = square(radius/(radius+thickness)); 
    25     //Note: lim_{thickness -> 0} psi = J0(radius*qs) 
    26     //Note: lim_{radius -> 0} psi = sas_J1c(thickness*qs) 
     25    //Note: lim_{thickness -> 0} psi = sas_J0(radius*qs) 
     26    //Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qs) 
    2727    const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 
    28     const double t2 = sinc(0.5*q*length*cos_val); 
     28    const double t2 = sas_sinx_x(0.5*q*length*cos_val); 
    2929    return psi*t2; 
    3030} 
  • sasmodels/models/hollow_rectangular_prism.c

    r6f676fb r1e7b0db0  
    4545        SINCOS(theta, sin_theta, cos_theta); 
    4646 
    47         const double termC1 = sinc(q * c_half * cos(theta)); 
    48         const double termC2 = sinc(q * (c_half-thickness)*cos(theta)); 
     47        const double termC1 = sas_sinx_x(q * c_half * cos(theta)); 
     48        const double termC2 = sas_sinx_x(q * (c_half-thickness)*cos(theta)); 
    4949 
    5050        double inner_sum = 0.0; 
     
    5757            // Amplitude AP from eqn. (13), rewritten to avoid round-off effects when arg=0 
    5858 
    59             const double termA1 = sinc(q * a_half * sin_theta * sin_phi); 
    60             const double termA2 = sinc(q * (a_half-thickness) * sin_theta * sin_phi); 
     59            const double termA1 = sas_sinx_x(q * a_half * sin_theta * sin_phi); 
     60            const double termA2 = sas_sinx_x(q * (a_half-thickness) * sin_theta * sin_phi); 
    6161 
    62             const double termB1 = sinc(q * b_half * sin_theta * cos_phi); 
    63             const double termB2 = sinc(q * (b_half-thickness) * sin_theta * cos_phi); 
     62            const double termB1 = sas_sinx_x(q * b_half * sin_theta * cos_phi); 
     63            const double termB2 = sas_sinx_x(q * (b_half-thickness) * sin_theta * cos_phi); 
    6464 
    6565            const double AP1 = vol_total * termA1 * termB1 * termC1; 
  • sasmodels/models/lib/core_shell.c

    r3a48772 r925ad6e  
    1616    const double core_qr = q * radius; 
    1717    const double core_contrast = core_sld - shell_sld; 
    18     const double core_bes = sph_j1c(core_qr); 
     18    const double core_bes = sas_3j1x_x(core_qr); 
    1919    const double core_volume = M_4PI_3 * cube(radius); 
    2020    double f = core_volume * core_bes * core_contrast; 
     
    2323    const double shell_qr = q * (radius + thickness); 
    2424    const double shell_contrast = shell_sld - solvent_sld; 
    25     const double shell_bes = sph_j1c(shell_qr); 
     25    const double shell_bes = sas_3j1x_x(shell_qr); 
    2626    const double shell_volume = M_4PI_3 * cube(radius + thickness); 
    2727    f += shell_volume * shell_bes * shell_contrast; 
  • sasmodels/models/lib/gfn.c

    r3a48772 r925ad6e  
    1818    // changing to more accurate sph_j1c since the following inexplicably fails on Radeon Nano. 
    1919    //const double siq = (uq == 0.0 ? 1.0 : 3.0*(sin(uq)/uq/uq - cos(uq)/uq)/uq); 
    20     const double siq = sph_j1c(uq); 
     20    const double siq = sas_3j1x_x(uq); 
    2121    const double vc = M_4PI_3*aa*aa*bb; 
    2222    const double gfnc = siq*vc*delpc; 
     
    2626    const double vt = M_4PI_3*trmaj*trmaj*trmin; 
    2727    //const double sit = (ut == 0.0 ? 1.0 : 3.0*(sin(ut)/ut/ut - cos(ut)/ut)/ut); 
    28     const double sit = sph_j1c(ut); 
     28    const double sit = sas_3j1x_x(ut); 
    2929    const double gfnt = sit*vt*delps; 
    3030 
  • sasmodels/models/lib/polevl.c

    r0278e3f r447e9aa  
    2828 *            N                   0 
    2929 * 
    30  *  The function p1evl() assumes that coef[N] = 1.0 and is 
     30 * The function p1evl() assumes that C_N = 1.0 and is 
    3131 * omitted from the array.  Its calling arguments are 
    3232 * otherwise the same as polevl(). 
  • sasmodels/models/lib/sas_3j1x_x.c

    rba32cdd r473a9f1  
    77* using double precision that are the source. 
    88*/ 
    9 double sph_j1c(double q); 
     9double sas_3j1x_x(double q); 
    1010 
    1111// The choice of the number of terms in the series and the cutoff value for 
     
    4444#endif 
    4545 
    46 double sph_j1c(double q) 
     46double sas_3j1x_x(double q) 
    4747{ 
    4848    if (q < SPH_J1C_CUTOFF) { 
  • sasmodels/models/lib/sas_J0.c

    r1596de3 rc8902ac  
    5555#if FLOAT_SIZE>4 
    5656//Cephes double precission 
    57 double j0(double x); 
     57double cephes_j0(double x); 
    5858 
    5959 constant double PPJ0[8] = { 
     
    147147  }; 
    148148 
    149 double j0(double x) 
     149double cephes_j0(double x) 
    150150{ 
    151151    double w, z, p, q, xn; 
     
    186186#else 
    187187//Cephes single precission 
    188 float j0f(float x); 
     188float cephes_j0f(float x); 
    189189 
    190190 constant float MOJ0[8] = { 
     
    221221 }; 
    222222 
    223 float j0f(float x) 
     223float cephes_j0f(float x) 
    224224{ 
    225225    float xx, w, z, p, q, xn; 
     
    257257 
    258258#if FLOAT_SIZE>4 
    259 #define sas_J0 j0 
     259#define sas_J0 cephes_j0 
    260260#else 
    261 #define sas_J0 j0f 
     261#define sas_J0 cephes_j0f 
    262262#endif 
  • sasmodels/models/lib/sas_J1.c

    r1596de3 r473a9f1  
    4242#if FLOAT_SIZE>4 
    4343//Cephes double pression function 
    44 double j1(double x); 
     44double cephes_j1(double x); 
    4545 
    4646constant double RPJ1[8] = { 
     
    106106    0.0 }; 
    107107 
    108 double j1(double x) 
     108double cephes_j1(double x) 
    109109{ 
    110110 
     
    144144#else 
    145145//Single precission version of cephes 
    146 float j1f(float x); 
     146float cephes_j1f(float x); 
    147147 
    148148constant float JPJ1[8] = { 
     
    179179    }; 
    180180 
    181 float j1f(float x) 
     181float cephes_j1f(float x) 
    182182{ 
    183183 
     
    211211 
    212212#if FLOAT_SIZE>4 
    213 #define sas_J1 j1 
     213#define sas_J1 cephes_j1 
    214214#else 
    215 #define sas_J1 j1f 
     215#define sas_J1 cephes_j1f 
    216216#endif 
    217217 
    218218//Finally J1c function that equals 2*J1(x)/x 
    219 double sas_J1c(double x); 
    220 double sas_J1c(double x) 
     219double sas_2J1x_x(double x); 
     220double sas_2J1x_x(double x) 
    221221{ 
    222222    return (x != 0.0 ) ? 2.0*sas_J1(x)/x : 1.0; 
  • sasmodels/models/lib/sas_JN.c

    r1596de3 rc8902ac  
    5050#if FLOAT_SIZE > 4 
    5151 
    52 double jn( int n, double x ); 
    53 double jn( int n, double x ) { 
     52double cephes_jn( int n, double x ); 
     53double cephes_jn( int n, double x ) { 
    5454 
    5555    // PAK: seems to be machine epsilon/2 
     
    7575 
    7676    if( n == 0 ) 
    77         return( sign * j0(x) ); 
     77        return( sign * cephes_j0(x) ); 
    7878    if( n == 1 ) 
    79         return( sign * j1(x) ); 
     79        return( sign * cephes_j1(x) ); 
    8080    if( n == 2 ) 
    81         return( sign * (2.0 * j1(x) / x  -  j0(x)) ); 
     81        return( sign * (2.0 * cephes_j1(x) / x  -  cephes_j0(x)) ); 
    8282 
    8383    if( x < MACHEP ) 
     
    112112 
    113113    if( fabs(pk) > fabs(pkm1) ) 
    114         ans = j1(x)/pk; 
     114        ans = cephes_j1(x)/pk; 
    115115    else 
    116         ans = j0(x)/pkm1; 
     116        ans = cephes_j0(x)/pkm1; 
    117117 
    118118    return( sign * ans ); 
     
    121121#else 
    122122 
    123 float jnf(int n, float x); 
    124 float jnf(int n, float x) 
     123float cephes_jnf(int n, float x); 
     124float cephes_jnf(int n, float x) 
    125125{ 
    126126    // PAK: seems to be machine epsilon/2 
     
    146146 
    147147    if( n == 0 ) 
    148         return( sign * j0f(x) ); 
     148        return( sign * cephes_j0f(x) ); 
    149149    if( n == 1 ) 
    150         return( sign * j1f(x) ); 
     150        return( sign * cephes_j1f(x) ); 
    151151    if( n == 2 ) 
    152         return( sign * (2.0 * j1f(x) / x  -  j0f(x)) ); 
     152        return( sign * (2.0 * cephes_j1f(x) / x  -  cephes_j0f(x)) ); 
    153153 
    154154    if( x < MACHEP ) 
     
    189189 
    190190    if( r > ans )  /* if( fabs(pk) > fabs(pkm1) ) */ 
    191         ans = sign * j1f(x)/pk; 
     191        ans = sign * cephes_j1f(x)/pk; 
    192192    else 
    193         ans = sign * j0f(x)/pkm1; 
     193        ans = sign * cephes_j0f(x)/pkm1; 
    194194    return( ans ); 
    195195} 
     
    197197 
    198198#if FLOAT_SIZE>4 
    199 #define sas_JN jn 
     199#define sas_JN cephes_jn 
    200200#else 
    201 #define sas_JN jnf 
     201#define sas_JN cephes_jnf 
    202202#endif 
  • sasmodels/models/lib/sas_Si.c

    rf719764 r473a9f1  
    11// integral of sin(x)/x Taylor series approximated to w/i 0.1% 
    2 double Si(double x); 
    3 double Si(double x) 
     2double sas_Si(double x); 
     3double sas_Si(double x) 
    44{ 
    55    if (x >= M_PI*6.2/4.0) { 
  • sasmodels/models/lib/sphere_form.c

    rba32cdd r925ad6e  
    99double sphere_form(double q, double radius, double sld, double solvent_sld) 
    1010{ 
    11     const double fq = sphere_volume(radius) * sph_j1c(q*radius); 
     11    const double fq = sphere_volume(radius) * sas_3j1x_x(q*radius); 
    1212    const double contrast = (sld - solvent_sld); 
    1313    return 1.0e-4*square(contrast * fq); 
  • sasmodels/models/linear_pearls.c

    r4962519 r925ad6e  
    4444 
    4545    //sine functions of a pearl 
    46     double psi = sph_j1c(q * radius); 
     46    double psi = sas_3j1x_x(q * radius); 
    4747 
    4848    // N pearls contribution 
     
    5050    n_contrib = num_pearls; 
    5151    for(int num=1; num<=n_max; num++) { 
    52         n_contrib += (2.0*(num_pearls-num)*sinc(q*separation*num)); 
     52        n_contrib += (2.0*(num_pearls-num)*sas_sinx_x(q*separation*num)); 
    5353    } 
    5454    // form factor for num_pearls 
  • sasmodels/models/linear_pearls.py

    r4962519 r925ad6e  
    6363single = False 
    6464 
    65 source = ["lib/sph_j1c.c", "linear_pearls.c"] 
     65source = ["lib/sas_3j1x_x.c", "linear_pearls.c"] 
    6666 
    6767demo = dict(scale=1.0, background=0.0, 
  • sasmodels/models/mass_fractal.c

    r6d96b66 r925ad6e  
    55{ 
    66    //calculate P(q) 
    7     const double pq = square(sph_j1c(q*radius)); 
     7    const double pq = square(sas_3j1x_x(q*radius)); 
    88 
    99    //calculate S(q) 
  • sasmodels/models/mass_fractal.py

    r6d96b66 r925ad6e  
    8686# pylint: enable=bad-whitespace, line-too-long 
    8787 
    88 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "mass_fractal.c"] 
     88source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "mass_fractal.c"] 
    8989 
    9090demo = dict(scale=1, background=0, 
  • sasmodels/models/multilayer_vesicle.c

    r3a48772 r925ad6e  
    2020        // layer 1 
    2121        voli = M_4PI_3*ri*ri*ri; 
    22         fval += voli*sldi*sph_j1c(ri*q); 
     22        fval += voli*sldi*sas_3j1x_x(ri*q); 
    2323 
    2424        ri += thick_shell; 
     
    2626        // layer 2 
    2727        voli = M_4PI_3*ri*ri*ri; 
    28         fval -= voli*sldi*sph_j1c(ri*q); 
     28        fval -= voli*sldi*sas_3j1x_x(ri*q); 
    2929 
    3030        //do 2 layers at a time 
  • sasmodels/models/multilayer_vesicle.py

    r041bc75 r925ad6e  
    107107# pylint: enable=bad-whitespace, line-too-long 
    108108 
    109 source = ["lib/sph_j1c.c", "multilayer_vesicle.c"] 
     109source = ["lib/sas_3j1x_x.c", "multilayer_vesicle.c"] 
    110110 
    111111polydispersity = ["radius", "n_pairs"] 
  • sasmodels/models/onion.c

    r9762341 r925ad6e  
    66  const double vol = M_4PI_3 * cube(r); 
    77  const double qr = q * r; 
    8   const double bes = sph_j1c(qr); 
     8  const double bes = sas_3j1x_x(qr); 
    99  const double alpha = A * r/thickness; 
    1010  double result; 
  • sasmodels/models/onion.py

    r9762341 r925ad6e  
    314314# pylint: enable=bad-whitespace, line-too-long 
    315315 
    316 source = ["lib/sph_j1c.c", "onion.c"] 
     316source = ["lib/sas_3j1x_x.c", "onion.c"] 
    317317single = False 
    318318 
  • sasmodels/models/parallelepiped.c

    r14838a3 r1e7b0db0  
    3939            double sin_uu, cos_uu; 
    4040            SINCOS(M_PI_2*uu, sin_uu, cos_uu); 
    41             const double si1 = sinc(mu_proj * sin_uu * a_scaled); 
    42             const double si2 = sinc(mu_proj * cos_uu); 
     41            const double si1 = sas_sinx_x(mu_proj * sin_uu * a_scaled); 
     42            const double si2 = sas_sinx_x(mu_proj * cos_uu); 
    4343            inner_total += Gauss76Wt[j] * square(si1 * si2); 
    4444        } 
    4545        inner_total *= 0.5; 
    4646 
    47         const double si = sinc(mu * c_scaled * sigma); 
     47        const double si = sas_sinx_x(mu * c_scaled * sigma); 
    4848        outer_total += Gauss76Wt[i] * inner_total * si * si; 
    4949    } 
     
    7070    ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, cos_val_c, cos_val_b, cos_val_a); 
    7171 
    72     const double siA = sinc(0.5*q*length_a*cos_val_a); 
    73     const double siB = sinc(0.5*q*length_b*cos_val_b); 
    74     const double siC = sinc(0.5*q*length_c*cos_val_c); 
     72    const double siA = sas_sinx_x(0.5*q*length_a*cos_val_a); 
     73    const double siB = sas_sinx_x(0.5*q*length_b*cos_val_b); 
     74    const double siC = sas_sinx_x(0.5*q*length_c*cos_val_c); 
    7575    const double V = form_volume(length_a, length_b, length_c); 
    7676    const double drho = (sld - solvent_sld); 
  • sasmodels/models/pearl_necklace.c

    r2126131 r4b541ac  
    3434    // But there is a 1/(1-sinc) term below which blows up so don't bother 
    3535    const double q_edge = q * edge_sep; 
    36     const double beta = (Si(q*(A_s-radius)) - Si(q*radius)) / q_edge; 
    37     const double gamma = Si(q_edge) / q_edge; 
    38     const double psi = sph_j1c(q*radius); 
     36    const double beta = (sas_Si(q*(A_s-radius)) - sas_Si(q*radius)) / q_edge; 
     37    const double gamma = sas_Si(q_edge) / q_edge; 
     38    const double psi = sas_3j1x_x(q*radius); 
    3939 
    4040    // Precomputed sinc terms 
    41     const double si = sinc(q*A_s); 
     41    const double si = sas_sinx_x(q*A_s); 
    4242    const double omsi = 1.0 - si; 
    4343    const double pow_si = pow(si, num_pearls); 
     
    5454        - 2.0 * (1.0 - pow_si/si)*beta*beta / (omsi*omsi) 
    5555        + 2.0 * num_strings*beta*beta / omsi 
    56         + num_strings * (2.0*gamma - square(sinc(q_edge/2.0))) 
     56        + num_strings * (2.0*gamma - square(sas_sinx_x(q_edge/2.0))) 
    5757        ); 
    5858 
  • sasmodels/models/pearl_necklace.py

    r2126131 r4b541ac  
    9292             ] 
    9393 
    94 source = ["lib/Si.c", "lib/sph_j1c.c", "pearl_necklace.c"] 
     94source = ["lib/sas_Si.c", "lib/sas_3j1x_x.c", "pearl_necklace.c"] 
    9595single = False  # use double precision unless told otherwise 
    9696 
  • sasmodels/models/polymer_micelle.c

    rc3ebc71 r925ad6e  
    3131 
    3232    // Self-correlation term of the core 
    33     const double bes_core = sph_j1c(q*radius_core); 
     33    const double bes_core = sas_3j1x_x(q*radius_core); 
    3434    const double term1 = square(n_aggreg*beta_core*bes_core); 
    3535 
     
    4141    // Interference cross-term between core and chains 
    4242    const double chain_ampl = (qrg2 == 0.0) ? 1.0 : -expm1(-qrg2)/qrg2; 
    43     const double bes_corona = sinc(q*(radius_core + d_penetration * rg)); 
     43    const double bes_corona = sas_sinx_x(q*(radius_core + d_penetration * rg)); 
    4444    const double term3 = 2.0 * n_aggreg * n_aggreg * beta_core * beta_corona * 
    4545                 bes_core * chain_ampl * bes_corona; 
  • sasmodels/models/polymer_micelle.py

    rbba9361 r925ad6e  
    104104single = False 
    105105 
    106 source = ["lib/sph_j1c.c", "polymer_micelle.c"] 
     106source = ["lib/sas_3j1x_x.c", "polymer_micelle.c"] 
    107107 
    108108demo = dict(scale=1, background=0, 
  • sasmodels/models/pringle.c

    r30fbe2e r1e7b0db0  
    9191        SINCOS(psi, sin_psi, cos_psi); 
    9292        double bessel_term = _sum_bessel_orders(radius, alpha, beta, q*sin_psi, q*cos_psi); 
    93         double sinc_term = square(sinc(q * thickness * cos_psi / 2.0)); 
     93        double sinc_term = square(sas_sinx_x(q * thickness * cos_psi / 2.0)); 
    9494        double pringle_kernel = 4.0 * sin_psi * bessel_term * sinc_term; 
    9595        sum += Gauss76Wt[i] * pringle_kernel; 
  • sasmodels/models/raspberry.c

    r2c74c11 r925ad6e  
    5151 
    5252    //Form factors for each particle 
    53     psiL = sph_j1c(q*rL); 
    54     psiS = sph_j1c(q*rS); 
     53    psiL = sas_3j1x_x(q*rL); 
     54    psiS = sas_3j1x_x(q*rS); 
    5555 
    5656    //Cross term between large and small particles 
    57     sfLS = psiL*psiS*sinc(q*(rL+deltaS*rS)); 
     57    sfLS = psiL*psiS*sas_sinx_x(q*(rL+deltaS*rS)); 
    5858    //Cross term between small particles at the surface 
    59     sfSS = psiS*psiS*sinc(q*(rL+deltaS*rS))*sinc(q*(rL+deltaS*rS)); 
     59    sfSS = psiS*psiS*sas_sinx_x(q*(rL+deltaS*rS))*sas_sinx_x(q*(rL+deltaS*rS)); 
    6060 
    6161    //Large sphere form factor term 
  • sasmodels/models/raspberry.py

    r40a87fa r8e68ea0  
    129129            Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.""" 
    130130category = "shape:sphere" 
    131 #single = False 
     131 
    132132 
    133133#             [ "name", "units", default, [lower, upper], "type", "description"], 
     
    152152             ] 
    153153 
    154 source = ["lib/sph_j1c.c", "raspberry.c"] 
     154source = ["lib/sas_3j1x_x.c", "raspberry.c"] 
    155155 
    156156# parameters for demo 
  • sasmodels/models/rectangular_prism.c

    rab2aea8 r1e7b0db0  
    3333        SINCOS(theta, sin_theta, cos_theta); 
    3434 
    35         const double termC = sinc(q * c_half * cos_theta); 
     35        const double termC = sas_sinx_x(q * c_half * cos_theta); 
    3636 
    3737        double inner_sum = 0.0; 
     
    4242 
    4343            // Amplitude AP from eqn. (12), rewritten to avoid round-off effects when arg=0 
    44             const double termA = sinc(q * a_half * sin_theta * sin_phi); 
    45             const double termB = sinc(q * b_half * sin_theta * cos_phi); 
     44            const double termA = sas_sinx_x(q * a_half * sin_theta * sin_phi); 
     45            const double termB = sas_sinx_x(q * b_half * sin_theta * cos_phi); 
    4646            const double AP = termA * termB * termC; 
    4747            inner_sum += Gauss76Wt[j] * AP * AP; 
  • sasmodels/models/sc_paracrystal.py

    r0bef47b r925ad6e  
    133133# pylint: enable=bad-whitespace, line-too-long 
    134134 
    135 source = ["lib/sph_j1c.c", "lib/sphere_form.c", "lib/gauss150.c", "sc_paracrystal.c"] 
     135source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c", "lib/gauss150.c", "sc_paracrystal.c"] 
    136136 
    137137demo = dict(scale=1, background=0, 
  • sasmodels/models/sphere.py

    r7e6bea81 r925ad6e  
    6666             ] 
    6767 
    68 source = ["lib/sph_j1c.c", "lib/sphere_form.c"] 
     68source = ["lib/sas_3j1x_x.c", "lib/sphere_form.c"] 
    6969 
    7070# No volume normalization despite having a volume parameter 
  • sasmodels/models/spherical_sld.c

    r54bcd4a r925ad6e  
    3434    const double qr = q * r; 
    3535    const double qrsq = qr * qr; 
    36     const double bes = sph_j1c(qr); 
     36    const double bes = sas_3j1x_x(qr); 
    3737    double sinqr, cosqr; 
    3838    SINCOS(qr, sinqr, cosqr); 
     
    6060 
    6161        // uniform shell; r=0 => r^3=0 => f=0, so works for core as well. 
    62         f -= M_4PI_3 * cube(r) * sld_l * sph_j1c(q*r); 
     62        f -= M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 
    6363        r += thickness[shell]; 
    64         f += M_4PI_3 * cube(r) * sld_l * sph_j1c(q*r); 
     64        f += M_4PI_3 * cube(r) * sld_l * sas_3j1x_x(q*r); 
    6565 
    6666        // iterate over sub_shells in the interface 
     
    9292    } 
    9393    // add in solvent effect 
    94     f -= M_4PI_3 * cube(r) * sld_solvent * sph_j1c(q*r); 
     94    f -= M_4PI_3 * cube(r) * sld_solvent * sas_3j1x_x(q*r); 
    9595 
    9696    const double f2 = f * f * 1.0e-4; 
  • sasmodels/models/spherical_sld.py

    r2d65d51 r925ad6e  
    214214             ] 
    215215# pylint: enable=bad-whitespace, line-too-long 
    216 source = ["lib/polevl.c", "lib/sas_erf.c", "lib/sph_j1c.c", "spherical_sld.c"] 
     216source = ["lib/polevl.c", "lib/sas_erf.c", "lib/sas_3j1x_x.c", "spherical_sld.c"] 
    217217single = False  # TODO: fix low q behaviour 
    218218 
  • sasmodels/models/stacked_disks.c

    r98ce141 r6c3e266  
    5353    const double sinarg2 = q*(halfheight+thick_layer)*cos_alpha; 
    5454 
    55     const double be1 = sas_J1c(besarg1); 
    56     //const double be2 = sas_J1c(besarg2); 
     55    const double be1 = sas_2J1x_x(besarg1); 
     56    //const double be2 = sas_2J1x_x(besarg2); 
    5757    const double be2 = be1; 
    58     const double si1 = sinc(sinarg1); 
    59     const double si2 = sinc(sinarg2); 
     58    const double si1 = sas_sinx_x(sinarg1); 
     59    const double si2 = sas_sinx_x(sinarg2); 
    6060 
    6161    const double dr1 = core_sld - solvent_sld; 
  • sasmodels/models/stacked_disks.py

    r07300ea rb7e8b94  
    148148            sld_layer=0.0, 
    149149            sld_solvent=5.0, 
    150             theta=0, 
     150            theta=90, 
    151151            phi=0) 
    152 #After redefinition to spherical coordinates find new reasonable test values 
    153 #tests = [ 
    154 #    # Accuracy tests based on content in test/utest_extra_models.py. 
    155 #    # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB 
    156 #    [{'thick_core': 10.0, 
    157 #      'thick_layer': 15.0, 
    158 #      'radius': 3000.0, 
    159 #      'n_stacking': 1.0, 
    160 #      'sigma_d': 0.0, 
    161 #      'sld_core': 4.0, 
    162 #      'sld_layer': -0.4, 
    163 #      'solvent_sd': 5.0, 
    164 #      'theta': 0.0, 
    165 #      'phi': 0.0, 
    166 #      'scale': 0.01, 
    167 #      'background': 0.001, 
    168 #     }, 0.001, 5075.12], 
    169  
    170 #    [{'thick_core': 10.0, 
    171 #      'thick_layer': 15.0, 
    172 #      'radius': 3000.0, 
    173 #      'n_stacking': 5.0, 
    174 #      'sigma_d': 0.0, 
    175 #      'sld_core': 4.0, 
    176 #      'sld_layer': -0.4, 
    177 #      'solvent_sd': 5.0, 
    178 #      'theta': 0.0, 
    179 #      'phi': 0.0, 
    180 #      'scale': 0.01, 
    181 #      'background': 0.001, 
    182 #     }, 0.001, 5065.12793824], 
    183  
    184 #    [{'thick_core': 10.0, 
    185 #      'thick_layer': 15.0, 
    186 #      'radius': 3000.0, 
    187 #      'n_stacking': 5.0, 
    188 #      'sigma_d': 0.0, 
    189 #      'sld_core': 4.0, 
    190 #      'sld_layer': -0.4, 
    191 #      'solvent_sd': 5.0, 
    192 #      'theta': 0.0, 
    193 #      'phi': 0.0, 
    194 #      'scale': 0.01, 
    195 #      'background': 0.001, 
    196 #     }, 0.164, 0.0127673597265], 
    197  
    198 #    [{'thick_core': 10.0, 
    199 #      'thick_layer': 15.0, 
    200 #      'radius': 3000.0, 
    201 #      'n_stacking': 1.0, 
    202 #      'sigma_d': 0.0, 
    203 #      'sld_core': 4.0, 
    204 #      'sld_layer': -0.4, 
    205 #      'solvent_sd': 5.0, 
    206 #      'theta': 0.0, 
    207 #      'phi': 0.0, 
    208 #      'scale': 0.01, 
    209 #      'background': 0.001, 
    210 #     }, [0.001, 90.0], [5075.12, 0.001]], 
    211  
    212 #    [{'thick_core': 10.0, 
    213 #      'thick_layer': 15.0, 
    214 #      'radius': 3000.0, 
    215 #      'n_stacking': 1.0, 
    216 #      'sigma_d': 0.0, 
    217 #      'sld_core': 4.0, 
    218 #      'sld_layer': -0.4, 
    219 #      'solvent_sd': 5.0, 
    220 #      'theta': 0.0, 
    221 #      'phi': 0.0, 
    222 #      'scale': 0.01, 
    223 #      'background': 0.001, 
    224 #     }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 
    225  
    226 #    [{'thick_core': 10.0, 
    227 #      'thick_layer': 15.0, 
    228 #      'radius': 3000.0, 
    229 #      'n_stacking': 1.0, 
    230 #      'sigma_d': 0.0, 
    231 #      'sld_core': 4.0, 
    232 #      'sld_layer': -0.4, 
    233 #     'solvent_sd': 5.0, 
    234 #      'theta': 0.0, 
    235 #      'phi': 0.0, 
    236 #      'scale': 0.01, 
    237 #      'background': 0.001, 
    238 #     }, ([1.3, 1.57]), [0.0010039, 0.0010038]], 
    239 #    ] 
    240 # 21Mar2016   RKH notes that unit tests all have n_stacking=1, ought to test other values 
    241  
     152# After redefinition of spherical coordinates - 
     153# tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 
     154# but should not matter here as so far all the tests are 1D not 2D 
     155tests = [ 
     156# Accuracy tests based on content in test/utest_extra_models.py. 
     157# Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB; for which alas q=0.001 values seem closer to n_stacked=1 not 5, changed assuming my 4.1 code OK, RKH 
     158    [{'thick_core': 10.0, 
     159      'thick_layer': 15.0, 
     160      'radius': 3000.0, 
     161      'n_stacking': 1.0, 
     162      'sigma_d': 0.0, 
     163      'sld_core': 4.0, 
     164      'sld_layer': -0.4, 
     165      'solvent_sd': 5.0, 
     166      'theta': 90.0, 
     167      'phi': 0.0, 
     168      'scale': 0.01, 
     169      'background': 0.001, 
     170     }, 0.001, 5075.12], 
     171    [{'thick_core': 10.0, 
     172      'thick_layer': 15.0, 
     173      'radius': 3000.0, 
     174      'n_stacking': 5, 
     175      'sigma_d': 0.0, 
     176      'sld_core': 4.0, 
     177      'sld_layer': -0.4, 
     178      'solvent_sd': 5.0, 
     179      'theta': 90.0, 
     180      'phi': 0.0, 
     181      'scale': 0.01, 
     182      'background': 0.001, 
     183#     }, 0.001, 5065.12793824],    n_stacking=1 not 5 ? slight change in value here 11jan2017, check other cpu types 
     184#     }, 0.001, 5075.11570493], 
     185     }, 0.001, 25325.635693], 
     186    [{'thick_core': 10.0, 
     187      'thick_layer': 15.0, 
     188      'radius': 3000.0, 
     189      'n_stacking': 5, 
     190      'sigma_d': 0.0, 
     191      'sld_core': 4.0, 
     192      'sld_layer': -0.4, 
     193      'solvent_sd': 5.0, 
     194      'theta': 90.0, 
     195      'phi': 0.0, 
     196      'scale': 0.01, 
     197      'background': 0.001, 
     198#     }, 0.164, 0.0127673597265],    n_stacking=1 not 5 ?  slight change in value here 11jan2017, check other cpu types 
     199#     }, 0.164, 0.01480812968], 
     200     }, 0.164, 0.0598367986509], 
     201 
     202    [{'thick_core': 10.0, 
     203      'thick_layer': 15.0, 
     204      'radius': 3000.0, 
     205      'n_stacking': 1.0, 
     206      'sigma_d': 0.0, 
     207      'sld_core': 4.0, 
     208      'sld_layer': -0.4, 
     209      'solvent_sd': 5.0, 
     210      'theta': 90.0, 
     211      'phi': 0.0, 
     212      'scale': 0.01, 
     213      'background': 0.001, 
     214# second test here was at q=90, changed it to q=5, note I(q) is then just value of flat background 
     215     }, [0.001, 5.0], [5075.12, 0.001]], 
     216 
     217    [{'thick_core': 10.0, 
     218      'thick_layer': 15.0, 
     219      'radius': 3000.0, 
     220      'n_stacking': 1.0, 
     221      'sigma_d': 0.0, 
     222      'sld_core': 4.0, 
     223      'sld_layer': -0.4, 
     224      'solvent_sd': 5.0, 
     225      'theta': 90.0, 
     226      'phi': 0.0, 
     227      'scale': 0.01, 
     228      'background': 0.001, 
     229     }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 
     230 
     231    [{'thick_core': 10.0, 
     232      'thick_layer': 15.0, 
     233      'radius': 3000.0, 
     234      'n_stacking': 1.0, 
     235      'sigma_d': 0.0, 
     236      'sld_core': 4.0, 
     237      'sld_layer': -0.4, 
     238     'solvent_sd': 5.0, 
     239      'theta': 90.0, 
     240      'phi': 0.0, 
     241      'scale': 0.01, 
     242      'background': 0.001, 
     243     }, ([1.3, 1.57]), [0.0010039, 0.0010038]], 
     244    ] 
     245# 11Jan2017   RKH checking unit test agai, note they are all 1D, no 2D 
     246 
  • sasmodels/models/surface_fractal.c

    rb716cc6 r925ad6e  
    1515{ 
    1616    // calculate P(q) 
    17     const double pq = square(sph_j1c(q*radius)); 
     17    const double pq = square(sas_3j1x_x(q*radius)); 
    1818 
    1919    // calculate S(q) 
  • sasmodels/models/surface_fractal.py

    r5c94f41 r925ad6e  
    7272# pylint: enable=bad-whitespace, line-too-long 
    7373 
    74 source = ["lib/sph_j1c.c", "lib/sas_gamma.c", "surface_fractal.c"] 
     74source = ["lib/sas_3j1x_x.c", "lib/sas_gamma.c", "surface_fractal.c"] 
    7575 
    7676demo = dict(scale=1, background=1e-5, 
  • sasmodels/models/triaxial_ellipsoid.c

    r3a48772 r925ad6e  
    3737            const double ysq = square(Gauss76Z[j]*zm + zb); 
    3838            const double t = q*sqrt(acosx2 + bsinx2*(1.0-ysq) + c2*ysq); 
    39             const double fq = sph_j1c(t); 
     39            const double fq = sas_3j1x_x(t); 
    4040            inner += Gauss76Wt[j] * fq * fq ; 
    4141        } 
     
    6464                          + radius_equat_major*radius_equat_major*cmu*cmu 
    6565                          + radius_polar*radius_polar*calpha*calpha); 
    66     const double fq = sph_j1c(t); 
     66    const double fq = sas_3j1x_x(t); 
    6767    const double s = (sld - sld_solvent) * form_volume(radius_equat_minor, radius_equat_major, radius_polar); 
    6868 
  • sasmodels/models/triaxial_ellipsoid.py

    r416f5c7 r925ad6e  
    104104             ] 
    105105 
    106 source = ["lib/sph_j1c.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 
     106source = ["lib/sas_3j1x_x.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 
    107107 
    108108def ER(radius_equat_minor, radius_equat_major, radius_polar): 
  • sasmodels/models/unified_power_Rg.py

    rb3f2a24 r66ca2a6  
    33---------- 
    44 
    5 The Beaucage model employs the empirical multiple level unified 
    6 Exponential/Power-law fit method developed by G. Beaucage. Four functions 
    7 are included so that 1, 2, 3, or 4 levels can be used. In addition a 0 level 
    8 has been added which simply calculates 
     5This model employs the empirical multiple level unified Exponential/Power-law  
     6fit method developed by Beaucage. Four functions are included so that 1, 2, 3,  
     7or 4 levels can be used. In addition a 0 level has been added which simply  
     8calculates 
    99 
    1010.. math:: 
     
    1515many different types of particles, including fractal clusters, random coils 
    1616(Debye equation), ellipsoidal particles, etc. 
     17 
     18The model works best for mass fractal systems characterized by Porod exponents  
     19between 5/3 and 3. It should not be used for surface fractal systems. Hammouda  
     20(2010) has pointed out a deficiency in the way this model handles the  
     21transitioning between the Guinier and Porod regimes and which can create  
     22artefacts that appear as kinks in the fitted model function. 
     23 
     24Also see the Guinier_Porod model. 
    1725 
    1826The empirical fit function is: 
     
    3038.. math:: 
    3139 
    32     q_i^* = \frac{q}{\operatorname{erf}^3(q R_{gi}/\sqrt{6}} 
     40    q_i^* = q \left[\operatorname{erf} 
     41            \left(\frac{q R_{gi}}{\sqrt{6}}\right) 
     42        \right]^{-3} 
    3343 
    3444 
     
    5666 
    5767G Beaucage, *J. Appl. Cryst.*, 29 (1996) 134-146 
     68 
     69B Hammouda, *Analysis of the Beaucage model, J. Appl. Cryst.*, (2010), 43, 1474-1478 
    5870 
    5971""" 
  • sasmodels/models/vesicle.c

    r3a48772 r925ad6e  
    3030    contrast = sld_solvent-sld; 
    3131    vol = M_4PI_3*cube(radius); 
    32     f = vol * sph_j1c(q*radius) * contrast; 
     32    f = vol * sas_3j1x_x(q*radius) * contrast; 
    3333  
    3434    //now the shell. No volume normalization as this is done by the caller 
    3535    contrast = sld-sld_solvent; 
    3636    vol = M_4PI_3*cube(radius+thickness); 
    37     f += vol * sph_j1c(q*(radius+thickness)) * contrast; 
     37    f += vol * sas_3j1x_x(q*(radius+thickness)) * contrast; 
    3838 
    3939    //rescale to [cm-1].  
  • sasmodels/models/vesicle.py

    r3a48772 r925ad6e  
    9494             ] 
    9595 
    96 source = ["lib/sph_j1c.c", "vesicle.c"] 
     96source = ["lib/sas_3j1x_x.c", "vesicle.c"] 
    9797 
    9898def ER(radius, thickness): 
  • sasmodels/resolution2d.py

    r40a87fa r7e94989  
    6464        # just need q_calc and weights 
    6565        self.data = data 
    66         self.index = index 
    67  
    68         self.qx_data = data.qx_data[index] 
    69         self.qy_data = data.qy_data[index] 
    70         self.q_data = data.q_data[index] 
     66        self.index = index if index is not None else slice(None) 
     67 
     68        self.qx_data = data.qx_data[self.index] 
     69        self.qy_data = data.qy_data[self.index] 
     70        self.q_data = data.q_data[self.index] 
    7171 
    7272        dqx = getattr(data, 'dqx_data', None) 
     
    7474        if dqx is not None and dqy is not None: 
    7575            # Here dqx and dqy mean dq_parr and dq_perp 
    76             self.dqx_data = dqx[index] 
    77             self.dqy_data = dqy[index] 
     76            self.dqx_data = dqx[self.index] 
     77            self.dqy_data = dqy[self.index] 
    7878            ## Remove singular points if exists 
    7979            self.dqx_data[self.dqx_data < SIGMA_ZERO] = SIGMA_ZERO 
     
    126126        # The angle (phi) of the original q point 
    127127        q_phi = np.arctan(q_phi).repeat(nbins)\ 
    128             .reshape(nq, nbins).transpose().flatten() 
     128            .reshape([nq, nbins]).transpose().flatten() 
    129129        ## Find Gaussian weight for each dq bins: The weight depends only 
    130130        #  on r-direction (The integration may not need) 
Note: See TracChangeset for help on using the changeset viewer.