Changeset e6378f9 in sasmodels


Ignore:
Timestamp:
Oct 4, 2016 3:44:00 PM (5 years ago)
Author:
richardh
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
bb2d187, 71f8bdb
Parents:
ca55aa0 (diff), d247047 (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' of https://github.com/Sasview/sasmodels

rkh trying to change one line in modelinfo.py

Files:
2 deleted
77 edited
8 moved

Legend:

Unmodified
Added
Removed
  • sascomp

    r6708a6a r424fe00  
    1919 
    2020    import sasmodels.compare 
    21     sasmodels.compare.main() 
     21    sasmodels.compare.main(*sys.argv[1:]) 
    2222 
    2323if __name__ == "__main__": 
  • sasmodels/__init__.py

    rb2377b0 r79906d1  
    1414defining new models. 
    1515""" 
    16 __version__ = "0.93" 
     16__version__ = "0.94" 
    1717 
    1818def data_files(): 
  • sasmodels/compare.py

    r050c2c8 r41e7f2e  
    789789 
    790790 
    791 def parse_opts(): 
    792     # type: () -> Dict[str, Any] 
     791def parse_opts(argv): 
     792    # type: (List[str]) -> Dict[str, Any] 
    793793    """ 
    794794    Parse command line options. 
    795795    """ 
    796796    MODELS = core.list_models() 
    797     flags = [arg for arg in sys.argv[1:] 
     797    flags = [arg for arg in argv 
    798798             if arg.startswith('-')] 
    799     values = [arg for arg in sys.argv[1:] 
     799    values = [arg for arg in argv 
    800800              if not arg.startswith('-') and '=' in arg] 
    801     args = [arg for arg in sys.argv[1:] 
     801    positional_args = [arg for arg in argv 
    802802            if not arg.startswith('-') and '=' not in arg] 
    803803    models = "\n    ".join("%-15s"%v for v in MODELS) 
    804     if len(args) == 0: 
     804    if len(positional_args) == 0: 
    805805        print(USAGE) 
    806806        print("\nAvailable models:") 
    807807        print(columnize(MODELS, indent="  ")) 
    808         sys.exit(1) 
    809     if len(args) > 3: 
     808        return None 
     809    if len(positional_args) > 3: 
    810810        print("expected parameters: model N1 N2") 
    811811 
    812     name = args[0] 
     812    name = positional_args[0] 
    813813    try: 
    814814        model_info = core.load_model_info(name) 
     
    816816        print(str(exc)) 
    817817        print("Could not find model; use one of:\n    " + models) 
    818         sys.exit(1) 
     818        return None 
    819819 
    820820    invalid = [o[1:] for o in flags 
     
    823823    if invalid: 
    824824        print("Invalid options: %s"%(", ".join(invalid))) 
    825         sys.exit(1) 
     825        return None 
    826826 
    827827 
     
    898898        del engines[2:] 
    899899 
    900     n1 = int(args[1]) if len(args) > 1 else 1 
    901     n2 = int(args[2]) if len(args) > 2 else 1 
     900    n1 = int(positional_args[1]) if len(positional_args) > 1 else 1 
     901    n2 = int(positional_args[2]) if len(positional_args) > 2 else 1 
    902902    use_sasview = any(engine == 'sasview' and count > 0 
    903903                      for engine, count in zip(engines, [n1, n2])) 
     
    916916            s = set(p.split('_pd')[0] for p in pars) 
    917917            print("%r invalid; parameters are: %s"%(k, ", ".join(sorted(s)))) 
    918             sys.exit(1) 
     918            return None 
    919919        presets[k] = float(v) if not k.endswith('type') else v 
    920920 
     
    970970    from bumps.gui.app_frame import AppFrame  # type: ignore 
    971971 
     972    is_mac = "cocoa" in wx.version() 
     973    # Create an app if not running embedded 
     974    app = wx.App() if wx.GetApp() is None else None 
    972975    problem = FitProblem(Explore(opts)) 
    973     is_mac = "cocoa" in wx.version() 
    974     app = wx.App() 
    975     frame = AppFrame(parent=None, title="explore") 
     976    frame = AppFrame(parent=None, title="explore", size=(1000,700)) 
    976977    if not is_mac: frame.Show() 
    977978    frame.panel.set_model(model=problem) 
     
    979980    frame.panel.aui.Split(0, wx.TOP) 
    980981    if is_mac: frame.Show() 
    981     app.MainLoop() 
     982    # If running withing an app, start the main loop 
     983    if app: app.MainLoop() 
    982984 
    983985class Explore(object): 
     
    10481050 
    10491051 
    1050 def main(): 
    1051     # type: () -> None 
     1052def main(*argv): 
     1053    # type: (*str) -> None 
    10521054    """ 
    10531055    Main program. 
    10541056    """ 
    1055     opts = parse_opts() 
    1056     if opts['explore']: 
    1057         explore(opts) 
    1058     else: 
    1059         compare(opts) 
     1057    opts = parse_opts(argv) 
     1058    if opts is not None: 
     1059        if opts['explore']: 
     1060            explore(opts) 
     1061        else: 
     1062            compare(opts) 
    10601063 
    10611064if __name__ == "__main__": 
    1062     main() 
     1065    main(*sys.argv[1:]) 
  • sasmodels/compare_many.py

    r40a87fa r424fe00  
    229229    print_models() 
    230230 
    231 def main(): 
     231def main(argv): 
    232232    """ 
    233233    Main program. 
    234234    """ 
    235     if len(sys.argv) not in (6, 7): 
     235    if len(argv) not in (5, 6): 
    236236        print_help() 
    237         sys.exit(1) 
    238  
    239     model = sys.argv[1] 
     237        return 
     238 
     239    model = argv[0] 
    240240    if not (model in MODELS) and (model != "all"): 
    241241        print('Bad model %s.  Use "all" or one of:'%model) 
    242242        print_models() 
    243         sys.exit(1) 
     243        return 
    244244    try: 
    245         count = int(sys.argv[2]) 
    246         is2D = sys.argv[3].startswith('2d') 
    247         assert sys.argv[3][1] == 'd' 
    248         Nq = int(sys.argv[3][2:]) 
    249         mono = sys.argv[4] == 'mono' 
    250         cutoff = float(sys.argv[4]) if not mono else 0 
    251         base = sys.argv[5] 
    252         comp = sys.argv[6] if len(sys.argv) > 6 else "sasview" 
     245        count = int(argv[1]) 
     246        is2D = argv[2].startswith('2d') 
     247        assert argv[2][1] == 'd' 
     248        Nq = int(argv[2][2:]) 
     249        mono = argv[3] == 'mono' 
     250        cutoff = float(argv[3]) if not mono else 0 
     251        base = argv[4] 
     252        comp = argv[5] if len(argv) > 5 else "sasview" 
    253253    except Exception: 
    254254        traceback.print_exc() 
    255255        print_usage() 
    256         sys.exit(1) 
     256        return 
    257257 
    258258    data, index = make_data({'qmax':1.0, 'is2d':is2D, 'nq':Nq, 'res':0., 
     
    265265if __name__ == "__main__": 
    266266    #from .compare import push_seed 
    267     #with push_seed(1): main() 
    268     main() 
     267    #with push_seed(1): main(sys.argv[1:]) 
     268    main(sys.argv[1:]) 
  • sasmodels/conversion_table.py

    rc95dfc63 r5f1acda  
    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" 
     
    157157        } 
    158158    ], 
    159     "core_shell_ellipsoid_xt": [ 
     159    "core_shell_ellipsoid": [ 
    160160        "CoreShellEllipsoidXTModel", 
    161161        { 
     
    164164            "x_core": "X_core", 
    165165            "sld_solvent": "sld_solvent", 
    166             "t_shell": "T_shell", 
     166            "thick_shell": "T_shell", 
    167167            "x_polar_shell": "XpolarShell", 
    168168            "theta": "axis_theta", 
     
    179179            "sld_b": "sld_rimB", 
    180180            "sld_solvent": "sld_solv", 
    181             "a_side": "shortA", 
     181            "length_a": "shortA", 
    182182            "sld_a": "sld_rimA", 
    183             "b_side": "midB", 
    184             "crim_thickness": "rimC", 
     183            "length_b": "midB", 
     184            "thick_rimc": "rimC", 
    185185            "theta": "parallel_theta", 
    186             "arim_thickness": "rimA", 
    187             "c_side": "longC", 
    188             "brim_thickness": "rimB" 
     186            "thick_rim_a": "rimA", 
     187            "length_c": "longC", 
     188            "thick_rim_b": "rimB" 
    189189        } 
    190190    ], 
     
    214214            "porod_scale": "scale_p", 
    215215            "lorentz_scale": "scale_l", 
    216             "exponent_p": "exponent_p", 
    217             "exponent_l": "exponent_l", 
     216            "porod_exp": "exponent_p", 
     217            "lorentz_exp": "exponent_l", 
    218218            "cor_length": "length_l" 
    219219        } 
     
    247247        { 
    248248            "phi": "axis_phi", 
    249             "r_equatorial": "radius_b", 
     249            "radius_equatorial": "radius_b", 
    250250            "sld": "sldEll", 
    251251            "theta": "axis_theta", 
    252             "r_polar": "radius_a", 
     252            "radius_polar": "radius_a", 
    253253            "sld_solvent": "sldSolv" 
    254254        } 
     
    316316        "GaussLorentzGelModel", 
    317317        { 
    318             "gauss_scale_factor": "scale_g", 
    319             "dynamic_cor_length": "dyn_colength", 
    320             "static_cor_length": "stat_colength", 
     318            "gauss_scale": "scale_g", 
     319            "cor_length_dynamic": "dyn_colength", 
     320            "cor_length_static": "stat_colength", 
    321321            "background": "background", 
    322             "lorentz_scale_factor": "scale_l" 
     322            "lorentz_scale": "scale_l" 
    323323        } 
    324324    ], 
     
    332332        "GelFitModel", 
    333333        { 
    334             "gyration_radius": "radius", 
    335             "lorentzian_scale": "lScale", 
    336             "fractal_exp": "FractalExp", 
     334            "rg": "radius", 
     335            "lorentz_scale": "lScale", 
     336            "fractal_dim": "FractalExp", 
    337337            "cor_length": "zeta", 
    338338            "guinier_scale": "gScale" 
     
    377377            "phi": "axis_phi", 
    378378            "scale": "scale", 
    379             "core_radius": "core_radius", 
     379            "radius_core": "core_radius", 
    380380            "sld_solvent": "sldSolv", 
    381381            "length": "length", 
     
    390390        { 
    391391            "b2a_ratio": "b2a_ratio", 
    392             "a_side": "short_side", 
     392            "length_a": "short_side", 
    393393            "sld": "sldPipe", 
    394             "c_side": "c2a_ratio", 
     394            "length_c": "c2a_ratio", 
    395395            "sld_solvent": "sldSolv", 
    396396            "thickness": "thickness" 
     
    402402            "sld": "sldPipe", 
    403403            "b2a_ratio": "b2a_ratio", 
    404             "a_side": "short_side", 
    405             "c_side": "c2a_ratio", 
     404            "length_a": "short_side", 
     405            "length_c": "c2a_ratio", 
    406406            "sld_solvent": "sldSolv" 
    407407        } 
     
    421421            "sld_solvent": "sld_solvent", 
    422422            "sld_head": "sld_head", 
    423             "tail_length": "t_length", 
    424             "head_length": "h_thickness" 
     423            "length_tail": "t_length", 
     424            "length_head": "h_thickness" 
    425425        } 
    426426    ], 
     
    431431            "Nlayers": "n_plates", 
    432432            "sld_head": "sld_head", 
    433             "tail_length": "deltaT", 
    434             "head_length": "deltaH", 
     433            "length_tail": "deltaT", 
     434            "length_head": "deltaH", 
    435435            "sld": "sld_tail", 
    436436            "sld_solvent": "sld_solvent" 
     
    451451        { 
    452452            "sld": "sld_layer", 
    453             "spacing_polydisp": "pd_spacing", 
     453            "sigma_d": "pd_spacing", 
    454454            "sld_solvent": "sld_solvent" 
    455455        } 
     
    483483            "cutoff_length": "co_length", 
    484484            "radius": "radius", 
    485             "mass_dim": "mass_dim" 
     485            "fractal_dim_mass": "mass_dim" 
    486486        } 
    487487    ], 
     
    489489        "MassSurfaceFractal", 
    490490        { 
    491             "cluster_rg": "cluster_rg", 
    492             "mass_dim": "mass_dim", 
     491            "rg_cluster": "cluster_rg", 
     492            "fractal_dim_mass": "mass_dim", 
    493493            "radius": "radius", 
    494             "surface_dim": "surface_dim", 
    495             "primary_rg": "primary_rg" 
     494            "fractal_dim_surf": "surface_dim", 
     495            "rg_primary": "primary_rg" 
    496496        } 
    497497    ], 
     
    499499        "DebyeModel", 
    500500        { 
    501             "radius_gyration": "rg", 
     501            "rg": "rg", 
    502502            "scale": "scale", 
    503503            "background": "background" 
     
    521521            "A": "A_shell", 
    522522            "sld_core": "sld_core0", 
    523             "core_radius": "rad_core0", 
     523            "radius_core": "rad_core0", 
    524524            "sld_solvent": "sld_solv", 
    525525            "thickness": "thick_shell", 
     
    534534            "psi": "parallel_psi", 
    535535            "sld_solvent": "sldSolv", 
    536             "a_side": "short_a", 
    537             "b_side": "short_b", 
     536            "length_a": "short_a", 
     537            "length_b": "short_b", 
    538538            "sld": "sldPipe", 
    539539            "theta": "parallel_theta", 
    540             "c_side": "long_c", 
     540            "length_c": "long_c", 
    541541            "M0:sld": "M0_sld_pipe", 
    542542            "mtheta:sld": "M_theta_pipe", 
     
    561561        { 
    562562            "scale": "scale", 
    563             "string_thickness": "thick_string", 
     563            "thick_string": "thick_string", 
    564564            "sld_string": "sld_string", 
    565565            "sld_solvent": "sld_solv", 
    566             "edge_separation": "edge_separation", 
    567             "number_of_pearls": "num_pearls", 
     566            "edge_sep": "edge_separation", 
     567            "num_pearls": "num_pearls", 
    568568            "radius": "radius", 
    569569            "background": "background", 
     
    574574        "Poly_GaussCoil", 
    575575        { 
    576             "radius_gyration": "rg", 
     576            "rg": "rg", 
    577577            "polydispersity": "poly_m", 
    578578            "scale": "scale", 
     
    622622            "background": "background", 
    623623            "alpha": "alpha", 
    624             "pringle_sld": "sld_pringle" 
     624            "sld": "sld_pringle" 
    625625        } 
    626626    ], 
     
    644644            "sld": "sldPipe", 
    645645            "b2a_ratio": "b2a_ratio", 
    646             "a_side": "short_side", 
    647             "c_side": "c2a_ratio", 
     646            "length_a": "short_side", 
     647            "length_c": "c2a_ratio", 
    648648            "sld_solvent": "sldSolv" 
    649649        } 
     
    752752            "cutoff_length": "co_length", 
    753753            "radius": "radius", 
    754             "surface_dim": "surface_dim" 
     754            "fractal_dim_surf": "surface_dim" 
    755755        } 
    756756    ], 
     
    765765        { 
    766766            "phi": "axis_phi", 
    767             "req_minor": "semi_axisA", 
    768             "rpolar": "semi_axisC", 
    769             "req_major": "semi_axisB", 
    770             "solvent_sld": "sldSolv", 
     767            "radius_equat_minor": "semi_axisA", 
     768            "radius_polar": "semi_axisC", 
     769            "radius_equat_major": "semi_axisB", 
     770            "sld_solvent": "sldSolv", 
    771771            "psi": "axis_psi", 
    772772            "sld": "sldEll", 
  • sasmodels/custom/__init__.py

    r40a87fa r2a0c7a6  
    1717    def load_module_from_path(fullname, path): 
    1818        """load module from *path* as *fullname*""" 
    19         spec = spec_from_file_location(fullname, path) 
     19        spec = spec_from_file_location(fullname, os.path.expanduser(path)) 
    2020        module = module_from_spec(spec) 
    2121        spec.loader.exec_module(module) 
     
    2626    def load_module_from_path(fullname, path): 
    2727        """load module from *path* as *fullname*""" 
    28         module = imp.load_source(fullname, path) 
     28        module = imp.load_source(fullname, os.path.expanduser(path)) 
    2929        #os.unlink(path+"c")  # remove the automatic pyc file 
    3030        return module 
     
    3535    name = basename(splitext(path)[0]) 
    3636    # Placing the model in the 'sasmodels.custom' name space. 
    37     kernel_module = load_module_from_path('sasmodels.custom.'+name, path) 
     37    kernel_module = load_module_from_path('sasmodels.custom.'+name, 
     38                                          os.path.expanduser(path)) 
    3839    return kernel_module 
  • sasmodels/direct_model.py

    rbde38b5 r4cc161e  
    8585    if model_info.ER is None: 
    8686        return 1.0 
     87    elif not model_info.parameters.form_volume_parameters: 
     88        # handle the case where ER is provided but model is not polydisperse 
     89        return model_info.ER() 
    8790    else: 
    8891        value, weight = _vol_pars(model_info, pars) 
     
    101104    if model_info.VR is None: 
    102105        return 1.0 
     106    elif not model_info.parameters.form_volume_parameters: 
     107        # handle the case where ER is provided but model is not polydisperse 
     108        return model_info.VR() 
    103109    else: 
    104110        value, weight = _vol_pars(model_info, pars) 
     
    152158                for p in model_info.parameters.call_parameters 
    153159                if p.type == 'volume'] 
     160    #import pylab; pylab.plot(vol_pars[0][0],vol_pars[0][1]); pylab.show() 
    154161    value, weight = dispersion_mesh(model_info, vol_pars) 
    155162    return value, weight 
     
    395402    model = build_model(model_info) 
    396403    calculator = DirectModel(data, model) 
    397     pars = dict((k, float(v)) 
     404    pars = dict((k, (float(v) if not k.endswith("_pd_type") else v)) 
    398405                for pair in sys.argv[3:] 
    399406                for k, v in [pair.split('=')]) 
  • sasmodels/generate.py

    r52ec91e r2e49f9e  
    362362    for long double precision. 
    363363    """ 
     364    source = _fix_tgmath_int(source) 
    364365    if dtype == F16: 
    365366        fbytes = 2 
     
    391392    source = re.sub(r'(^|[^a-zA-Z0-9_]c?)double(([248]|16)?($|[^a-zA-Z0-9_]))', 
    392393                    r'\1%s\2'%type_name, source) 
     394    source = _tag_float(source, constant_flag) 
     395    return source 
     396 
     397TGMATH_INT_RE = re.compile(r""" 
     398(?: # Non-capturing match; not lookbehind since pattern length is variable 
     399  \b              # word boundary 
     400   # various math functions 
     401  (a?(sin|cos|tan)h? | atan2 
     402   | erfc? | tgamma 
     403   | exp(2|10|m1)? | log(2|10|1p)? | pow[nr]? | sqrt | rsqrt | rootn 
     404   | fabs | fmax | fmin 
     405   ) 
     406  \s*[(]\s*       # open parenthesis 
     407) 
     408[+-]?(0|[1-9]\d*) # integer 
     409(?=               # lookahead match: don't want to move from end of int 
     410  \s*[,)]         # comma or close parenthesis for end of argument 
     411)                 # end lookahead 
     412""", re.VERBOSE) 
     413def _fix_tgmath_int(source): 
     414    # type: (str) -> str 
     415    """ 
     416    Replace f(integer) with f(integer.) for sin, cos, pow, etc. 
     417 
     418    OS X OpenCL complains that it can't resolve the type generic calls to 
     419    the standard math functions when they are called with integer constants, 
     420    but this does not happen with the Windows Intel driver for example. 
     421    To avoid confusion on the matrix marketplace, automatically promote 
     422    integers to floats if we recognize them in the source. 
     423 
     424    The specific functions we look for are: 
     425 
     426        trigonometric: sin, asin, sinh, asinh, etc., and atan2 
     427        exponential:   exp, exp2, exp10, expm1, log, log2, log10, logp1 
     428        power:         pow, pown, powr, sqrt, rsqrt, rootn 
     429        special:       erf, erfc, tgamma 
     430        float:         fabs, fmin, fmax 
     431 
     432    Note that we don't convert the second argument of dual argument 
     433    functions: atan2, fmax, fmin, pow, powr.  This could potentially 
     434    be a problem for pow(x, 2), but that case seems to work without change. 
     435    """ 
     436    out = TGMATH_INT_RE.sub(r'\g<0>.', source) 
     437    return out 
     438 
     439 
     440# Floating point regular expression 
     441# 
     442# Define parts: 
     443# 
     444#    E = [eE][+-]?\d+    : Exponent 
     445#    P = [.]             : Decimal separator 
     446#    N = [1-9]\d*        : Natural number, no leading zeros 
     447#    Z = 0               : Zero 
     448#    F = \d+             : Fractional number, maybe leading zeros 
     449#    F? = \d*            : Optional fractional number 
     450# 
     451# We want to reject bare natural numbers and bare decimal points, so we 
     452# need to tediously outline the cases where we have either a fraction or 
     453# an exponent: 
     454# 
     455#   ( ZP | ZPF | ZE | ZPE | ZPFE | NP | NPF | NE | NPE | NPFE | PF | PFE ) 
     456# 
     457# 
     458# We can then join cases by making parts optional.  The following are 
     459# some ways to do this: 
     460# 
     461#   ( (Z|N)(P|PF|E|PE|PFE) | PFE? )                   # Split on lead 
     462#     => ( (Z|N)(PF?|(PF?)?E) | PFE? ) 
     463#   ( ((Z|N)PF?|PF)E? | (Z|N)E)                       # Split on point 
     464#   ( (ZP|ZPF|NP|NPF|PF) | (Z|ZP|ZPF|N|NP|NPF|PF)E )  # Split on E 
     465#     => ( ((Z|N)PF?|PF) | ((Z|N)(PF?)? | PF) E ) 
     466FLOAT_RE = re.compile(r""" 
     467    (?<!\w)  # use negative lookbehind since '.' confuses \b test 
     468    # use split on lead to match float ( (Z|N)(PF?|(PF?)?E) | PFE? ) 
     469    ( ( 0 | [1-9]\d* )                     # ( ( Z | N ) 
     470      ([.]\d* | ([.]\d*)? [eE][+-]?\d+ )   #   (PF? | (PF?)? E ) 
     471    | [.]\d+ ([eE][+-]?\d+)?               # | PF (E)? 
     472    )                                      # ) 
     473    (?!\w)  # use negative lookahead since '.' confuses \b test 
     474    """, re.VERBOSE) 
     475def _tag_float(source, constant_flag): 
    393476    # Convert floating point constants to single by adding 'f' to the end, 
    394477    # or long double with an 'L' suffix.  OS/X complains if you don't do this. 
    395     source = re.sub(r'[^a-zA-Z_](\d*[.]\d+|\d+[.]\d*)([eE][+-]?\d+)?', 
    396                     r'\g<0>%s'%constant_flag, source) 
    397     return source 
     478    out = FLOAT_RE.sub(r'\g<0>%s'%constant_flag, source) 
     479    #print("in",repr(source),"out",repr(out), constant_flag) 
     480    return out 
     481 
     482def test_tag_float(): 
     483 
     484    cases=""" 
     485ZP  : 0. 
     486ZPF : 0.0,0.01,0.1 
     487Z  E: 0e+001 
     488ZP E: 0.E0 
     489ZPFE: 0.13e-031 
     490NP  : 1., 12. 
     491NPF : 1.0001, 1.1, 1.0 
     492N  E: 1e0, 37E-080 
     493NP E: 1.e0, 37.E-080 
     494NPFE: 845.017e+22 
     495 PF : .1, .0, .0100 
     496 PFE: .6e+9, .82E-004 
     497# isolated cases 
     4980. 
     4991e0 
     5000.13e-013 
     501# untouched 
     502struct3.e3, 03.05.67, 37 
     503# expressions 
     5043.75+-1.6e-7-27+13.2 
     505a3.e2 - 0. 
     5064*atan(1) 
     5074.*atan(1.) 
     508""" 
     509 
     510    output=""" 
     511ZP  : 0.f 
     512ZPF : 0.0f,0.01f,0.1f 
     513Z  E: 0e+001f 
     514ZP E: 0.E0f 
     515ZPFE: 0.13e-031f 
     516NP  : 1.f, 12.f 
     517NPF : 1.0001f, 1.1f, 1.0f 
     518N  E: 1e0f, 37E-080f 
     519NP E: 1.e0f, 37.E-080f 
     520NPFE: 845.017e+22f 
     521 PF : .1f, .0f, .0100f 
     522 PFE: .6e+9f, .82E-004f 
     523# isolated cases 
     5240.f 
     5251e0f 
     5260.13e-013f 
     527# untouched 
     528struct3.e3, 03.05.67, 37 
     529# expressions 
     5303.75f+-1.6e-7f-27+13.2f 
     531a3.e2 - 0.f 
     5324*atan(1) 
     5334.f*atan(1.f) 
     534""" 
     535 
     536    for case_in, case_out in zip(cases.split('\n'), output.split('\n')): 
     537        out = _tag_float(case_in, 'f') 
     538        assert case_out == out, "%r => %r"%(case_in, out) 
    398539 
    399540 
     
    706847    Iq_units = "The returned value is scaled to units of |cm^-1| |sr^-1|, absolute scale." 
    707848    Sq_units = "The returned value is a dimensionless structure factor, $S(q)$." 
    708     docs = convert_section_titles_to_boldface(model_info.docs) 
     849    docs = model_info.docs if model_info.docs is not None else "" 
     850    docs = convert_section_titles_to_boldface(docs) 
    709851    pars = make_partable(model_info.parameters.COMMON 
    710852                         + model_info.parameters.kernel_parameters) 
     
    718860 
    719861 
     862# TODO: need a single source for rst_prolog; it is also in doc/rst_prolog 
     863RST_PROLOG = """\ 
     864.. |Ang| unicode:: U+212B 
     865.. |Ang^-1| replace:: |Ang|\ :sup:`-1` 
     866.. |Ang^2| replace:: |Ang|\ :sup:`2` 
     867.. |Ang^-2| replace:: |Ang|\ :sup:`-2` 
     868.. |1e-6Ang^-2| replace:: 10\ :sup:`-6`\ |Ang|\ :sup:`-2` 
     869.. |Ang^3| replace:: |Ang|\ :sup:`3` 
     870.. |Ang^-3| replace:: |Ang|\ :sup:`-3` 
     871.. |Ang^-4| replace:: |Ang|\ :sup:`-4` 
     872.. |cm^-1| replace:: cm\ :sup:`-1` 
     873.. |cm^2| replace:: cm\ :sup:`2` 
     874.. |cm^-2| replace:: cm\ :sup:`-2` 
     875.. |cm^3| replace:: cm\ :sup:`3` 
     876.. |1e15cm^3| replace:: 10\ :sup:`15`\ cm\ :sup:`3` 
     877.. |cm^-3| replace:: cm\ :sup:`-3` 
     878.. |sr^-1| replace:: sr\ :sup:`-1` 
     879.. |P0| replace:: P\ :sub:`0`\ 
     880 
     881.. |equiv| unicode:: U+2261 
     882.. |noteql| unicode:: U+2260 
     883.. |TM| unicode:: U+2122 
     884 
     885.. |cdot| unicode:: U+00B7 
     886.. |deg| unicode:: U+00B0 
     887.. |g/cm^3| replace:: g\ |cdot|\ cm\ :sup:`-3` 
     888.. |mg/m^2| replace:: mg\ |cdot|\ m\ :sup:`-2` 
     889.. |fm^2| replace:: fm\ :sup:`2` 
     890.. |Ang*cm^-1| replace:: |Ang|\ |cdot|\ cm\ :sup:`-1` 
     891""" 
     892 
     893# TODO: make a better fake reference role 
     894RST_ROLES = """\ 
     895.. role:: ref 
     896 
     897.. role:: numref 
     898 
     899""" 
     900 
    720901def make_html(model_info): 
    721902    """ 
     
    723904    """ 
    724905    from . import rst2html 
    725     return rst2html.convert(make_doc(model_info)) 
     906 
     907    rst = make_doc(model_info) 
     908    return rst2html.rst2html("".join((RST_ROLES, RST_PROLOG, rst))) 
     909 
     910def view_html(model_name): 
     911    from . import rst2html 
     912    from . import modelinfo 
     913    kernel_module = load_kernel_module(model_name) 
     914    info = modelinfo.make_model_info(kernel_module) 
     915    url = "file://"+dirname(info.filename)+"/" 
     916    rst2html.wxview(make_html(info), url=url) 
    726917 
    727918def demo_time(): 
  • 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/kerneldll.py

    r14a15a3 r3764ec1  
    22DLL driver for C kernels 
    33 
    4 The global attribute *ALLOW_SINGLE_PRECISION_DLLS* should be set to *True* if 
    5 you wish to allow single precision floating point evaluation for the compiled 
    6 models, otherwise it defaults to *False*. 
    7  
    8 The compiler command line is stored in the attribute *COMPILE*, with string 
    9 substitutions for %(source)s and %(output)s indicating what to compile and 
    10 where to store it.  The actual command is system dependent. 
    11  
    12 On windows systems, you have a choice of compilers.  *MinGW* is the GNU 
    13 compiler toolchain, available in packages such as anaconda and PythonXY, 
    14 or available stand alone. This toolchain has had difficulties on some 
    15 systems, and may or may not work for you.  In order to build DLLs, *gcc* 
    16 must be on your path.  If the environment variable *SAS_OPENMP* is given 
    17 then -fopenmp is added to the compiler flags.  This requires a version 
    18 of MinGW compiled with OpenMP support. 
    19  
    20 An alternative toolchain uses the Microsoft Visual C++ compiler, available 
    21 free from microsoft: 
     4If the environment variable *SAS_OPENMP* is set, then sasmodels 
     5will attempt to compile with OpenMP flags so that the model can use all 
     6available kernels.  This may or may not be available on your compiler 
     7toolchain.  Depending on operating system and environment. 
     8 
     9Windows does not have provide a compiler with the operating system. 
     10Instead, we assume that TinyCC is installed and available.  This can 
     11be done with a simple pip command if it is not already available:: 
     12 
     13    pip install tinycc 
     14 
     15If Microsoft Visual C++ is available (because VCINSTALLDIR is 
     16defined in the environment), then that will be used instead. 
     17Microsoft Visual C++ for Python is available from Microsoft: 
    2218 
    2319    `<http://www.microsoft.com/en-us/download/details.aspx?id=44266>`_ 
    2420 
    25 Again, this requires that the compiler is available on your path.  This is 
    26 done by running vcvarsall.bat in a windows terminal.  Install locations are 
    27 system dependent, such as: 
     21If neither compiler is available, sasmodels will check for *MinGW*, 
     22the GNU compiler toolchain. This available in packages such as Anaconda 
     23and PythonXY, or available stand alone. This toolchain has had 
     24difficulties on some systems, and may or may not work for you. 
     25 
     26You can control which compiler to use by setting SAS_COMPILER in the 
     27environment: 
     28 
     29  - tinycc (Windows): use the TinyCC compiler shipped with SasView 
     30  - msvc (Windows): use the Microsoft Visual C++ compiler 
     31  - mingw (Windows): use the MinGW GNU cc compiler 
     32  - unix (Linux): use the system cc compiler. 
     33  - unix (Mac): use the clang compiler. You will need XCode installed, and 
     34    the XCode command line tools. Mac comes with OpenCL drivers, so generally 
     35    this will not be needed. 
     36 
     37Both *msvc* and *mingw* require that the compiler is available on your path. 
     38For *msvc*, this can done by running vcvarsall.bat in a windows terminal. 
     39Install locations are system dependent, such as: 
    2840 
    2941    C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
     
    3345    C:\Users\yourname\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
    3446 
    35 And again, the environment variable *SAS_OPENMP* controls whether OpenMP is 
    36 used to compile the C code.  This requires the Microsoft vcomp90.dll library, 
    37 which doesn't seem to be included with the compiler, nor does there appear 
    38 to be a public download location.  There may be one on your machine already 
    39 in a location such as: 
     47OpenMP for *msvc* requires the Microsoft vcomp90.dll library, which doesn't 
     48seem to be included with the compiler, nor does there appear to be a public 
     49download location.  There may be one on your machine already in a location 
     50such as: 
    4051 
    4152    C:\Windows\winsxs\x86_microsoft.vc90.openmp*\vcomp90.dll 
    4253 
    43 If you copy this onto your path, such as the python directory or the install 
    44 directory for this application, then OpenMP should be supported. 
     54If you copy this to somewhere on your path, such as the python directory or 
     55the install directory for this application, then OpenMP should be supported. 
     56 
     57For full control of the compiler, define a function 
     58*compile_command(source,output)* which takes the name of the source file 
     59and the name of the output file and returns a compile command that can be 
     60evaluated in the shell.  For even more control, replace the entire 
     61*compile(source,output)* function. 
     62 
     63The global attribute *ALLOW_SINGLE_PRECISION_DLLS* should be set to *False* if 
     64you wish to prevent single precision floating point evaluation for the compiled 
     65models, otherwise set it defaults to *True*. 
    4566""" 
    4667from __future__ import print_function 
     
    90111    compiler = "unix" 
    91112 
    92 ARCH = "" if sys.maxint > 2**32 else "x86"  # maxint=2**31-1 on 32 bit 
     113ARCH = "" if ct.sizeof(c_void_p) > 4 else "x86"  # 4 byte pointers on x86 
    93114if compiler == "unix": 
    94115    # Generic unix compile 
  • sasmodels/model_test.py

    r40a87fa r897ca7f  
    5050import numpy as np  # type: ignore 
    5151 
    52 from .core import list_models, load_model_info, build_model, HAVE_OPENCL 
     52from . import core 
     53from .core import list_models, load_model_info, build_model 
    5354from .direct_model import call_kernel, call_ER, call_VR 
    5455from .exception import annotate_exception 
     
    9899        if is_py:  # kernel implemented in python 
    99100            test_name = "Model: %s, Kernel: python"%model_name 
    100             test_method_name = "test_%s_python" % model_name 
     101            test_method_name = "test_%s_python" % model_info.id 
    101102            test = ModelTestCase(test_name, model_info, 
    102103                                 test_method_name, 
     
    106107        else:   # kernel implemented in C 
    107108            # test using opencl if desired and available 
    108             if 'opencl' in loaders and HAVE_OPENCL: 
     109            if 'opencl' in loaders and core.HAVE_OPENCL: 
    109110                test_name = "Model: %s, Kernel: OpenCL"%model_name 
    110                 test_method_name = "test_%s_opencl" % model_name 
     111                test_method_name = "test_%s_opencl" % model_info.id 
    111112                # Using dtype=None so that the models that are only 
    112113                # correct for double precision are not tested using 
     
    122123            if 'dll' in loaders: 
    123124                test_name = "Model: %s, Kernel: dll"%model_name 
    124                 test_method_name = "test_%s_dll" % model_name 
     125                test_method_name = "test_%s_dll" % model_info.id 
    125126                test = ModelTestCase(test_name, model_info, 
    126127                                     test_method_name, 
     
    249250    return abs(target-actual)/shift < 1.5*10**-digits 
    250251 
    251 def main(): 
    252     # type: () -> int 
    253     """ 
    254     Run tests given is sys.argv. 
     252def run_one(model): 
     253    # type: (str) -> None 
     254    """ 
     255    Run the tests for a single model, printing the results to stdout. 
     256 
     257    *model* can by a python file, which is handy for checking user defined 
     258    plugin models. 
     259    """ 
     260    # Note that running main() directly did not work from within the 
     261    # wxPython pycrust console.  Instead of the results appearing in the 
     262    # window they were printed to the underlying console. 
     263    from unittest.runner import TextTestResult, _WritelnDecorator 
     264 
     265    # Build a object to capture and print the test results 
     266    stream = _WritelnDecorator(sys.stdout)  # Add writeln() method to stream 
     267    verbosity = 2 
     268    descriptions = True 
     269    result = TextTestResult(stream, descriptions, verbosity) 
     270 
     271    # Build a test suite containing just the model 
     272    loaders = ['opencl'] 
     273    models = [model] 
     274    try: 
     275        suite = make_suite(loaders, models) 
     276    except Exception: 
     277        import traceback 
     278        stream.writeln(traceback.format_exc()) 
     279        return 
     280 
     281    # Run the test suite 
     282    suite.run(result) 
     283 
     284    # Print the failures and errors 
     285    for _, tb in result.errors: 
     286        stream.writeln(tb) 
     287    for _, tb in result.failures: 
     288        stream.writeln(tb) 
     289 
     290    # Check if there are user defined tests. 
     291    # Yes, it is naughty to peek into the structure of the test suite, and 
     292    # to assume that it contains only one test. 
     293    if not suite._tests[0].info.tests: 
     294        stream.writeln("Note: %s has no user defined tests."%model) 
     295 
     296 
     297def main(*models): 
     298    # type: (*str) -> int 
     299    """ 
     300    Run tests given is models. 
    255301 
    256302    Returns 0 if success or 1 if any tests fail. 
     
    263309        test_args = {} 
    264310 
    265     models = sys.argv[1:] 
    266311    if models and models[0] == '-v': 
    267312        verbosity = 2 
     
    270315        verbosity = 1 
    271316    if models and models[0] == 'opencl': 
    272         if not HAVE_OPENCL: 
     317        if not core.HAVE_OPENCL: 
    273318            print("opencl is not available") 
    274319            return 1 
     
    318363 
    319364if __name__ == "__main__": 
    320     sys.exit(main()) 
     365    sys.exit(main(*sys.argv[1:])) 
  • 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_multi_shell.py

    r8c6fbbc r7b68dc5  
    132132def ER(radius, n, thickness): 
    133133    """Effective radius""" 
    134     n = n[0]  # n cannot be polydisperse 
     134    n = int(n[0])  # n cannot be polydisperse 
    135135    return np.sum(thickness[:n], axis=0) + radius 
    136136 
  • 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/onion.py

    r3cd1001 r7b68dc5  
    368368def ER(core_radius, n, thickness): 
    369369    """Effective radius""" 
    370     return np.sum(thickness[:n[0]], axis=0) + core_radius 
     370    return np.sum(thickness[:int(n[0])], axis=0) + core_radius 
    371371 
    372372demo = { 
  • 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

    r58c3367 r30fbe2e  
    66          double alpha, 
    77          double beta, 
    8           double sld_pringle, 
     8          double sld, 
    99          double sld_solvent); 
    1010 
     
    110110    double alpha, 
    111111    double beta, 
    112     double sld_pringle, 
     112    double sld, 
    113113    double sld_solvent) 
    114114{ 
    115115    double form = _integrate_psi(q, radius, thickness, alpha, beta); 
    116     double contrast = sld_pringle - sld_solvent; 
     116    double contrast = sld - sld_solvent; 
    117117    double volume = M_PI*radius*radius*thickness; 
    118118    return 1.0e-4*form * square(contrast * volume); 
  • sasmodels/models/pringle.py

    r5fd684d r30fbe2e  
    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, 
    104104      'background': 0.001, 
     
    110110      'alpha': 0.001, 
    111111      'beta': 0.02, 
    112       'sld_pringle': 1.0, 
     112      'sld': 1.0, 
    113113      'sld_solvent': 6.3, 
    114114      'background': 0.001, 
     
    120120      'alpha': 0.001, 
    121121      'beta': 0.02, 
    122       'sld_pringle': 1.0, 
     122      'sld': 1.0, 
    123123      'sld_solvent': 6.3, 
    124124      'background': 0.001, 
  • 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/sphere.py

    r9a4811a r7e6bea81  
    22For information about polarised and magnetic scattering, see 
    33the :ref:`magnetism` documentation. 
    4 documentation. 
    54 
    65Definition 
     
    1615 
    1716where *scale* is a volume fraction, $V$ is the volume of the scatterer, 
    18 $r$ is the radius of the sphere, *background* is the background level and 
     17$r$ is the radius of the sphere and *background* is the background level. 
    1918*sld* and *sld_solvent* are the scattering length densities (SLDs) of the 
    20 scatterer and the solvent respectively. 
     19scatterer and the solvent respectively, whose difference is $\Delta\rho$. 
    2120 
    2221Note that if your data is in absolute scale, the *scale* should represent 
     
    9190            radius=120, 
    9291            radius_pd=.2, radius_pd_n=45) 
     92 
     93tests = [ 
     94    [{}, 0.2, 0.726362], 
     95    [{"scale": 1., "background": 0., "sld": 6., "sld_solvent": 1., 
     96      "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
     97     0.2, 0.228843], 
     98    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, "ER", 120.], 
     99    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, "VR", 1.], 
     100] 
     101 
     102 
  • 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