Changeset 33e91b1 in sasmodels for sasmodels/models/parallelepiped.py


Ignore:
Timestamp:
Mar 3, 2015 2:28:50 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:
53d0e24, 3a45c2c
Parents:
6c8db9e
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/parallelepiped.py

    ra5d0d00 r33e91b1  
    99---------- 
    1010 
    11 This model provides the form factor, *P(q)*, for a rectangular parallelepiped  
    12 (below) where the form factor is normalized by the volume of the  
    13 parallelepiped. If you need to apply polydispersity, see also the  
     11This model provides the form factor, *P(q)*, for a rectangular parallelepiped 
     12(below) where the form factor is normalized by the volume of the 
     13parallelepiped. If you need to apply polydispersity, see also the 
    1414RectangularPrismModel_. 
    1515 
     
    2020    P(Q) = {\text{scale} \over V} F^2(Q) + \text{background} 
    2121 
    22 where the volume *V* = *A B C* and the averaging < > is applied over all  
     22where the volume *V* = *A B C* and the averaging < > is applied over all 
    2323orientations for 1D. 
    2424 
     
    2727*Figure. Parallelepiped with the corresponding Definition of sides. 
    2828 
    29 The edge of the solid must satisfy the condition that** *A* < *B* < *C*.  
    30 Then, assuming *a* = *A* / *B* < 1, *b* = *B* / *B* = 1, and  
     29The edge of the solid must satisfy the condition that** *A* < *B* < *C*. 
     30Then, assuming *a* = *A* / *B* < 1, *b* = *B* / *B* = 1, and 
    3131*c* = *C* / *B* > 1, the form factor is 
    3232 
    3333.. math:: 
    3434 
    35     P(q) = \frac{\textstyle{scale}}{V}\int_0^1 \phi(\mu \sqrt{1-\sigma^2},a)  
     35    P(q) = \frac{\textstyle{scale}}{V}\int_0^1 \phi(\mu \sqrt{1-\sigma^2},a) 
    3636    [S(\mu c \sigma/2)]^2 d\sigma 
    3737 
     
    4040.. math:: 
    4141 
    42     \phi(\mu,a) = \int_0^1 \{S[\frac{\mu}{2}\cos(\frac{\pi}{2}u)]  
     42    \phi(\mu,a) = \int_0^1 \{S[\frac{\mu}{2}\cos(\frac{\pi}{2}u)] 
    4343    S[\frac{\mu a}{2}\sin(\frac{\pi}{2}u)]\}^2 du 
    4444 
    4545    S(x) = \frac{\sin x}{x} 
    46      
     46 
    4747    \mu = qB 
    4848 
     
    5353    \Delta\rho = \rho_{\textstyle p} - \rho_{\textstyle solvent} 
    5454 
    55 The scattering intensity per unit volume is returned in units of |cm^-1|;  
     55The scattering intensity per unit volume is returned in units of |cm^-1|; 
    5656ie, *I(q)* = |phi| *P(q)*\ . 
    5757 
    58 NB: The 2nd virial coefficient of the parallelpiped is calculated based on  
    59 the averaged effective radius (= sqrt(*short_a* \* *short_b* / |pi|)) and  
     58NB: The 2nd virial coefficient of the parallelpiped is calculated based on 
     59the averaged effective radius (= sqrt(*short_a* \* *short_b* / |pi|)) and 
    6060length(= *long_c*) values, and used as the effective radius for 
    6161*S(Q)* when *P(Q)* \* *S(Q)* is applied. 
    6262 
    63 To provide easy access to the orientation of the parallelepiped, we define  
     63To provide easy access to the orientation of the parallelepiped, we define 
    6464three angles |theta|, |phi| and |bigpsi|. The definition of |theta| and |phi| 
    65 is the same as for the cylinder model (see also figures below).  
    66 The angle |bigpsi| is the rotational angle around the *long_c* axis against  
    67 the *q* plane. For example, |bigpsi| = 0 when the *short_b* axis is parallel  
     65is the same as for the cylinder model (see also figures below). 
     66The angle |bigpsi| is the rotational angle around the *long_c* axis against 
     67the *q* plane. For example, |bigpsi| = 0 when the *short_b* axis is parallel 
    6868to the *x*-axis of the detector. 
    6969 
     
    8383---------- 
    8484 
    85 Validation of the code was done by comparing the output of the 1D calculation  
    86 to the angular average of the output of a 2D calculation over all possible  
    87 angles. The Figure below shows the comparison where the solid dot refers to  
    88 averaged 2D while the line represents the result of the 1D calculation (for  
    89 the averaging, 76, 180, 76 points are taken for the angles of |theta|, |phi|,  
     85Validation of the code was done by comparing the output of the 1D calculation 
     86to the angular average of the output of a 2D calculation over all possible 
     87angles. The Figure below shows the comparison where the solid dot refers to 
     88averaged 2D while the line represents the result of the 1D calculation (for 
     89the averaging, 76, 180, 76 points are taken for the angles of |theta|, |phi|, 
    9090and |psi| respectively). 
    9191 
     
    9696*Figure. Comparison between 1D and averaged 2D.* 
    9797 
    98 This model reimplements the form factor calculations implemented in a c-library  
     98This model reimplements the form factor calculations implemented in a c-library 
    9999provided by the NIST Center for Neutron Research (Kline, 2006). 
    100100 
    101101""" 
    102102 
    103 from numpy import pi, inf 
     103from numpy import pi, inf, sqrt 
    104104 
    105105name = "parallelepiped" 
     
    108108     P(q)= scale/V*integral from 0 to 1 of ... 
    109109           phi(mu*sqrt(1-sigma^2),a) * S(mu*c*sigma/2)^2 * dsigma 
    110       
     110 
    111111            phi(mu,a) = integral from 0 to 1 of .. 
    112             (S((mu/2)*cos(pi*u/2))*S((mu*a/2)*sin(pi*u/2)))^2 * du 
     112        (S((mu/2)*cos(pi*u/2))*S((mu*a/2)*sin(pi*u/2)))^2 * du 
    113113            S(x) = sin(x)/x 
    114             mu = q*B 
     114        mu = q*B 
    115115""" 
    116116category = "shape:parallelpiped" 
    117117 
    118118parameters = [ 
    119 #   [ "name", "units", default, [lower, upper], "type", 
    120 #     "description" ], 
    121     [ "sld", "1e-6/Ang^2", 4, [-inf,inf], "", 
    122       "Parallelepiped scattering length density" ], 
    123     [ "solvent_sld", "1e-6/Ang^2", 1, [-inf,inf], "", 
    124       "Solvent scattering length density" ], 
    125     [ "a_side", "Ang", 35, [0, inf], "volume", 
    126       "Shorter side of the parallelepiped" ], 
    127     [ "b_side", "Ang", 75, [0, inf], "volume", 
    128       "Second side of the parallelepiped" ], 
    129     [ "c_side", "Ang", 400, [0, inf], "volume", 
    130       "Larger side of the parallelepiped" ], 
    131     [ "theta", "degrees", 60, [-inf, inf], "orientation", 
    132       "In plane angle" ], 
    133     [ "phi", "degrees", 60, [-inf, inf], "orientation", 
    134       "Out of plane angle" ], 
    135     [ "psi", "degrees", 60, [-inf, inf], "orientation", 
    136       "Rotation angle around its own c axis against q plane" ], 
     119    #   [ "name", "units", default, [lower, upper], "type", 
     120    #     "description" ], 
     121    ["sld", "1e-6/Ang^2", 4, [-inf, inf], "", 
     122     "Parallelepiped scattering length density"], 
     123    ["solvent_sld", "1e-6/Ang^2", 1, [-inf, inf], "", 
     124     "Solvent scattering length density"], 
     125    ["a_side", "Ang", 35, [0, inf], "volume", 
     126     "Shorter side of the parallelepiped"], 
     127    ["b_side", "Ang", 75, [0, inf], "volume", 
     128     "Second side of the parallelepiped"], 
     129    ["c_side", "Ang", 400, [0, inf], "volume", 
     130     "Larger side of the parallelepiped"], 
     131    ["theta", "degrees", 60, [-inf, inf], "orientation", 
     132     "In plane angle"], 
     133    ["phi", "degrees", 60, [-inf, inf], "orientation", 
     134     "Out of plane angle"], 
     135    ["psi", "degrees", 60, [-inf, inf], "orientation", 
     136     "Rotation angle around its own c axis against q plane"], 
    137137    ] 
    138138 
    139 source = [ "lib/J1.c", "lib/gauss76.c", "parallelepiped.c" ] 
     139source = ["lib/J1.c", "lib/gauss76.c", "parallelepiped.c"] 
    140140 
    141141def ER(a_side, b_side, c_side): 
     
    148148    b = 0.5 * c_side 
    149149    t1 = a * a * b 
    150     t2 = 1.0 + (b/a)*(1.0+a/b/2.0)*(1.0+pi*a/b/2.0) 
     150    t2 = 1.0 + (b / a) * (1.0 + a / b / 2.0) * (1.0 + pi * a / b / 2.0) 
    151151    ddd = 3.0 * t1 * t2 
    152152 
    153     return 0.5 * (ddd)**(1./3.) 
     153    return 0.5 * (ddd) ** (1. / 3.) 
    154154 
    155155# parameters for demo 
     
    169169# For testing against the old sasview models, include the converted parameter 
    170170# names and the target sasview model name. 
    171 oldname='ParallelepipedModel' 
    172 oldpars=dict(theta='parallel_theta', phi='parallel_phi', psi='parallel_psi', 
    173              a_side='short_a', b_side='short_b', c_side='long_c', 
    174              sld='sldPipe', solvent_sld='sldSolv') 
     171oldname = 'ParallelepipedModel' 
     172oldpars = dict(theta='parallel_theta', phi='parallel_phi', psi='parallel_psi', 
     173               a_side='short_a', b_side='short_b', c_side='long_c', 
     174               sld='sldPipe', solvent_sld='sldSolv') 
    175175 
Note: See TracChangeset for help on using the changeset viewer.