Changeset 3e428ec in sasmodels for sasmodels/models/ellipsoid.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/ellipsoid.py

    r3c56da87 r3e428ec  
    123123description = """\ 
    124124P(q.alpha)= scale*f(q)^2 + background, where f(q)= 3*(sld 
    125                 - solvent_sld)*V*[sin(q*r(Rp,Re,alpha)) 
    126                 -q*r*cos(qr(Rp,Re,alpha))] 
    127                 /[qr(Rp,Re,alpha)]^3" 
     125        - solvent_sld)*V*[sin(q*r(Rp,Re,alpha)) 
     126        -q*r*cos(qr(Rp,Re,alpha))] 
     127        /[qr(Rp,Re,alpha)]^3" 
    128128 
    129129     r(Rp,Re,alpha)= [Re^(2)*(sin(alpha))^2 
    130                 + Rp^(2)*(cos(alpha))^2]^(1/2) 
     130        + Rp^(2)*(cos(alpha))^2]^(1/2) 
    131131 
    132                 sld: SLD of the ellipsoid 
    133                 solvent_sld: SLD of the solvent 
    134                 V: volume of the ellipsoid 
    135                 Rp: polar radius of the ellipsoid 
    136                 Re: equatorial radius of the ellipsoid 
     132        sld: SLD of the ellipsoid 
     133        solvent_sld: SLD of the solvent 
     134        V: volume of the ellipsoid 
     135        Rp: polar radius of the ellipsoid 
     136        Re: equatorial radius of the ellipsoid 
    137137""" 
    138138category = "shape:ellipsoid" 
    139139 
    140 parameters = [ 
    141 #   [ "name", "units", default, [lower, upper], "type", 
    142 #     "description" ], 
    143     [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "", 
    144       "Ellipsoid scattering length density" ], 
    145     [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "", 
    146       "Solvent scattering length density" ], 
    147     [ "rpolar", "Ang",  20, [0, inf], "volume", 
    148       "Polar radius" ], 
    149     [ "requatorial", "Ang",  400, [0, inf], "volume", 
    150       "Equatorial radius" ], 
    151     [ "theta", "degrees", 60, [-inf, inf], "orientation", 
    152       "In plane angle" ], 
    153     [ "phi", "degrees", 60, [-inf, inf], "orientation", 
    154       "Out of plane angle" ], 
    155     ] 
     140#             ["name", "units", default, [lower, upper], "type","description"], 
     141parameters = [["sld", "1e-6/Ang^2", 4, [-inf, inf], "", 
     142               "Ellipsoid scattering length density"], 
     143              ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", 
     144               "Solvent scattering length density"], 
     145              ["rpolar", "Ang", 20, [0, inf], "volume", 
     146               "Polar radius"], 
     147              ["requatorial", "Ang", 400, [0, inf], "volume", 
     148               "Equatorial radius"], 
     149              ["theta", "degrees", 60, [-inf, inf], "orientation", 
     150               "In plane angle"], 
     151              ["phi", "degrees", 60, [-inf, inf], "orientation", 
     152               "Out of plane angle"], 
     153             ] 
    156154 
    157 source = [ "lib/J1.c", "lib/gauss76.c", "ellipsoid.c"] 
     155source = ["lib/J1.c", "lib/gauss76.c", "ellipsoid.c"] 
    158156 
    159157def ER(rpolar, requatorial): 
     
    162160    ee = np.empty_like(rpolar) 
    163161    idx = rpolar > requatorial 
    164     ee[idx] = (rpolar[idx]**2 - requatorial[idx]**2)/rpolar[idx]**2 
     162    ee[idx] = (rpolar[idx] ** 2 - requatorial[idx] ** 2) / rpolar[idx] ** 2 
    165163    idx = rpolar < requatorial 
    166     ee[idx] = (requatorial[idx]**2 - rpolar[idx]**2)/requatorial[idx]**2 
     164    ee[idx] = (requatorial[idx] ** 2 - rpolar[idx] ** 2) / requatorial[idx] ** 2 
    167165    idx = rpolar == requatorial 
    168     ee[idx] = 2*rpolar[idx] 
    169     valid = (rpolar*requatorial != 0) 
    170     bd = 1.0-ee[valid] 
     166    ee[idx] = 2 * rpolar[idx] 
     167    valid = (rpolar * requatorial != 0) 
     168    bd = 1.0 - ee[valid] 
    171169    e1 = np.sqrt(ee[valid]) 
    172     b1 = 1.0 + np.arcsin(e1)/(e1*np.sqrt(bd)) 
    173     bL = (1.0+e1)/(1.0-e1) 
    174     b2 = 1.0 + bd/2/e1*np.log(bL) 
    175     delta = 0.75*b1*b2 
     170    b1 = 1.0 + np.arcsin(e1) / (e1 * np.sqrt(bd)) 
     171    bL = (1.0 + e1) / (1.0 - e1) 
     172    b2 = 1.0 + bd / 2 / e1 * np.log(bL) 
     173    delta = 0.75 * b1 * b2 
    176174 
    177175    ddd = np.zeros_like(rpolar) 
    178     ddd[valid] = 2.0*(delta+1.0)*rpolar*requatorial**2 
    179     return 0.5*ddd**(1.0/3.0) 
     176    ddd[valid] = 2.0 * (delta + 1.0) * rpolar * requatorial ** 2 
     177    return 0.5 * ddd ** (1.0 / 3.0) 
    180178 
    181179 
    182 demo = dict( 
    183         scale=1, background=0, 
    184         sld=6, solvent_sld=1, 
    185         rpolar=50, requatorial=30, 
    186         theta=30, phi=15, 
    187         rpolar_pd=.2, rpolar_pd_n=15, 
    188         requatorial_pd=.2, requatorial_pd_n=15, 
    189         theta_pd=15, theta_pd_n=45, 
    190         phi_pd=15, phi_pd_n=1, 
    191         ) 
     180demo = dict(scale=1, background=0, 
     181            sld=6, solvent_sld=1, 
     182            rpolar=50, requatorial=30, 
     183            theta=30, phi=15, 
     184            rpolar_pd=.2, rpolar_pd_n=15, 
     185            requatorial_pd=.2, requatorial_pd_n=15, 
     186            theta_pd=15, theta_pd_n=45, 
     187            phi_pd=15, phi_pd_n=1) 
    192188oldname = 'EllipsoidModel' 
    193189oldpars = dict(theta='axis_theta', phi='axis_phi', 
Note: See TracChangeset for help on using the changeset viewer.