Changes in / [9f2cc5c:946cdc8e] in sasmodels
- Location:
- sasmodels/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/fcc.c
re7b3d7b r3271e20 5 5 double theta, double phi, double psi); 6 6 7 double _ FCC_Integrand(double q, double dnn, double d_factor, double theta, double phi);8 double _ FCCeval(double Theta, double Phi, double temp1, double temp3);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); 9 9 double _sphereform(double q, double radius, double sld, double solvent_sld); 10 10 11 11 12 double _ FCC_Integrand(double q, double dnn, double d_factor, double theta, double phi) {12 double _BCC_Integrand(double q, double dnn, double d_factor, double theta, double phi) { 13 13 14 14 const double Da = d_factor*dnn; … … 16 16 const double temp3 = q*dnn; 17 17 18 double retVal = _ FCCeval(theta,phi,temp1,temp3)/(4.0*M_PI);18 double retVal = _BCCeval(theta,phi,temp1,temp3)/(4.0*M_PI); 19 19 return(retVal); 20 20 } 21 21 22 double _ FCCeval(double Theta, double Phi, double temp1, double temp3) {22 double _BCCeval(double Theta, double Phi, double temp1, double temp3) { 23 23 24 24 double temp6,temp7,temp8,temp9,temp10; … … 26 26 27 27 temp6 = sin(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) ;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); 31 31 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))); 33 33 34 34 return (result); … … 54 54 55 55 //Volume fraction calculated from lattice symmetry and sphere radius 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);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); 58 58 59 59 const double va = 0.0; … … 71 71 //20 gauss points for the inner integral 72 72 double ztheta = ( Gauss150Z[j]*(vbj-vaj) + vaj + vbj )/2.0; //the inner dummy is theta 73 double yyy = Gauss150Wt[j] * _ FCC_Integrand(q,dnn,d_factor,ztheta,zphi);73 double yyy = Gauss150Wt[j] * _BCC_Integrand(q,dnn,d_factor,ztheta,zphi); 74 74 summj += yyy; 75 75 } … … 140 140 // The following test should always pass 141 141 if (fabs(cos_val_b3)>1.0) { 142 //printf(" FCC_ana_2D: Unexpected error: cos()>1\n");142 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 143 143 cos_val_b3 = 1.0; 144 144 } 145 145 if (fabs(cos_val_b2)>1.0) { 146 //printf(" FCC_ana_2D: Unexpected error: cos()>1\n");146 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 147 147 cos_val_b2 = 1.0; 148 148 } 149 149 if (fabs(cos_val_b1)>1.0) { 150 //printf(" FCC_ana_2D: Unexpected error: cos()>1\n");150 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 151 151 cos_val_b1 = 1.0; 152 152 } -
sasmodels/models/fcc.py
re7b3d7b r3271e20 1 # fcc paracrystal model1 #bcc paracrystal model 2 2 #note model title and parameter table are automatically inserted 3 3 #note - calculation requires double precision 4 r"""5 Calculates the scattering from a ** face-centered cubic lattice** with paracrystalline distortion. Thermal vibrations4 """ 5 Calculates the scattering from a **body-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 6 6 are considered to be negligible, and the size of the paracrystal is infinitely large. Paracrystalline distortion is 7 7 assumed to be isotropic and characterized by a Gaussian distribution. … … 14 14 The scattering intensity *I(q)* is calculated as 15 15 16 .. image:: img/image1 58.jpg16 .. image:: img/image167.jpg 17 17 18 18 where *scale* is the volume fraction of spheres, *Vp* is the volume of the primary particle, *V(lattice)* is a volume 19 19 correction 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 face-centered cubic structure.20 paracrystalline structure factor for a body-centered cubic structure. 21 21 22 Equation (1) of the 1990 reference is used to calculate *Z(q)*, using equations (2 3)-(25) from the 1987 paper for22 Equation (1) of the 1990 reference is used to calculate *Z(q)*, using equations (29)-(31) from the 1987 paper for 23 23 *Z1*\ , *Z2*\ , and *Z3*\ . 24 24 25 The lattice correction (the occupied volume of the lattice) for a face-centered cubic structure of particles of radius25 The lattice correction (the occupied volume of the lattice) for a body-centered cubic structure of particles of radius 26 26 *R* and nearest neighbor separation *D* is 27 27 … … 34 34 where *g* is a fractional distortion based on the nearest neighbor distance. 35 35 36 The face-centered cubic lattice is36 The body-centered cubic lattice is 37 37 38 .. image:: img/image16 1.jpg38 .. image:: img/image168.jpg 39 39 40 40 For a crystal, diffraction peaks appear at reduced q-values given by … … 42 42 .. image:: img/image162.jpg 43 43 44 where for a face-centered cubic lattice *h*\ , *k*\ , *l* all odd or all even are allowed and reflections where45 *h*\ , *k*\ , *l* are mixed odd/evenare forbidden. Thus the peak positions correspond to (just the first 5)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) 46 46 47 .. image:: img/image16 3.jpg47 .. image:: img/image169.jpg 48 48 49 49 **NB: The calculation of** *Z(q)* **is a double numerical integral that must be carried out with a high density of** … … 52 52 makes a triple integral. Very, very slow. Go get lunch! 53 53 54 This example dataset is produced using 200 data points, *qmin* = 0.0 1 |Ang^-1|, *qmax* = 0.1 |Ang^-1| and the above54 This example dataset is produced using 200 data points, *qmin* = 0.001 |Ang^-1|, *qmax* = 0.1 |Ang^-1| and the above 55 55 default values. 56 56 57 .. image:: img/image1 64.jpg57 .. image:: img/image170.jpg 58 58 59 59 *Figure. 1D plot in the linear scale using the default values (w/200 data point).* … … 65 65 .. image:: img/image165.gif 66 66 67 .. image:: img/image1 66.jpg67 .. image:: img/image171.jpg 68 68 69 69 *Figure. 2D plot using the default values (w/200X200 pixels).* … … 80 80 from numpy import pi, inf 81 81 82 name = " fcc_paracrystal"83 title = " Face-centred cubic lattic with paracrystalline distortion"82 name = "BCCparacrystal" 83 title = "Body-centred cubic lattic with paracrystalline distortion" 84 84 description = """ 85 Calculates the scattering from a ** face-centered cubic lattice** with paracrystalline distortion. Thermal vibrations85 Calculates the scattering from a **body-centered cubic lattice** with paracrystalline distortion. Thermal vibrations 86 86 are considered to be negligible, and the size of the paracrystal is infinitely large. Paracrystalline distortion is 87 87 assumed to be isotropic and characterized by a Gaussian distribution. … … 100 100 ] 101 101 102 source = [ "lib/J1.c", "lib/gauss150.c", " fcc.c" ]102 source = [ "lib/J1.c", "lib/gauss150.c", "bcc.c" ] 103 103 104 104 def ER(radius, length): … … 119 119 # For testing against the old sasview models, include the converted parameter 120 120 # names and the target sasview model name. 121 oldname=' FCCrystalModel'121 oldname='BCCrystalModel' 122 122 oldpars=dict(sld='sldSph', 123 123 solvent_sld='sldSolv')
Note: See TracChangeset
for help on using the changeset viewer.