Changeset 3e428ec in sasmodels for sasmodels/models/hardsphere.py


Ignore:
Timestamp:
Mar 9, 2015 3:14:03 PM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
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:
ddfe69c
Parents:
485aee2
Message:

Cleaning up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hardsphere.py

    r3c56da87 r3e428ec  
    3737title = "Hard sphere structure factor, with Percus-Yevick closure" 
    3838description = """\ 
    39         [Hard sphere structure factor, with Percus-Yevick closure] 
     39    [Hard sphere structure factor, with Percus-Yevick closure] 
    4040        Interparticle S(Q) for random, non-interacting spheres. 
    41         May be a reasonable approximation for other shapes of 
    42         particles that freely rotate, and for moderately polydisperse 
    43         systems. Though strictly the maths needs to be modified -  
    44         which sasview does not do yet. 
    45         effect_radius is the hard sphere radius 
    46         volfraction is the volume fraction occupied by the spheres. 
     41    May be a reasonable approximation for other shapes of 
     42    particles that freely rotate, and for moderately polydisperse 
     43        systems. Though strictly the maths needs to be modified - 
     44    which sasview does not do yet. 
     45    effect_radius is the hard sphere radius 
     46    volfraction is the volume fraction occupied by the spheres. 
    4747""" 
    4848category = "structure-factor" 
    4949 
    50 parameters = [ 
    51 #   [ "name", "units", default, [lower, upper], "type", 
    52 #     "description" ], 
    53     [ "effect_radius", "Ang",  50.0, [0, inf], "volume", 
    54       "effective radius of hard sphere" ], 
    55     [ "volfraction", "",  0.2, [0, 0.74], "", 
    56       "volume fraction of hard spheres" ], 
    57      ] 
     50#             ["name", "units", default, [lower, upper], "type","description"], 
     51parameters = [["effect_radius", "Ang", 50.0, [0, inf], "volume", 
     52               "effective radius of hard sphere"], 
     53              ["volfraction", "", 0.2, [0, 0.74], "", 
     54               "volume fraction of hard spheres"], 
     55             ] 
    5856 
    5957# No volume normalization despite having a volume parameter 
     
    6462 
    6563Iq = """ 
    66         double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa; 
    67         double calp,cbeta,cgam,prefac,c,vstruc; 
    68         double struc; 
    69          
    70         //  compute constants 
    71         denom = pow((1.0-volfraction),4); 
    72         dnum = pow((1.0 + 2.0*volfraction),2); 
    73         alpha = dnum/denom; 
    74         beta = -6.0*volfraction*pow((1.0 + volfraction/2.0),2)/denom; 
    75         gamm = 0.50*volfraction*dnum/denom; 
    76         // 
    77         //  calculate the structure factor 
    78         //      
    79         a = 2.0*q*effect_radius; 
    80         asq = a*a; 
    81         ath = asq*a; 
    82         afor = ath*a; 
    83         SINCOS(a,rsa,rca); 
    84         //rca = cos(a); 
    85         //rsa = sin(a); 
    86         calp = alpha*(rsa/asq - rca/a); 
    87         cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath); 
    88         cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor)); 
    89         prefac = -24.0*volfraction/a; 
    90         c = prefac*(calp + cbeta + cgam); 
    91         vstruc = 1.0/(1.0-c); 
    92         struc = vstruc; 
    93          
    94         return(struc); 
     64    double denom,dnum,alpha,beta,gamm,a,asq,ath,afor,rca,rsa; 
     65    double calp,cbeta,cgam,prefac,c,vstruc; 
     66    double struc; 
     67 
     68    //  compute constants 
     69    denom = pow((1.0-volfraction),4); 
     70    dnum = pow((1.0 + 2.0*volfraction),2); 
     71    alpha = dnum/denom; 
     72    beta = -6.0*volfraction*pow((1.0 + volfraction/2.0),2)/denom; 
     73    gamm = 0.50*volfraction*dnum/denom; 
     74    // 
     75    //  calculate the structure factor 
     76    // 
     77    a = 2.0*q*effect_radius; 
     78    asq = a*a; 
     79    ath = asq*a; 
     80    afor = ath*a; 
     81    SINCOS(a,rsa,rca); 
     82    //rca = cos(a); 
     83    //rsa = sin(a); 
     84    calp = alpha*(rsa/asq - rca/a); 
     85    cbeta = beta*(2.0*rsa/asq - (asq - 2.0)*rca/ath - 2.0/ath); 
     86    cgam = gamm*(-rca/a + (4.0/a)*((3.0*asq - 6.0)*rca/afor + (asq - 6.0)*rsa/ath + 6.0/afor)); 
     87    prefac = -24.0*volfraction/a; 
     88    c = prefac*(calp + cbeta + cgam); 
     89    vstruc = 1.0/(1.0-c); 
     90    struc = vstruc; 
     91 
     92    return(struc); 
    9593   """ 
    9694 
     
    103101# VR defaults to 1.0 
    104102 
    105 demo = dict(effect_radius = 200,volfraction = 0.2,effect_radius_pd = 0.1,effect_radius_pd_n = 40) 
     103demo = dict(effect_radius=200, volfraction=0.2, effect_radius_pd=0.1, effect_radius_pd_n=40) 
    106104oldname = 'HardsphereStructure' 
    107105oldpars = dict() 
Note: See TracChangeset for help on using the changeset viewer.