Changeset b6422c7 in sasmodels for explore


Ignore:
Timestamp:
Mar 25, 2019 1:06:41 PM (6 years ago)
Author:
richardh
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
0507e09
Parents:
2fe39d1
Message:

more edits to sasfit_compare_new, vesicle and hollow cylinder improving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/beta/sasfit_compare_new.py

    r6916174 rb6422c7  
    2121#Used to calculate F(q) for the cylinder, sphere, ellipsoid models 
    2222# RKH adding vesicle and hollow_cylinder to test sasview special cases of ER and VR 
    23 # BEWARE there are issues here if you run this from python3 (i.e. qt5 version of sasview), so do "source activate sasview" 
     23# There were issues here from python3 (i.e. qt5 version of sasview),fixed by Paul K (else do "source activate sasview") 
    2424def sas_sinx_x(x): 
    2525    with np.errstate(all='ignore'): 
     
    275275    if radius_effective is None: 
    276276        radius_effective = radius 
    277         print("radius_effective  ",radius_effective) 
    278277        average_volume = total_volume/total_weight 
    279278    if norm == 'sasfit': 
     
    285284        F2 *= 1e-12 
    286285        IQD = F2/average_volume*1e8*volfraction 
     286    print("in sphere_r : radius_effective  ",radius_effective,"  volfraction",volfraction) 
    287287    SQ = hardsphere_simple(q, radius_effective, volfraction) 
    288288    beta = F1**2/F2 
     
    332332    if radius_effective is None: 
    333333        radius_effective = radius_eff/total_weight 
    334         print("radius_effective  ",radius_effective) 
     334        print("in vesicle_pe : radius_effective  ",radius_effective) 
    335335    if norm == 'sasfit': 
    336336        IQD = F2 
     
    348348        F2 *= 1e-12 
    349349        IQD = F2/average_volume*1e8*volfraction 
    350     # RKH SORT THIS OUT WHEN HAVE NEW MODEL 
    351     vfff=volfraction*(30./20.)**3 
    352     print("radius_effective, fudged volfaction for S(Q) ",radius_effective,vfff) 
     350    # RKH SORT THIS OUT WHEN HAVE NEW MODEL  Vtot/Vshell = (R+T)^3/ ( (R+T)^3 -R^3 ) 
     351    vfff=volfraction*( 1.0/(1.0 - ( (radius/(radius+thickness))**3 ))) 
     352    print("in vesicle_pe : radius_effective, fudged volfraction for S(Q) ",radius_effective,vfff) 
    353353    SQ = hardsphere_simple(q, radius_effective, vfff) 
    354354    beta = F1**2/F2 
     
    359359# 
    360360#polydispersity for hollow_cylinder 
    361 def hollow_cylinder_pe(q,radius=20, thickness=10, sld=4, sld_solvent=1, volfraction=0.15, 
    362         radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", thickness_pd_type="gaussian", 
    363         radius_effective=None, background=0, scale=1, 
     361def hollow_cylinder_pe(q,radius=20, thickness=10, length=80, sld=4, sld_solvent=1, volfraction=0.15, 
     362        radius_pd=0.1, thickness_pd=0.2, length_pd=0.05, radius_pd_type="gaussian", length_pd_type="gaussian",  
     363        thickness_pd_type="gaussian", radius_effective=None, background=0, scale=1, 
    364364                 norm='sasview'): 
    365365    if norm not in ['sasview', 'sasfit', 'yun']: 
     
    374374        T_val, T_prob = schulz_distribution(thickness, thickness_pd*thickness, 0, inf) 
    375375    if length_pd_type == 'gaussian': 
    376         T_val, T_prob = gaussian_distribution(length, length_pd*length, 0, inf) 
     376        L_val, L_prob = gaussian_distribution(length, length_pd*length, 0, inf) 
    377377    elif length_pd_type == 'schulz': 
    378378        L_val, L_prob = schulz_distribution(length, length_pd*length, 0, inf) 
     
    402402    if radius_effective is None: 
    403403        radius_effective = radius_eff/total_weight 
    404         print("radius_effective  ",radius_effective) 
     404        print("in hollow_cylinder : radius_effective  ",radius_effective) 
    405405    if norm == 'sasfit': 
    406406        IQD = F2 
     
    420420# RKH SORT THIS OUT WHEN HAVE NEW MODEL 
    421421    vfff=volfraction 
    422     print("radius_effective, volfaction for S(Q) ",radius_effective,vfff) 
     422    print("in hollow_cylinder : radius_effective, volfaction for S(Q) ",radius_effective,vfff) 
    423423    SQ = hardsphere_simple(q, radius_effective, vfff) 
    424424    beta = F1**2/F2 
     
    548548    #Iq = None#= Sq = None 
    549549    r = dict(I._kernel.results()) 
    550     #print(r) 
     550    print(r) 
    551551    return Theory(Q=q, F1=None, F2=None, P=Pq, S=None, I=None, Seff=r["S_eff(Q)"], Ibeta=Iq) 
    552552 
     
    591591        radius_pd=.1, radius_pd_type=pd_type, 
    592592        volfraction=0.15, 
    593         radius_effective=12.59921049894873,  # equivalent average sphere radius 
     593        radius_effective=20  # equivalent average sphere radius 
     594#       NOTE sasview computes its own radius_effective in "target" (the print(r) at end of sasmodels_theory will reveal its value), 
     595#       this one is only used locally for "actual" 
    594596        ) 
    595597    target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
     
    604606    q = np.logspace(-5, 0, 250) 
    605607    model = 'vesicle' 
    606     print("F2 seems OK, but big issues with S(Q), wo work in progress") 
    607 # NOTE parameers for vesicle model are soon to be changed to remove "volfraction" 
     608    print("F2 seems OK, but big issues with S(Q), so work in progress") 
     609# NOTE parameters for vesicle model are soon to be changed to remove "volfraction" (though still there in 5.0) 
    608610    pars = dict( 
    609611        radius=20, thickness=10, sld=4, sld_solvent=1, volfraction=0.03, 
    610612        background=0, 
    611         radius_pd=0.1, thickness_pd=0.0, radius_pd_type=pd_type, thickness_pd_type=pd_type 
    612         #,radius_effective=12.59921049894873,  # equivalent average sphere radius 
    613         ) 
     613        radius_pd=0.01, thickness_pd=0.01, radius_pd_type=pd_type, thickness_pd_type=pd_type, 
     614        radius_effective=30. )  
     615        # equivalent average sphere radius for local "actual" to match what sasview uses, use None to compute average outer radius here, 
     616 
    614617    target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
    615618    actual = vesicle_pe(q, norm='sasview', **pars) 
     
    629632        radius=20, thickness=10, length=80, sld=4, sld_solvent=1, 
    630633        background=0, 
    631         radius_pd=0.1, thickness_pd=0.0, length_pd=0.0, radius_pd_type=pd_type, thickness_pd_type=pd_type, length_pd_type=pd_type 
    632         #,radius_effective=12.59921049894873,  # equivalent average sphere radius 
    633         ) 
     634        radius_pd=0.1, thickness_pd=0.0, length_pd=0.0, radius_pd_type=pd_type, thickness_pd_type=pd_type, length_pd_type=pd_type, 
     635        radius_effective=40.687)   
     636        # equivalent average sphere radius for local "actual" to match what sasview uses 
    634637    target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
    635638    actual = hollow_cylinder_pe(q, norm='sasview', **pars) 
     
    651654        volfraction=0.15, 
    652655        radius_effective=270.7543927018, 
    653         #radius_effective=12.59921049894873, 
     656# if change radius_effective to some other value, the S(Q) from sasview does not agree 
    654657        ) 
    655658    target = sasmodels_theory(q, model, effective_radius_mode=0, structure_factor_mode=1, **pars) 
Note: See TracChangeset for help on using the changeset viewer.