Changeset 41e7f2e in sasmodels


Ignore:
Timestamp:
Oct 1, 2016 4:04:51 PM (2 years ago)
Author:
ajj
Branches:
master, beta_approx, costrafo411, release_v0.94, release_v0.95, ticket-608-user-defined-weights, ticket_1156, webgl_jitter_viewer
Children:
3a45c2c
Parents:
80013a6 (diff), 2f46e83 (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 ticket651

Files:
2 deleted
77 edited
8 moved

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r80013a6 r41e7f2e  
    3838from . import core 
    3939from . import kerneldll 
     40from . import weights 
    4041from .data import plot_theory, empty_data1D, empty_data2D 
    4142from .direct_model import DirectModel 
     
    390391    from sas.models.qsmearing import smear_selection 
    391392    from sas.models.MultiplicationModel import MultiplicationModel 
     393    from sas.models.dispersion_models import models as dispersers 
    392394 
    393395    def get_model_class(name): 
     
    422424        ModelClass = get_model_class(old_name) 
    423425        model = [ModelClass()] 
     426    model[0].disperser_handles = {} 
    424427 
    425428    # build a smearer with which to call the model, if necessary 
     
    458461            model[0] = ModelClass(control) 
    459462        # paying for parameter conversion each time to keep life simple, if not fast 
     463        for k, v in oldpars.items(): 
     464            if k.endswith('.type'): 
     465                par = k[:-5] 
     466                cls = dispersers[v if v != 'rectangle' else 'rectangula'] 
     467                handle = cls() 
     468                model[0].disperser_handles[par] = handle 
     469                model[0].set_dispersion(par, handle) 
     470 
    460471        #print("sasview pars",oldpars) 
    461472        for k, v in oldpars.items(): 
    462473            name_attr = k.split('.')  # polydispersity components 
    463474            if len(name_attr) == 2: 
    464                 model[0].dispersion[name_attr[0]][name_attr[1]] = v 
     475                par, disp_par = name_attr 
     476                model[0].dispersion[par][disp_par] = v 
    465477            else: 
    466478                model[0].setParam(k, v) 
  • sasmodels/conversion_table.py

    rc95dfc63 r2f46e83  
    2929            "sld": "sld_barbell", 
    3030            "length": "len_bar", 
    31             "bell_radius": "rad_bell", 
     31            "radius_bell": "rad_bell", 
    3232            "radius": "rad_bar", 
    3333            "sld_solvent": "sld_solv" 
     
    8383            "sld": "sld_capcyl", 
    8484            "length": "len_cyl", 
    85             "cap_radius": "rad_cap", 
     85            "radius_cap": "rad_cap", 
    8686            "radius": "rad_cyl", 
    8787            "sld_solvent": "sld_solv" 
     
    126126            "sld_core": "core_sld", 
    127127            "sld_rim": "rim_sld", 
    128             "face_thickness": "face_thick", 
     128            "thick_face": "face_thick", 
    129129            "sld_solvent": "solvent_sld", 
    130             "rim_thickness": "rim_thick", 
     130            "thick_rim": "rim_thick", 
    131131            "sld_face": "face_sld", 
    132132            "theta": "axis_theta" 
     
    144144    ], 
    145145    "core_shell_ellipsoid": [ 
    146         "CoreShellEllipsoidModel", 
    147         { 
    148             "phi": "axis_phi", 
    149             "sld_core": "sld_core", 
    150             "polar_shell": "polar_shell", 
    151             "sld_solvent": "sld_solvent", 
    152             "equat_shell": "equat_shell", 
    153             "equat_core": "equat_core", 
    154             "theta": "axis_theta", 
    155             "polar_core": "polar_core", 
    156             "sld_shell": "sld_shell" 
    157         } 
    158     ], 
    159     "core_shell_ellipsoid_xt": [ 
    160146        "CoreShellEllipsoidXTModel", 
    161147        { 
     
    164150            "x_core": "X_core", 
    165151            "sld_solvent": "sld_solvent", 
    166             "t_shell": "T_shell", 
     152            "thick_shell": "T_shell", 
    167153            "x_polar_shell": "XpolarShell", 
    168154            "theta": "axis_theta", 
     
    179165            "sld_b": "sld_rimB", 
    180166            "sld_solvent": "sld_solv", 
    181             "a_side": "shortA", 
     167            "length_a": "shortA", 
    182168            "sld_a": "sld_rimA", 
    183             "b_side": "midB", 
    184             "crim_thickness": "rimC", 
     169            "length_b": "midB", 
     170            "thick_rimc": "rimC", 
    185171            "theta": "parallel_theta", 
    186             "arim_thickness": "rimA", 
    187             "c_side": "longC", 
    188             "brim_thickness": "rimB" 
     172            "thick_rim_a": "rimA", 
     173            "length_c": "longC", 
     174            "thick_rim_b": "rimB" 
    189175        } 
    190176    ], 
     
    214200            "porod_scale": "scale_p", 
    215201            "lorentz_scale": "scale_l", 
    216             "exponent_p": "exponent_p", 
    217             "exponent_l": "exponent_l", 
     202            "porod_exp": "exponent_p", 
     203            "lorentz_exp": "exponent_l", 
    218204            "cor_length": "length_l" 
    219205        } 
     
    247233        { 
    248234            "phi": "axis_phi", 
    249             "r_equatorial": "radius_b", 
     235            "radius_equatorial": "radius_b", 
    250236            "sld": "sldEll", 
    251237            "theta": "axis_theta", 
    252             "r_polar": "radius_a", 
     238            "radius_polar": "radius_a", 
    253239            "sld_solvent": "sldSolv" 
    254240        } 
     
    316302        "GaussLorentzGelModel", 
    317303        { 
    318             "gauss_scale_factor": "scale_g", 
    319             "dynamic_cor_length": "dyn_colength", 
    320             "static_cor_length": "stat_colength", 
    321             "background": "background", 
    322             "lorentz_scale_factor": "scale_l" 
     304            "gauss_scale": "scale_g", 
     305            "cor_length_dynamic": "dyn_colength", 
     306            "cor_length_static": "stat_colength", 
     307            "background": "background", 
     308            "lorentz_scale": "scale_l" 
    323309        } 
    324310    ], 
     
    332318        "GelFitModel", 
    333319        { 
    334             "gyration_radius": "radius", 
    335             "lorentzian_scale": "lScale", 
    336             "fractal_exp": "FractalExp", 
     320            "rg": "radius", 
     321            "lorentz_scale": "lScale", 
     322            "fractal_dim": "FractalExp", 
    337323            "cor_length": "zeta", 
    338324            "guinier_scale": "gScale" 
     
    377363            "phi": "axis_phi", 
    378364            "scale": "scale", 
    379             "core_radius": "core_radius", 
     365            "radius_core": "core_radius", 
    380366            "sld_solvent": "sldSolv", 
    381367            "length": "length", 
     
    390376        { 
    391377            "b2a_ratio": "b2a_ratio", 
    392             "a_side": "short_side", 
     378            "length_a": "short_side", 
    393379            "sld": "sldPipe", 
    394             "c_side": "c2a_ratio", 
     380            "length_c": "c2a_ratio", 
    395381            "sld_solvent": "sldSolv", 
    396382            "thickness": "thickness" 
     
    402388            "sld": "sldPipe", 
    403389            "b2a_ratio": "b2a_ratio", 
    404             "a_side": "short_side", 
    405             "c_side": "c2a_ratio", 
     390            "length_a": "short_side", 
     391            "length_c": "c2a_ratio", 
    406392            "sld_solvent": "sldSolv" 
    407393        } 
     
    421407            "sld_solvent": "sld_solvent", 
    422408            "sld_head": "sld_head", 
    423             "tail_length": "t_length", 
    424             "head_length": "h_thickness" 
     409            "length_tail": "t_length", 
     410            "length_head": "h_thickness" 
    425411        } 
    426412    ], 
     
    431417            "Nlayers": "n_plates", 
    432418            "sld_head": "sld_head", 
    433             "tail_length": "deltaT", 
    434             "head_length": "deltaH", 
     419            "length_tail": "deltaT", 
     420            "length_head": "deltaH", 
    435421            "sld": "sld_tail", 
    436422            "sld_solvent": "sld_solvent" 
     
    451437        { 
    452438            "sld": "sld_layer", 
    453             "spacing_polydisp": "pd_spacing", 
     439            "sigma_d": "pd_spacing", 
    454440            "sld_solvent": "sld_solvent" 
    455441        } 
     
    483469            "cutoff_length": "co_length", 
    484470            "radius": "radius", 
    485             "mass_dim": "mass_dim" 
     471            "fractal_dim_mass": "mass_dim" 
    486472        } 
    487473    ], 
     
    489475        "MassSurfaceFractal", 
    490476        { 
    491             "cluster_rg": "cluster_rg", 
    492             "mass_dim": "mass_dim", 
    493             "radius": "radius", 
    494             "surface_dim": "surface_dim", 
    495             "primary_rg": "primary_rg" 
     477            "rg_cluster": "cluster_rg", 
     478            "fractal_dim_mass": "mass_dim", 
     479            "radius": "radius", 
     480            "fractal_dim_surf": "surface_dim", 
     481            "rg_primary": "primary_rg" 
    496482        } 
    497483    ], 
     
    499485        "DebyeModel", 
    500486        { 
    501             "radius_gyration": "rg", 
     487            "rg": "rg", 
    502488            "scale": "scale", 
    503489            "background": "background" 
     
    521507            "A": "A_shell", 
    522508            "sld_core": "sld_core0", 
    523             "core_radius": "rad_core0", 
     509            "radius_core": "rad_core0", 
    524510            "sld_solvent": "sld_solv", 
    525511            "thickness": "thick_shell", 
     
    534520            "psi": "parallel_psi", 
    535521            "sld_solvent": "sldSolv", 
    536             "a_side": "short_a", 
    537             "b_side": "short_b", 
     522            "length_a": "short_a", 
     523            "length_b": "short_b", 
    538524            "sld": "sldPipe", 
    539525            "theta": "parallel_theta", 
    540             "c_side": "long_c", 
     526            "length_c": "long_c", 
    541527            "M0:sld": "M0_sld_pipe", 
    542528            "mtheta:sld": "M_theta_pipe", 
     
    561547        { 
    562548            "scale": "scale", 
    563             "string_thickness": "thick_string", 
     549            "thick_string": "thick_string", 
    564550            "sld_string": "sld_string", 
    565551            "sld_solvent": "sld_solv", 
    566             "edge_separation": "edge_separation", 
    567             "number_of_pearls": "num_pearls", 
     552            "edge_sep": "edge_separation", 
     553            "num_pearls": "num_pearls", 
    568554            "radius": "radius", 
    569555            "background": "background", 
     
    574560        "Poly_GaussCoil", 
    575561        { 
    576             "radius_gyration": "rg", 
     562            "rg": "rg", 
    577563            "polydispersity": "poly_m", 
    578564            "scale": "scale", 
     
    622608            "background": "background", 
    623609            "alpha": "alpha", 
    624             "pringle_sld": "sld_pringle" 
     610            "sld": "sld_pringle" 
    625611        } 
    626612    ], 
     
    644630            "sld": "sldPipe", 
    645631            "b2a_ratio": "b2a_ratio", 
    646             "a_side": "short_side", 
    647             "c_side": "c2a_ratio", 
     632            "length_a": "short_side", 
     633            "length_c": "c2a_ratio", 
    648634            "sld_solvent": "sldSolv" 
    649635        } 
     
    752738            "cutoff_length": "co_length", 
    753739            "radius": "radius", 
    754             "surface_dim": "surface_dim" 
     740            "fractal_dim_surf": "surface_dim" 
    755741        } 
    756742    ], 
     
    765751        { 
    766752            "phi": "axis_phi", 
    767             "req_minor": "semi_axisA", 
    768             "rpolar": "semi_axisC", 
    769             "req_major": "semi_axisB", 
    770             "solvent_sld": "sldSolv", 
     753            "radius_equat_minor": "semi_axisA", 
     754            "radius_polar": "semi_axisC", 
     755            "radius_equat_major": "semi_axisB", 
     756            "sld_solvent": "sldSolv", 
    771757            "psi": "axis_psi", 
    772758            "sld": "sldEll", 
  • sasmodels/kernelcl.py

    ra557a99 r6e5b2a7  
    5454import warnings 
    5555import logging 
     56import time 
    5657 
    5758import numpy as np  # type: ignore 
     
    557558        #call_details.show(values) 
    558559        # Call kernel and retrieve results 
    559         last_call = None 
    560         step = 100 
     560        wait_for = None 
     561        last_nap = time.clock() 
     562        step = 1000000//self.q_input.nq + 1 
    561563        for start in range(0, call_details.num_eval, step): 
    562564            stop = min(start + step, call_details.num_eval) 
    563565            #print("queuing",start,stop) 
    564566            args[1:3] = [np.int32(start), np.int32(stop)] 
    565             last_call = [kernel(self.queue, self.q_input.global_size, 
    566                                 None, *args, wait_for=last_call)] 
     567            wait_for = [kernel(self.queue, self.q_input.global_size, None, 
     568                               *args, wait_for=wait_for)] 
     569            if stop < call_details.num_eval: 
     570                # Allow other processes to run 
     571                wait_for[0].wait() 
     572                current_time = time.clock() 
     573                if current_time - last_nap > 0.5: 
     574                    time.sleep(0.05) 
     575                    last_nap = current_time 
    567576        cl.enqueue_copy(self.queue, self.result, self.result_b) 
    568577        #print("result", self.result) 
  • sasmodels/modelinfo.py

    r8407d8c r340428e  
    768768    """ 
    769769    #: Full path to the file defining the kernel, if any. 
    770     filename = None         # type: Optiona[str] 
     770    filename = None         # type: Optional[str] 
    771771    #: Id of the kernel used to load it from the filesystem. 
    772772    id = None               # type: str 
  • sasmodels/models/barbell.c

    r2f5c6d4 r2222134  
    1 double form_volume(double bell_radius, double radius, double length); 
     1double form_volume(double radius_bell, double radius, double length); 
    22double Iq(double q, double sld, double solvent_sld, 
    3         double bell_radius, double radius, double length); 
     3        double radius_bell, double radius, double length); 
    44double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    5         double bell_radius, double radius, double length, 
     5        double radius_bell, double radius, double length, 
    66        double theta, double phi); 
    77 
    8 #define INVALID(v) (v.bell_radius < v.radius) 
     8#define INVALID(v) (v.radius_bell < v.radius) 
    99 
    1010//barbell kernel - same as dumbell 
    1111static double 
    12 _bell_kernel(double q, double h, double bell_radius, 
     12_bell_kernel(double q, double h, double radius_bell, 
    1313             double half_length, double sin_alpha, double cos_alpha) 
    1414{ 
    1515    // translate a point in [-1,1] to a point in [lower,upper] 
    1616    const double upper = 1.0; 
    17     const double lower = h/bell_radius; 
     17    const double lower = h/radius_bell; 
    1818    const double zm = 0.5*(upper-lower); 
    1919    const double zb = 0.5*(upper+lower); 
     
    2626    //    m = q R cos(alpha) 
    2727    //    b = q(L/2-h) cos(alpha) 
    28     const double m = q*bell_radius*cos_alpha; // cos argument slope 
     28    const double m = q*radius_bell*cos_alpha; // cos argument slope 
    2929    const double b = q*(half_length-h)*cos_alpha; // cos argument intercept 
    30     const double qrst = q*bell_radius*sin_alpha; // Q*R*sin(theta) 
     30    const double qrst = q*radius_bell*sin_alpha; // Q*R*sin(theta) 
    3131    double total = 0.0; 
    3232    for (int i = 0; i < 76; i++){ 
     
    3939    // translate dx in [-1,1] to dx in [lower,upper] 
    4040    const double integral = total*zm; 
    41     const double bell_Fq = 2*M_PI*cube(bell_radius)*integral; 
     41    const double bell_Fq = 2*M_PI*cube(radius_bell)*integral; 
    4242    return bell_Fq; 
    4343} 
    4444 
    45 double form_volume(double bell_radius, 
     45double form_volume(double radius_bell, 
    4646        double radius, 
    4747        double length) 
     
    4949 
    5050    // bell radius should never be less than radius when this is called 
    51     const double hdist = sqrt(square(bell_radius) - square(radius)); 
    52     const double p1 = 2.0/3.0*cube(bell_radius); 
    53     const double p2 = square(bell_radius)*hdist; 
     51    const double hdist = sqrt(square(radius_bell) - square(radius)); 
     52    const double p1 = 2.0/3.0*cube(radius_bell); 
     53    const double p2 = square(radius_bell)*hdist; 
    5454    const double p3 = cube(hdist)/3.0; 
    5555 
     
    5858 
    5959double Iq(double q, double sld, double solvent_sld, 
    60           double bell_radius, double radius, double length) 
     60          double radius_bell, double radius, double length) 
    6161{ 
    62     const double h = -sqrt(bell_radius*bell_radius - radius*radius); 
     62    const double h = -sqrt(radius_bell*radius_bell - radius*radius); 
    6363    const double half_length = 0.5*length; 
    6464 
     
    7272        SINCOS(alpha, sin_alpha, cos_alpha); 
    7373 
    74         const double bell_Fq = _bell_kernel(q, h, bell_radius, half_length, sin_alpha, cos_alpha); 
     74        const double bell_Fq = _bell_kernel(q, h, radius_bell, half_length, sin_alpha, cos_alpha); 
    7575        const double bj = sas_J1c(q*radius*sin_alpha); 
    7676        const double si = sinc(q*half_length*cos_alpha); 
     
    9090double Iqxy(double qx, double qy, 
    9191        double sld, double solvent_sld, 
    92         double bell_radius, double radius, double length, 
     92        double radius_bell, double radius, double length, 
    9393        double theta, double phi) 
    9494{ 
     
    100100    const double alpha = acos(cos_val); // rod angle relative to q 
    101101 
    102     const double h = -sqrt(square(bell_radius) - square(radius)); 
     102    const double h = -sqrt(square(radius_bell) - square(radius)); 
    103103    const double half_length = 0.5*length; 
    104104 
    105105    double sin_alpha, cos_alpha; // slots to hold sincos function output 
    106106    SINCOS(alpha, sin_alpha, cos_alpha); 
    107     const double bell_Fq = _bell_kernel(q, h, bell_radius, half_length, sin_alpha, cos_alpha); 
     107    const double bell_Fq = _bell_kernel(q, h, radius_bell, half_length, sin_alpha, cos_alpha); 
    108108    const double bj = sas_J1c(q*radius*sin_alpha); 
    109109    const double si = sinc(q*half_length*cos_alpha); 
  • sasmodels/models/barbell.py

    r42356c8 r2222134  
    1313.. figure:: img/barbell_geometry.jpg 
    1414 
    15     Barbell geometry, where $r$ is *radius*, $R$ is *bell_radius* and 
     15    Barbell geometry, where $r$ is *radius*, $R$ is *radius_bell* and 
    1616    $L$ is *length*. Since the end cap radius $R \geq r$ and by definition 
    1717    for this geometry $h < 0$, $h$ is then defined by $r$ and $R$ as 
     
    103103parameters = [["sld",         "1e-6/Ang^2",   4, [-inf, inf], "sld",         "Barbell scattering length density"], 
    104104              ["sld_solvent", "1e-6/Ang^2",   1, [-inf, inf], "sld",         "Solvent scattering length density"], 
    105               ["bell_radius", "Ang",         40, [0, inf],    "volume",      "Spherical bell radius"], 
     105              ["radius_bell", "Ang",         40, [0, inf],    "volume",      "Spherical bell radius"], 
    106106              ["radius",      "Ang",         20, [0, inf],    "volume",      "Cylindrical bar radius"], 
    107107              ["length",      "Ang",        400, [0, inf],    "volume",      "Cylinder bar length"], 
     
    116116demo = dict(scale=1, background=0, 
    117117            sld=6, sld_solvent=1, 
    118             bell_radius=40, radius=20, length=400, 
     118            radius_bell=40, radius=20, length=400, 
    119119            theta=60, phi=60, 
    120120            radius_pd=.2, radius_pd_n=5, 
  • sasmodels/models/bcc_paracrystal.py

    r42356c8 r0bef47b  
    124124# pylint: enable=bad-whitespace, line-too-long 
    125125 
    126 source = ["lib/sph_j1c.c", "lib/gauss150.c", "lib/sphere_form.c", "bcc_paracrystal_kernel.c"] 
     126source = ["lib/sph_j1c.c", "lib/gauss150.c", "lib/sphere_form.c", "bcc_paracrystal.c"] 
    127127 
    128128# parameters for demo 
  • sasmodels/models/capped_cylinder.c

    r2f5c6d4 r2222134  
    1 double form_volume(double radius, double cap_radius, double length); 
     1double form_volume(double radius, double radius_cap, double length); 
    22double Iq(double q, double sld, double solvent_sld, 
    3     double radius, double cap_radius, double length); 
     3    double radius, double radius_cap, double length); 
    44double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    5     double radius, double cap_radius, double length, double theta, double phi); 
     5    double radius, double radius_cap, double length, double theta, double phi); 
    66 
    7 #define INVALID(v) (v.cap_radius < v.radius) 
     7#define INVALID(v) (v.radius_cap < v.radius) 
    88 
    99// Integral over a convex lens kernel for t in [h/R,1].  See the docs for 
     
    1212//   h is the length of the lens "inside" the cylinder.  This negative wrt the 
    1313//       definition of h in the docs. 
    14 //   cap_radius is the radius of the lens 
     14//   radius_cap is the radius of the lens 
    1515//   length is the cylinder length, or the separation between the lens halves 
    1616//   alpha is the angle of the cylinder wrt q. 
    1717static double 
    18 _cap_kernel(double q, double h, double cap_radius, 
     18_cap_kernel(double q, double h, double radius_cap, 
    1919                      double half_length, double sin_alpha, double cos_alpha) 
    2020{ 
    2121    // translate a point in [-1,1] to a point in [lower,upper] 
    2222    const double upper = 1.0; 
    23     const double lower = h/cap_radius; // integral lower bound 
     23    const double lower = h/radius_cap; // integral lower bound 
    2424    const double zm = 0.5*(upper-lower); 
    2525    const double zb = 0.5*(upper+lower); 
     
    3232    //    m = q R cos(alpha) 
    3333    //    b = q(L/2-h) cos(alpha) 
    34     const double m = q*cap_radius*cos_alpha; // cos argument slope 
     34    const double m = q*radius_cap*cos_alpha; // cos argument slope 
    3535    const double b = q*(half_length-h)*cos_alpha; // cos argument intercept 
    36     const double qrst = q*cap_radius*sin_alpha; // Q*R*sin(theta) 
     36    const double qrst = q*radius_cap*sin_alpha; // Q*R*sin(theta) 
    3737    double total = 0.0; 
    3838    for (int i=0; i<76 ;i++) { 
     
    4545    // translate dx in [-1,1] to dx in [lower,upper] 
    4646    const double integral = total*zm; 
    47     const double cap_Fq = 2*M_PI*cube(cap_radius)*integral; 
     47    const double cap_Fq = 2*M_PI*cube(radius_cap)*integral; 
    4848    return cap_Fq; 
    4949} 
    5050 
    51 double form_volume(double radius, double cap_radius, double length) 
     51double form_volume(double radius, double radius_cap, double length) 
    5252{ 
    5353    // cap radius should never be less than radius when this is called 
     
    7474    //        = pi r^2 L + pi hc (r^2 + hc^2/3) 
    7575    //        = pi (r^2 (L+hc) + hc^3/3) 
    76     const double hc = cap_radius - sqrt(cap_radius*cap_radius - radius*radius); 
     76    const double hc = radius_cap - sqrt(radius_cap*radius_cap - radius*radius); 
    7777    return M_PI*(radius*radius*(length+hc) + hc*hc*hc/3.0); 
    7878} 
    7979 
    8080double Iq(double q, double sld, double solvent_sld, 
    81           double radius, double cap_radius, double length) 
     81          double radius, double radius_cap, double length) 
    8282{ 
    83     const double h = sqrt(cap_radius*cap_radius - radius*radius); 
     83    const double h = sqrt(radius_cap*radius_cap - radius*radius); 
    8484    const double half_length = 0.5*length; 
    8585 
     
    9393        SINCOS(alpha, sin_alpha, cos_alpha); 
    9494 
    95         const double cap_Fq = _cap_kernel(q, h, cap_radius, half_length, sin_alpha, cos_alpha); 
     95        const double cap_Fq = _cap_kernel(q, h, radius_cap, half_length, sin_alpha, cos_alpha); 
    9696        const double bj = sas_J1c(q*radius*sin_alpha); 
    9797        const double si = sinc(q*half_length*cos_alpha); 
     
    111111double Iqxy(double qx, double qy, 
    112112    double sld, double solvent_sld, double radius, 
    113     double cap_radius, double length, 
     113    double radius_cap, double length, 
    114114    double theta, double phi) 
    115115{ 
     
    121121    const double alpha = acos(cos_val); // rod angle relative to q 
    122122 
    123     const double h = sqrt(cap_radius*cap_radius - radius*radius); 
     123    const double h = sqrt(radius_cap*radius_cap - radius*radius); 
    124124    const double half_length = 0.5*length; 
    125125 
    126126    double sin_alpha, cos_alpha; // slots to hold sincos function output 
    127127    SINCOS(alpha, sin_alpha, cos_alpha); 
    128     const double cap_Fq = _cap_kernel(q, h, cap_radius, half_length, sin_alpha, cos_alpha); 
     128    const double cap_Fq = _cap_kernel(q, h, radius_cap, half_length, sin_alpha, cos_alpha); 
    129129    const double bj = sas_J1c(q*radius*sin_alpha); 
    130130    const double si = sinc(q*half_length*cos_alpha); 
  • sasmodels/models/capped_cylinder.py

    r42356c8 r2222134  
    9696    Note: As the length of cylinder -->0, 
    9797    it becomes a Convex Lens. 
    98     It must be that radius <(=) cap_radius. 
     98    It must be that radius <(=) radius_cap. 
    9999    [Parameters]; 
    100100    scale: volume fraction of spheres, 
     
    102102    radius: radius of the cylinder, 
    103103    length: length of the cylinder, 
    104     cap_radius: radius of the semi-spherical cap, 
     104    radius_cap: radius of the semi-spherical cap, 
    105105    sld: SLD of the capped cylinder, 
    106106    sld_solvent: SLD of the solvent. 
     
    122122              # in the capped cylinder, and zero for no bar in the barbell model.  In 
    123123              # both models, one would be a pill. 
    124               ["cap_radius", "Ang",     20, [0, inf],    "volume", "Cap radius"], 
     124              ["radius_cap", "Ang",     20, [0, inf],    "volume", "Cap radius"], 
    125125              ["length",     "Ang",    400, [0, inf],    "volume", "Cylinder length"], 
    126126              ["theta",      "degrees", 60, [-inf, inf], "orientation", "In plane angle"], 
     
    133133demo = dict(scale=1, background=0, 
    134134            sld=6, sld_solvent=1, 
    135             radius=260, cap_radius=290, length=290, 
     135            radius=260, radius_cap=290, length=290, 
    136136            theta=30, phi=15, 
    137137            radius_pd=.2, radius_pd_n=1, 
    138             cap_radius_pd=.2, cap_radius_pd_n=1, 
     138            radius_cap_pd=.2, radius_cap_pd_n=1, 
    139139            length_pd=.2, length_pd_n=10, 
    140140            theta_pd=15, theta_pd_n=45, 
  • sasmodels/models/core_shell_bicelle.c

    r43b7eea r2222134  
    1 double form_volume(double radius, double rim_thickness, double face_thickness, double length); 
     1double form_volume(double radius, double thick_rim, double thick_face, double length); 
    22double Iq(double q, 
    33          double radius, 
    4           double rim_thickness, 
    5           double face_thickness, 
     4          double thick_rim, 
     5          double thick_face, 
    66          double length, 
    77          double core_sld, 
     
    1313double Iqxy(double qx, double qy, 
    1414          double radius, 
    15           double rim_thickness, 
    16           double face_thickness, 
     15          double thick_rim, 
     16          double thick_face, 
    1717          double length, 
    1818          double core_sld, 
     
    2424 
    2525 
    26 double form_volume(double radius, double rim_thickness, double face_thickness, double length) 
     26double form_volume(double radius, double thick_rim, double thick_face, double length) 
    2727{ 
    28     return M_PI*(radius+rim_thickness)*(radius+rim_thickness)*(length+2*face_thickness); 
     28    return M_PI*(radius+thick_rim)*(radius+thick_rim)*(length+2*thick_face); 
    2929} 
    3030 
     
    102102bicelle_kernel_2d(double q, double q_x, double q_y, 
    103103          double radius, 
    104           double rim_thickness, 
    105           double face_thickness, 
     104          double thick_rim, 
     105          double thick_face, 
    106106          double length, 
    107107          double core_sld, 
     
    125125 
    126126    // Get the kernel 
    127     double answer = bicelle_kernel(q, radius, rim_thickness, face_thickness, 
     127    double answer = bicelle_kernel(q, radius, thick_rim, thick_face, 
    128128                           length/2.0, core_sld, face_sld, rim_sld, 
    129129                           solvent_sld, alpha) / fabs(sin(alpha)); 
     
    136136double Iq(double q, 
    137137          double radius, 
    138           double rim_thickness, 
    139           double face_thickness, 
     138          double thick_rim, 
     139          double thick_face, 
    140140          double length, 
    141141          double core_sld, 
     
    144144          double solvent_sld) 
    145145{ 
    146     double intensity = bicelle_integration(q, radius, rim_thickness, face_thickness, 
     146    double intensity = bicelle_integration(q, radius, thick_rim, thick_face, 
    147147                       length, core_sld, face_sld, rim_sld, solvent_sld); 
    148148    return intensity*1.0e-4; 
     
    152152double Iqxy(double qx, double qy, 
    153153          double radius, 
    154           double rim_thickness, 
    155           double face_thickness, 
     154          double thick_rim, 
     155          double thick_face, 
    156156          double length, 
    157157          double core_sld, 
     
    166166    double intensity = bicelle_kernel_2d(q, qx/q, qy/q, 
    167167                      radius, 
    168                       rim_thickness, 
    169                       face_thickness, 
     168                      thick_rim, 
     169                      thick_face, 
    170170                      length, 
    171171                      core_sld, 
  • sasmodels/models/core_shell_bicelle.py

    r40a87fa r2222134  
    7676parameters = [ 
    7777    ["radius",         "Ang",       20, [0, inf],    "volume",      "Cylinder core radius"], 
    78     ["rim_thickness",  "Ang",       10, [0, inf],    "volume",      "Rim shell thickness"], 
    79     ["face_thickness", "Ang",       10, [0, inf],    "volume",      "Cylinder face thickness"], 
     78    ["thick_rim",  "Ang",       10, [0, inf],    "volume",      "Rim shell thickness"], 
     79    ["thick_face", "Ang",       10, [0, inf],    "volume",      "Cylinder face thickness"], 
    8080    ["length",         "Ang",      400, [0, inf],    "volume",      "Cylinder length"], 
    8181    ["sld_core",       "1e-6/Ang^2", 1, [-inf, inf], "sld",         "Cylinder core scattering length density"], 
     
    9494demo = dict(scale=1, background=0, 
    9595            radius=20.0, 
    96             rim_thickness=10.0, 
    97             face_thickness=10.0, 
     96            thick_rim=10.0, 
     97            thick_face=10.0, 
    9898            length=400.0, 
    9999            sld_core=1.0, 
     
    108108    # Accuracy tests based on content in test/utest_other_models.py 
    109109    [{'radius': 20.0, 
    110       'rim_thickness': 10.0, 
    111       'face_thickness': 10.0, 
     110      'thick_rim': 10.0, 
     111      'thick_face': 10.0, 
    112112      'length': 400.0, 
    113113      'sld_core': 1.0, 
     
    119119 
    120120    [{'radius': 20.0, 
    121       'rim_thickness': 10.0, 
    122       'face_thickness': 10.0, 
     121      'thick_rim': 10.0, 
     122      'thick_face': 10.0, 
    123123      'length': 400.0, 
    124124      'sld_core': 1.0, 
     
    133133    # Additional tests with larger range of parameters 
    134134    [{'radius': 3.0, 
    135       'rim_thickness': 100.0, 
    136       'face_thickness': 100.0, 
     135      'thick_rim': 100.0, 
     136      'thick_face': 100.0, 
    137137      'length': 1200.0, 
    138138      'sld_core': 5.0, 
  • sasmodels/models/core_shell_ellipsoid.c

    r29172aa r5031ca3  
    1 double form_volume(double equat_core, 
     1double form_volume(double radius_equat_core, 
    22                   double polar_core, 
    33                   double equat_shell, 
    44                   double polar_shell); 
    55double Iq(double q, 
    6           double equat_core, 
    7           double polar_core, 
    8           double equat_shell, 
    9           double polar_shell, 
    10           double sld_core, 
    11           double sld_shell, 
    12           double sld_solvent); 
     6          double radius_equat_core, 
     7          double x_core, 
     8          double thick_shell, 
     9          double x_polar_shell, 
     10          double core_sld, 
     11          double shell_sld, 
     12          double solvent_sld); 
    1313 
    1414 
    1515double Iqxy(double qx, double qy, 
    16           double equat_core, 
    17           double polar_core, 
    18           double equat_shell, 
    19           double polar_shell, 
    20           double sld_core, 
    21           double sld_shell, 
    22           double sld_solvent, 
     16          double radius_equat_core, 
     17          double x_core, 
     18          double thick_shell, 
     19          double x_polar_shell, 
     20          double core_sld, 
     21          double shell_sld, 
     22          double solvent_sld, 
    2323          double theta, 
    2424          double phi); 
    2525 
    2626 
    27 double form_volume(double equat_core, 
    28                    double polar_core, 
    29                    double equat_shell, 
    30                    double polar_shell) 
     27double form_volume(double radius_equat_core, 
     28                   double x_core, 
     29                   double thick_shell, 
     30                   double x_polar_shell) 
    3131{ 
     32    const double equat_shell = radius_equat_core + thick_shell; 
     33    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; 
    3234    double vol = 4.0*M_PI/3.0*equat_shell*equat_shell*polar_shell; 
    3335    return vol; 
     
    3537 
    3638static double 
    37 core_shell_ellipsoid_kernel(double q, 
    38           double equat_core, 
    39           double polar_core, 
    40           double equat_shell, 
    41           double polar_shell, 
    42           double sld_core, 
    43           double sld_shell, 
    44           double sld_solvent) 
     39core_shell_ellipsoid_xt_kernel(double q, 
     40          double radius_equat_core, 
     41          double x_core, 
     42          double thick_shell, 
     43          double x_polar_shell, 
     44          double core_sld, 
     45          double shell_sld, 
     46          double solvent_sld) 
    4547{ 
    46  
    47     //upper and lower integration limits 
    4848    const double lolim = 0.0; 
    4949    const double uplim = 1.0; 
     
    5151    double summ = 0.0;   //initialize intergral 
    5252 
    53     const double delpc = sld_core - sld_shell;    //core - shell 
    54     const double delps = sld_shell - sld_solvent; //shell - solvent 
     53    const double delpc = core_sld - shell_sld; //core - shell 
     54    const double delps = shell_sld - solvent_sld; //shell - solvent 
     55 
     56 
     57    const double polar_core = radius_equat_core*x_core; 
     58    const double equat_shell = radius_equat_core + thick_shell; 
     59    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; 
    5560 
    5661    for(int i=0;i<N_POINTS_76;i++) { 
    5762        double zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
    5863        double yyy = Gauss76Wt[i] * gfn4(zi, 
    59                                   equat_core, 
     64                                  radius_equat_core, 
    6065                                  polar_core, 
    6166                                  equat_shell, 
     
    6873 
    6974    double answer = (uplim-lolim)/2.0*summ; 
    70  
    7175    //convert to [cm-1] 
    7276    answer *= 1.0e-4; 
     
    7680 
    7781static double 
    78 core_shell_ellipsoid_kernel_2d(double q, double q_x, double q_y, 
    79           double equat_core, 
    80           double polar_core, 
    81           double equat_shell, 
    82           double polar_shell, 
    83           double sld_core, 
    84           double sld_shell, 
    85           double sld_solvent, 
     82core_shell_ellipsoid_xt_kernel_2d(double q, double q_x, double q_y, 
     83          double radius_equat_core, 
     84          double x_core, 
     85          double thick_shell, 
     86          double x_polar_shell, 
     87          double core_sld, 
     88          double shell_sld, 
     89          double solvent_sld, 
    8690          double theta, 
    8791          double phi) 
     
    9195    phi = phi * M_PI_180; 
    9296 
    93  
    9497    // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. 
    9598    const double cyl_x = cos(theta) * cos(phi); 
    9699    const double cyl_y = sin(theta); 
    97100 
    98     const double sldcs = sld_core - sld_shell; 
    99     const double sldss = sld_shell- sld_solvent; 
     101    const double sldcs = core_sld - shell_sld; 
     102    const double sldss = shell_sld- solvent_sld; 
    100103 
    101104    // Compute the angle btw vector q and the 
     
    103106    const double cos_val = cyl_x*q_x + cyl_y*q_y; 
    104107 
    105     // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params. 
     108    const double polar_core = radius_equat_core*x_core; 
     109    const double equat_shell = radius_equat_core + thick_shell; 
     110    const double polar_shell = radius_equat_core*x_core + thick_shell*x_polar_shell; 
     111 
     112    // Call the IGOR library function to get the kernel: 
     113    // MUST use gfn4 not gf2 because of the def of params. 
    106114    double answer = gfn4(cos_val, 
    107                   equat_core, 
     115                  radius_equat_core, 
    108116                  polar_core, 
    109117                  equat_shell, 
     
    120128 
    121129double Iq(double q, 
    122           double equat_core, 
    123           double polar_core, 
    124           double equat_shell, 
    125           double polar_shell, 
    126           double sld_core, 
    127           double sld_shell, 
    128           double sld_solvent) 
     130          double radius_equat_core, 
     131          double x_core, 
     132          double thick_shell, 
     133          double x_polar_shell, 
     134          double core_sld, 
     135          double shell_sld, 
     136          double solvent_sld) 
    129137{ 
    130     double intensity = core_shell_ellipsoid_kernel(q, 
    131            equat_core, 
    132            polar_core, 
    133            equat_shell, 
    134            polar_shell, 
    135            sld_core, 
    136            sld_shell, 
    137            sld_solvent); 
     138    double intensity = core_shell_ellipsoid_xt_kernel(q, 
     139           radius_equat_core, 
     140           x_core, 
     141           thick_shell, 
     142           x_polar_shell, 
     143           core_sld, 
     144           shell_sld, 
     145           solvent_sld); 
    138146 
    139147    return intensity; 
     
    142150 
    143151double Iqxy(double qx, double qy, 
    144           double equat_core, 
    145           double polar_core, 
    146           double equat_shell, 
    147           double polar_shell, 
    148           double sld_core, 
    149           double sld_shell, 
    150           double sld_solvent, 
     152          double radius_equat_core, 
     153          double x_core, 
     154          double thick_shell, 
     155          double x_polar_shell, 
     156          double core_sld, 
     157          double shell_sld, 
     158          double solvent_sld, 
    151159          double theta, 
    152160          double phi) 
     
    154162    double q; 
    155163    q = sqrt(qx*qx+qy*qy); 
    156     double intensity = core_shell_ellipsoid_kernel_2d(q, qx/q, qy/q, 
    157                        equat_core, 
    158                        polar_core, 
    159                        equat_shell, 
    160                        polar_shell, 
    161                        sld_core, 
    162                        sld_shell, 
    163                        sld_solvent, 
     164    double intensity = core_shell_ellipsoid_xt_kernel_2d(q, qx/q, qy/q, 
     165                       radius_equat_core, 
     166                       x_core, 
     167                       thick_shell, 
     168                       x_polar_shell, 
     169                       core_sld, 
     170                       shell_sld, 
     171                       solvent_sld, 
    164172                       theta, 
    165173                       phi); 
  • sasmodels/models/core_shell_ellipsoid.py

    r40a87fa rb99734a  
    11r""" 
    2 This model provides the form factor, $P(q)$, for a core shell ellipsoid (below) 
    3 where the form factor is normalized by the volume of the outer [CHECK]. 
     2Definition 
     3---------- 
    44 
    5 .. math:: 
     5Parameters for this model are the core axial ratio X and a shell thickness, 
     6which are more often what we would like to determine and makes the model 
     7better behaved, particularly when polydispersity is applied than the four 
     8independent radii used in the original parameterization of this model. 
    69 
    7     P(q) = \text{scale} * \left<f^2\right>/V + \text{background} 
    8  
    9 where the volume $V = (4/3)\pi(r_\text{major outer} r_\text{minor outer}^2)$ 
    10 and the averaging $< >$ is applied over all orientations for 1D. 
    1110 
    1211.. figure:: img/core_shell_ellipsoid_geometry.png 
    1312 
    14     The returned value is in units of |cm^-1|, on absolute scale. 
     13The geometric parameters of this model are 
    1514 
    16 Definition 
    17 ---------- 
     15*radius_equat_core =* equatorial core radius *= Rminor_core* 
    1816 
    19 The form factor calculated is 
     17*X_core = polar_core / radius_equat_core = Rmajor_core / Rminor_core* 
    2018 
    21 .. math:: 
     19*Thick_shell = equat_outer - radius_equat_core = Rminor_outer - Rminor_core* 
    2220 
    23     P(q) &= \frac{\text{scale}}{V}\int_0^1 
    24         \left|F(q,r_\text{minor core},r_\text{major core},\alpha) 
    25         + F(q,r_\text{minor outer},r_\text{major outer},\alpha)\right|^2 
    26         d\alpha 
    27         + \text{background} 
     21*XpolarShell = Tpolar_shell / Thick_shell = (Rmajor_outer - Rmajor_core)/ 
     22(Rminor_outer - Rminor_core)* 
    2823 
    29     \left|F(q,r_\text{minor},r_\text{major},\alpha)\right| 
    30         &=(4\pi/3)r_\text{major}r_\text{minor}^2 \Delta \rho \cdot (3j_1(u)/u) 
     24In terms of the original radii 
    3125 
    32     u &= q\left[ r_\text{major}^2\alpha ^2 
    33                   + r_\text{minor}^2(1-\alpha ^2)\right]^{1/2} 
     26*polar_core = radius_equat_core * X_core* 
    3427 
    35 where 
     28*equat_shell = radius_equat_core + Thick_shell* 
    3629 
    37 .. math:: 
     30*polar_shell = radius_equat_core * X_core + Thick_shell * XpolarShell* 
    3831 
    39     j_1(u)=(\sin x - x \cos x)/x^2 
     32(where we note that "shell" perhaps confusingly, relates to the outer radius) 
     33When *X_core < 1* the core is oblate; when *X_core > 1* it is prolate. 
     34*X_core = 1* is a spherical core. 
    4035 
    41 To provide easy access to the orientation of the core-shell ellipsoid, 
    42 we define the axis of the solid ellipsoid using two angles $\theta$ and $\phi$. 
    43 These angles are defined as for 
    44 :ref:`cylinder orientation <cylinder-angle-definition>`. 
    45 The contrast is defined as SLD(core) - SLD(shell) and SLD(shell) - SLD(solvent). 
     36For a fixed shell thickness *XpolarShell = 1*, to scale the shell thickness 
     37pro-rata with the radius *XpolarShell = X_core*. 
    4638 
    47 Note: It is the users' responsibility to ensure that shell radii are larger than 
    48 the core radii, especially if both are polydisperse, in which case the 
    49 core_shell_ellipsoid_xt model may be much better. 
     39When including an $S(q)$, the radius in $S(q)$ is calculated to be that of 
     40a sphere with the same 2nd virial coefficient of the outer surface of the 
     41ellipsoid. This may have some undesirable effects if the aspect ratio of the 
     42ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$ 
     43- which assumes spheres - will not in any case be valid. 
    5044 
    51  
    52 .. note:: 
    53     The 2nd virial coefficient of the solid ellipsoid is calculated based on 
    54     the *radius_a* (= *polar_shell)* and *radius_b (= equat_shell)* values, 
    55     and used as the effective radius for *S(Q)* when $P(Q) * S(Q)$ is applied. 
    56  
    57 .. figure:: img/core_shell_ellipsoid_angle_projection.jpg 
    58  
    59     The angles for oriented core_shell_ellipsoid. 
    60  
    61 Our model uses the form factor calculations implemented in a c-library provided 
    62 by the NIST Center for Neutron Research (Kline, 2006). 
     45If SAS data are in absolute units, and the SLDs are correct, then scale should 
     46be the total volume fraction of the "outer particle". When $S(q)$ is introduced 
     47this moves to the $S(q)$ volume fraction, and scale should then be 1.0, 
     48or contain some other units conversion factor (for example, if you have SAXS data). 
    6349 
    6450References 
    6551---------- 
    6652 
    67 M Kotlarchyk, S H Chen, *J. Chem. Phys.*, 79 (1983) 2461 
     53R K Heenan, 2015, reparametrised the core_shell_ellipsoid model 
    6854 
    69 S J Berr, *Phys. Chem.*, 91 (1987) 4760 
    7055""" 
    7156 
     
    7560title = "Form factor for an spheroid ellipsoid particle with a core shell structure." 
    7661description = """ 
    77     [SpheroidCoreShellModel] Calculates the form factor for an spheroid 
    78     ellipsoid particle with a core_shell structure. 
    79     The form factor is averaged over all possible 
    80     orientations of the ellipsoid such that P(q) 
    81     = scale*<f^2>/Vol + bkg, where f is the 
    82     single particle scattering amplitude. 
    83     [Parameters]: 
    84     equat_core = equatorial radius of core, Rminor_core, 
    85     polar_core = polar radius of core, Rmajor_core, 
    86     equat_shell = equatorial radius of shell, Rminor_outer, 
    87     polar_shell = polar radius of shell, Rmajor_outer, 
    88     sld_core = scattering length density of core, 
    89     sld_shell = scattering length density of shell, 
    90     sld_solvent = scattering length density of solvent, 
    91     background = Incoherent bkg 
    92     scale =scale 
    93     Note:It is the users' responsibility to ensure 
    94     that shell radii are larger than core radii, 
    95     especially if both are polydisperse. 
    96     oblate: polar radius < equatorial radius 
    97     prolate :  polar radius > equatorial radius 
     62        [core_shell_ellipsoid] Calculates the form factor for an spheroid 
     63        ellipsoid particle with a core_shell structure. 
     64        The form factor is averaged over all possible 
     65        orientations of the ellipsoid such that P(q) 
     66        = scale*<f^2>/Vol + bkg, where f is the 
     67        single particle scattering amplitude. 
     68        [Parameters]: 
     69        radius_equat_core = equatorial radius of core, 
     70        x_core = ratio of core polar/equatorial radii, 
     71        thick_shell = equatorial radius of outer surface, 
     72        x_polar_shell = ratio of polar shell thickness to equatorial shell thickness, 
     73        sld_core = SLD_core 
     74        sld_shell = SLD_shell 
     75        sld_solvent = SLD_solvent 
     76        background = Incoherent bkg 
     77        scale =scale 
     78        Note:It is the users' responsibility to ensure 
     79        that shell radii are larger than core radii. 
     80        oblate: polar radius < equatorial radius 
     81        prolate :  polar radius > equatorial radius - this new model will make this easier 
     82        and polydispersity integrals more logical (as previously the shell could disappear). 
    9883    """ 
    9984category = "shape:ellipsoid" 
    10085 
    10186# pylint: disable=bad-whitespace, line-too-long 
    102 #   ["name", "units", default, [lower, upper], "type", "description"], 
     87#             ["name", "units", default, [lower, upper], "type", "description"], 
    10388parameters = [ 
    104     ["equat_core",  "Ang",      200,   [0, inf],    "volume",      "Equatorial radius of core, r minor core"], 
    105     ["polar_core",  "Ang",       10,   [0, inf],    "volume",      "Polar radius of core, r major core"], 
    106     ["equat_shell", "Ang",      250,   [0, inf],    "volume",      "Equatorial radius of shell, r minor outer"], 
    107     ["polar_shell", "Ang",       30,   [0, inf],    "volume",      "Polar radius of shell, r major outer"], 
    108     ["sld_core",    "1e-6/Ang^2", 2,   [-inf, inf], "sld",         "Core scattering length density"], 
    109     ["sld_shell",   "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"], 
    110     ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"], 
    111     ["theta",       "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"], 
    112     ["phi",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"], 
     89    ["radius_equat_core","Ang",     20,   [0, inf],    "volume",      "Equatorial radius of core"], 
     90    ["x_core",        "None",       3,   [0, inf],    "volume",      "axial ratio of core, X = r_polar/r_equatorial"], 
     91    ["thick_shell",   "Ang",       30,   [0, inf],    "volume",      "thickness of shell at equator"], 
     92    ["x_polar_shell", "",           1,   [0, inf],    "volume",      "ratio of thickness of shell at pole to that at equator"], 
     93    ["sld_core",      "1e-6/Ang^2", 2,   [-inf, inf], "sld",         "Core scattering length density"], 
     94    ["sld_shell",     "1e-6/Ang^2", 1,   [-inf, inf], "sld",         "Shell scattering length density"], 
     95    ["sld_solvent",   "1e-6/Ang^2", 6.3, [-inf, inf], "sld",         "Solvent scattering length density"], 
     96    ["theta",         "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation wrt incoming beam"], 
     97    ["phi",           "degrees",    0,   [-inf, inf], "orientation", "Oblate orientation in the plane of the detector"], 
    11398    ] 
    11499# pylint: enable=bad-whitespace, line-too-long 
    115100 
    116 source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", "core_shell_ellipsoid.c"] 
     101source = ["lib/sph_j1c.c", "lib/gfn.c", "lib/gauss76.c", 
     102          "core_shell_ellipsoid.c"] 
    117103 
    118 def ER(equat_core, polar_core, equat_shell, polar_shell): 
     104def ER(radius_equat_core, x_core, thick_shell, x_polar_shell): 
    119105    """ 
    120106        Returns the effective radius used in the S*P calculation 
    121107    """ 
    122108    from .ellipsoid import ER as ellipsoid_ER 
    123     return ellipsoid_ER(polar_shell, equat_shell) 
     109    polar_outer = radius_equat_core*x_core + thick_shell*x_polar_shell 
     110    equat_outer = radius_equat_core + thick_shell 
     111    return ellipsoid_ER(polar_outer, equat_outer) 
    124112 
    125113 
    126 demo = dict(scale=1, background=0.001, 
    127             equat_core=200.0, 
    128             polar_core=10.0, 
    129             equat_shell=250.0, 
    130             polar_shell=30.0, 
     114demo = dict(scale=0.05, background=0.001, 
     115            radius_equat_core=20.0, 
     116            x_core=3.0, 
     117            thick_shell=30.0, 
     118            x_polar_shell=1.0, 
    131119            sld_core=2.0, 
    132120            sld_shell=1.0, 
     
    141129 
    142130tests = [ 
    143     # Accuracy tests based on content in test/utest_other_models.py 
    144     [{'equat_core': 200.0, 
    145       'polar_core': 20.0, 
    146       'equat_shell': 250.0, 
    147       'polar_shell': 30.0, 
     131    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
     132    [{'radius_equat_core': 200.0, 
     133      'x_core': 0.1, 
     134      'thick_shell': 50.0, 
     135      'x_polar_shell': 0.2, 
    148136      'sld_core': 2.0, 
    149137      'sld_shell': 1.0, 
     
    154142 
    155143    # Additional tests with larger range of parameters 
    156     [{'background': 0.01}, 0.1, 8.86741], 
     144    [{'background': 0.01}, 0.1, 11.6915], 
    157145 
    158     [{'equat_core': 20.0, 
    159       'polar_core': 200.0, 
    160       'equat_shell': 54.0, 
    161       'polar_shell': 3.0, 
     146    [{'radius_equat_core': 20.0, 
     147      'x_core': 200.0, 
     148      'thick_shell': 54.0, 
     149      'x_polar_shell': 3.0, 
    162150      'sld_core': 20.0, 
    163151      'sld_shell': 10.0, 
     
    165153      'background': 0.0, 
    166154      'scale': 1.0, 
    167      }, 0.01, 26150.4], 
     155     }, 0.01, 8688.53], 
    168156 
    169     [{'background': 0.001}, (0.4, 0.5), 0.00170471], 
     157    [{'background': 0.001}, (0.4, 0.5), 0.00690673], 
    170158 
    171     [{'equat_core': 20.0, 
    172       'polar_core': 200.0, 
    173       'equat_shell': 54.0, 
    174       'polar_shell': 3.0, 
     159    [{'radius_equat_core': 20.0, 
     160      'x_core': 200.0, 
     161      'thick_shell': 54.0, 
     162      'x_polar_shell': 3.0, 
    175163      'sld_core': 20.0, 
    176164      'sld_shell': 10.0, 
     
    178166      'background': 0.01, 
    179167      'scale': 0.01, 
    180      }, (qx, qy), 0.105764], 
     168     }, (qx, qy), 0.0100002], 
    181169    ] 
  • sasmodels/models/core_shell_parallelepiped.c

    rabdd01c r2222134  
    1 double form_volume(double a_side, double b_side, double c_side,  
    2                    double arim_thickness, double brim_thickness, double crim_thickness); 
     1double form_volume(double length_a, double length_b, double length_c,  
     2                   double thick_rim_a, double thick_rim_b, double thick_rim_c); 
    33double Iq(double q, double core_sld, double arim_sld, double brim_sld, double crim_sld, 
    4           double solvent_sld, double a_side, double b_side, double c_side, 
    5           double arim_thickness, double brim_thickness, double crim_thickness); 
     4          double solvent_sld, double length_a, double length_b, double length_c, 
     5          double thick_rim_a, double thick_rim_b, double thick_rim_c); 
    66double Iqxy(double qx, double qy, double core_sld, double arim_sld, double brim_sld, 
    7             double crim_sld, double solvent_sld, double a_side, double b_side, 
    8             double c_side, double arim_thickness, double brim_thickness, 
    9             double crim_thickness, double theta, double phi, double psi); 
    10  
    11 double form_volume(double a_side, double b_side, double c_side,  
    12                    double arim_thickness, double brim_thickness, double crim_thickness) 
     7            double crim_sld, double solvent_sld, double length_a, double length_b, 
     8            double length_c, double thick_rim_a, double thick_rim_b, 
     9            double thick_rim_c, double theta, double phi, double psi); 
     10 
     11double form_volume(double length_a, double length_b, double length_c,  
     12                   double thick_rim_a, double thick_rim_b, double thick_rim_c) 
    1313{ 
    14     //return a_side * b_side * c_side; 
    15     return a_side * b_side * c_side +  
    16            2.0 * arim_thickness * b_side * c_side +  
    17            2.0 * brim_thickness * a_side * c_side + 
    18            2.0 * crim_thickness * a_side * b_side; 
     14    //return length_a * length_b * length_c; 
     15    return length_a * length_b * length_c +  
     16           2.0 * thick_rim_a * length_b * length_c +  
     17           2.0 * thick_rim_b * length_a * length_c + 
     18           2.0 * thick_rim_c * length_a * length_b; 
    1919} 
    2020 
     
    2525    double crim_sld, 
    2626    double solvent_sld, 
    27     double a_side, 
    28     double b_side, 
    29     double c_side, 
    30     double arim_thickness, 
    31     double brim_thickness, 
    32     double crim_thickness) 
     27    double length_a, 
     28    double length_b, 
     29    double length_c, 
     30    double thick_rim_a, 
     31    double thick_rim_b, 
     32    double thick_rim_c) 
    3333{ 
    3434    // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c_scaled 
     
    3636     
    3737    double t1, t2, t3, t4, tmp, answer;    
    38     double mu = q * b_side; 
     38    double mu = q * length_b; 
    3939     
    4040    //calculate volume before rescaling (in original code, but not used) 
    41     //double vol = form_volume(a_side, b_side, c_side, arim_thickness, brim_thickness, crim_thickness);          
    42     //double vol = a_side * b_side * c_side +  
    43     //       2.0 * arim_thickness * b_side * c_side +  
    44     //       2.0 * brim_thickness * a_side * c_side + 
    45     //       2.0 * crim_thickness * a_side * b_side; 
     41    //double vol = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c);             
     42    //double vol = length_a * length_b * length_c +  
     43    //       2.0 * thick_rim_a * length_b * length_c +  
     44    //       2.0 * thick_rim_b * length_a * length_c + 
     45    //       2.0 * thick_rim_c * length_a * length_b; 
    4646     
    4747    // Scale sides by B 
    48     double a_scaled = a_side / b_side; 
    49     double c_scaled = c_side / b_side; 
     48    double a_scaled = length_a / length_b; 
     49    double c_scaled = length_c / length_b; 
    5050 
    5151    // DelRho values (note that drC is not used later)        
     
    7474            double mudum = mu * sqrt(1.0-sigma*sigma); 
    7575 
    76                 double Vin = a_side * b_side * c_side; 
    77                 //double Vot = (a_side * b_side * c_side + 
    78             //            2.0 * arim_thickness * b_side * c_side + 
    79             //            2.0 * a_side * brim_thickness * c_side + 
    80             //            2.0 * a_side * b_side * crim_thickness); 
    81                 double V1 = (2.0 * arim_thickness * b_side * c_side);    // incorrect V1 (aa*bb*cc+2*ta*bb*cc) 
    82                 double V2 = (2.0 * a_side * brim_thickness * c_side);    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
     76                double Vin = length_a * length_b * length_c; 
     77                //double Vot = (length_a * length_b * length_c + 
     78            //            2.0 * thick_rim_a * length_b * length_c + 
     79            //            2.0 * length_a * thick_rim_b * length_c + 
     80            //            2.0 * length_a * length_b * thick_rim_c); 
     81                double V1 = (2.0 * thick_rim_a * length_b * length_c);    // incorrect V1 (aa*bb*cc+2*ta*bb*cc) 
     82                double V2 = (2.0 * length_a * thick_rim_b * length_c);    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
    8383         
    8484            // ta and tb correspond to the definitions in CSPPKernel, but they don't make sense to me (MG) 
     
    8686            // while in cspkernel in csparallelepiped.cpp (used for the 2D), all the definitions 
    8787            // for ta, tb, tc use also A + 2*rim_thickness (but not scaled by B!!!)             
    88             double ta = (a_scaled+2.0*arim_thickness)/b_side;  
    89             double tb = (a_scaled+2.0*brim_thickness)/b_side; 
     88            double ta = (a_scaled+2.0*thick_rim_a)/length_b;  
     89            double tb = (a_scaled+2.0*thick_rim_b)/length_b; 
    9090     
    9191                double arg1 = (0.5*mudum*a_scaled) * sin(0.5*M_PI*uu); 
     
    160160    double crim_sld, 
    161161    double solvent_sld, 
    162     double a_side, 
    163     double b_side, 
    164     double c_side, 
    165     double arim_thickness, 
    166     double brim_thickness, 
    167     double crim_thickness, 
     162    double length_a, 
     163    double length_b, 
     164    double length_c, 
     165    double thick_rim_a, 
     166    double thick_rim_b, 
     167    double thick_rim_c, 
    168168    double theta, 
    169169    double phi, 
     
    217217        double drB = brim_sld-solvent_sld; 
    218218        double drC = crim_sld-solvent_sld; 
    219         double Vin = a_side * b_side * c_side; 
     219        double Vin = length_a * length_b * length_c; 
    220220    // As for the 1D case, Vot is not used 
    221         //double Vot = (a_side * b_side * c_side + 
    222     //              2.0 * arim_thickness * b_side * c_side + 
    223     //              2.0 * a_side * brim_thickness * c_side + 
    224     //              2.0 * a_side * b_side * crim_thickness); 
    225         double V1 = (2.0 * arim_thickness * b_side * c_side);    // incorrect V1 (aa*bb*cc+2*ta*bb*cc) 
    226         double V2 = (2.0 * a_side * brim_thickness * c_side);    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
    227     double V3 = (2.0 * a_side * b_side * crim_thickness); 
     221        //double Vot = (length_a * length_b * length_c + 
     222    //              2.0 * thick_rim_a * length_b * length_c + 
     223    //              2.0 * length_a * thick_rim_b * length_c + 
     224    //              2.0 * length_a * length_b * thick_rim_c); 
     225        double V1 = (2.0 * thick_rim_a * length_b * length_c);    // incorrect V1 (aa*bb*cc+2*ta*bb*cc) 
     226        double V2 = (2.0 * length_a * thick_rim_b * length_c);    // incorrect V2(aa*bb*cc+2*aa*tb*cc) 
     227    double V3 = (2.0 * length_a * length_b * thick_rim_c); 
    228228    // The definitions of ta, tb, tc are not the same as in the 1D case because there is no 
    229     // the scaling by B. The use of a_side for the 3 of them seems clearly a mistake to me, 
     229    // the scaling by B. The use of length_a for the 3 of them seems clearly a mistake to me, 
    230230    // but for the moment I let it like this until understanding better the code. 
    231         double ta = a_side + 2.0*arim_thickness; 
    232     double tb = a_side + 2.0*brim_thickness; 
    233     double tc = a_side + 2.0*crim_thickness; 
     231        double ta = length_a + 2.0*thick_rim_a; 
     232    double tb = length_a + 2.0*thick_rim_b; 
     233    double tc = length_a + 2.0*thick_rim_c; 
    234234    //handle arg=0 separately, as sin(t)/t -> 1 as t->0 
    235     double argA = 0.5*q*a_side*cos_val_a; 
    236     double argB = 0.5*q*b_side*cos_val_b; 
    237     double argC = 0.5*q*c_side*cos_val_c; 
     235    double argA = 0.5*q*length_a*cos_val_a; 
     236    double argB = 0.5*q*length_b*cos_val_b; 
     237    double argC = 0.5*q*length_c*cos_val_c; 
    238238    double argtA = 0.5*q*ta*cos_val_a; 
    239239    double argtB = 0.5*q*tb*cos_val_b; 
  • sasmodels/models/core_shell_parallelepiped.py

    r42356c8 r2222134  
    124124              ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld", 
    125125               "Solvent scattering length density"], 
    126               ["a_side", "Ang", 35, [0, inf], "volume", 
     126              ["length_a", "Ang", 35, [0, inf], "volume", 
    127127               "Shorter side of the parallelepiped"], 
    128               ["b_side", "Ang", 75, [0, inf], "volume", 
     128              ["length_b", "Ang", 75, [0, inf], "volume", 
    129129               "Second side of the parallelepiped"], 
    130               ["c_side", "Ang", 400, [0, inf], "volume", 
     130              ["length_c", "Ang", 400, [0, inf], "volume", 
    131131               "Larger side of the parallelepiped"], 
    132               ["arim_thickness", "Ang", 10, [0, inf], "volume", 
     132              ["thick_rim_a", "Ang", 10, [0, inf], "volume", 
    133133               "Thickness of A rim"], 
    134               ["brim_thickness", "Ang", 10, [0, inf], "volume", 
     134              ["thick_rim_b", "Ang", 10, [0, inf], "volume", 
    135135               "Thickness of B rim"], 
    136               ["crim_thickness", "Ang", 10, [0, inf], "volume", 
     136              ["thick_rim_c", "Ang", 10, [0, inf], "volume", 
    137137               "Thickness of C rim"], 
    138138              ["theta", "degrees", 0, [-inf, inf], "orientation", 
     
    147147 
    148148 
    149 def ER(a_side, b_side, c_side, arim_thickness, brim_thickness, crim_thickness): 
     149def ER(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c): 
    150150    """ 
    151151        Return equivalent radius (ER) 
     
    153153 
    154154    # surface average radius (rough approximation) 
    155     surf_rad = sqrt((a_side + 2.0*arim_thickness) * (b_side + 2.0*brim_thickness) / pi) 
     155    surf_rad = sqrt((length_a + 2.0*thick_rim_a) * (length_b + 2.0*thick_rim_b) / pi) 
    156156 
    157     height = c_side + 2.0*crim_thickness 
     157    height = length_c + 2.0*thick_rim_c 
    158158 
    159159    ddd = 0.75 * surf_rad * (2 * surf_rad * height + (height + surf_rad) * (height + pi * surf_rad)) 
     
    166166            sld_core=1e-6, sld_a=2e-6, sld_b=4e-6, 
    167167            sld_c=2e-6, sld_solvent=6e-6, 
    168             a_side=35, b_side=75, c_side=400, 
    169             arim_thickness=10, brim_thickness=10, crim_thickness=10, 
     168            length_a=35, length_b=75, length_c=400, 
     169            thick_rim_a=10, thick_rim_b=10, thick_rim_c=10, 
    170170            theta=0, phi=0, psi=0, 
    171             a_side_pd=0.1, a_side_pd_n=1, 
    172             b_side_pd=0.1, b_side_pd_n=1, 
    173             c_side_pd=0.1, c_side_pd_n=1, 
    174             arim_thickness_pd=0.1, arim_thickness_pd_n=1, 
    175             brim_thickness_pd=0.1, brim_thickness_pd_n=1, 
    176             crim_thickness_pd=0.1, crim_thickness_pd_n=1, 
     171            length_a_pd=0.1, length_a_pd_n=1, 
     172            length_b_pd=0.1, length_b_pd_n=1, 
     173            length_c_pd=0.1, length_c_pd_n=1, 
     174            thick_rim_a_pd=0.1, thick_rim_a_pd_n=1, 
     175            thick_rim_b_pd=0.1, thick_rim_b_pd_n=1, 
     176            thick_rim_c_pd=0.1, thick_rim_c_pd_n=1, 
    177177            theta_pd=10, theta_pd_n=1, 
    178178            phi_pd=10, phi_pd_n=1, 
  • sasmodels/models/correlation_length.py

    r40a87fa ra807206  
    1616multiplicative factors $A$ and $C$, and the two exponents $n$ and $m$ are 
    1717used as fitting parameters. (Respectively *porod_scale*, *lorentz_scale*, 
    18 *exponent_p* and *exponent_l* in the parameter list.) The remaining 
     18*porod_exp* and *lorentz_exp* in the parameter list.) The remaining 
    1919parameter $\xi$ (*cor_length* in the parameter list) is a correlation 
    2020length for the polymer chains. Note that when $m=2$ this functional form 
     
    4848              ["porod_scale", "", 1e-06, [0, inf], "", "Porod Scaling Factor"], 
    4949              ["cor_length", "Ang", 50.0, [0, inf], "", "Correlation length, xi, in Lorentzian"], 
    50               ["exponent_p", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"], 
    51               ["exponent_l", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"], 
     50              ["porod_exp", "", 3.0, [0, inf], "", "Porod Exponent, n, in q^-n"], 
     51              ["lorentz_exp", "1/Ang^2", 2.0, [0, inf], "", "Lorentzian Exponent, m, in 1/( 1 + (q.xi)^m)"], 
    5252             ] 
    5353# pylint: enable=bad-continuation, line-too-long 
    5454 
    55 def Iq(q, lorentz_scale, porod_scale, cor_length, exponent_p, exponent_l): 
     55def Iq(q, lorentz_scale, porod_scale, cor_length, porod_exp, lorentz_exp): 
    5656    """ 
    5757    1D calculation of the Correlation length model 
    5858    """ 
    5959    with errstate(divide='ignore'): 
    60         porod = porod_scale / q**exponent_p 
    61         lorentz = lorentz_scale / (1.0 + (q * cor_length)**exponent_l) 
     60        porod = porod_scale / q**porod_exp 
     61        lorentz = lorentz_scale / (1.0 + (q * cor_length)**lorentz_exp) 
    6262    inten = porod + lorentz 
    6363    return inten 
     
    6666# parameters for demo 
    6767demo = dict(lorentz_scale=10.0, porod_scale=1.0e-06, cor_length=50.0, 
    68             exponent_p=3.0, exponent_l=2.0, background=0.1, 
     68            porod_exp=3.0, lorentz_exp=2.0, background=0.1, 
    6969           ) 
    7070 
  • sasmodels/models/dab.py

    r2c74c11 ra807206  
    5555 
    5656#             ["name", "units", default, [lower, upper], "type", "description"], 
    57 parameters = [["length", "Ang", 50.0, [0, inf], "", "correlation length"], 
     57parameters = [["cor_length", "Ang", 50.0, [0, inf], "", "correlation length"], 
    5858             ] 
    5959 
    6060Iq = """ 
    61     double numerator   = pow(length, 3); 
    62     double denominator = pow(1 + pow(q*length,2), 2); 
     61    double numerator   = pow(cor_length, 3); 
     62    double denominator = pow(1 + pow(q*cor_length,2), 2); 
    6363     
    6464    return numerator / denominator ; 
     
    6969# VR defaults to 1.0 
    7070 
    71 demo = dict(scale=1, background=0, length=50) 
     71demo = dict(scale=1, background=0, cor_length=50) 
  • sasmodels/models/ellipsoid.c

    r50e1e40 ra807206  
    1 double form_volume(double rpolar, double requatorial); 
    2 double Iq(double q, double sld, double solvent_sld, double rpolar, double requatorial); 
    3 double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    4     double rpolar, double requatorial, double theta, double phi); 
     1double form_volume(double radius_polar, double radius_equatorial); 
     2double Iq(double q, double sld, double sld_solvent, double radius_polar, double radius_equatorial); 
     3double Iqxy(double qx, double qy, double sld, double sld_solvent, 
     4    double radius_polar, double radius_equatorial, double theta, double phi); 
    55 
    6 double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha); 
    7 double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha) 
     6double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha); 
     7double _ellipsoid_kernel(double q, double radius_polar, double radius_equatorial, double sin_alpha) 
    88{ 
    9     double ratio = rpolar/requatorial; 
    10     const double u = q*requatorial*sqrt(1.0 
     9    double ratio = radius_polar/radius_equatorial; 
     10    const double u = q*radius_equatorial*sqrt(1.0 
    1111                   + sin_alpha*sin_alpha*(ratio*ratio - 1.0)); 
    1212    const double f = sph_j1c(u); 
     
    1515} 
    1616 
    17 double form_volume(double rpolar, double requatorial) 
     17double form_volume(double radius_polar, double radius_equatorial) 
    1818{ 
    19     return M_4PI_3*rpolar*requatorial*requatorial; 
     19    return M_4PI_3*radius_polar*radius_equatorial*radius_equatorial; 
    2020} 
    2121 
    2222double Iq(double q, 
    2323    double sld, 
    24     double solvent_sld, 
    25     double rpolar, 
    26     double requatorial) 
     24    double sld_solvent, 
     25    double radius_polar, 
     26    double radius_equatorial) 
    2727{ 
    2828    // translate a point in [-1,1] to a point in [0, 1] 
     
    3333        //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2; 
    3434        const double sin_alpha = Gauss76Z[i]*zm + zb; 
    35         total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, sin_alpha); 
     35        total += Gauss76Wt[i] * _ellipsoid_kernel(q, radius_polar, radius_equatorial, sin_alpha); 
    3636    } 
    3737    // translate dx in [-1,1] to dx in [lower,upper] 
    3838    const double form = total*zm; 
    39     const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 
     39    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 
    4040    return 1.0e-4 * s * s * form; 
    4141} 
     
    4343double Iqxy(double qx, double qy, 
    4444    double sld, 
    45     double solvent_sld, 
    46     double rpolar, 
    47     double requatorial, 
     45    double sld_solvent, 
     46    double radius_polar, 
     47    double radius_equatorial, 
    4848    double theta, 
    4949    double phi) 
     
    5555    // TODO: check if this is actually sin(alpha), not cos(alpha) 
    5656    const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 
    57     const double form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha); 
    58     const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 
     57    const double form = _ellipsoid_kernel(q, radius_polar, radius_equatorial, cos_alpha); 
     58    const double s = (sld - sld_solvent) * form_volume(radius_polar, radius_equatorial); 
    5959 
    6060    return 1.0e-4 * form * s * s; 
  • sasmodels/models/ellipsoid.py

    r42356c8 ra807206  
    7474    calculated from our 2D model and the intensity from the NIST SANS 
    7575    analysis software. The parameters used were: *scale* = 1.0, 
    76     *r_polar* = 20 |Ang|, *r_equatorial* = 400 |Ang|, 
     76    *radius_polar* = 20 |Ang|, *radius_equatorial* = 400 |Ang|, 
    7777    *contrast* = 3e-6 |Ang^-2|, and *background* = 0.0 |cm^-1|. 
    7878 
     
    122122              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    123123               "Solvent scattering length density"], 
    124               ["r_polar", "Ang", 20, [0, inf], "volume", 
     124              ["radius_polar", "Ang", 20, [0, inf], "volume", 
    125125               "Polar radius"], 
    126               ["r_equatorial", "Ang", 400, [0, inf], "volume", 
     126              ["radius_equatorial", "Ang", 400, [0, inf], "volume", 
    127127               "Equatorial radius"], 
    128128              ["theta", "degrees", 60, [-inf, inf], "orientation", 
     
    134134source = ["lib/sph_j1c.c", "lib/gauss76.c", "ellipsoid.c"] 
    135135 
    136 def ER(r_polar, r_equatorial): 
     136def ER(radius_polar, radius_equatorial): 
    137137    import numpy as np 
    138138 
    139     ee = np.empty_like(r_polar) 
    140     idx = r_polar > r_equatorial 
    141     ee[idx] = (r_polar[idx] ** 2 - r_equatorial[idx] ** 2) / r_polar[idx] ** 2 
    142     idx = r_polar < r_equatorial 
    143     ee[idx] = (r_equatorial[idx] ** 2 - r_polar[idx] ** 2) / r_equatorial[idx] ** 2 
    144     idx = r_polar == r_equatorial 
    145     ee[idx] = 2 * r_polar[idx] 
    146     valid = (r_polar * r_equatorial != 0) 
     139    ee = np.empty_like(radius_polar) 
     140    idx = radius_polar > radius_equatorial 
     141    ee[idx] = (radius_polar[idx] ** 2 - radius_equatorial[idx] ** 2) / radius_polar[idx] ** 2 
     142    idx = radius_polar < radius_equatorial 
     143    ee[idx] = (radius_equatorial[idx] ** 2 - radius_polar[idx] ** 2) / radius_equatorial[idx] ** 2 
     144    idx = radius_polar == radius_equatorial 
     145    ee[idx] = 2 * radius_polar[idx] 
     146    valid = (radius_polar * radius_equatorial != 0) 
    147147    bd = 1.0 - ee[valid] 
    148148    e1 = np.sqrt(ee[valid]) 
     
    152152    delta = 0.75 * b1 * b2 
    153153 
    154     ddd = np.zeros_like(r_polar) 
    155     ddd[valid] = 2.0 * (delta + 1.0) * r_polar * r_equatorial ** 2 
     154    ddd = np.zeros_like(radius_polar) 
     155    ddd[valid] = 2.0 * (delta + 1.0) * radius_polar * radius_equatorial ** 2 
    156156    return 0.5 * ddd ** (1.0 / 3.0) 
    157157 
     
    159159demo = dict(scale=1, background=0, 
    160160            sld=6, sld_solvent=1, 
    161             r_polar=50, r_equatorial=30, 
     161            radius_polar=50, radius_equatorial=30, 
    162162            theta=30, phi=15, 
    163             r_polar_pd=.2, r_polar_pd_n=15, 
    164             r_equatorial_pd=.2, r_equatorial_pd_n=15, 
     163            radius_polar_pd=.2, radius_polar_pd_n=15, 
     164            radius_equatorial_pd=.2, radius_equatorial_pd_n=15, 
    165165            theta_pd=15, theta_pd_n=45, 
    166166            phi_pd=15, phi_pd_n=1) 
  • sasmodels/models/elliptical_cylinder.c

    r40a87fa ra807206  
    1 double form_volume(double r_minor, double r_ratio, double length); 
    2 double Iq(double q, double r_minor, double r_ratio, double length, 
     1double form_volume(double radius_minor, double r_ratio, double length); 
     2double Iq(double q, double radius_minor, double r_ratio, double length, 
    33          double sld, double solvent_sld); 
    4 double Iqxy(double qx, double qy, double r_minor, double r_ratio, double length, 
     4double Iqxy(double qx, double qy, double radius_minor, double r_ratio, double length, 
    55            double sld, double solvent_sld, double theta, double phi, double psi); 
    66 
    77 
    8 double _elliptical_cylinder_kernel(double q, double r_minor, double r_ratio, double theta); 
     8double _elliptical_cylinder_kernel(double q, double radius_minor, double r_ratio, double theta); 
    99 
    10 double _elliptical_cylinder_kernel(double q, double r_minor, double r_ratio, double theta) 
     10double _elliptical_cylinder_kernel(double q, double radius_minor, double r_ratio, double theta) 
    1111{ 
    1212    // This is the function LAMBDA1^2 in Feigin's notation 
    1313    // q is the q-value for the calculation (1/A) 
    14     // r_minor is the transformed radius"a" in Feigin's notation 
     14    // radius_minor is the transformed radius"a" in Feigin's notation 
    1515    // r_ratio is the ratio (major radius)/(minor radius) of the Ellipsoid [=] --- 
    1616    // theta is the dummy variable of the integration 
     
    1818    double retval,arg; 
    1919 
    20     arg = q*r_minor*sqrt((1.0+r_ratio*r_ratio)/2+(1.0-r_ratio*r_ratio)*cos(theta)/2); 
     20    arg = q*radius_minor*sqrt((1.0+r_ratio*r_ratio)/2+(1.0-r_ratio*r_ratio)*cos(theta)/2); 
    2121    //retval = 2.0*J1(arg)/arg; 
    2222    retval = sas_J1c(arg); 
     
    2525 
    2626 
    27 double form_volume(double r_minor, double r_ratio, double length) 
     27double form_volume(double radius_minor, double r_ratio, double length) 
    2828{ 
    29     return M_PI * r_minor * r_minor * r_ratio * length; 
     29    return M_PI * radius_minor * radius_minor * r_ratio * length; 
    3030} 
    3131 
    32 double Iq(double q, double r_minor, double r_ratio, double length, 
     32double Iq(double q, double radius_minor, double r_ratio, double length, 
    3333          double sld, double solvent_sld) { 
    3434 
     
    5555        summj=0; 
    5656        zi = ( Gauss76Z[i]*(vb-va) + va + vb )/2.0;     //the "x" dummy 
    57         arg = r_minor*sqrt(1.0-zi*zi); 
     57        arg = radius_minor*sqrt(1.0-zi*zi); 
    5858        for(int j=0;j<nordj;j++) { 
    5959            //20 gauss points for the inner integral 
     
    7777    answer *= delrho*delrho; 
    7878 
    79     const double vol = form_volume(r_minor, r_ratio, length); 
     79    const double vol = form_volume(radius_minor, r_ratio, length); 
    8080    return answer*vol*vol*1.0e-4; 
    8181} 
    8282 
    8383 
    84 double Iqxy(double qx, double qy, double r_minor, double r_ratio, double length, 
     84double Iqxy(double qx, double qy, double radius_minor, double r_ratio, double length, 
    8585            double sld, double solvent_sld, double theta, double phi, double psi) { 
    8686    const double _theta = theta * M_PI / 180.0; 
     
    139139    } 
    140140 
    141     const double r_major = r_ratio * r_minor; 
    142     const double qr = q*sqrt( r_major*r_major*cos_nu*cos_nu + r_minor*r_minor*cos_mu*cos_mu ); 
     141    const double r_major = r_ratio * radius_minor; 
     142    const double qr = q*sqrt( r_major*r_major*cos_nu*cos_nu + radius_minor*radius_minor*cos_mu*cos_mu ); 
    143143    const double qL = q*length*cos_val/2.0; 
    144144 
     
    159159 
    160160    const double k = 2.0 * Be * Si; 
    161     const double vol = form_volume(r_minor, r_ratio, length); 
     161    const double vol = form_volume(radius_minor, r_ratio, length); 
    162162    return (sld - solvent_sld) * (sld - solvent_sld) * k * k *vol*vol*1.0e-4; 
    163163} 
  • sasmodels/models/elliptical_cylinder.py

    r40a87fa ra807206  
    110110# pylint: disable=bad-whitespace, line-too-long 
    111111#             ["name", "units", default, [lower, upper], "type","description"], 
    112 parameters = [["r_minor",     "Ang",        20.0,  [0, inf],    "volume",      "Ellipse minor radius"], 
     112parameters = [["radius_minor",     "Ang",        20.0,  [0, inf],    "volume",      "Ellipse minor radius"], 
    113113              ["axis_ratio",   "",          1.5,   [1, inf],    "volume",      "Ratio of major radius over minor radius"], 
    114114              ["length",      "Ang",        400.0, [1, inf],    "volume",      "Length of the cylinder"], 
     
    124124          "elliptical_cylinder.c"] 
    125125 
    126 demo = dict(scale=1, background=0, r_minor=100, axis_ratio=1.5, length=400.0, 
     126demo = dict(scale=1, background=0, radius_minor=100, axis_ratio=1.5, length=400.0, 
    127127            sld=4.0, sld_solvent=1.0, theta=10.0, phi=20, psi=30, 
    128128            theta_pd=10, phi_pd=2, psi_pd=3) 
    129129 
    130 def ER(r_minor, axis_ratio, length): 
     130def ER(radius_minor, axis_ratio, length): 
    131131    """ 
    132132        Equivalent radius 
    133         @param r_minor: Ellipse minor radius 
     133        @param radius_minor: Ellipse minor radius 
    134134        @param axis_ratio: Ratio of major radius over minor radius 
    135135        @param length: Length of the cylinder 
    136136    """ 
    137     radius = sqrt(r_minor * r_minor * axis_ratio) 
     137    radius = sqrt(radius_minor * radius_minor * axis_ratio) 
    138138    ddd = 0.75 * radius * (2 * radius * length 
    139139                           + (length + radius) * (length + pi * radius)) 
     
    141141 
    142142tests = [ 
    143     [{'r_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 
    144     [{'r_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 
     143    [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'length':400.0}, 'ER', 79.89245454155024], 
     144    [{'radius_minor': 20.0, 'axis_ratio': 1.2, 'length':300.0}, 'VR', 1], 
    145145 
    146146    # The SasView test result was 0.00169, with a background of 0.001 
    147     [{'r_minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0, 
     147    [{'radius_minor': 20.0, 'axis_ratio': 1.5, 'sld': 4.0, 'length':400.0, 
    148148      'sld_solvent':1.0, 'background':0.0}, 
    149149     0.001, 675.504402], 
  • sasmodels/models/fcc_paracrystal.py

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

    r2c74c11 ra807206  
    88          double solvent_sld, 
    99          double volfraction, 
    10           double frac_dim, 
     10          double fractal_dim, 
    1111          double cor_length); 
    1212 
     
    2323          double solvent_sld, 
    2424          double volfraction, 
    25           double frac_dim, 
     25          double fractal_dim, 
    2626          double cor_length) { 
    2727 
     
    3434                              solvent_sld); 
    3535    //calculate S(q) 
    36     double frac_1 = frac_dim-1.0; 
     36    double frac_1 = fractal_dim-1.0; 
    3737    double qr = q*radius; 
    3838 
    39     double t1 = frac_dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length)); 
     39    double t1 = fractal_dim*sas_gamma(frac_1)*sin(frac_1*atan(q*cor_length)); 
    4040    double t2 = (1.0 + 1.0/(q*cor_length)/(q*cor_length)); 
    41     double t3 = pow(qr, frac_dim) * pow(t2, (frac_1/2.0)); 
     41    double t3 = pow(qr, fractal_dim) * pow(t2, (frac_1/2.0)); 
    4242    double sq = t1/t3; 
    4343    sq += 1.0; 
  • sasmodels/models/fractal_core_shell.py

    r42356c8 ra807206  
    3131    {(qr_c)^{D_f}\left(1+\frac{1}{q^2\xi ^2} \right)^{\frac{D_f-1}{2}}} 
    3232 
    33 where $D_f$ = frac_dim, |xi| = cor_length, $r_c$ = (core) radius, and 
     33where $D_f$ = fractal_dim, |xi| = cor_length, $r_c$ = (core) radius, and 
    3434$scale$ = volume fraction. 
    3535 
     
    6969    ["sld_solvent", "1e-6/Ang^2", 3.0,  [-inf, inf], "sld",    "Solvent scattering length density"], 
    7070    ["volfraction", "",           1.0,  [0, inf],    "",       "Volume fraction of building block spheres"], 
    71     ["frac_dim",    "",           2.0,  [-inf, inf], "",       "Fractal dimension"], 
     71    ["fractal_dim",    "",           2.0,  [-inf, inf], "",       "Fractal dimension"], 
    7272    ["cor_length",  "Ang",      100.0,  [0, inf],    "",       "Correlation length of fractal-like aggregates"]] 
    7373# pylint: enable=bad-whitespace, line-too-long 
     
    8383            sld_solvent=6.35, 
    8484            volfraction=0.05, 
    85             frac_dim=2.0, 
     85            fractal_dim=2.0, 
    8686            cor_length=100.0) 
    8787 
  • sasmodels/models/gauss_lorentz_gel.py

    r40a87fa ra807206  
    5656# pylint: disable=bad-whitespace, line-too-long 
    5757#            ["name", "units", default, [lower, upper], "type", "description"], 
    58 parameters = [["gauss_scale_factor",   "",    100.0,  [-inf, inf], "", "Gauss scale factor"], 
    59               ["static_cor_length",    "Ang", 100.0,  [0, inf],    "", "Static correlation length"], 
    60               ["lorentz_scale_factor", "",     50.0,  [-inf, inf], "", "Lorentzian scale factor"], 
    61               ["dynamic_cor_length",   "Ang",  20.0,  [0, inf],    "", "Dynamic correlation length"], 
     58parameters = [["gauss_scale",   "",    100.0,  [-inf, inf], "", "Gauss scale factor"], 
     59              ["cor_length_static",    "Ang", 100.0,  [0, inf],    "", "Static correlation length"], 
     60              ["lorentz_scale", "",     50.0,  [-inf, inf], "", "Lorentzian scale factor"], 
     61              ["cor_length_dynamic",   "Ang",  20.0,  [0, inf],    "", "Dynamic correlation length"], 
    6262             ] 
    6363# pylint: enable=bad-whitespace, line-too-long 
    6464 
    6565def Iq(q, 
    66        gauss_scale_factor=100.0, 
    67        static_cor_length=100.0, 
    68        lorentz_scale_factor=50.0, 
    69        dynamic_cor_length=20.0): 
     66       gauss_scale=100.0, 
     67       cor_length_static=100.0, 
     68       lorentz_scale=50.0, 
     69       cor_length_dynamic=20.0): 
    7070    """ 
    7171 
    7272    :param q:                    Input q-value 
    73     :param gauss_scale_factor:   Gauss scale factor 
    74     :param static_cor_length:    Static correlation length 
    75     :param lorentz_scale_factor: Lorentzian scale factor 
    76     :param dynamic_cor_length:   Dynamic correlation length 
     73    :param gauss_scale:   Gauss scale factor 
     74    :param cor_length_static:    Static correlation length 
     75    :param lorentz_scale: Lorentzian scale factor 
     76    :param cor_length_dynamic:   Dynamic correlation length 
    7777    :return:                     1-D intensity 
    7878    """ 
    7979 
    80     term1 = gauss_scale_factor *\ 
    81             exp(-1.0*q*q*static_cor_length*static_cor_length/2.0) 
    82     term2 = lorentz_scale_factor /\ 
    83             (1.0+(q*dynamic_cor_length)*(q*dynamic_cor_length)) 
     80    term1 = gauss_scale *\ 
     81            exp(-1.0*q*q*cor_length_static*cor_length_static/2.0) 
     82    term2 = lorentz_scale /\ 
     83            (1.0+(q*cor_length_dynamic)*(q*cor_length_dynamic)) 
    8484 
    8585    return term1 + term2 
     
    8989 
    9090demo = dict(scale=1, background=0.1, 
    91             gauss_scale_factor=100.0, 
    92             static_cor_length=100.0, 
    93             lorentz_scale_factor=50.0, 
    94             dynamic_cor_length=20.0) 
     91            gauss_scale=100.0, 
     92            cor_length_static=100.0, 
     93            lorentz_scale=50.0, 
     94            cor_length_dynamic=20.0) 
    9595 
    9696tests = [ 
    9797 
    9898    # Accuracy tests based on content in test/utest_extra_models.py 
    99     [{'gauss_scale_factor':  100.0, 
    100       'static_cor_length':   100.0, 
    101       'lorentz_scale_factor': 50.0, 
    102       'dynamic_cor_length':   20.0, 
     99    [{'gauss_scale':  100.0, 
     100      'cor_length_static':   100.0, 
     101      'lorentz_scale': 50.0, 
     102      'cor_length_dynamic':   20.0, 
    103103     }, 0.001, 149.482], 
    104104 
    105     [{'gauss_scale_factor':  100.0, 
    106       'static_cor_length':   100.0, 
    107       'lorentz_scale_factor': 50.0, 
    108       'dynamic_cor_length':   20.0, 
     105    [{'gauss_scale':  100.0, 
     106      'cor_length_static':   100.0, 
     107      'lorentz_scale': 50.0, 
     108      'cor_length_dynamic':   20.0, 
    109109     }, 0.105363, 9.1913], 
    110110 
    111     [{'gauss_scale_factor':  100.0, 
    112       'static_cor_length':   100.0, 
    113       'lorentz_scale_factor': 50.0, 
    114       'dynamic_cor_length':   20.0, 
     111    [{'gauss_scale':  100.0, 
     112      'cor_length_static':   100.0, 
     113      'lorentz_scale': 50.0, 
     114      'cor_length_dynamic':   20.0, 
    115115     }, 0.441623, 0.633811], 
    116116 
    117117    # Additional tests with larger range of parameters 
    118     [{'gauss_scale_factor':  10.0, 
    119       'static_cor_length':  100.0, 
    120       'lorentz_scale_factor': 3.0, 
    121       'dynamic_cor_length':   1.0, 
     118    [{'gauss_scale':  10.0, 
     119      'cor_length_static':  100.0, 
     120      'lorentz_scale': 3.0, 
     121      'cor_length_dynamic':   1.0, 
    122122     }, 0.1, 2.9712970297], 
    123123 
    124     [{'gauss_scale_factor':  10.0, 
    125       'static_cor_length':  100.0, 
    126       'lorentz_scale_factor': 3.0, 
    127       'dynamic_cor_length':   1.0, 
     124    [{'gauss_scale':  10.0, 
     125      'cor_length_static':  100.0, 
     126      'lorentz_scale': 3.0, 
     127      'cor_length_dynamic':   1.0, 
    128128      'background':         100.0 
    129129     }, 5.0, 100.116384615], 
    130130 
    131     [{'gauss_scale_factor':  10.0, 
    132       'static_cor_length':  100.0, 
    133       'lorentz_scale_factor': 3.0, 
    134       'dynamic_cor_length':   1.0, 
     131    [{'gauss_scale':  10.0, 
     132      'cor_length_static':  100.0, 
     133      'lorentz_scale': 3.0, 
     134      'cor_length_dynamic':   1.0, 
    135135      'background':           0.0, 
    136136     }, 200., 7.49981250469e-05], 
  • sasmodels/models/gaussian_peak.py

    r7f1ee79 ra807206  
    3434description = """ 
    3535    Model describes a Gaussian shaped peak including a flat background 
    36     Provide F(q) = scale*exp( -1/2 *[(q-q0)/sigma]^2 )+ background 
     36    Provide F(q) = scale*exp( -1/2 *[(q-peak_pos)/sigma]^2 )+ background 
    3737""" 
    3838category = "shape-independent" 
    3939 
    4040#             ["name", "units", default, [lower, upper], "type","description"], 
    41 parameters = [["q0", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], 
     41parameters = [["peak_pos", "1/Ang", 0.05, [-inf, inf], "", "Peak position"], 
    4242              ["sigma", "1/Ang", 0.005, [0, inf], "", 
    4343               "Peak width (standard deviation)"], 
     
    4545 
    4646Iq = """ 
    47     double scaled_dq = (q - q0)/sigma; 
     47    double scaled_dq = (q - peak_pos)/sigma; 
    4848    return exp(-0.5*scaled_dq*scaled_dq); //sqrt(2*M_PI*sigma*sigma); 
    4949    """ 
     
    5151# VR defaults to 1.0 
    5252 
    53 demo = dict(scale=1, background=0, q0=0.05, sigma=0.005) 
     53demo = dict(scale=1, background=0, peak_pos=0.05, sigma=0.005) 
  • sasmodels/models/gel_fit.c

    r03cac08 ra807206  
    11static double Iq(double q, 
    22          double guinier_scale, 
    3           double lorentzian_scale, 
    4           double gyration_radius, 
    5           double fractal_exp, 
     3          double lorentz_scale, 
     4          double rg, 
     5          double fractal_dim, 
    66          double cor_length) 
    77{ 
     
    99    ////////////////////////double a(x[i]*x[i]*zeta*zeta); 
    1010    double lorentzian_term = square(q*cor_length); 
    11     lorentzian_term = 1.0 + ((fractal_exp + 1.0)/3.0)*lorentzian_term; 
    12     lorentzian_term = pow(lorentzian_term, (fractal_exp/2.0) ); 
     11    lorentzian_term = 1.0 + ((fractal_dim + 1.0)/3.0)*lorentzian_term; 
     12    lorentzian_term = pow(lorentzian_term, (fractal_dim/2.0) ); 
    1313 
    1414    // Exponential Term 
    1515    ////////////////////////double d(x[i]*x[i]*rg*rg); 
    16     double exp_term = square(q*gyration_radius); 
     16    double exp_term = square(q*rg); 
    1717    exp_term = exp(-1.0*(exp_term/3.0)); 
    1818 
    1919    // Scattering Law 
    20     double result = lorentzian_scale/lorentzian_term + guinier_scale*exp_term; 
     20    double result = lorentz_scale/lorentzian_term + guinier_scale*exp_term; 
    2121    return result; 
    2222} 
  • sasmodels/models/gel_fit.py

    r40a87fa ra807206  
    6262#             ["name", "units", default, [lower, upper], "type","description"], 
    6363parameters = [["guinier_scale",    "cm^-1",   1.7, [-inf, inf], "", "Guinier length scale"], 
    64               ["lorentzian_scale", "cm^-1",   3.5, [-inf, inf], "", "Lorentzian length scale"], 
    65               ["gyration_radius",  "Ang",     104.0, [2, inf],    "", "Radius of gyration"], 
    66               ["fractal_exp",      "",          2.0, [0, inf],    "", "Fractal exponent"], 
     64              ["lorentz_scale", "cm^-1",   3.5, [-inf, inf], "", "Lorentzian length scale"], 
     65              ["rg",  "Ang",     104.0, [2, inf],    "", "Radius of gyration"], 
     66              ["fractal_dim",      "",          2.0, [0, inf],    "", "Fractal exponent"], 
    6767              ["cor_length",       "Ang",      16.0, [0, inf],    "", "Correlation length"] 
    6868             ] 
     
    7373demo = dict(background=0.01, 
    7474            guinier_scale=1.7, 
    75             lorentzian_scale=3.5, 
    76             gyration_radius=104, 
    77             fractal_exp=2.0, 
     75            lorentz_scale=3.5, 
     76            rg=104, 
     77            fractal_dim=2.0, 
    7878            cor_length=16.0) 
    7979 
    8080tests = [[{'guinier_scale': 1.0, 
    81            'lorentzian_scale': 1.0, 
    82            'gyration_radius': 10.0, 
    83            'fractal_exp': 10.0, 
     81           'lorentz_scale': 1.0, 
     82           'rg': 10.0, 
     83           'fractal_dim': 10.0, 
    8484           'cor_length': 20.0, 
    8585           'background': 0.0, 
     
    8787 
    8888         [{'guinier_scale': 4.0, 
    89            'lorentzian_scale': 10.0, 
    90            'gyration_radius': 500.0, 
    91            'fractal_exp': 1.0, 
     89           'lorentz_scale': 10.0, 
     90           'rg': 500.0, 
     91           'fractal_dim': 1.0, 
    9292           'cor_length': 20.0, 
    9393           'background': 20.0, 
  • sasmodels/models/guinier_porod.py

    r40a87fa ra807206  
    7272description = """\ 
    7373         I(q) = scale/q^s* exp ( - R_g^2 q^2 / (3-s) ) for q<= ql 
    74          = scale/q^m*exp((-ql^2*Rg^2)/(3-s))*ql^(m-s) for q>=ql 
    75                         where ql = sqrt((m-s)(3-s)/2)/Rg. 
     74         = scale/q^porod_exp*exp((-ql^2*Rg^2)/(3-s))*ql^(porod_exp-s) for q>=ql 
     75                        where ql = sqrt((porod_exp-s)(3-s)/2)/Rg. 
    7676                        List of parameters: 
    7777                        scale = Guinier Scale 
    7878                        s = Dimension Variable 
    7979                        Rg = Radius of Gyration [A]  
    80                         m = Porod Exponent 
     80                        porod_exp = Porod Exponent 
    8181                        background  = Background [1/cm]""" 
    8282 
     
    8787parameters = [["rg", "Ang", 60.0, [0, inf], "", "Radius of gyration"], 
    8888              ["s",  "",    1.0,  [0, inf], "", "Dimension variable"], 
    89               ["m",  "",    3.0,  [0, inf], "", "Porod exponent"]] 
     89              ["porod_exp",  "",    3.0,  [0, inf], "", "Porod exponent"]] 
    9090# pylint: enable=bad-whitespace, line-too-long 
    9191 
    9292# pylint: disable=C0103 
    93 def Iq(q, rg, s, m): 
     93def Iq(q, rg, s, porod_exp): 
    9494    """ 
    9595    @param q: Input q-value 
    9696    """ 
    9797    n = 3.0 - s 
    98     ms = 0.5*(m-s) # =(n-3+m)/2 
     98    ms = 0.5*(porod_exp-s) # =(n-3+porod_exp)/2 
    9999 
    100100    # preallocate return value 
     
    109109    with errstate(divide='ignore'): 
    110110        iq[idx] = q[idx]**-s * exp(-(q[idx]*rg)**2/n) 
    111         iq[~idx] = q[~idx]**-m * (exp(-ms) * (n*ms/rg**2)**ms) 
     111        iq[~idx] = q[~idx]**-porod_exp * (exp(-ms) * (n*ms/rg**2)**ms) 
    112112    return iq 
    113113 
    114114Iq.vectorized = True # Iq accepts an array of q values 
    115115 
    116 demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, m=3.0) 
     116demo = dict(scale=1.5, background=0.5, rg=60, s=1.0, porod_exp=3.0) 
    117117 
    118118tests = [[{'scale': 1.5, 'background':0.5}, 0.04, 5.290096890253155]] 
  • sasmodels/models/hayter_msa.py

    r40a87fa ra807206  
    5151#  dp[2] = volfraction(); 
    5252#  dp[3] = temperature(); 
    53 #  dp[4] = salt_concentration(); 
     53#  dp[4] = concentration_salt(); 
    5454#  dp[5] = dielectconst(); 
    5555 
     
    7676    ["charge",        "e",   19.0,    [0, inf],    "", "charge on sphere (in electrons)"], 
    7777    ["temperature",   "K",  318.16,   [0, inf],    "", "temperature, in Kelvin, for Debye length calculation"], 
    78     ["salt_concentration",      "M",    0.0,    [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
     78    ["concentration_salt",      "M",    0.0,    [-inf, inf], "", "conc of salt, moles/litre, 1:1 electolyte, for Debye length"], 
    7979    ["dielectconst",  "None",    71.08,   [-inf, inf], "", "dielectric constant (relative permittivity) of solvent, default water, for Debye length"] 
    8080    ] 
    8181# pylint: enable=bad-whitespace, line-too-long 
    8282 
    83 source = ["hayter_msa_kernel.c"] 
     83source = ["hayter_msa.c"] 
    8484# No volume normalization despite having a volume parameter 
    8585# This should perhaps be volume normalized? 
     
    9393# note the calculation varies in different limiting cases so a wide range of 
    9494# parameters will be required for a thorough test! 
    95 # odd that the default st has salt_concentration zero 
     95# odd that the default st has concentration_salt zero 
    9696demo = dict(radius_effective=20.75, 
    9797            charge=19.0, 
    9898            volfraction=0.0192, 
    9999            temperature=318.16, 
    100             salt_concentration=0.05, 
     100            concentration_salt=0.05, 
    101101            dielectconst=71.08, 
    102102            radius_effective_pd=0.1, 
     
    113113      'volfraction': 0.0192, 
    114114      'temperature': 298.0, 
    115       'salt_concentration': 0, 
     115      'concentration_salt': 0, 
    116116      'dielectconst': 78.0, 
    117117      'radius_effective_pd': 0}, 
     
    123123      'volfraction': 0.0192, 
    124124      'temperature': 298.0, 
    125       'salt_concentration': 0.05, 
     125      'concentration_salt': 0.05, 
    126126      'dielectconst': 78.0, 
    127127      'radius_effective_pd': 0.1, 
  • sasmodels/models/hollow_cylinder.c

    rf95556f ra807206  
    1 double form_volume(double radius, double core_radius, double length); 
     1double form_volume(double radius, double radius_core, double length); 
    22 
    3 double Iq(double q, double radius, double core_radius, double length, double sld, 
     3double Iq(double q, double radius, double radius_core, double length, double sld, 
    44        double solvent_sld); 
    5 double Iqxy(double qx, double qy, double radius, double core_radius, double length, double sld, 
     5double Iqxy(double qx, double qy, double radius, double radius_core, double length, double sld, 
    66        double solvent_sld, double theta, double phi); 
    77 
    8 #define INVALID(v) (v.core_radius >= v.radius) 
     8#define INVALID(v) (v.radius_core >= v.radius) 
    99 
    1010// From Igor library 
     
    2727 
    2828static double _hollow_cylinder_kernel( 
    29     double q, double core_radius, double radius, double length, double dum) 
     29    double q, double radius_core, double radius, double length, double dum) 
    3030{ 
    3131    const double qs = q*sqrt(1.0-dum*dum); 
    3232    const double lam1 = sas_J1c(radius*qs); 
    33     const double lam2 = sas_J1c(core_radius*qs); 
    34     const double gamma_sq = square(core_radius/radius); 
    35     //Note: lim_{r -> r_c} psi = J0(core_radius*qs) 
     33    const double lam2 = sas_J1c(radius_core*qs); 
     34    const double gamma_sq = square(radius_core/radius); 
     35    //Note: lim_{r -> r_c} psi = J0(radius_core*qs) 
    3636    const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 
    3737    const double t2 = sinc(q*length*dum/2.0); 
     
    4141 
    4242static double hollow_cylinder_analytical_2D_scaled( 
    43     double q, double q_x, double q_y, double radius, double core_radius, 
     43    double q, double q_x, double q_y, double radius, double radius_core, 
    4444    double length, double sld, double solvent_sld, double theta, double phi) 
    4545{ 
     
    6565    cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 
    6666 
    67     answer = _hollow_cylinder_kernel(q, core_radius, radius, length, cos_val); 
     67    answer = _hollow_cylinder_kernel(q, radius_core, radius, length, cos_val); 
    6868 
    69     vol = form_volume(radius, core_radius, length); 
     69    vol = form_volume(radius, radius_core, length); 
    7070    answer = hollow_cylinder_scaling(answer, delrho, vol); 
    7171 
     
    7474 
    7575 
    76 double form_volume(double radius, double core_radius, double length) 
     76double form_volume(double radius, double radius_core, double length) 
    7777{ 
    78     double v_shell = M_PI*length*(radius*radius-core_radius*core_radius); 
     78    double v_shell = M_PI*length*(radius*radius-radius_core*radius_core); 
    7979    return(v_shell); 
    8080} 
    8181 
    8282 
    83 double Iq(double q, double radius, double core_radius, double length, 
     83double Iq(double q, double radius, double radius_core, double length, 
    8484    double sld, double solvent_sld) 
    8585{ 
     
    9595    for (i=0;i<76;i++) { 
    9696        zi = ( Gauss76Z[i] * (upper-lower) + lower + upper )/2.0; 
    97         inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, core_radius, radius, length, zi); 
     97        inter = Gauss76Wt[i] * _hollow_cylinder_kernel(q, radius_core, radius, length, zi); 
    9898        summ += inter; 
    9999    } 
    100100 
    101101    norm = summ*(upper-lower)/2.0; 
    102     volume = form_volume(radius, core_radius, length); 
     102    volume = form_volume(radius, radius_core, length); 
    103103    delrho = solvent_sld - sld; 
    104104    answer = hollow_cylinder_scaling(norm, delrho, volume); 
     
    108108 
    109109 
    110 double Iqxy(double qx, double qy, double radius, double core_radius, 
     110double Iqxy(double qx, double qy, double radius, double radius_core, 
    111111    double length, double sld, double solvent_sld, double theta, double phi) 
    112112{ 
    113113    const double q = sqrt(qx*qx+qy*qy); 
    114     return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, core_radius, length, sld, solvent_sld, theta, phi); 
     114    return hollow_cylinder_analytical_2D_scaled(q, qx/q, qy/q, radius, radius_core, length, sld, solvent_sld, theta, phi); 
    115115} 
  • sasmodels/models/hollow_cylinder.py

    r58210db ra807206  
    3939 
    4040In the parameters, the contrast represents SLD :sub:`shell` - SLD :sub:`solvent` 
    41 and the *radius* is $R_\text{shell}$ while *core_radius* is $R_\text{core}$. 
     41and the *radius* is $R_\text{shell}$ while *radius_core* is $R_\text{core}$. 
    4242 
    4343To provide easy access to the orientation of the core-shell cylinder, we define 
     
    5858description = """ 
    5959P(q) = scale*<f*f>/Vol + background, where f is the scattering amplitude. 
    60 core_radius = the radius of core 
     60radius_core = the radius of core 
    6161radius = the radius of shell 
    6262length = the total length of the cylinder 
     
    7070parameters = [ 
    7171    ["radius",      "Ang",     30.0, [0, inf],    "volume",      "Cylinder radius"], 
    72     ["core_radius", "Ang",     20.0, [0, inf],    "volume",      "Hollow core radius"], 
     72    ["radius_core", "Ang",     20.0, [0, inf],    "volume",      "Hollow core radius"], 
    7373    ["length",      "Ang",    400.0, [0, inf],    "volume",      "Cylinder length"], 
    7474    ["sld",         "1/Ang^2",  6.3, [-inf, inf], "sld",         "Cylinder sld"], 
     
    8282 
    8383# pylint: disable=W0613 
    84 def ER(radius, core_radius, length): 
     84def ER(radius, radius_core, length): 
    8585    """ 
    8686    :param radius:      Cylinder radius 
    87     :param core_radius: Hollow core radius, UNUSED 
     87    :param radius_core: Hollow core radius, UNUSED 
    8888    :param length:      Cylinder length 
    8989    :return:            Effective radius 
     
    9999    return diam 
    100100 
    101 def VR(radius, core_radius, length): 
     101def VR(radius, radius_core, length): 
    102102    """ 
    103103    :param radius:      Cylinder radius 
    104     :param core_radius: Hollow core radius 
     104    :param radius_core: Hollow core radius 
    105105    :param length:      Cylinder length 
    106106    :return:            Volf ratio for P(q)*S(q) 
    107107    """ 
    108     vol_core = pi*core_radius*core_radius*length 
     108    vol_core = pi*radius_core*radius_core*length 
    109109    vol_total = pi*radius*radius*length 
    110110    vol_shell = vol_total - vol_core 
     
    113113# parameters for demo 
    114114demo = dict(scale=1.0, background=0.0, length=400.0, radius=30.0, 
    115             core_radius=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0, 
     115            radius_core=20.0, sld=6.3, sld_solvent=1, theta=90, phi=0, 
    116116            radius_pd=.2, radius_pd_n=9, 
    117117            length_pd=.2, length_pd_n=10, 
    118             core_radius_pd=.2, core_radius_pd_n=9, 
     118            radius_core_pd=.2, radius_core_pd_n=9, 
    119119            theta_pd=10, theta_pd_n=5, 
    120120           ) 
  • sasmodels/models/hollow_rectangular_prism.c

    rdeb7ee0 ra807206  
    1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio, double thickness); 
    2 double Iq(double q, double sld, double solvent_sld, double a_side,  
     1double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness); 
     2double Iq(double q, double sld, double solvent_sld, double length_a,  
    33          double b2a_ratio, double c2a_ratio, double thickness); 
    44double Iqxy(double qx, double qy, double sld, double solvent_sld,  
    5             double a_side, double b2a_ratio, double c2a_ratio, double thickness); 
     5            double length_a, double b2a_ratio, double c2a_ratio, double thickness); 
    66 
    7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio, double thickness) 
     7double form_volume(double length_a, double b2a_ratio, double c2a_ratio, double thickness) 
    88{ 
    9     double b_side = a_side * b2a_ratio; 
    10     double c_side = a_side * c2a_ratio; 
    11     double a_core = a_side - 2.0*thickness; 
     9    double b_side = length_a * b2a_ratio; 
     10    double c_side = length_a * c2a_ratio; 
     11    double a_core = length_a - 2.0*thickness; 
    1212    double b_core = b_side - 2.0*thickness; 
    1313    double c_core = c_side - 2.0*thickness; 
    1414    double vol_core = a_core * b_core * c_core; 
    15     double vol_total = a_side * b_side * c_side; 
     15    double vol_total = length_a * b_side * c_side; 
    1616    double vol_shell = vol_total - vol_core; 
    1717    return vol_shell; 
     
    2121    double sld, 
    2222    double solvent_sld, 
    23     double a_side, 
     23    double length_a, 
    2424    double b2a_ratio, 
    2525    double c2a_ratio, 
     
    2828    double termA1, termA2, termB1, termB2, termC1, termC2; 
    2929     
    30     double b_side = a_side * b2a_ratio; 
    31     double c_side = a_side * c2a_ratio; 
    32     double a_half = 0.5 * a_side; 
     30    double b_side = length_a * b2a_ratio; 
     31    double c_side = length_a * c2a_ratio; 
     32    double a_half = 0.5 * length_a; 
    3333    double b_half = 0.5 * b_side; 
    3434    double c_half = 0.5 * c_side; 
     
    7373                if (fabs(arg) > 1.e-16) {termB2 = sin(arg)/arg;} else {termB2 = 1.0;} 
    7474 
    75             double AP1 = (a_side*b_side*c_side) * termA1 * termB1 * termC1; 
     75            double AP1 = (length_a*b_side*c_side) * termA1 * termB1 * termC1; 
    7676            double AP2 = 8.0 * (a_half-thickness) * (b_half-thickness) * (c_half-thickness) * termA2 * termB2 * termC2; 
    7777            double AP = AP1 - AP2; 
     
    105105    double sld, 
    106106    double solvent_sld, 
    107     double a_side, 
     107    double length_a, 
    108108    double b2a_ratio, 
    109109    double c2a_ratio, 
     
    111111{ 
    112112    double q = sqrt(qx*qx + qy*qy); 
    113     double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio, thickness);  
     113    double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio, thickness);  
    114114    return intensity;     
    115115} 
  • sasmodels/models/hollow_rectangular_prism.py

    r40a87fa ra807206  
    105105              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    106106               "Solvent scattering length density"], 
    107               ["a_side", "Ang", 35, [0, inf], "volume", 
     107              ["length_a", "Ang", 35, [0, inf], "volume", 
    108108               "Shorter side of the parallelepiped"], 
    109109              ["b2a_ratio", "Ang", 1, [0, inf], "volume", 
     
    117117source = ["lib/gauss76.c", "hollow_rectangular_prism.c"] 
    118118 
    119 def ER(a_side, b2a_ratio, c2a_ratio, thickness): 
     119def ER(length_a, b2a_ratio, c2a_ratio, thickness): 
    120120    """ 
    121121    Return equivalent radius (ER) 
    122122    thickness parameter not used 
    123123    """ 
    124     b_side = a_side * b2a_ratio 
    125     c_side = a_side * c2a_ratio 
     124    b_side = length_a * b2a_ratio 
     125    c_side = length_a * c2a_ratio 
    126126 
    127127    # surface average radius (rough approximation) 
    128     surf_rad = sqrt(a_side * b_side / pi) 
     128    surf_rad = sqrt(length_a * b_side / pi) 
    129129 
    130130    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 
    131131    return 0.5 * (ddd) ** (1. / 3.) 
    132132 
    133 def VR(a_side, b2a_ratio, c2a_ratio, thickness): 
     133def VR(length_a, b2a_ratio, c2a_ratio, thickness): 
    134134    """ 
    135135    Return shell volume and total volume 
    136136    """ 
    137     b_side = a_side * b2a_ratio 
    138     c_side = a_side * c2a_ratio 
    139     a_core = a_side - 2.0*thickness 
     137    b_side = length_a * b2a_ratio 
     138    c_side = length_a * c2a_ratio 
     139    a_core = length_a - 2.0*thickness 
    140140    b_core = b_side - 2.0*thickness 
    141141    c_core = c_side - 2.0*thickness 
    142142    vol_core = a_core * b_core * c_core 
    143     vol_total = a_side * b_side * c_side 
     143    vol_total = length_a * b_side * c_side 
    144144    vol_shell = vol_total - vol_core 
    145145    return vol_total, vol_shell 
     
    149149demo = dict(scale=1, background=0, 
    150150            sld=6.3e-6, sld_solvent=1.0e-6, 
    151             a_side=35, b2a_ratio=1, c2a_ratio=1, thickness=1, 
    152             a_side_pd=0.1, a_side_pd_n=10, 
     151            length_a=35, b2a_ratio=1, c2a_ratio=1, thickness=1, 
     152            length_a_pd=0.1, length_a_pd_n=10, 
    153153            b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 
    154154            c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.c

    r3d8283b ra807206  
    1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio); 
    2 double Iq(double q, double sld, double solvent_sld, double a_side,  
     1double form_volume(double length_a, double b2a_ratio, double c2a_ratio); 
     2double Iq(double q, double sld, double solvent_sld, double length_a,  
    33          double b2a_ratio, double c2a_ratio); 
    44double Iqxy(double qx, double qy, double sld, double solvent_sld,  
    5             double a_side, double b2a_ratio, double c2a_ratio); 
     5            double length_a, double b2a_ratio, double c2a_ratio); 
    66 
    7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio) 
     7double form_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    88{ 
    9     double b_side = a_side * b2a_ratio; 
    10     double c_side = a_side * c2a_ratio; 
    11     double vol_shell = 2.0 * (a_side*b_side + a_side*c_side + b_side*c_side); 
     9    double b_side = length_a * b2a_ratio; 
     10    double c_side = length_a * c2a_ratio; 
     11    double vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side); 
    1212    return vol_shell; 
    1313} 
     
    1616    double sld, 
    1717    double solvent_sld, 
    18     double a_side, 
     18    double length_a, 
    1919    double b2a_ratio, 
    2020    double c2a_ratio) 
    2121{ 
    22     double b_side = a_side * b2a_ratio; 
    23     double c_side = a_side * c2a_ratio; 
    24     double a_half = 0.5 * a_side; 
     22    double b_side = length_a * b2a_ratio; 
     23    double c_side = length_a * c2a_ratio; 
     24    double a_half = 0.5 * length_a; 
    2525    double b_half = 0.5 * b_side; 
    2626    double c_half = 0.5 * c_side; 
     
    8888    double sld, 
    8989    double solvent_sld, 
    90     double a_side, 
     90    double length_a, 
    9191    double b2a_ratio, 
    9292    double c2a_ratio) 
    9393{ 
    9494    double q = sqrt(qx*qx + qy*qy); 
    95     double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio);  
     95    double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio);  
    9696    return intensity;     
    9797} 
  • sasmodels/models/hollow_rectangular_prism_thin_walls.py

    r42356c8 ra807206  
    9191              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    9292               "Solvent scattering length density"], 
    93               ["a_side", "Ang", 35, [0, inf], "volume", 
     93              ["length_a", "Ang", 35, [0, inf], "volume", 
    9494               "Shorter side of the parallelepiped"], 
    9595              ["b2a_ratio", "Ang", 1, [0, inf], "volume", 
     
    101101source = ["lib/gauss76.c", "hollow_rectangular_prism_thin_walls.c"] 
    102102 
    103 def ER(a_side, b2a_ratio, c2a_ratio): 
     103def ER(length_a, b2a_ratio, c2a_ratio): 
    104104    """ 
    105105        Return equivalent radius (ER) 
    106106    """ 
    107     b_side = a_side * b2a_ratio 
    108     c_side = a_side * c2a_ratio 
     107    b_side = length_a * b2a_ratio 
     108    c_side = length_a * c2a_ratio 
    109109 
    110110    # surface average radius (rough approximation) 
    111     surf_rad = sqrt(a_side * b_side / pi) 
     111    surf_rad = sqrt(length_a * b_side / pi) 
    112112 
    113113    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 
    114114    return 0.5 * (ddd) ** (1. / 3.) 
    115115 
    116 def VR(a_side, b2a_ratio, c2a_ratio): 
     116def VR(length_a, b2a_ratio, c2a_ratio): 
    117117    """ 
    118118        Return shell volume and total volume 
    119119    """ 
    120     b_side = a_side * b2a_ratio 
    121     c_side = a_side * c2a_ratio 
    122     vol_total = a_side * b_side * c_side 
    123     vol_shell = 2.0 * (a_side*b_side + a_side*c_side + b_side*c_side) 
     120    b_side = length_a * b2a_ratio 
     121    c_side = length_a * c2a_ratio 
     122    vol_total = length_a * b_side * c_side 
     123    vol_shell = 2.0 * (length_a*b_side + length_a*c_side + b_side*c_side) 
    124124    return vol_shell, vol_total 
    125125 
     
    128128demo = dict(scale=1, background=0, 
    129129            sld=6.3e-6, sld_solvent=1.0e-6, 
    130             a_side=35, b2a_ratio=1, c2a_ratio=1, 
    131             a_side_pd=0.1, a_side_pd_n=10, 
     130            length_a=35, b2a_ratio=1, c2a_ratio=1, 
     131            length_a_pd=0.1, length_a_pd_n=10, 
    132132            b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 
    133133            c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) 
  • sasmodels/models/lamellar_hg.py

    r40a87fa ra807206  
    2525        \right\rbrace^2 
    2626 
    27 where $\delta_T$ is *tail_length*, $\delta_H$ is *head_length*, 
     27where $\delta_T$ is *length_tail*, $\delta_H$ is *length_head*, 
    2828$\Delta\rho_H$ is the head contrast (*sld_head* $-$ *sld_solvent*), 
    2929and $\Delta\rho_T$ is tail contrast (*sld* $-$ *sld_solvent*). 
     
    6767# pylint: disable=bad-whitespace, line-too-long 
    6868#             ["name", "units", default, [lower, upper], "type","description"], 
    69 parameters = [["tail_length", "Ang",       15,   [0, inf],  "volume",  "Tail thickness ( total = H+T+T+H)"], 
    70               ["head_length", "Ang",       10,   [0, inf],  "volume",  "Head thickness"], 
     69parameters = [["length_tail", "Ang",       15,   [0, inf],  "volume",  "Tail thickness ( total = H+T+T+H)"], 
     70              ["length_head", "Ang",       10,   [0, inf],  "volume",  "Head thickness"], 
    7171              ["sld",         "1e-6/Ang^2", 0.4, [-inf,inf], "sld",    "Tail scattering length density"], 
    7272              ["sld_head",    "1e-6/Ang^2", 3.0, [-inf,inf], "sld",    "Head scattering length density"], 
     
    8484    const double drh = sld_head - sld_solvent; 
    8585    const double drt = sld - sld_solvent;    //correction 13FEB06 by L.Porcar 
    86     const double qT = q*tail_length; 
     86    const double qT = q*length_tail; 
    8787    double Pq, inten; 
    88     Pq = drh*(sin(q*(head_length+tail_length))-sin(qT)) + drt*sin(qT); 
     88    Pq = drh*(sin(q*(length_head+length_tail))-sin(qT)) + drt*sin(qT); 
    8989    Pq *= Pq; 
    9090    Pq *= 4.0/(qsq); 
     
    9393 
    9494    // normalize by the bilayer thickness 
    95     inten /= 2.0*(head_length+tail_length); 
     95    inten /= 2.0*(length_head+length_tail); 
    9696 
    9797    return inten; 
     
    102102 
    103103demo = dict(scale=1, background=0, 
    104             tail_length=15, head_length=10, 
     104            length_tail=15, length_head=10, 
    105105            sld=0.4, sld_head=3.0, sld_solvent=6.0, 
    106             tail_length_pd=0.2, tail_length_pd_n=40, 
    107             head_length_pd=0.01, head_length_pd_n=40) 
     106            length_tail_pd=0.2, length_tail_pd_n=40, 
     107            length_head_pd=0.01, length_head_pd_n=40) 
    108108 
    109109# 
    110110tests = [ 
    111     [{'scale': 1.0, 'background': 0.0, 'tail_length': 15.0, 'head_length': 10.0, 
     111    [{'scale': 1.0, 'background': 0.0, 'length_tail': 15.0, 'length_head': 10.0, 
    112112      'sld': 0.4, 'sld_head': 3.0, 'sld_solvent': 6.0}, 
    113113     [0.001], [653143.9209]], 
  • sasmodels/models/lamellar_hg_stack_caille.c

    r6ab4ed8 ra807206  
    44 
    55double Iq(double qval, 
    6       double tail_length, 
    7       double head_length, 
     6      double length_tail, 
     7      double length_head, 
    88      double Nlayers,  
    99      double dd, 
     
    1414 
    1515double Iq(double qval, 
    16       double tail_length, 
    17       double head_length, 
     16      double length_tail, 
     17      double length_head, 
    1818      double Nlayers,  
    1919      double dd, 
     
    3434  NN = trunc(Nlayers);    //be sure that NN is an integer 
    3535   
    36   Pq = (head_sld-solvent_sld)*(sin(qval*(head_length+tail_length))-sin(qval*tail_length)) + 
    37               (tail_sld-solvent_sld)*sin(qval*tail_length); 
     36  Pq = (head_sld-solvent_sld)*(sin(qval*(length_head+length_tail))-sin(qval*length_tail)) + 
     37              (tail_sld-solvent_sld)*sin(qval*length_tail); 
    3838  Pq *= Pq; 
    3939  Pq *= 4.0/(qval*qval); 
  • sasmodels/models/lamellar_hg_stack_caille.py

    r40a87fa r7c57861  
    4242 
    4343 
    44 $\delta_T$ is the tail length (or *tail_length*), $\delta_H$ is the head 
    45 thickness (or *head_length*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent), 
     44$\delta_T$ is the tail length (or *length_tail*), $\delta_H$ is the head 
     45thickness (or *length_head*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent), 
    4646and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing, 
    4747$K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the 
     
    9494    #   [ "name", "units", default, [lower, upper], "type", 
    9595    #     "description" ], 
    96     ["tail_length", "Ang", 10, [0, inf], "volume", 
     96    ["length_tail", "Ang", 10, [0, inf], "volume", 
    9797     "Tail thickness"], 
    98     ["head_length", "Ang", 2, [0, inf], "volume", 
     98    ["length_head", "Ang", 2, [0, inf], "volume", 
    9999     "head thickness"], 
    100100    ["Nlayers", "", 30, [0, inf], "", 
    101101     "Number of layers"], 
    102     ["spacing", "Ang", 40., [0.0, inf], "volume", 
    103      "d-spacing of Caille S(Q)"], 
     102    ["d_spacing", "Ang", 40., [0.0, inf], "volume", 
     103     "lamellar d-spacing of Caille S(Q)"], 
    104104    ["Caille_parameter", "", 0.001, [0.0, 0.8], "", 
    105105     "Caille parameter"], 
     
    112112    ] 
    113113 
    114 source = ["lamellar_hg_stack_caille_kernel.c"] 
     114source = ["lamellar_hg_stack_caille.c"] 
    115115 
    116116# No volume normalization despite having a volume parameter 
     
    125125demo = dict( 
    126126    scale=1, background=0, 
    127     Nlayers=20, spacing=200., Caille_parameter=0.05, 
    128     tail_length=15, head_length=10, 
     127    Nlayers=20, d_spacing=200., Caille_parameter=0.05, 
     128    length_tail=15, length_head=10, 
    129129    #sld=-1, sld_head=4.0, sld_solvent=6.0, 
    130130    sld=-1, sld_head=4.1, sld_solvent=6.0, 
    131     tail_length_pd=0.1, tail_length_pd_n=20, 
    132     head_length_pd=0.05, head_length_pd_n=30, 
    133     spacing_pd=0.2, spacing_pd_n=40, 
     131    length_tail_pd=0.1, length_tail_pd_n=20, 
     132    length_head_pd=0.05, length_head_pd_n=30, 
     133    d_spacing_pd=0.2, d_spacing_pd_n=40, 
    134134    ) 
    135135 
    136136# 
    137 tests = [[{'scale': 1.0, 'background': 0.0, 'tail_length': 10.0, 'head_length': 2.0, 
    138            'Nlayers': 30.0, 'spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4, 
    139            'sld_head': 2.0, 'sld_solvent': 6.0, 'tail_length_pd': 0.0, 
    140            'head_length_pd': 0.0, 'spacing_pd': 0.0}, [0.001], [6838238.571488]]] 
     137tests = [[{'scale': 1.0, 'background': 0.0, 'length_tail': 10.0, 'length_head': 2.0, 
     138           'Nlayers': 30.0, 'd_spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4, 
     139           'sld_head': 2.0, 'sld_solvent': 6.0, 'length_tail_pd': 0.0, 
     140           'length_head_pd': 0.0, 'd_spacing_pd': 0.0}, [0.001], [6838238.571488]]] 
    141141# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs 
  • sasmodels/models/lamellar_stack_caille.py

    r40a87fa r7c57861  
    4040    \end{align*} 
    4141 
    42 Here $d$ = (repeat) spacing, $\delta$ = bilayer thickness, 
     42Here $d$ = (repeat) d_spacing, $\delta$ = bilayer thickness, 
    4343the contrast $\Delta\rho$ = SLD(headgroup) - SLD(solvent), 
    4444$K$ = smectic bending elasticity, $B$ = compression modulus, and 
     
    8989    ["thickness",        "Ang",      30.0,  [0, inf],   "volume", "sheet thickness"], 
    9090    ["Nlayers",          "",          20,   [0, inf],   "",       "Number of layers"], 
    91     ["spacing",          "Ang",      400.,  [0.0,inf],  "volume", "d-spacing of Caille S(Q)"], 
     91    ["d_spacing",        "Ang",      400.,  [0.0,inf],  "volume", "lamellar d-spacing of Caille S(Q)"], 
    9292    ["Caille_parameter", "1/Ang^2",    0.1, [0.0,0.8],  "",       "Caille parameter"], 
    9393    ["sld",              "1e-6/Ang^2", 6.3, [-inf,inf], "sld",    "layer scattering length density"], 
     
    9696# pylint: enable=bad-whitespace, line-too-long 
    9797 
    98 source = ["lamellar_stack_caille_kernel.c"] 
     98source = ["lamellar_stack_caille.c"] 
    9999 
    100100# No volume normalization despite having a volume parameter 
     
    108108 
    109109demo = dict(scale=1, background=0, 
    110             thickness=67., Nlayers=3.75, spacing=200., 
     110            thickness=67., Nlayers=3.75, d_spacing=200., 
    111111            Caille_parameter=0.268, sld=1.0, sld_solvent=6.34, 
    112112            thickness_pd=0.1, thickness_pd_n=100, 
    113             spacing_pd=0.05, spacing_pd_n=40) 
     113            d_spacing_pd=0.05, d_spacing_pd_n=40) 
    114114 
    115115# 
    116116tests = [ 
    117117    [{'scale': 1.0, 'background': 0.0, 'thickness': 30., 'Nlayers': 20.0, 
    118       'spacing': 400., 'Caille_parameter': 0.1, 'sld': 6.3, 
    119       'sld_solvent': 1.0, 'thickness_pd': 0.0, 'spacing_pd': 0.0}, 
     118      'd_spacing': 400., 'Caille_parameter': 0.1, 'sld': 6.3, 
     119      'sld_solvent': 1.0, 'thickness_pd': 0.0, 'd_spacing_pd': 0.0}, 
    120120     [0.001], [28895.13397]] 
    121121    ] 
  • sasmodels/models/lamellar_stack_paracrystal.py

    r40a87fa r7c57861  
    2222- *Nlayers* is the number of layers $N$, 
    2323 
    24 - *spacing* is the average distance between adjacent layers 
     24- *d_spacing* is the average distance between adjacent layers 
    2525  $\langle D \rangle$, and 
    2626 
    27 - *spacing_polydisp* is the relative standard deviation of the Gaussian 
     27- *sigma_d* is the relative standard deviation of the Gaussian 
    2828  layer distance distribution $\sigma_D / \langle D \rangle$. 
    2929 
     
    115115              ["Nlayers", "", 20, [0, inf], "", 
    116116               "Number of layers"], 
    117               ["spacing", "Ang", 250., [0.0, inf], "", 
    118                "d-spacing of paracrystal stack"], 
    119               ["spacing_polydisp", "Ang", 0.0, [0.0, inf], "", 
    120                "d-spacing polydispersity"], 
     117              ["d_spacing", "Ang", 250., [0.0, inf], "", 
     118               "lamellar spacing of paracrystal stack"], 
     119              ["sigma_d", "Ang", 0.0, [0.0, inf], "", 
     120               "Sigma (polydispersity) of the lamellar spacing"], 
    121121              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", 
    122122               "layer scattering length density"], 
     
    126126 
    127127 
    128 source = ["lamellar_stack_paracrystal_kernel.c"] 
     128source = ["lamellar_stack_paracrystal.c"] 
    129129 
    130130form_volume = """ 
     
    136136 
    137137demo = dict(scale=1, background=0, 
    138             thickness=33, Nlayers=20, spacing=250, spacing_polydisp=0.2, 
     138            thickness=33, Nlayers=20, d_spacing=250, sigma_d=0.2, 
    139139            sld=1.0, sld_solvent=6.34, 
    140140            thickness_pd=0.2, thickness_pd_n=40) 
     
    143143tests = [ 
    144144    [{'scale': 1.0, 'background': 0.0, 'thickness': 33.,'Nlayers': 20.0, 
    145       'spacing': 250., 'spacing_polydisp': 0.2, 'sld': 1.0, 
     145      'd_spacing': 250., 'sigma_d': 0.2, 'sld': 1.0, 
    146146      'sld_solvent': 6.34, 'thickness_pd': 0.0, 'thickness_pd_n': 40 }, 
    147147     [0.001, 0.215268], [21829.3, 0.00487686]], 
  • sasmodels/models/mass_fractal.c

    r2c74c11 ra807206  
    33double Iq(double q, 
    44          double radius, 
    5           double mass_dim, 
     5          double fractal_dim_mass, 
    66          double cutoff_length); 
    77 
    88static double _mass_fractal_kernel(double q, 
    99          double radius, 
    10           double mass_dim, 
     10          double fractal_dim_mass, 
    1111          double cutoff_length) 
    1212{ 
    1313    // Actively check the argument. 
    14     if (mass_dim <= 1.0){ 
     14    if (fractal_dim_mass <= 1.0){ 
    1515       return 0.0; 
    1616    } 
     
    2121 
    2222    //calculate S(q) 
    23     double mmo = mass_dim-1.0; 
     23    double mmo = fractal_dim_mass-1.0; 
    2424    double sq = sas_gamma(mmo)*sin((mmo)*atan(q*cutoff_length)); 
    2525    sq *= pow(cutoff_length, mmo); 
     
    3939double Iq(double q, 
    4040          double radius, 
    41           double mass_dim, 
     41          double fractal_dim_mass, 
    4242          double cutoff_length) 
    4343{ 
    4444    return _mass_fractal_kernel(q, 
    4545           radius, 
    46            mass_dim, 
     46           fractal_dim_mass, 
    4747           cutoff_length); 
    4848} 
  • sasmodels/models/mass_fractal.py

    rec45c4f ra807206  
    6868        where delta = sldParticle -sldSolv. 
    6969        radius       =  Particle radius 
    70         mass_dim  =  Mass fractal dimension 
     70        fractal_dim_mass  =  Mass fractal dimension 
    7171        cutoff_length  =  Cut-off length 
    7272        background   =  background 
    7373        Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 9, 1535-1545 
    74         Note I: This model is valid for 1<mass_dim<6. 
     74        Note I: This model is valid for 1<fractal_dim_mass<6. 
    7575        Note II: This model is not in absolute scale. 
    7676        """ 
     
    8080#             ["name", "units", default, [lower, upper], "type","description"], 
    8181parameters = [["radius",        "Ang",  10.0, [0.0, inf], "", "Particle radius"], 
    82               ["mass_dim",      "",      1.9, [1.0, 6.0], "", "Mass fractal dimension"], 
     82              ["fractal_dim_mass",      "",      1.9, [1.0, 6.0], "", "Mass fractal dimension"], 
    8383              ["cutoff_length", "Ang", 100.0, [0.0, inf], "", "Cut-off length"], 
    8484             ] 
     
    8989demo = dict(scale=1, background=0, 
    9090            radius=10.0, 
    91             mass_dim=1.9, 
     91            fractal_dim_mass=1.9, 
    9292            cutoff_length=100.0) 
    9393 
     
    9696    # Accuracy tests based on content in test/utest_other_models.py 
    9797    [{'radius':         10.0, 
    98       'mass_dim':        1.9, 
     98      'fractal_dim_mass':        1.9, 
    9999      'cutoff_length': 100.0, 
    100100     }, 0.05, 279.59422], 
     
    102102    # Additional tests with larger range of parameters 
    103103    [{'radius':        2.0, 
    104       'mass_dim':      3.3, 
     104      'fractal_dim_mass':      3.3, 
    105105      'cutoff_length': 1.0, 
    106106     }, 0.5, 1.29116774904], 
    107107 
    108108    [{'radius':        1.0, 
    109       'mass_dim':      1.3, 
     109      'fractal_dim_mass':      1.3, 
    110110      'cutoff_length': 1.0, 
    111111      'background':    0.8, 
     
    113113 
    114114    [{'radius':        1.0, 
    115       'mass_dim':      2.3, 
     115      'fractal_dim_mass':      2.3, 
    116116      'cutoff_length': 1.0, 
    117117      'scale':        10.0, 
  • sasmodels/models/mass_surface_fractal.c

    r2c74c11 r30fbe2e  
    22 
    33double Iq(double q, 
    4           double mass_dim, 
    5           double surface_dim, 
    6           double cluster_rg, 
    7           double primary_rg); 
     4          double fractal_dim_mass, 
     5          double fractal_dim_surf, 
     6          double rg_cluster, 
     7          double rg_primary); 
    88 
    99static double _mass_surface_fractal_kernel(double q, 
    10           double mass_dim, 
    11           double surface_dim, 
    12           double cluster_rg, 
    13           double primary_rg) 
     10          double fractal_dim_mass, 
     11          double fractal_dim_surf, 
     12          double rg_cluster, 
     13          double rg_primary) 
    1414{ 
    1515     //computation 
    16     double tot_dim = 6.0 - surface_dim - mass_dim; 
    17     mass_dim /= 2.0; 
     16    double tot_dim = 6.0 - fractal_dim_surf - fractal_dim_mass; 
     17    fractal_dim_mass /= 2.0; 
    1818    tot_dim /= 2.0; 
    1919 
    20     double rc_norm = cluster_rg * cluster_rg / (3.0 * mass_dim); 
    21     double rp_norm = primary_rg * primary_rg / (3.0 * tot_dim); 
     20    double rc_norm = rg_cluster * rg_cluster / (3.0 * fractal_dim_mass); 
     21    double rp_norm = rg_primary * rg_primary / (3.0 * tot_dim); 
    2222 
    2323    //x for P 
     
    2525    double x_val2 = 1.0 +  q * q * rp_norm; 
    2626 
    27     double inv_form = pow(x_val1, mass_dim) * pow(x_val2, tot_dim); 
     27    double inv_form = pow(x_val1, fractal_dim_mass) * pow(x_val2, tot_dim); 
    2828 
    2929    //another singular 
     
    4141 
    4242double Iq(double q, 
    43           double mass_dim, 
    44           double surface_dim, 
    45           double cluster_rg, 
    46           double primary_rg) 
     43          double fractal_dim_mass, 
     44          double fractal_dim_surf, 
     45          double rg_cluster, 
     46          double rg_primary) 
    4747{ 
    4848    return _mass_surface_fractal_kernel(q, 
    49             mass_dim, 
    50             surface_dim, 
    51             cluster_rg, 
    52             primary_rg); 
     49            fractal_dim_mass, 
     50            fractal_dim_surf, 
     51            rg_cluster, 
     52            rg_primary); 
    5353} 
  • sasmodels/models/mass_surface_fractal.py

    rec45c4f r30fbe2e  
    6666        b = rg^2/(3*(6-Ds-Dm)/2) 
    6767        scale        =  scale factor * N*Volume^2*contrast^2 
    68         mass_dim       =  Dm (mass fractal dimension) 
    69         surface_dim  =  Ds 
    70         cluster_rg  =  Rg 
    71         primary_rg    =  rg 
     68        fractal_dim_mass       =  Dm (mass fractal dimension) 
     69        fractal_dim_surf  =  Ds 
     70        rg_cluster  =  Rg 
     71        rg_primary    =  rg 
    7272        background   =  background 
    7373        Ref: Schmidt, J Appl Cryst, eq(19), (1991), 24, 414-435 
     
    7979# pylint: disable=bad-whitespace, line-too-long 
    8080#             ["name", "units", default, [lower, upper], "type","description"], 
    81 parameters = [["mass_dim",      "",    1.8, [1e-16, 6.0], "", 
     81parameters = [["fractal_dim_mass",      "",    1.8, [1e-16, 6.0], "", 
    8282               "Mass fractal dimension"], 
    83               ["surface_dim",   "",    2.3, [1e-16, 6.0], "", 
     83              ["fractal_dim_surf",   "",    2.3, [1e-16, 6.0], "", 
    8484               "Surface fractal dimension"], 
    85               ["cluster_rg", "Ang",   86.7, [0.0, inf], "", 
     85              ["rg_cluster", "Ang",   86.7, [0.0, inf], "", 
    8686               "Cluster radius of gyration"], 
    87               ["primary_rg", "Ang", 4000.,  [0.0, inf], "", 
     87              ["rg_primary", "Ang", 4000.,  [0.0, inf], "", 
    8888               "Primary particle radius of gyration"], 
    8989             ] 
     
    9393 
    9494demo = dict(scale=1, background=0, 
    95             mass_dim=1.8, 
    96             surface_dim=2.3, 
    97             cluster_rg=86.7, 
    98             primary_rg=4000.0) 
     95            fractal_dim_mass=1.8, 
     96            fractal_dim_surf=2.3, 
     97            rg_cluster=86.7, 
     98            rg_primary=4000.0) 
    9999 
    100100tests = [ 
    101101 
    102102    # Accuracy tests based on content in test/utest_other_models.py 
    103     [{'mass_dim':      1.8, 
    104       'surface_dim':   2.3, 
    105       'cluster_rg':   86.7, 
    106       'primary_rg': 4000.0, 
     103    [{'fractal_dim_mass':      1.8, 
     104      'fractal_dim_surf':   2.3, 
     105      'rg_cluster':   86.7, 
     106      'rg_primary': 4000.0, 
    107107      'background':    0.0, 
    108108     }, 0.05, 1.77537e-05], 
    109109 
    110110    # Additional tests with larger range of parameters 
    111     [{'mass_dim':      3.3, 
    112       'surface_dim':   1.0, 
    113       'cluster_rg':   90.0, 
    114       'primary_rg': 4000.0, 
     111    [{'fractal_dim_mass':      3.3, 
     112      'fractal_dim_surf':   1.0, 
     113      'rg_cluster':   90.0, 
     114      'rg_primary': 4000.0, 
    115115     }, 0.001, 0.18562699016], 
    116116 
    117     [{'mass_dim':      1.3, 
    118       'surface_dim':   1.0, 
    119       'cluster_rg':   90.0, 
    120       'primary_rg': 2000.0, 
     117    [{'fractal_dim_mass':      1.3, 
     118      'fractal_dim_surf':   1.0, 
     119      'rg_cluster':   90.0, 
     120      'rg_primary': 2000.0, 
    121121      'background':    0.8, 
    122122     }, 0.001, 1.16539753641], 
    123123 
    124     [{'mass_dim':      2.3, 
    125       'surface_dim':   1.0, 
    126       'cluster_rg':   90.0, 
    127       'primary_rg': 1000.0, 
     124    [{'fractal_dim_mass':      2.3, 
     125      'fractal_dim_surf':   1.0, 
     126      'rg_cluster':   90.0, 
     127      'rg_primary': 1000.0, 
    128128      'scale':        10.0, 
    129129      'background':    0.0, 
  • sasmodels/models/mono_gauss_coil.py

    r40a87fa ra807206  
    7171parameters = [ 
    7272    ["i_zero", "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
    73     ["radius_gyration", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
     73    ["rg", "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
    7474    ] 
    7575# pylint: enable=bad-whitespace, line-too-long 
    7676 
    7777# NB: Scale and Background are implicit parameters on every model 
    78 def Iq(q, i_zero, radius_gyration): 
     78def Iq(q, i_zero, rg): 
    7979    # pylint: disable = missing-docstring 
    80     z = (q * radius_gyration)**2 
     80    z = (q * rg)**2 
    8181 
    8282    with errstate(invalid='ignore'): 
     
    8686Iq.vectorized = True # Iq accepts an array of q values 
    8787 
    88 demo = dict(scale=1.0, i_zero=70.0, radius_gyration=75.0, background=0.0) 
     88demo = dict(scale=1.0, i_zero=70.0, rg=75.0, background=0.0) 
    8989 
    9090# these unit test values taken from SasView 3.1.2 
    9191tests = [ 
    92     [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 'background': 0.0}, 
     92    [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, 'background': 0.0}, 
    9393     [0.0106939, 0.469418], [57.1241, 0.112859]], 
    9494    ] 
  • sasmodels/models/parallelepiped.c

    rdeb7ee0 ra807206  
    1 double form_volume(double a_side, double b_side, double c_side); 
    2 double Iq(double q, double sld, double solvent_sld, double a_side, double b_side, double c_side); 
     1double form_volume(double length_a, double length_b, double length_c); 
     2double Iq(double q, double sld, double solvent_sld, double length_a, double length_b, double length_c); 
    33double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    4     double a_side, double b_side, double c_side, double theta, double phi, double psi); 
     4    double length_a, double length_b, double length_c, double theta, double phi, double psi); 
    55 
    66// From Igor library 
     
    3232 
    3333 
    34 double form_volume(double a_side, double b_side, double c_side) 
     34double form_volume(double length_a, double length_b, double length_c) 
    3535{ 
    36     return a_side * b_side * c_side; 
     36    return length_a * length_b * length_c; 
    3737} 
    3838 
     
    4141    double sld, 
    4242    double solvent_sld, 
    43     double a_side, 
    44     double b_side, 
    45     double c_side) 
     43    double length_a, 
     44    double length_b, 
     45    double length_c) 
    4646{ 
    4747    double tmp1, tmp2; 
    4848     
    49     double mu = q * b_side; 
     49    double mu = q * length_b; 
    5050     
    5151    // Scale sides by B 
    52     double a_scaled = a_side / b_side; 
    53     double c_scaled = c_side / b_side; 
     52    double a_scaled = length_a / length_b; 
     53    double c_scaled = length_c / length_b; 
    5454         
    5555    //Order of integration 
     
    102102    }    
    103103    
    104     const double vd = (sld-solvent_sld) * form_volume(a_side, b_side, c_side); 
     104    const double vd = (sld-solvent_sld) * form_volume(length_a, length_b, length_c); 
    105105     
    106106    // convert from [1e-12 A-1] to [cm-1] and 0.5 factor for outer integral 
     
    113113    double sld, 
    114114    double solvent_sld, 
    115     double a_side, 
    116     double b_side, 
    117     double c_side, 
     115    double length_a, 
     116    double length_b, 
     117    double length_c, 
    118118    double theta, 
    119119    double phi, 
     
    161161     
    162162    // Call the IGOR library function to get the kernel 
    163     double form = _pkernel( q*a_side, q*b_side, q*c_side, cos_val_a, cos_val_b, cos_val_c); 
     163    double form = _pkernel( q*length_a, q*length_b, q*length_c, cos_val_a, cos_val_b, cos_val_c); 
    164164   
    165165    // Multiply by contrast^2 
    166     const double vd = (sld - solvent_sld) * form_volume(a_side, b_side, c_side); 
     166    const double vd = (sld - solvent_sld) * form_volume(length_a, length_b, length_c); 
    167167    return 1.0e-4 * vd * vd * form; 
    168168} 
  • sasmodels/models/parallelepiped.py

    r9a4811a ra807206  
    190190              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    191191               "Solvent scattering length density"], 
    192               ["a_side", "Ang", 35, [0, inf], "volume", 
     192              ["length_a", "Ang", 35, [0, inf], "volume", 
    193193               "Shorter side of the parallelepiped"], 
    194               ["b_side", "Ang", 75, [0, inf], "volume", 
     194              ["length_b", "Ang", 75, [0, inf], "volume", 
    195195               "Second side of the parallelepiped"], 
    196               ["c_side", "Ang", 400, [0, inf], "volume", 
     196              ["length_c", "Ang", 400, [0, inf], "volume", 
    197197               "Larger side of the parallelepiped"], 
    198198              ["theta", "degrees", 60, [-inf, inf], "orientation", 
     
    206206source = ["lib/gauss76.c", "parallelepiped.c"] 
    207207 
    208 def ER(a_side, b_side, c_side): 
     208def ER(length_a, length_b, length_c): 
    209209    """ 
    210210        Return effective radius (ER) for P(q)*S(q) 
     
    212212 
    213213    # surface average radius (rough approximation) 
    214     surf_rad = sqrt(a_side * b_side / pi) 
    215  
    216     ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 
     214    surf_rad = sqrt(length_a * length_b / pi) 
     215 
     216    ddd = 0.75 * surf_rad * (2 * surf_rad * length_c + (length_c + surf_rad) * (length_c + pi * surf_rad)) 
    217217    return 0.5 * (ddd) ** (1. / 3.) 
    218218 
     
    222222demo = dict(scale=1, background=0, 
    223223            sld=6.3e-6, sld_solvent=1.0e-6, 
    224             a_side=35, b_side=75, c_side=400, 
     224            length_a=35, length_b=75, length_c=400, 
    225225            theta=45, phi=30, psi=15, 
    226             a_side_pd=0.1, a_side_pd_n=10, 
    227             b_side_pd=0.1, b_side_pd_n=1, 
    228             c_side_pd=0.1, c_side_pd_n=1, 
     226            length_a_pd=0.1, length_a_pd_n=10, 
     227            length_b_pd=0.1, length_b_pd_n=1, 
     228            length_c_pd=0.1, length_c_pd_n=1, 
    229229            theta_pd=10, theta_pd_n=1, 
    230230            phi_pd=10, phi_pd_n=1, 
  • sasmodels/models/pearl_necklace.c

    r2f5c6d4 ra807206  
    1 double _pearl_necklace_kernel(double q, double radius, double edge_separation, 
     1double _pearl_necklace_kernel(double q, double radius, double edge_sep, 
    22        double thick_string, double num_pearls, double sld_pearl, 
    33        double sld_string, double sld_solv); 
    4 double form_volume(double radius, double edge_separation, 
    5         double string_thickness, double number_of_pearls); 
     4double form_volume(double radius, double edge_sep, 
     5        double thick_string, double num_pearls); 
    66 
    7 double Iq(double q, double radius, double edge_separation, 
    8         double string_thickness, double number_of_pearls, double sld,  
     7double Iq(double q, double radius, double edge_sep, 
     8        double thick_string, double num_pearls, double sld,  
    99        double string_sld, double solvent_sld); 
    1010 
    11 #define INVALID(v) (v.string_thickness >= v.radius || v.number_of_pearls <= 0) 
     11#define INVALID(v) (v.thick_string >= v.radius || v.num_pearls <= 0) 
    1212 
    1313// From Igor library 
    14 double _pearl_necklace_kernel(double q, double radius, double edge_separation, double thick_string, 
     14double _pearl_necklace_kernel(double q, double radius, double edge_sep, double thick_string, 
    1515        double num_pearls, double sld_pearl, double sld_string, double sld_solv) 
    1616{ 
     
    2727         
    2828        // center to center distance between the neighboring pearls 
    29         double A_s = edge_separation + 2.0 * radius; 
     29        double A_s = edge_sep + 2.0 * radius; 
    3030         
    3131        // Repeated Calculations 
     
    3333        double oneminussinc = 1 - sincasq; 
    3434        double q_r = q * radius; 
    35         double q_edge = q * edge_separation; 
     35        double q_edge = q * edge_sep; 
    3636         
    3737        // each volume 
    38         double string_vol = edge_separation * pi * thick_string * thick_string / 4.0; 
     38        double string_vol = edge_sep * pi * thick_string * thick_string / 4.0; 
    3939        double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; 
    4040 
     
    105105} 
    106106 
    107 double form_volume(double radius, double edge_separation, 
    108         double string_thickness, double number_of_pearls) 
     107double form_volume(double radius, double edge_sep, 
     108        double thick_string, double num_pearls) 
    109109{ 
    110110        double total_vol; 
    111111 
    112112        double pi = 4.0*atan(1.0); 
    113         double number_of_strings = number_of_pearls - 1.0; 
     113        double number_of_strings = num_pearls - 1.0; 
    114114         
    115         double string_vol = edge_separation * pi * string_thickness * string_thickness / 4.0; 
     115        double string_vol = edge_sep * pi * thick_string * thick_string / 4.0; 
    116116        double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; 
    117117 
    118118        total_vol = number_of_strings * string_vol; 
    119         total_vol += number_of_pearls * pearl_vol; 
     119        total_vol += num_pearls * pearl_vol; 
    120120 
    121121        return(total_vol); 
    122122} 
    123123 
    124 double Iq(double q, double radius, double edge_separation, 
    125         double string_thickness, double number_of_pearls, double sld,  
     124double Iq(double q, double radius, double edge_sep, 
     125        double thick_string, double num_pearls, double sld,  
    126126        double string_sld, double solvent_sld) 
    127127{ 
    128128        double value, tot_vol; 
    129129         
    130         value = _pearl_necklace_kernel(q, radius, edge_separation, string_thickness, 
    131                 number_of_pearls, sld, string_sld, solvent_sld); 
    132         tot_vol = form_volume(radius, edge_separation, string_thickness, number_of_pearls); 
     130        value = _pearl_necklace_kernel(q, radius, edge_sep, thick_string, 
     131                num_pearls, sld, string_sld, solvent_sld); 
     132        tot_vol = form_volume(radius, edge_sep, thick_string, num_pearls); 
    133133 
    134134        return value*tot_vol; 
  • sasmodels/models/pearl_necklace.py

    r42356c8 ra807206  
    4646pearl_necklace model are the following 
    4747 
    48 NB: *number_of_pearls* must be an integer. 
     48NB: *num_pearls* must be an integer. 
    4949 
    5050References 
     
    6868sld_string: the SLD of the strings 
    6969sld_solvent: the SLD of the solvent 
    70 number_of_pearls: number of the pearls 
     70num_pearls: number of the pearls 
    7171radius: the radius of a pearl 
    72 edge_separation: the length of string segment; surface to surface 
    73 string_thickness: thickness (ie, diameter) of the string 
     72edge_sep: the length of string segment; surface to surface 
     73thick_string: thickness (ie, diameter) of the string 
    7474""" 
    7575category = "shape:cylinder" 
     
    7878parameters = [["radius", "Ang", 80.0, [0, inf], "volume", 
    7979               "Mean radius of the chained spheres"], 
    80               ["edge_separation", "Ang", 350.0, [0, inf], "volume", 
     80              ["edge_sep", "Ang", 350.0, [0, inf], "volume", 
    8181               "Mean separation of chained particles"], 
    82               ["string_thickness", "Ang", 2.5, [0, inf], "volume", 
     82              ["thick_string", "Ang", 2.5, [0, inf], "volume", 
    8383               "Thickness of the chain linkage"], 
    84               ["number_of_pearls", "none", 3, [0, inf], "volume", 
     84              ["num_pearls", "none", 3, [0, inf], "volume", 
    8585               "Number of pearls in the necklace (must be integer)"], 
    8686              ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", 
     
    9595single = False  # use double precision unless told otherwise 
    9696 
    97 def volume(radius, edge_separation, string_thickness, number_of_pearls): 
     97def volume(radius, edge_sep, thick_string, num_pearls): 
    9898    """ 
    9999    Calculates the total particle volume of the necklace. 
    100100    Redundant with form_volume. 
    101101    """ 
    102     number_of_strings = number_of_pearls - 1.0 
    103     string_vol = edge_separation * pi * pow((string_thickness / 2.0), 2.0) 
     102    number_of_strings = num_pearls - 1.0 
     103    string_vol = edge_sep * pi * pow((thick_string / 2.0), 2.0) 
    104104    pearl_vol = 4.0 /3.0 * pi * pow(radius, 3.0) 
    105105    total_vol = number_of_strings * string_vol 
    106     total_vol += number_of_pearls * pearl_vol 
     106    total_vol += num_pearls * pearl_vol 
    107107    return total_vol 
    108108 
    109 def ER(radius, edge_separation, string_thickness, number_of_pearls): 
     109def ER(radius, edge_sep, thick_string, num_pearls): 
    110110    """ 
    111111    Calculation for effective radius. 
    112112    """ 
    113     tot_vol = volume(radius, edge_separation, string_thickness, number_of_pearls) 
     113    tot_vol = volume(radius, edge_sep, thick_string, num_pearls) 
    114114    rad_out = pow((3.0*tot_vol/4.0/pi), 0.33333) 
    115115    return rad_out 
    116116 
    117117# parameters for demo 
    118 demo = dict(scale=1, background=0, radius=80.0, edge_separation=350.0, 
    119             number_of_pearls=3, sld=1, sld_solvent=6.3, sld_string=1, 
    120             string_thickness=2.5, 
     118demo = dict(scale=1, background=0, radius=80.0, edge_sep=350.0, 
     119            num_pearls=3, sld=1, sld_solvent=6.3, sld_string=1, 
     120            thick_string=2.5, 
    121121            radius_pd=.2, radius_pd_n=5, 
    122             edge_separation_pd=25.0, edge_separation_pd_n=5, 
    123             number_of_pearls_pd=0, number_of_pearls_pd_n=0, 
    124             string_thickness_pd=0.2, string_thickness_pd_n=5, 
     122            edge_sep_pd=25.0, edge_sep_pd_n=5, 
     123            num_pearls_pd=0, num_pearls_pd_n=0, 
     124            thick_string_pd=0.2, thick_string_pd_n=5, 
    125125           ) 
    126126 
  • sasmodels/models/poly_gauss_coil.py

    r40a87fa ra807206  
    7474parameters = [ 
    7575    ["i_zero",          "1/cm", 70.0, [0.0, inf], "", "Intensity at q=0"], 
    76     ["radius_gyration",  "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
     76    ["rg",  "Ang", 75.0, [0.0, inf], "", "Radius of gyration"], 
    7777    ["polydispersity",  "None",  2.0, [1.0, inf], "", "Polymer Mw/Mn"], 
    7878    ] 
     
    8080 
    8181# NB: Scale and Background are implicit parameters on every model 
    82 def Iq(q, i_zero, radius_gyration, polydispersity): 
     82def Iq(q, i_zero, rg, polydispersity): 
    8383    # pylint: disable = missing-docstring 
    8484    u = polydispersity - 1.0 
    85     z = (q*radius_gyration)**2 / (1.0 + 2.0*u) 
     85    z = (q*rg)**2 / (1.0 + 2.0*u) 
    8686    # need to trap the case of the polydispersity being 1 (ie, monodisperse!) 
    8787    if polydispersity == 1.0: 
     
    9797demo = dict(scale=1.0, 
    9898            i_zero=70.0, 
    99             radius_gyration=75.0, 
     99            rg=75.0, 
    100100            polydispersity=2.0, 
    101101            background=0.0) 
     
    103103# these unit test values taken from SasView 3.1.2 
    104104tests = [ 
    105     [{'scale': 1.0, 'i_zero': 70.0, 'radius_gyration': 75.0, 
     105    [{'scale': 1.0, 'i_zero': 70.0, 'rg': 75.0, 
    106106      'polydispersity': 2.0, 'background': 0.0}, 
    107107     [0.0106939, 0.469418], [57.6405, 0.169016]], 
  • sasmodels/models/polymer_micelle.c

    rc915373 ra807206  
    77        double corona_sld, 
    88        double radius_core, 
    9         double radius_gyr, 
     9        double rg, 
    1010        double d_penetration, 
    1111        double n_aggreg); 
     
    1919        double corona_sld, 
    2020        double radius_core, 
    21         double radius_gyr, 
     21        double rg, 
    2222        double d_penetration, 
    2323        double n_aggreg) 
     
    3535 
    3636    // Self-correlation term of the chains 
    37     const double qrg2 = q*radius_gyr*q*radius_gyr; 
     37    const double qrg2 = q*rg*q*rg; 
    3838    const double debye_chain = (qrg2 == 0.0) ? 1.0 : 2.0*(expm1(-qrg2)+qrg2)/(qrg2*qrg2); 
    3939    const double term2 = n_aggreg * beta_corona * beta_corona * debye_chain; 
     
    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 * radius_gyr)); 
     43    const double bes_corona = sinc(q*(radius_core + d_penetration * rg)); 
    4444    const double term3 = 2 * n_aggreg * n_aggreg * beta_core * beta_corona * 
    4545                 bes_core * chain_ampl * bes_corona; 
     
    7070        double corona_sld, 
    7171        double radius_core, 
    72         double radius_gyr, 
     72        double rg, 
    7373        double d_penetration, 
    7474        double n_aggreg) 
     
    8282            corona_sld, 
    8383            radius_core, 
    84             radius_gyr, 
     84            rg, 
    8585            d_penetration, 
    8686            n_aggreg); 
  • sasmodels/models/polymer_micelle.py

    r40a87fa ra807206  
    4545    ["sld_core",      "1e-6/Ang^2", 0.34, [0.0, inf], "sld", "Core scattering length density"], 
    4646    ["sld_corona",    "1e-6/Ang^2", 0.8,  [0.0, inf], "sld", "Corona scattering length density"], 
    47     ["radius_core",   "Ang",       45.0,  [0.0, inf], "", "Radius of core ( must be >> radius_gyr )"], 
    48     ["radius_gyr",    "Ang",       20.0,  [0.0, inf], "", "Radius of gyration of chains in corona"], 
     47    ["radius_core",   "Ang",       45.0,  [0.0, inf], "", "Radius of core ( must be >> rg )"], 
     48    ["rg",    "Ang",       20.0,  [0.0, inf], "", "Radius of gyration of chains in corona"], 
    4949    ["d_penetration", "",           1.0,  [-inf, inf], "", "Factor to mimic non-penetration of Gaussian chains"], 
    5050    ["n_aggreg",      "",           6.0,  [-inf, inf], "", "Aggregation number of the micelle"], 
     
    5454single = False 
    5555 
    56 source = ["lib/sph_j1c.c", "polymer_micelle_kernel.c"] 
     56source = ["lib/sph_j1c.c", "polymer_micelle.c"] 
    5757 
    5858demo = dict(scale=1, background=0, 
     
    6464            sld_corona=0.8, 
    6565            radius_core=45.0, 
    66             radius_gyr=20.0, 
     66            rg=20.0, 
    6767            d_penetration=1.0, 
    6868            n_aggreg=6.0) 
  • sasmodels/models/pringle.c

    rc047acf r30fbe2e  
    66          double alpha, 
    77          double beta, 
    8           double sld_pringle, 
     8          double sld, 
    99          double sld_solvent); 
    1010 
     
    4242    } 
    4343 
    44     #if 1 
    45     // TODO: should the normalization be to R^2 or the last value, r^2 
    46     // the gaussian window does not go all the way from 0 to 1. 
    47     //radius = Gauss76Z[75] * zm + zb; 
    48     *Sn = zm*sumS / (r*r); 
    49     *Cn = zm*sumC / (r*r); 
    50     #else 
    5144    *Sn = zm*sumS / (radius*radius); 
    5245    *Cn = zm*sumC / (radius*radius); 
    53     #endif 
    5446} 
    5547 
     
    109101double form_volume(double radius, double thickness, double alpha, double beta) 
    110102{ 
    111     // TODO: Normalize by form volume 
    112     //return M_PI*radius*radius*thickness; 
    113     return 1.0; 
     103    return M_PI*radius*radius*thickness; 
    114104} 
    115105 
     
    120110    double alpha, 
    121111    double beta, 
    122     double sld_pringle, 
     112    double sld, 
    123113    double sld_solvent) 
    124114{ 
    125115    double form = _integrate_psi(q, radius, thickness, alpha, beta); 
    126     double contrast = sld_pringle - sld_solvent; 
     116    double contrast = sld - sld_solvent; 
    127117    double volume = M_PI*radius*radius*thickness; 
    128     // TODO: If normalize by form volume, need an extra volume here 
    129     //return 1.0e-4*form * square(contrast * volume); 
    130     return 1.0e-4*form * square(contrast) * volume; 
     118    return 1.0e-4*form * square(contrast * volume); 
    131119} 
  • sasmodels/models/pringle.py

    r40a87fa r30fbe2e  
    1717.. math:: 
    1818 
    19     C_n = \int^{R}_{0} r dr\cos(qr^2\alpha \cos{\psi}) 
     19    C_n = \frac{1}{r^2}\int^{R}_{0} r dr\cos(qr^2\alpha \cos{\psi}) 
    2020    J_n\left( qr^2\beta \cos{\psi}\right) 
    2121    J_{2n}\left( qr \sin{\psi}\right) 
     
    2323.. math:: 
    2424 
    25     S_n = \int^{R}_{0} r dr\sin(qr^2\alpha \cos{\psi}) 
     25    S_n = \frac{1}{r^2}\int^{R}_{0} r dr\sin(qr^2\alpha \cos{\psi}) 
    2626    J_n\left( qr^2\beta \cos{\psi}\right) 
    2727    J_{2n}\left( qr \sin{\psi}\right) 
     
    4747**Last Modified by:** Wojciech Wpotrzebowski **on:** March 20, 2016 
    4848 
    49 **Last Reviewed by:** Paul Butler **on:** March 21, 2016 
     49**Last Reviewed by:** Andrew Jackson **on:** September 26, 2016 
    5050 
    5151""" 
     
    6868    ["alpha",       "",            0.001,  [-inf, inf], "volume", "Curvature parameter alpha"], 
    6969    ["beta",        "",            0.02,   [-inf, inf], "volume", "Curvature paramter beta"], 
    70     ["sld_pringle", "1e-6/Ang^2",  1.0,    [-inf, inf], "sld", "Pringle sld"], 
     70    ["sld", "1e-6/Ang^2",  1.0,    [-inf, inf], "sld", "Pringle sld"], 
    7171    ["sld_solvent", "1e-6/Ang^2",  6.3,    [-inf, inf], "sld", "Solvent sld"] 
    7272    ] 
     
    9191            alpha=0.001, 
    9292            beta=0.02, 
    93             sld_pringle=1.0, 
     93            sld=1.0, 
    9494            sld_solvent=6.35) 
    9595 
     
    100100      'alpha': 0.001, 
    101101      'beta': 0.02, 
    102       'sld_pringle': 1.0, 
     102      'sld': 1.0, 
    103103      'sld_solvent': 6.3, 
    104       'background': 6.3, 
    105      }, 0.1, 16.185532], 
     104      'background': 0.001, 
     105     }, 0.1, 9.87676], 
    106106 
    107107    [{'scale' : 1.0, 
     
    110110      'alpha': 0.001, 
    111111      'beta': 0.02, 
    112       'sld_pringle': 1.0, 
     112      'sld': 1.0, 
    113113      'sld_solvent': 6.3, 
    114       'background': 6.3, 
    115      }, 0.01, 297.153496], 
     114      'background': 0.001, 
     115     }, 0.01, 290.56723], 
    116116 
    117117    [{'scale' : 1.0, 
     
    120120      'alpha': 0.001, 
    121121      'beta': 0.02, 
    122       'sld_pringle': 1.0, 
     122      'sld': 1.0, 
    123123      'sld_solvent': 6.3, 
    124       'background': 6.3, 
    125      }, 0.001, 324.021256415], 
    126  
    127     [{'scale' : 1.0, 
    128       'radius': 60.0, 
    129       'thickness': 10.0, 
    130       'alpha': 0.001, 
    131       'beta': 0.02, 
    132       'sld_pringle': 1.0, 
    133       'sld_solvent': 6.3, 
    134       'background': 6.3, 
    135      }, (0.001, 90.0), 6.30000026876], 
     124      'background': 0.001, 
     125     }, 0.001, 317.40847], 
    136126] 
  • sasmodels/models/rectangular_prism.c

    rdeb7ee0 ra807206  
    1 double form_volume(double a_side, double b2a_ratio, double c2a_ratio); 
    2 double Iq(double q, double sld, double solvent_sld, double a_side,  
     1double form_volume(double length_a, double b2a_ratio, double c2a_ratio); 
     2double Iq(double q, double sld, double solvent_sld, double length_a,  
    33          double b2a_ratio, double c2a_ratio); 
    44double Iqxy(double qx, double qy, double sld, double solvent_sld,  
    5             double a_side, double b2a_ratio, double c2a_ratio); 
     5            double length_a, double b2a_ratio, double c2a_ratio); 
    66 
    7 double form_volume(double a_side, double b2a_ratio, double c2a_ratio) 
     7double form_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    88{ 
    9     return a_side * (a_side*b2a_ratio) * (a_side*c2a_ratio); 
     9    return length_a * (length_a*b2a_ratio) * (length_a*c2a_ratio); 
    1010} 
    1111 
     
    1313    double sld, 
    1414    double solvent_sld, 
    15     double a_side, 
     15    double length_a, 
    1616    double b2a_ratio, 
    1717    double c2a_ratio) 
     
    1919    double termA, termB, termC; 
    2020     
    21     double b_side = a_side * b2a_ratio; 
    22     double c_side = a_side * c2a_ratio; 
    23     double volume = a_side * b_side * c_side; 
    24     double a_half = 0.5 * a_side; 
     21    double b_side = length_a * b2a_ratio; 
     22    double c_side = length_a * c2a_ratio; 
     23    double volume = length_a * b_side * c_side; 
     24    double a_half = 0.5 * length_a; 
    2525    double b_half = 0.5 * b_side; 
    2626    double c_half = 0.5 * c_side; 
     
    9292    double sld, 
    9393    double solvent_sld, 
    94     double a_side, 
     94    double length_a, 
    9595    double b2a_ratio, 
    9696    double c2a_ratio) 
    9797{ 
    9898    double q = sqrt(qx*qx + qy*qy); 
    99     double intensity = Iq(q, sld, solvent_sld, a_side, b2a_ratio, c2a_ratio);  
     99    double intensity = Iq(q, sld, solvent_sld, length_a, b2a_ratio, c2a_ratio);  
    100100    return intensity;     
    101101} 
  • sasmodels/models/rectangular_prism.py

    r42356c8 ra807206  
    9999              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    100100               "Solvent scattering length density"], 
    101               ["a_side", "Ang", 35, [0, inf], "volume", 
     101              ["length_a", "Ang", 35, [0, inf], "volume", 
    102102               "Shorter side of the parallelepiped"], 
    103103              ["b2a_ratio", "Ang", 1, [0, inf], "volume", 
     
    109109source = ["lib/gauss76.c", "rectangular_prism.c"] 
    110110 
    111 def ER(a_side, b2a_ratio, c2a_ratio): 
     111def ER(length_a, b2a_ratio, c2a_ratio): 
    112112    """ 
    113113        Return equivalent radius (ER) 
    114114    """ 
    115     b_side = a_side * b2a_ratio 
    116     c_side = a_side * c2a_ratio 
     115    b_side = length_a * b2a_ratio 
     116    c_side = length_a * c2a_ratio 
    117117 
    118118    # surface average radius (rough approximation) 
    119     surf_rad = sqrt(a_side * b_side / pi) 
     119    surf_rad = sqrt(length_a * b_side / pi) 
    120120 
    121121    ddd = 0.75 * surf_rad * (2 * surf_rad * c_side + (c_side + surf_rad) * (c_side + pi * surf_rad)) 
     
    126126demo = dict(scale=1, background=0, 
    127127            sld=6.3e-6, sld_solvent=1.0e-6, 
    128             a_side=35, b2a_ratio=1, c2a_ratio=1, 
    129             a_side_pd=0.1, a_side_pd_n=10, 
     128            length_a=35, b2a_ratio=1, c2a_ratio=1, 
     129            length_a_pd=0.1, length_a_pd_n=10, 
    130130            b2a_ratio_pd=0.1, b2a_ratio_pd_n=1, 
    131131            c2a_ratio_pd=0.1, c2a_ratio_pd_n=1) 
  • sasmodels/models/sc_paracrystal.py

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

    r2c74c11 ra807206  
    1 double form_volume(double core_thick, 
    2                    double layer_thick, 
     1double form_volume(double thick_core, 
     2                   double thick_layer, 
    33                   double radius, 
    44                   double n_stacking); 
    55 
    66double Iq(double q, 
    7           double core_thick, 
    8           double layer_thick, 
     7          double thick_core, 
     8          double thick_layer, 
    99          double radius, 
    1010          double n_stacking, 
    11           double sigma_d, 
     11          double sigma_dnn, 
    1212          double core_sld, 
    1313          double layer_sld, 
     
    2121               double solvent_sld, 
    2222               double halfheight, 
    23                double layer_thick, 
     23               double thick_layer, 
    2424               double zi, 
    25                double sigma_d, 
     25               double sigma_dnn, 
    2626               double d, 
    2727               double n_stacking) 
     
    3838 
    3939        const double sinarg1 = qq*halfheight*cos(zi); 
    40         const double sinarg2 = qq*(halfheight+layer_thick)*cos(zi); 
     40        const double sinarg2 = qq*(halfheight+thick_layer)*cos(zi); 
    4141 
    4242        const double be1 = sas_J1c(besarg1); 
     
    4848        const double dr2 = (layer_sld-solvent_sld); 
    4949        const double area = M_PI*radius*radius; 
    50         const double totald=2.0*(layer_thick+halfheight); 
     50        const double totald=2.0*(thick_layer+halfheight); 
    5151 
    5252        const double t1 = area*(2.0*halfheight)*dr1*(si1)*(be1); 
     
    5959        double sqq=0.0; 
    6060        for(int kk=1;kk<n_stacking;kk+=1) { 
    61                 double dexpt=qq*cos(zi)*qq*cos(zi)*d*d*sigma_d*sigma_d*kk/2.0; 
     61                double dexpt=qq*cos(zi)*qq*cos(zi)*d*d*sigma_dnn*sigma_dnn*kk/2.0; 
    6262                sqq=sqq+(n_stacking-kk)*cos(qq*cos(zi)*d*kk)*exp(-1.*dexpt); 
    6363        } 
     
    7474static 
    7575double stacked_disks_kernel(double q, 
    76                             double core_thick, 
    77                             double layer_thick, 
     76                            double thick_core, 
     77                            double thick_layer, 
    7878                            double radius, 
    7979                            double n_stacking, 
    80                             double sigma_d, 
     80                            double sigma_dnn, 
    8181                            double core_sld, 
    8282                            double layer_sld, 
     
    8888        double summ = 0.0;      //initialize integral 
    8989 
    90         double d=2.0*layer_thick+core_thick; 
    91         double halfheight = core_thick/2.0; 
     90        double d=2.0*thick_layer+thick_core; 
     91        double halfheight = thick_core/2.0; 
    9292 
    9393        for(int i=0;i<N_POINTS_76;i++) { 
     
    100100                                   solvent_sld, 
    101101                                   halfheight, 
    102                                    layer_thick, 
     102                                   thick_layer, 
    103103                                   zi, 
    104                                    sigma_d, 
     104                                   sigma_dnn, 
    105105                                   d, 
    106106                                   n_stacking); 
     
    117117 
    118118static double stacked_disks_kernel_2d(double q, double q_x, double q_y, 
    119                             double core_thick, 
    120                             double layer_thick, 
     119                            double thick_core, 
     120                            double thick_layer, 
    121121                            double radius, 
    122122                            double n_stacking, 
    123                             double sigma_d, 
     123                            double sigma_dnn, 
    124124                            double core_sld, 
    125125                            double layer_sld, 
     
    154154 
    155155    // Call the IGOR library function to get the kernel 
    156     double d = 2 * layer_thick + core_thick; 
    157     double halfheight = core_thick/2.0; 
     156    double d = 2 * thick_layer + thick_core; 
     157    double halfheight = thick_core/2.0; 
    158158    double answer = _kernel(q, 
    159159                     radius, 
     
    162162                     solvent_sld, 
    163163                     halfheight, 
    164                      layer_thick, 
     164                     thick_layer, 
    165165                     alpha, 
    166                      sigma_d, 
     166                     sigma_dnn, 
    167167                     d, 
    168168                     n_stacking); 
     
    175175} 
    176176 
    177 double form_volume(double core_thick, 
    178                    double layer_thick, 
     177double form_volume(double thick_core, 
     178                   double thick_layer, 
    179179                   double radius, 
    180180                   double n_stacking){ 
    181     double d = 2 * layer_thick + core_thick; 
     181    double d = 2 * thick_layer + thick_core; 
    182182    return acos(-1.0) * radius * radius * d * n_stacking; 
    183183} 
    184184 
    185185double Iq(double q, 
    186           double core_thick, 
    187           double layer_thick, 
     186          double thick_core, 
     187          double thick_layer, 
    188188          double radius, 
    189189          double n_stacking, 
    190           double sigma_d, 
     190          double sigma_dnn, 
    191191          double core_sld, 
    192192          double layer_sld, 
     
    194194{ 
    195195    return stacked_disks_kernel(q, 
    196                     core_thick, 
    197                     layer_thick, 
     196                    thick_core, 
     197                    thick_layer, 
    198198                    radius, 
    199199                    n_stacking, 
    200                     sigma_d, 
     200                    sigma_dnn, 
    201201                    core_sld, 
    202202                    layer_sld, 
  • sasmodels/models/stacked_disks.py

    r40a87fa r7c57861  
    5454    \right]^2 \sin{\alpha}\ d\alpha 
    5555 
    56 where $d$ = thickness of the layer (*layer_thick*), 
    57 $2h$ = core thickness (*core_thick*), and $R$ = radius of the disc (*radius*). 
     56where $d$ = thickness of the layer (*thick_layer*), 
     57$2h$ = core thickness (*thick_core*), and $R$ = radius of the disc (*radius*). 
    5858 
    5959.. math:: 
    6060 
    6161    S(q) = 1 + \frac{1}{2}\sum_{k=1}^n(n-k)\cos{(kDq\cos{\alpha})} 
    62     \exp\left[ -k(q\cos{\alpha})^2\sigma_D/2\right] 
     62    \exp\left[ -k(q\cos{\alpha})^2\sigma_d/2\right] 
    6363 
    6464where $n$ is the total number of the disc stacked (*n_stacking*), 
    6565$D = 2(d+h)$ is the next neighbor center-to-center distance (d-spacing), 
    66 and $\sigma_D$ = the Gaussian standard deviation of the d-spacing (*sigma_d*). 
     66and $\sigma_d$ = the Gaussian standard deviation of the d-spacing (*sigma_d*). 
    6767 
    6868.. note:: 
    69     Each assmebly in the stack is layer/core/layer, so the spacing of the 
     69    Each assembly in the stack is layer/core/layer, so the spacing of the 
    7070    cores is core plus two layers. The 2nd virial coefficient of the cylinder 
    7171    is calculated based on the *radius* and *length* 
    72     = *n_stacking* * (*core_thick* + 2 * *layer_thick*) 
     72    = *n_stacking* * (*thick_core* + 2 * *thick_layer*) 
    7373    values, and used as the effective radius for $S(Q)$ when $P(Q) * S(Q)$ 
    7474    is applied. 
     
    114114    One layer of disk consists of a core, a top layer, and a bottom layer. 
    115115    radius =  the radius of the disk 
    116     core_thick = thickness of the core 
    117     layer_thick = thickness of a layer 
     116    thick_core = thickness of the core 
     117    thick_layer = thickness of a layer 
    118118    sld_core = the SLD of the core 
    119119    sld_layer = the SLD of the layers 
     
    127127#   ["name", "units", default, [lower, upper], "type","description"], 
    128128parameters = [ 
    129     ["core_thick",  "Ang",        10.0, [0, inf],    "volume",      "Thickness of the core disk"], 
    130     ["layer_thick", "Ang",        10.0, [0, inf],    "volume",      "Thickness of layer each side of core"], 
     129    ["thick_core",  "Ang",        10.0, [0, inf],    "volume",      "Thickness of the core disk"], 
     130    ["thick_layer", "Ang",        10.0, [0, inf],    "volume",      "Thickness of layer each side of core"], 
    131131    ["radius",      "Ang",        15.0, [0, inf],    "volume",      "Radius of the stacked disk"], 
    132132    ["n_stacking",  "",            1.0, [0, inf],    "volume",      "Number of stacked layer/core/layer disks"], 
    133     ["sigma_d",     "Ang",         0,   [0, inf],    "",            "GSD of disks sigma_d"], 
     133    ["sigma_d",     "Ang",         0,   [0, inf],    "",            "Sigma of nearest neighbor spacing"], 
    134134    ["sld_core",    "1e-6/Ang^2",  4,   [-inf, inf], "sld",         "Core scattering length density"], 
    135135    ["sld_layer",   "1e-6/Ang^2",  0.0, [-inf, inf], "sld",         "Layer scattering length density"], 
     
    144144demo = dict(background=0.001, 
    145145            scale=0.01, 
    146             core_thick=10.0, 
    147             layer_thick=10.0, 
     146            thick_core=10.0, 
     147            thick_layer=10.0, 
    148148            radius=15.0, 
    149149            n_stacking=1, 
     
    158158    # Accuracy tests based on content in test/utest_extra_models.py. 
    159159    # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB 
    160     [{'core_thick': 10.0, 
    161       'layer_thick': 15.0, 
     160    [{'thick_core': 10.0, 
     161      'thick_layer': 15.0, 
    162162      'radius': 3000.0, 
    163163      'n_stacking': 1.0, 
     
    172172     }, 0.001, 5075.12], 
    173173 
    174     [{'core_thick': 10.0, 
    175       'layer_thick': 15.0, 
     174    [{'thick_core': 10.0, 
     175      'thick_layer': 15.0, 
    176176      'radius': 3000.0, 
    177177      'n_stacking': 5.0, 
     
    186186     }, 0.001, 5065.12793824], 
    187187 
    188     [{'core_thick': 10.0, 
    189       'layer_thick': 15.0, 
     188    [{'thick_core': 10.0, 
     189      'thick_layer': 15.0, 
    190190      'radius': 3000.0, 
    191191      'n_stacking': 5.0, 
     
    200200     }, 0.164, 0.0127673597265], 
    201201 
    202     [{'core_thick': 10.0, 
    203       'layer_thick': 15.0, 
     202    [{'thick_core': 10.0, 
     203      'thick_layer': 15.0, 
    204204      'radius': 3000.0, 
    205205      'n_stacking': 1.0, 
     
    214214     }, [0.001, 90.0], [5075.12, 0.001]], 
    215215 
    216     [{'core_thick': 10.0, 
    217       'layer_thick': 15.0, 
     216    [{'thick_core': 10.0, 
     217      'thick_layer': 15.0, 
    218218      'radius': 3000.0, 
    219219      'n_stacking': 1.0, 
     
    228228     }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 
    229229 
    230     [{'core_thick': 10.0, 
    231       'layer_thick': 15.0, 
     230    [{'thick_core': 10.0, 
     231      'thick_layer': 15.0, 
    232232      'radius': 3000.0, 
    233233      'n_stacking': 1.0, 
  • sasmodels/models/surface_fractal.c

    r2c74c11 ra807206  
    33double Iq(double q, 
    44          double radius, 
    5           double surface_dim, 
     5          double fractal_dim_surf, 
    66          double cutoff_length); 
    77 
    88static double _surface_fractal_kernel(double q, 
    99    double radius, 
    10     double surface_dim, 
     10    double fractal_dim_surf, 
    1111    double cutoff_length) 
    1212{ 
     
    2020 
    2121    //calculate S(q) 
    22     mmo = 5.0 - surface_dim; 
     22    mmo = 5.0 - fractal_dim_surf; 
    2323    sq  = sas_gamma(mmo)*sin(-(mmo)*atan(q*cutoff_length)); 
    2424    sq *= pow(cutoff_length, mmo); 
     
    3838double Iq(double q, 
    3939    double radius, 
    40     double surface_dim, 
     40    double fractal_dim_surf, 
    4141    double cutoff_length 
    4242    ) 
    4343{ 
    44     return _surface_fractal_kernel(q, radius, surface_dim, cutoff_length); 
     44    return _surface_fractal_kernel(q, radius, fractal_dim_surf, cutoff_length); 
    4545} 
  • sasmodels/models/surface_fractal.py

    r33875e3 ra807206  
    6666        delta        =  sldParticle -sldSolv. 
    6767        radius       =  Particle radius 
    68         surface_dim  =  Surface fractal dimension (Ds) 
     68        fractal_dim_surf  =  Surface fractal dimension (Ds) 
    6969        co_length    =  Cut-off length 
    7070        background   =  background 
    7171 
    7272        Ref.   :Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545 
    73         Note I : This model is valid for 1<surface_dim<3 with limited q range. 
     73        Note I : This model is valid for 1<fractal_dim_surf<3 with limited q range. 
    7474        Note II: This model is not in absolute scale. 
    7575""" 
     
    8080parameters = [["radius",        "Ang", 10.0, [0, inf],   "", 
    8181               "Particle radius"], 
    82               ["surface_dim",   "",    2.0,  [1, 3],   "", 
     82              ["fractal_dim_surf",   "",    2.0,  [1, 3],   "", 
    8383               "Surface fractal dimension"], 
    8484              ["cutoff_length", "Ang", 500., [0.0, inf], "", 
     
    9090 
    9191demo = dict(scale=1, background=0, 
    92             radius=10, surface_dim=2.0, cutoff_length=500) 
     92            radius=10, fractal_dim_surf=2.0, cutoff_length=500) 
    9393 
    9494tests = [ 
    9595    # Accuracy tests based on content in test/utest_other_models.py 
    9696    [{'radius': 10.0, 
    97       'surface_dim': 2.0, 
     97      'fractal_dim_surf': 2.0, 
    9898      'cutoff_length': 500.0, 
    9999     }, 0.05, 301428.66016], 
     
    101101    # Additional tests with larger range of parameters 
    102102    [{'radius': 1.0, 
    103       'surface_dim': 1.0, 
     103      'fractal_dim_surf': 1.0, 
    104104      'cutoff_length': 10.0, 
    105105     }, 0.332070182643, 1125.00421004], 
    106106 
    107107    [{'radius': 3.5, 
    108       'surface_dim': 0.1, 
     108      'fractal_dim_surf': 0.1, 
    109109      'cutoff_length': 30.0, 
    110110      'background': 0.01, 
     
    112112 
    113113    [{'radius': 3.0, 
    114       'surface_dim': 1.0, 
     114      'fractal_dim_surf': 1.0, 
    115115      'cutoff_length': 33.0, 
    116116      'scale': 0.1, 
  • sasmodels/models/teubner_strey.py

    r40a87fa rcaddb14  
    55This model calculates the scattered intensity of a two-component system 
    66using the Teubner-Strey model. Unlike :ref:`dab` this function generates 
    7 a peak. 
     7a peak. A two-phase material can be characterised by two length scales - 
     8a correlation length and a domain size (periodicity). 
     9 
     10The original paper by Teubner and Strey defined the function as: 
    811 
    912.. math:: 
    1013 
    11     I(q) = \frac{1}{a_2 + c_1 q^2 + c_2 q^4} + \text{background} 
     14    I(q) \propto \frac{1}{a_2 + c_1 q^2 + c_2 q^4} + \text{background} 
    1215 
    13 The parameters $a_2$, $c_1$ and $c_2$ can be used to determine the 
    14 characteristic domain size $d$, 
     16where the parameters $a_2$, $c_1$ and $c_2$ are defined in terms of the 
     17periodicity, $d$, and correlation length $\xi$ as: 
     18 
     19.. math:: 
     20 
     21    a_2 &= \biggl[1+\bigl(\frac{2\pi\xi}{d}\bigr)^2\biggr]\\ 
     22    c_1 &= -2\xi^2\bigl(\frac{2\pi\xi}{d}\bigr)^2+2\xi^2\\ 
     23    c_2 &= \xi^4 
     24 
     25and thus, the periodicity, $d$ is given by 
    1526 
    1627.. math:: 
    1728 
    1829    d = 2\pi\left[\frac12\left(\frac{a_2}{c_2}\right)^{1/2} 
    19                   + \frac14\frac{c_1}{c_2}\right]^{-1/2} 
     30                  - \frac14\frac{c_1}{c_2}\right]^{-1/2} 
    2031 
    21  
    22 and the correlation length $\xi$, 
     32and the correlation length, $\xi$, is given by 
    2333 
    2434.. math:: 
    2535 
    2636    \xi = \left[\frac12\left(\frac{a_2}{c_2}\right)^{1/2} 
    27                   - \frac14\frac{c_1}{c_2}\right]^{-1/2} 
     37                  + \frac14\frac{c_1}{c_2}\right]^{-1/2} 
    2838 
     39Here the model is parameterised in terms of  $d$ and $\xi$ and with an explicit 
     40volume fraction for one phase, $\phi_a$, and contrast, 
     41$\delta\rho^2 = (\rho_a - \rho_b)^2$ : 
     42 
     43.. math:: 
     44 
     45    I(q) = \frac{8\pi\phi_a(1-\phi_a)(\Delta\rho)^2c_2/\xi} 
     46        {a_2 + c_1q^2 + c_2q^4} 
     47 
     48where :math:`8\pi\phi_a(1-\phi_a)(\Delta\rho)^2c_2/\xi` is the constant of 
     49proportionality from the first equation above. 
     50 
     51In the case of a microemulsion, $a_2 > 0$, $c_1 < 0$, and $c_2 >0$. 
    2952 
    3053For 2D data, scattering intensity is calculated in the same way as 1D, 
     
    3457 
    3558    q = \sqrt{q_x^2 + q_y^2} 
    36  
    3759 
    3860References 
     
    4466*J. Chem. Phys.*, 101 (1994) 5343 
    4567 
     68H Endo, M Mihailescu, M. Monkenbusch, J Allgaier, G Gompper, D Richter, 
     69B Jakobs, T Sottmann, R Strey, and I Grillo, *J. Chem. Phys.*, 115 (2001), 580 
    4670""" 
    4771 
    4872import numpy as np 
    49 from numpy import inf 
     73from numpy import inf,power,pi 
    5074 
    5175name = "teubner_strey" 
    5276title = "Teubner-Strey model of microemulsions" 
    5377description = """\ 
    54    Scattering model class for the Teubner-Strey model given by 
    55     Provide F(x) = 1/( a2 + c1 q^2+  c2 q^4 ) + background 
    56     a2>0, c1<0, c2>0, 4 a2 c2 - c1^2 > 0 
     78    Calculates scattering according to the Teubner-Strey model 
    5779""" 
    5880category = "shape-independent" 
     
    6082#   ["name", "units", default, [lower, upper], "type","description"], 
    6183parameters = [ 
    62     ["a2", "", 0.1, [0, inf], "", "a2"], 
    63     ["c1", "1e-6/Ang^2", -30., [-inf, 0], "", "c1"], 
    64     ["c2", "Ang", 5000., [0, inf], "volume", "c2"], 
     84    ["volfraction_a", "", 0.5, [0, 1.0], "", "Volume fraction of phase a"], 
     85    ["sld_a", "1e-6/Ang^2", 0.3, [-inf, inf], "", "SLD of phase a"], 
     86    ["sld_b", "1e-6/Ang^2", 6.3, [-inf, inf], "", "SLD of phase b"], 
     87    ["d", "Ang", 100.0, [0, inf], "", "Domain size (periodicity)"], 
     88    ["xi", "Ang", 30.0, [0, inf], "", "Correlation length"], 
    6589    ] 
    6690 
    67 def Iq(q, a2, c1, c2): 
     91def Iq(q, volfraction, sld, sld_solvent,d,xi): 
    6892    """SAS form""" 
    69     return 1. / np.polyval([c2, c1, a2], q**2) 
     93    drho2 = (sld-sld_solvent)*(sld-sld_solvent) 
     94    a2 = power(1.0+power(2.0*pi*xi/d,2.0),2.0) 
     95    c1 = -2.0*xi*xi*power(2.0*pi*xi/d,2.0)+2*xi*xi 
     96    c2 = power(xi,4.0) 
     97    prefactor = 8.0*pi*volfraction*(1.0-volfraction)*drho2*c2/xi 
     98    #k2 = (2.0*pi/d)*(2.0*pi/d) 
     99    #xi2 = 1/(xi*xi) 
     100    #q2 = q*q 
     101    #result = prefactor/((xi2+k2)*(xi2+k2)+2.0*(xi2-k2)*q2+q2*q2) 
     102    return 1.0e-4*prefactor / np.polyval([c2, c1, a2], q**2) 
     103 
    70104Iq.vectorized = True  # Iq accepts an array of q values 
    71105 
    72 demo = dict(scale=1, background=0, a2=0.1, c1=-30.0, c2=5000.0) 
    73 tests = [[{}, 0.2, 0.145927536232]] 
     106demo = dict(scale=1, background=0, volfraction_a=0.5, 
     107                     sld_a=0.3, sld_b=6.3, 
     108                     d=100.0, xi=30.0) 
     109tests = [[{}, 0.06, 41.5918888453]] 
  • sasmodels/models/triaxial_ellipsoid.c

    r2f5c6d4 ra807206  
    1 double form_volume(double req_minor, double req_major, double rpolar); 
    2 double Iq(double q, double sld, double solvent_sld, 
    3     double req_minor, double req_major, double rpolar); 
    4 double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    5     double req_minor, double req_major, double rpolar, double theta, double phi, double psi); 
     1double form_volume(double radius_equat_minor, double radius_equat_major, double radius_polar); 
     2double Iq(double q, double sld, double sld_solvent, 
     3    double radius_equat_minor, double radius_equat_major, double radius_polar); 
     4double Iqxy(double qx, double qy, double sld, double sld_solvent, 
     5    double radius_equat_minor, double radius_equat_major, double radius_polar, double theta, double phi, double psi); 
    66 
    7 //#define INVALID(v) (v.req_minor > v.req_major || v.req_major > v.rpolar) 
     7//#define INVALID(v) (v.radius_equat_minor > v.radius_equat_major || v.radius_equat_major > v.radius_polar) 
    88 
    99 
    10 double form_volume(double req_minor, double req_major, double rpolar) 
     10double form_volume(double radius_equat_minor, double radius_equat_major, double radius_polar) 
    1111{ 
    12     return 1.333333333333333*M_PI*req_minor*req_major*rpolar; 
     12    return 1.333333333333333*M_PI*radius_equat_minor*radius_equat_major*radius_polar; 
    1313} 
    1414 
    1515double Iq(double q, 
    1616    double sld, 
    17     double solvent_sld, 
    18     double req_minor, 
    19     double req_major, 
    20     double rpolar) 
     17    double sld_solvent, 
     18    double radius_equat_minor, 
     19    double radius_equat_major, 
     20    double radius_polar) 
    2121{ 
    2222    double sn, cn; 
     
    2929        const double x = 0.5*(Gauss76Z[i] + 1.0); 
    3030        SINCOS(M_PI_2*x, sn, cn); 
    31         const double acosx2 = req_minor*req_minor*cn*cn; 
    32         const double bsinx2 = req_major*req_major*sn*sn; 
    33         const double c2 = rpolar*rpolar; 
     31        const double acosx2 = radius_equat_minor*radius_equat_minor*cn*cn; 
     32        const double bsinx2 = radius_equat_major*radius_equat_major*sn*sn; 
     33        const double c2 = radius_polar*radius_polar; 
    3434 
    3535        double inner = 0.0; 
     
    4444    // translate dx in [-1,1] to dx in [lower,upper] 
    4545    const double fqsq = outer*zm; 
    46     const double s = (sld - solvent_sld) * form_volume(req_minor, req_major, rpolar); 
     46    const double s = (sld - sld_solvent) * form_volume(radius_equat_minor, radius_equat_major, radius_polar); 
    4747    return 1.0e-4 * s * s * fqsq; 
    4848} 
     
    5050double Iqxy(double qx, double qy, 
    5151    double sld, 
    52     double solvent_sld, 
    53     double req_minor, 
    54     double req_major, 
    55     double rpolar, 
     52    double sld_solvent, 
     53    double radius_equat_minor, 
     54    double radius_equat_major, 
     55    double radius_polar, 
    5656    double theta, 
    5757    double phi, 
     
    7171    const double cnu = (-cphi*spsi*stheta + sphi*cpsi)*qxhat + spsi*ctheta*qyhat; 
    7272    const double cmu = (-stheta*cpsi*cphi - spsi*sphi)*qxhat + ctheta*cpsi*qyhat; 
    73     const double t = q*sqrt(req_minor*req_minor*cnu*cnu 
    74                           + req_major*req_major*cmu*cmu 
    75                           + rpolar*rpolar*calpha*calpha); 
     73    const double t = q*sqrt(radius_equat_minor*radius_equat_minor*cnu*cnu 
     74                          + radius_equat_major*radius_equat_major*cmu*cmu 
     75                          + radius_polar*radius_polar*calpha*calpha); 
    7676    const double fq = sph_j1c(t); 
    77     const double s = (sld - solvent_sld) * form_volume(req_minor, req_major, rpolar); 
     77    const double s = (sld - sld_solvent) * form_volume(radius_equat_minor, radius_equat_major, radius_polar); 
    7878 
    7979    return 1.0e-4 * square(s * fq); 
  • sasmodels/models/triaxial_ellipsoid.py

    r42356c8 ra807206  
    8888parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", 
    8989               "Ellipsoid scattering length density"], 
    90               ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
     90              ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", 
    9191               "Solvent scattering length density"], 
    92               ["req_minor", "Ang", 20, [0, inf], "volume", 
     92              ["radius_equat_minor", "Ang", 20, [0, inf], "volume", 
    9393               "Minor equatorial radius"], 
    94               ["req_major", "Ang", 400, [0, inf], "volume", 
     94              ["radius_equat_major", "Ang", 400, [0, inf], "volume", 
    9595               "Major equatorial radius"], 
    96               ["rpolar", "Ang", 10, [0, inf], "volume", 
     96              ["radius_polar", "Ang", 10, [0, inf], "volume", 
    9797               "Polar radius"], 
    9898              ["theta", "degrees", 60, [-inf, inf], "orientation", 
     
    106106source = ["lib/sph_j1c.c", "lib/gauss76.c", "triaxial_ellipsoid.c"] 
    107107 
    108 def ER(req_minor, req_major, rpolar): 
     108def ER(radius_equat_minor, radius_equat_major, radius_polar): 
    109109    """ 
    110110        Returns the effective radius used in the S*P calculation 
     
    112112    import numpy as np 
    113113    from .ellipsoid import ER as ellipsoid_ER 
    114     return ellipsoid_ER(rpolar, np.sqrt(req_minor * req_major)) 
     114    return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major)) 
    115115 
    116116demo = dict(scale=1, background=0, 
    117             sld=6, solvent_sld=1, 
     117            sld=6, sld_solvent=1, 
    118118            theta=30, phi=15, psi=5, 
    119             req_minor=25, req_major=36, rpolar=50, 
    120             req_minor_pd=0, req_minor_pd_n=1, 
    121             req_major_pd=0, req_major_pd_n=1, 
    122             rpolar_pd=.2, rpolar_pd_n=30, 
     119            radius_equat_minor=25, radius_equat_major=36, radius_polar=50, 
     120            radius_equat_minor_pd=0, radius_equat_minor_pd_n=1, 
     121            radius_equat_major_pd=0, radius_equat_major_pd_n=1, 
     122            radius_polar_pd=.2, radius_polar_pd_n=30, 
    123123            theta_pd=15, theta_pd_n=45, 
    124124            phi_pd=15, phi_pd_n=1, 
  • sasmodels/resolution.py

    r2472141 r69ef533  
    804804        pars = { 
    805805            'scale':0.05, 
    806             'r_polar':500, 'r_equatorial':15000, 
     806            'radius_polar':500, 'radius_equatorial':15000, 
    807807            'sld':6, 'sld_solvent': 1, 
    808808            } 
  • sasmodels/sasview_model.py

    r3bcb88c r9c1a59c  
    565565        parameters = self._model_info.parameters 
    566566        pairs = [self._get_weights(p) for p in parameters.call_parameters] 
     567        #weights.plot_weights(self._model_info, pairs) 
    567568        call_details, values, is_magnetic = make_kernel_args(calculator, pairs) 
    568569        #call_details.show() 
     
    618619            # remember them is kind of funky. 
    619620            # Note: can't seem to get disperser parameters from sasview 
    620             # (1) Could create a sasview model that has not yet # been 
     621            # (1) Could create a sasview model that has not yet been 
    621622            # converted, assign the disperser to one of its polydisperse 
    622623            # parameters, then retrieve the disperser parameters from the 
    623             # sasview model.  (2) Could write a disperser parameter retriever 
    624             # in sasview.  (3) Could modify sasview to use sasmodels.weights 
    625             # dispersers. 
     624            # sasview model. 
     625            # (2) Could write a disperser parameter retriever in sasview. 
     626            # (3) Could modify sasview to use sasmodels.weights dispersers. 
    626627            # For now, rely on the fact that the sasview only ever uses 
    627628            # new dispersers in the set_dispersion call and create a new 
    628629            # one instead of trying to assign parameters. 
    629             dispersion = weights.MODELS[dispersion.type]() 
    630630            self.dispersion[parameter] = dispersion.get_pars() 
    631631        else: 
     
    658658        elif par.polydisperse: 
    659659            dis = self.dispersion[par.name] 
    660             value, weight = weights.get_weights( 
    661                 dis['type'], dis['npts'], dis['width'], dis['nsigmas'], 
    662                 self.params[par.name], par.limits, par.relative_pd) 
     660            if dis['type'] == 'array': 
     661                value, weight = dis['values'], dis['weights'] 
     662            else: 
     663                value, weight = weights.get_weights( 
     664                    dis['type'], dis['npts'], dis['width'], dis['nsigmas'], 
     665                    self.params[par.name], par.limits, par.relative_pd) 
    663666            return value, weight / np.sum(weight) 
    664667        else: 
  • sasmodels/weights.py

    r733a3e1 r41e7f2e  
    22SAS distributions for polydispersity. 
    33""" 
    4 from __future__ import division 
     4# TODO: include dispersion docs with the disperser models 
     5from __future__ import division, print_function 
     6 
    57from math import sqrt  # type: ignore 
     8from collections import OrderedDict 
     9