Changes in / [dc02af0:efc517c] in sasmodels


Ignore:
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    rdf4dc86 r946cdc8e  
    11/build/ 
    22/dist/ 
     3/*.csv 
    34*.pyc 
    45*.cl 
  • sasmodels/kernelcl.py

    r87fce00 rda32ec3  
    3030try: 
    3131    import pyopencl as cl 
    32 except RuntimeError,exc: 
     32except ImportError,exc: 
    3333    warnings.warn(str(exc)) 
    3434    raise RuntimeError("OpenCL not available") 
     35 
     36try: 
     37    context = cl.create_some_context(interactive=False) 
     38    del context 
     39except cl.RuntimeError, exc: 
     40    warnings.warn(str(exc)) 
     41    raise RuntimeError("OpenCl not available") 
    3542 
    3643from pyopencl import mem_flags as mf 
  • sasmodels/kerneldll.py

    r87fce00 rafb2c78  
    2424    #COMPILE = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG /Tp%(source)s /link /DLL /INCREMENTAL:NO /MANIFEST /OUT:%(output)s" 
    2525    #COMPILE = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG /Tp%(source)s /openmp /link /DLL /INCREMENTAL:NO /MANIFEST /OUT:%(output)s" 
    26     COMPILE = "gcc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %(source)s -o %(output)s -lm" 
     26    #COMPILE = "gcc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %(source)s -o %(output)s -lm" 
     27    COMPILE = "gcc -shared -fPIC -std=c99 -O2 -Wall %(source)s -o %(output)s -lm" 
    2728else: 
    2829    COMPILE = "cc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %(source)s -o %(output)s -lm" 
  • sasmodels/models/fcc.c

    r3271e20 re7b3d7b  
    55    double theta, double phi, double psi); 
    66 
    7 double _BCC_Integrand(double q, double dnn, double d_factor, double theta, double phi); 
    8 double _BCCeval(double Theta, double Phi, double temp1, double temp3); 
     7double _FCC_Integrand(double q, double dnn, double d_factor, double theta, double phi); 
     8double _FCCeval(double Theta, double Phi, double temp1, double temp3); 
    99double _sphereform(double q, double radius, double sld, double solvent_sld); 
    1010 
    1111 
    12 double _BCC_Integrand(double q, double dnn, double d_factor, double theta, double phi) { 
     12double _FCC_Integrand(double q, double dnn, double d_factor, double theta, double phi) { 
    1313 
    1414        const double Da = d_factor*dnn; 
     
    1616        const double temp3 = q*dnn; 
    1717 
    18         double retVal = _BCCeval(theta,phi,temp1,temp3)/(4.0*M_PI); 
     18        double retVal = _FCCeval(theta,phi,temp1,temp3)/(4.0*M_PI); 
    1919        return(retVal); 
    2020} 
    2121 
    22 double _BCCeval(double Theta, double Phi, double temp1, double temp3) { 
     22double _FCCeval(double Theta, double Phi, double temp1, double temp3) { 
    2323 
    2424        double temp6,temp7,temp8,temp9,temp10; 
     
    2626 
    2727        temp6 = sin(Theta); 
    28         temp7 = sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)+cos(Theta); 
    29         temp8 = -1.0*sin(Theta)*cos(Phi)-sin(Theta)*sin(Phi)+cos(Theta); 
    30         temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)-cos(Theta); 
     28        temp7 = sin(Theta)*sin(Phi)+cos(Theta); 
     29        temp8 = -1.0*sin(Theta)*cos(Phi)+cos(Theta); 
     30        temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi); 
    3131        temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9))); 
    32         result = pow(1.0-(temp10*temp10),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10))); 
     32        result = pow((1.0-(temp10*temp10)),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10))); 
    3333 
    3434        return (result); 
     
    5454 
    5555        //Volume fraction calculated from lattice symmetry and sphere radius 
    56         const double s1 = dnn/sqrt(0.75); 
    57         const double latticescale = 2.0*(4.0/3.0)*M_PI*(radius*radius*radius)/(s1*s1*s1); 
     56        const double s1 = dnn*sqrt(2.0); 
     57        const double latticescale = 4.0*(4.0/3.0)*M_PI*(radius*radius*radius)/(s1*s1*s1); 
    5858 
    5959    const double va = 0.0; 
     
    7171                        //20 gauss points for the inner integral 
    7272                        double ztheta = ( Gauss150Z[j]*(vbj-vaj) + vaj + vbj )/2.0;             //the inner dummy is theta 
    73                         double yyy = Gauss150Wt[j] * _BCC_Integrand(q,dnn,d_factor,ztheta,zphi); 
     73                        double yyy = Gauss150Wt[j] * _FCC_Integrand(q,dnn,d_factor,ztheta,zphi); 
    7474                        summj += yyy; 
    7575                } 
     
    140140    // The following test should always pass 
    141141    if (fabs(cos_val_b3)>1.0) { 
    142       //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 
     142      //printf("FCC_ana_2D: Unexpected error: cos()>1\n"); 
    143143      cos_val_b3 = 1.0; 
    144144    } 
    145145    if (fabs(cos_val_b2)>1.0) { 
    146       //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 
     146      //printf("FCC_ana_2D: Unexpected error: cos()>1\n"); 
    147147      cos_val_b2 = 1.0; 
    148148    } 
    149149    if (fabs(cos_val_b1)>1.0) { 
    150       //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 
     150      //printf("FCC_ana_2D: Unexpected error: cos()>1\n"); 
    151151      cos_val_b1 = 1.0; 
    152152    } 
  • sasmodels/models/fcc.py

    r3271e20 re7b3d7b  
    1 #bcc paracrystal model 
     1#fcc paracrystal model 
    22#note model title and parameter table are automatically inserted 
    33#note - calculation requires double precision 
    4 """ 
    5 Calculates the scattering from a **body-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 
     4r""" 
     5Calculates the scattering from a **face-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 
    66are considered to be negligible, and the size of the paracrystal is infinitely large. Paracrystalline distortion is 
    77assumed to be isotropic and characterized by a Gaussian distribution. 
     
    1414The scattering intensity *I(q)* is calculated as 
    1515 
    16 .. image:: img/image167.jpg 
     16.. image:: img/image158.jpg 
    1717 
    1818where *scale* is the volume fraction of spheres, *Vp* is the volume of the primary particle, *V(lattice)* is a volume 
    1919correction for the crystal structure, *P(q)* is the form factor of the sphere (normalized), and *Z(q)* is the 
    20 paracrystalline structure factor for a body-centered cubic structure. 
     20paracrystalline structure factor for a face-centered cubic structure. 
    2121 
    22 Equation (1) of the 1990 reference is used to calculate *Z(q)*, using equations (29)-(31) from the 1987 paper for 
     22Equation (1) of the 1990 reference is used to calculate *Z(q)*, using equations (23)-(25) from the 1987 paper for 
    2323*Z1*\ , *Z2*\ , and *Z3*\ . 
    2424 
    25 The lattice correction (the occupied volume of the lattice) for a body-centered cubic structure of particles of radius 
     25The lattice correction (the occupied volume of the lattice) for a face-centered cubic structure of particles of radius 
    2626*R* and nearest neighbor separation *D* is 
    2727 
     
    3434where *g* is a fractional distortion based on the nearest neighbor distance. 
    3535 
    36 The body-centered cubic lattice is 
     36The face-centered cubic lattice is 
    3737 
    38 .. image:: img/image168.jpg 
     38.. image:: img/image161.jpg 
    3939 
    4040For a crystal, diffraction peaks appear at reduced q-values given by 
     
    4242.. image:: img/image162.jpg 
    4343 
    44 where for a body-centered cubic lattice, only reflections where (\ *h* + *k* + *l*\ ) = even are allowed and 
    45 reflections where (\ *h* + *k* + *l*\ ) = odd are forbidden. Thus the peak positions correspond to (just the first 5) 
     44where for a face-centered cubic lattice *h*\ , *k*\ , *l* all odd or all even are allowed and reflections where 
     45*h*\ , *k*\ , *l* are mixed odd/even are forbidden. Thus the peak positions correspond to (just the first 5) 
    4646 
    47 .. image:: img/image169.jpg 
     47.. image:: img/image163.jpg 
    4848 
    4949**NB: The calculation of** *Z(q)* **is a double numerical integral that must be carried out with a high density of** 
     
    5252makes a triple integral. Very, very slow. Go get lunch! 
    5353 
    54 This example dataset is produced using 200 data points, *qmin* = 0.001 |Ang^-1|, *qmax* = 0.1 |Ang^-1| and the above 
     54This example dataset is produced using 200 data points, *qmin* = 0.01 |Ang^-1|, *qmax* = 0.1 |Ang^-1| and the above 
    5555default values. 
    5656 
    57 .. image:: img/image170.jpg 
     57.. image:: img/image164.jpg 
    5858 
    5959*Figure. 1D plot in the linear scale using the default values (w/200 data point).* 
     
    6565.. image:: img/image165.gif 
    6666 
    67 .. image:: img/image171.jpg 
     67.. image:: img/image166.jpg 
    6868 
    6969*Figure. 2D plot using the default values (w/200X200 pixels).* 
     
    8080from numpy import pi, inf 
    8181 
    82 name = "BCCparacrystal" 
    83 title = "Body-centred cubic lattic with paracrystalline distortion" 
     82name = "fcc_paracrystal" 
     83title = "Face-centred cubic lattic with paracrystalline distortion" 
    8484description = """ 
    85     Calculates the scattering from a **body-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 
     85    Calculates the scattering from a **face-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 
    8686    are considered to be negligible, and the size of the paracrystal is infinitely large. Paracrystalline distortion is 
    8787    assumed to be isotropic and characterized by a Gaussian distribution. 
     
    100100    ] 
    101101 
    102 source = [ "lib/J1.c", "lib/gauss150.c", "bcc.c" ] 
     102source = [ "lib/J1.c", "lib/gauss150.c", "fcc.c" ] 
    103103 
    104104def ER(radius, length): 
     
    119119# For testing against the old sasview models, include the converted parameter 
    120120# names and the target sasview model name. 
    121 oldname='BCCrystalModel' 
     121oldname='FCCrystalModel' 
    122122oldpars=dict(sld='sldSph', 
    123123             solvent_sld='sldSolv') 
Note: See TracChangeset for help on using the changeset viewer.