Changeset 31df0c9 in sasmodels for sasmodels/models/capped_cylinder.py


Ignore:
Timestamp:
Aug 1, 2017 2:38:47 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
1511c37c
Parents:
d49ca5c
Message:

tuned random model generation for more models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/capped_cylinder.py

    r9802ab3 r31df0c9  
    8080 
    8181.. [#] H Kaya, *J. Appl. Cryst.*, 37 (2004) 223-230 
    82 .. [#] H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda  
     82.. [#] H Kaya and N-R deSouza, *J. Appl. Cryst.*, 37 (2004) 508-509 (addenda 
    8383   and errata) 
    8484 
     
    136136source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "capped_cylinder.c"] 
    137137 
     138def random(): 
     139    import numpy as np 
     140    # TODO: increase volume range once problem with bell radius is fixed 
     141    # The issue is that bell radii of more than about 200 fail at high q 
     142    V = 10**np.random.uniform(7, 9) 
     143    bar_volume = 10**np.random.uniform(-4, -1)*V 
     144    bell_volume = V - bar_volume 
     145    bell_radius = (bell_volume/6)**0.3333  # approximate 
     146    min_bar = bar_volume/np.pi/bell_radius**2 
     147    bar_length = 10**np.random.uniform(0, 3)*min_bar 
     148    bar_radius = np.sqrt(bar_volume/bar_length/np.pi) 
     149    if bar_radius > bell_radius: 
     150        bell_radius, bar_radius = bar_radius, bell_radius 
     151    pars = dict( 
     152        #background=0, 
     153        radius_cap=bell_radius, 
     154        radius=bar_radius, 
     155        length=bar_length, 
     156    ) 
     157    return pars 
     158 
     159 
    138160demo = dict(scale=1, background=0, 
    139161            sld=6, sld_solvent=1, 
Note: See TracChangeset for help on using the changeset viewer.