Changeset b297ba9 in sasmodels for sasmodels/models/hollow_cylinder.py


Ignore:
Timestamp:
Mar 20, 2019 5:03:50 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
4e28511
Parents:
0d362b7
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hollow_cylinder.py

    r99658f6 rb297ba9  
    6060.. [#] L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 
    6161   Neutron Scattering*, Plenum Press, New York, (1987) 
    62 L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949).  
     62L. Onsager, Ann. New York Acad. Sci. 51, 627-659 (1949). 
    6363 
    6464Authorship and Verification 
     
    103103have_Fq = True 
    104104effective_radius_type = [ 
    105     "excluded volume", "equivalent outer volume sphere", "outer radius", "half length", 
     105    "excluded volume", "equivalent outer volume sphere", 
     106    "outer radius", "half length", 
    106107    "half outer min dimension", "half outer max dimension", 
    107108    "half outer diagonal", 
     
    109110 
    110111def random(): 
     112    """Return a random parameter set for the model.""" 
    111113    length = 10**np.random.uniform(1, 4.7) 
    112114    outer_radius = 10**np.random.uniform(1, 4.7) 
     
    130132            theta_pd=10, theta_pd_n=5, 
    131133           ) 
     134 
     135def r_eff(radius, thickness, length): 
     136    """R_eff from excluded volume""" 
     137    radius += thickness 
     138    return (0.5*(0.75*radius*(2.0*radius*length 
     139                              + (radius + length)*(pi*radius + length)) 
     140                )**(1./3.)) 
     141 
     142def shell_volume(radius, thickness, length): 
     143    """shell volume for parameter set""" 
     144    return pi*((radius+thickness)**2-radius**2)*length 
     145 
     146def form_shell_ratio(radius, thickness, length): 
     147    """form:shell ratio""" 
     148    return (radius+thickness)**2/((radius+thickness)**2 - radius**2) 
     149 
    132150q = 0.1 
    133151# april 6 2017, rkh added a 2d unit test, assume correct! 
    134152qx = q*cos(pi/6.0) 
    135153qy = q*sin(pi/6.0) 
    136 radius = parameters[0][2] 
    137 thickness = parameters[1][2] 
    138 length = parameters[2][2] 
     154test_pars = [ 
     155    parameters[0][2], # radius 
     156    parameters[1][2], # thickness 
     157    parameters[2][2], # length 
     158] 
    139159# Parameters for unit tests 
    140160tests = [ 
    141161    [{}, 0.00005, 1764.926], 
    142162    [{}, 0.1, None, None, 
    143      0.5*(0.75*(radius+thickness)*(2.0*(radius+thickness)*length + ((radius+thickness) + length)*(pi*(radius+thickness) + length)))**(1./3.),  # R_eff from excluded volume 
    144      pi*((radius+thickness)**2-radius**2)*length,  # shell volume 
    145      (radius+thickness)**2/((radius+thickness)**2 - radius**2), # form:shell ratio 
     163     r_eff(*test_pars), shell_volume(*test_pars), form_shell_ratio(*test_pars), 
    146164    ], 
    147165    [{}, 0.001, 1756.76], 
    148166    [{}, (qx, qy), 2.36885476192], 
    149167] 
    150 del qx, qy  # not necessary to delete, but cleaner 
     168del qx, qy, test_pars  # not necessary to delete, but cleaner 
Note: See TracChangeset for help on using the changeset viewer.