Changeset 2d65d51 in sasmodels


Ignore:
Timestamp:
Aug 7, 2016 6:30:01 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
40a87fa
Parents:
906cadf
Message:

spherical sld: add test result

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/spherical_sld.py

    r785cbec r2d65d51  
    212212              ["nu[n_shells]",         "",           2.5,    [0, inf],       "", "interface shape exponent"], 
    213213              ["n_steps",              "",           35,     [0, inf],       "", "number of steps in each interface (must be an odd integer)"], 
    214               ] 
     214             ] 
    215215# pylint: enable=bad-whitespace, line-too-long 
    216216source = ["lib/polevl.c", "lib/sas_erf.c", "lib/sph_j1c.c", "spherical_sld.c"] 
     
    235235    z = [] 
    236236    rho = [] 
    237     z0 = 0 
     237    z_next = 0 
    238238    # two sld points for core 
    239     z.append(0) 
     239    z.append(z_next) 
    240240    rho.append(sld[0]) 
    241241 
    242242    for i in range(0, int(n_shells)): 
    243         z0 += thickness[i] 
    244         z.append(z0) 
     243        z_next += thickness[i] 
     244        z.append(z_next) 
    245245        rho.append(sld[i]) 
    246246        dz = interface[i]/n_steps 
    247247        sld_l = sld[i] 
    248248        sld_r = sld[i+1] if i < n_shells-1 else sld_solvent 
    249         fn = SHAPE_FUNCTIONS[int(np.clip(shape[i], 0, len(SHAPE_FUNCTIONS)-1))] 
     249        fun = SHAPE_FUNCTIONS[int(np.clip(shape[i], 0, len(SHAPE_FUNCTIONS)-1))] 
    250250        for step in range(1, n_steps+1): 
    251             portion = fn(float(step)/n_steps, max(abs(nu[i]), 1e-14)) 
    252             z0 += dz 
    253             z.append(z0) 
     251            portion = fun(float(step)/n_steps, max(abs(nu[i]), 1e-14)) 
     252            z_next += dz 
     253            z.append(z_next) 
    254254            rho.append((sld_r - sld_l)*portion + sld_l) 
    255     z.append(z0*1.2) 
     255    z.append(z_next*1.2) 
    256256    rho.append(sld_solvent) 
    257257    # return sld profile (r, beta) 
     
    260260 
    261261def ER(n_shells, thickness, interface): 
     262    """Effective radius""" 
    262263    n_shells = int(n_shells) 
    263264    total = (np.sum(thickness[:n_shells], axis=1) 
     
    270271    "n_steps": 35.0, 
    271272    "sld_solvent": 1.0, 
    272     "sld":[2.07,4.0,3.5,4.0,3.5], 
    273     "thickness":[50.0,100.0,100.0,100.0,100.0], 
    274     "interface":[50.0,50.0,50.0,50.0], 
    275     "shape": [0,0,0,0,0], 
    276     "nu":[2.5,2.5,2.5,2.5,2.5], 
     273    "sld": [2.07, 4.0, 3.5, 4.0, 3.5], 
     274    "thickness": [50.0, 100.0, 100.0, 100.0, 100.0], 
     275    "interface": [50.0]*5, 
     276    "shape": [0]*5, 
     277    "nu": [2.5]*5, 
    277278    } 
    278279 
    279 #TODO: Not working yet 
    280 """ 
    281280tests = [ 
    282     # Accuracy tests based on content in test/utest_extra_models.py 
     281    # Results checked against sasview 3.1 
    283282    [{"n_shells": 5, 
    284         "n_steps": 35, 
    285         "sld_solvent": 1.0, 
    286         "sld": [2.07, 4.0, 3.5, 4.0, 3.5], 
    287         "thickness": [50.0, 100.0, 100.0, 100.0, 100.0], 
    288         "interface": [50]*5, 
    289         "shape": [0]*5, 
    290         "nu": [2.5]*5, 
    291     }, 0.001, 0.001], 
     283      "n_steps": 35, 
     284      "sld_solvent": 1.0, 
     285      "sld": [2.07, 4.0, 3.5, 4.0, 3.5], 
     286      "thickness": [50.0, 100.0, 100.0, 100.0, 100.0], 
     287      "interface": [50]*5, 
     288      "shape": [0]*5, 
     289      "nu": [2.5]*5, 
     290     }, 0.001, 750697.238], 
    292291] 
    293 """ 
Note: See TracChangeset for help on using the changeset viewer.