Changeset 1511c37c in sasmodels for sasmodels


Ignore:
Timestamp:
Aug 1, 2017 5:29:07 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:
8f04da4
Parents:
31df0c9
Message:

tuned random model generation for more models

Location:
sasmodels/models
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/bcc_paracrystal.py

    r0bdddc2 r1511c37c  
    140140    # useful between 0.01 and 0.7.  Use an exponential distribution 
    141141    # in this range 'cuz its easy. 
     142    radius = 10**np.random.uniform(1.3, 4) 
     143    d_factor = 10**np.random.uniform(-2, -0.7)  # sigma_d in 0.01-0.7 
    142144    dnn_fraction = np.random.beta(a=10, b=1) 
     145    dnn = radius*4/np.sqrt(3)/dnn_fraction 
    143146    pars = dict( 
    144147        #sld=1, sld_solvent=0, scale=1, background=1e-32, 
    145         radius=10**np.random.uniform(1.3, 4), 
    146         d_factor=10**np.random.uniform(-2, -0.7),  # sigma_d in 0.01-0.7 
     148        dnn=dnn, 
     149        d_factor=d_factor, 
     150        radius=radius, 
    147151    ) 
    148     pars['dnn'] = pars['radius']*4/np.sqrt(3)/dnn_fraction 
    149     #pars['scale'] = 1/(0.68*dnn_fraction**3)  # bcc packing fraction is 0.68 
    150     pars['scale'] = 1 
    151152    return pars 
    152153 
    153 # parameters for demo 
    154 demo = dict( 
    155     scale=1, background=0, 
    156     dnn=220, d_factor=0.06, sld=4, sld_solvent=1, 
    157     radius=40, 
    158     theta=60, phi=60, psi=60, 
    159     radius_pd=.2, radius_pd_n=2, 
    160     theta_pd=15, theta_pd_n=0, 
    161     phi_pd=15, phi_pd_n=0, 
    162     psi_pd=15, psi_pd_n=0, 
    163     ) 
    164154# april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 
    165155# add 2d test later 
     
    168158    [{ }, 
    169159     [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 
    170     [{'theta':20.0,'phi':30,'psi':40.0},(-0.017,0.035),2082.20264399 ], 
    171     [{'theta':20.0,'phi':30,'psi':40.0},(-0.081,0.011),0.436323144781 ] 
     160    [{'theta': 20.0, 'phi': 30, 'psi': 40.0}, (-0.017, 0.035), 2082.20264399], 
     161    [{'theta': 20.0, 'phi': 30, 'psi': 40.0}, (-0.081, 0.011), 0.436323144781], 
    172162    ] 
  • sasmodels/models/core_multi_shell.py

    ra151caa r1511c37c  
    109109    thickness = np.random.exponential(size=num_shells+1) 
    110110    thickness *= total_radius/np.sum(thickness) 
    111     volume_fraction = 10**np.random.uniform(-4, -1) 
    112111    pars = dict( 
    113112        #background=0, 
    114         scale=volume_fraction/total_radius**3*1e10, 
    115113        n=num_shells, 
    116114        radius=thickness[0], 
  • sasmodels/models/fcc_paracrystal.py

    r404ebbd r1511c37c  
    121121def random(): 
    122122    import numpy as np 
    123     # Define lattice spacing as a multiple of the particle radius 
    124     # using the formulat a = 4 r/sqrt(3).  Systems which are ordered 
    125     # are probably mostly filled, so use a distribution which goes from 
    126     # zero to one, but leaving 90% of them within 80% of the 
    127     # maximum bcc packing.  Lattice distortion values are empirically 
    128     # useful between 0.01 and 0.7.  Use an exponential distribution 
    129     # in this range 'cuz its easy. 
     123    # copied from bcc_paracrystal 
     124    radius = 10**np.random.uniform(1.3, 4) 
     125    d_factor = 10**np.random.uniform(-2, -0.7)  # sigma_d in 0.01-0.7 
    130126    dnn_fraction = np.random.beta(a=10, b=1) 
     127    dnn = radius*4/np.sqrt(3)/dnn_fraction 
    131128    pars = dict( 
    132129        #sld=1, sld_solvent=0, scale=1, background=1e-32, 
    133         radius=10**np.random.uniform(1.3, 4), 
    134         d_factor=10**np.random.uniform(-2, -0.7),  # sigma_d in 0.01-0.7 
     130        dnn=dnn, 
     131        d_factor=d_factor, 
     132        radius=radius, 
    135133    ) 
    136     pars['dnn'] = pars['radius']*4/np.sqrt(3)/dnn_fraction 
    137     #pars['scale'] = 1/(0.68*dnn_fraction**3)  # bcc packing fraction is 0.68 
    138     pars['scale'] = 1 
    139134    return pars 
    140135 
    141 # parameters for demo 
    142 demo = dict(scale=1, background=0, 
    143             dnn=220, d_factor=0.06, sld=4, sld_solvent=1, 
    144             radius=40, 
    145             theta=60, phi=60, psi=60, 
    146             radius_pd=.2, radius_pd_n=0.2, 
    147             theta_pd=15, theta_pd_n=0, 
    148             phi_pd=15, phi_pd_n=0, 
    149             psi_pd=15, psi_pd_n=0, 
    150            ) 
    151136# april 10 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 
    152137q =4.*pi/220. 
     
    154139    [{ }, 
    155140     [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 
    156      [{}, (-0.047,-0.007), 238.103096286], 
    157      [{}, (0.053,0.063), 0.863609587796 ], 
     141     [{}, (-0.047, -0.007), 238.103096286 ], 
     142     [{}, (0.053, 0.063), 0.863609587796 ], 
    158143] 
  • sasmodels/models/fractal.py

    r404ebbd r1511c37c  
    111111    pars = dict( 
    112112        #background=0, sld_block=1, sld_solvent=0, 
    113         scale=1e4/radius**(fractal_dim/2), 
    114113        volfraction=volfraction, 
    115114        radius=radius, 
  • sasmodels/models/fractal_core_shell.py

    r404ebbd r1511c37c  
    113113    pars = dict( 
    114114        #background=0, sld_block=1, sld_solvent=0, 
    115         scale=1e3/total_radius**(fractal_dim/2), 
    116115        volfraction=volfraction, 
    117116        radius=radius, 
  • sasmodels/models/lamellar.py

    r404ebbd r1511c37c  
    9292    import numpy as np 
    9393    thickness = 10**np.random.uniform(1, 4) 
    94     scale = thickness * 10**np.random.uniform(-7, -4) 
    9594    pars = dict( 
    96         scale=scale, 
    9795        thickness=thickness, 
    9896    ) 
  • sasmodels/models/lamellar_hg.py

    r404ebbd r1511c37c  
    103103    length_head = thickness * np.random.uniform(0, 1) 
    104104    length_tail = thickness - length_head 
    105     scale = thickness * 10**np.random.uniform(-7, -4) 
    106105    pars = dict( 
    107         scale=scale, 
    108106        length_head=length_head, 
    109107        length_tail=length_tail, 
  • sasmodels/models/lamellar_hg_stack_caille.py

    r404ebbd r1511c37c  
    132132    length_tail = thickness - length_head 
    133133    Caille_parameter = np.random.uniform(0, 0.8) 
    134     scale = thickness * 10**np.random.uniform(-7, -4) 
    135134    pars = dict( 
    136         scale=1, 
    137135        length_head=length_head, 
    138136        length_tail=length_tail, 
  • sasmodels/models/lamellar_stack_caille.py

    r404ebbd r1511c37c  
    105105    thickness = d_spacing * np.random.uniform(0, 1) 
    106106    Caille_parameter = np.random.uniform(0, 0.8) 
    107     scale = thickness * 10**np.random.uniform(-7, -4) 
    108107    pars = dict( 
    109         scale=1, 
    110108        thickness=thickness, 
    111109        Nlayers=Nlayers, 
  • sasmodels/models/lamellar_stack_paracrystal.py

    r404ebbd r1511c37c  
    142142    scale = thickness * 10**np.random.uniform(-7, -4) 
    143143    pars = dict( 
    144         scale=1, 
     144        #scale=1, 
    145145        thickness=thickness, 
    146146        Nlayers=Nlayers, 
  • sasmodels/models/sc_paracrystal.py

    r404ebbd r1511c37c  
    140140def random(): 
    141141    import numpy as np 
    142     # Define lattice spacing as a multiple of the particle radius 
    143     # using the formulat a = 4 r/sqrt(3).  Systems which are ordered 
    144     # are probably mostly filled, so use a distribution which goes from 
    145     # zero to one, but leaving 90% of them within 80% of the 
    146     # maximum bcc packing.  Lattice distortion values are empirically 
    147     # useful between 0.01 and 0.7.  Use an exponential distribution 
    148     # in this range 'cuz its easy. 
     142    # copied from bcc_paracrystal 
     143    radius = 10**np.random.uniform(1.3, 4) 
     144    d_factor = 10**np.random.uniform(-2, -0.7)  # sigma_d in 0.01-0.7 
    149145    dnn_fraction = np.random.beta(a=10, b=1) 
     146    dnn = radius*4/np.sqrt(3)/dnn_fraction 
    150147    pars = dict( 
    151148        #sld=1, sld_solvent=0, scale=1, background=1e-32, 
    152         radius=10**np.random.uniform(1.3, 4), 
    153         d_factor=10**np.random.uniform(-2, -0.7),  # sigma_d in 0.01-0.7 
     149        dnn=dnn, 
     150        d_factor=d_factor, 
     151        radius=radius, 
    154152    ) 
    155     pars['dnn'] = pars['radius']*4/np.sqrt(3)/dnn_fraction 
    156     #pars['scale'] = 1/(0.68*dnn_fraction**3)  # bcc packing fraction is 0.68 
    157     pars['scale'] = 1 
    158153    return pars 
    159  
    160 demo = dict(scale=1, background=0, 
    161             dnn=220.0, 
    162             d_factor=0.06, 
    163             radius=40.0, 
    164             sld=3.0, 
    165             sld_solvent=6.3, 
    166             theta=0.0, 
    167             phi=0.0, 
    168             psi=0.0) 
    169154 
    170155tests = [ 
     
    172157    [{}, 0.001, 10.3048], 
    173158    [{}, 0.215268, 0.00814889], 
    174     [{}, (0.414467), 0.001313289], 
    175     [{'theta':10.0,'phi':20,'psi':30.0},(0.045,-0.035),18.0397138402 ], 
    176     [{'theta':10.0,'phi':20,'psi':30.0},(0.023,0.045),0.0177333171285 ] 
     159    [{}, 0.414467, 0.001313289], 
     160    [{'theta': 10.0, 'phi': 20, 'psi': 30.0}, (0.045, -0.035), 18.0397138402], 
     161    [{'theta': 10.0, 'phi': 20, 'psi': 30.0}, (0.023, 0.045), 0.0177333171285], 
    177162    ] 
    178163 
Note: See TracChangeset for help on using the changeset viewer.