Changeset 11ca2ab in sasmodels for sasmodels/models/bcc_paracrystal.c
- Timestamp:
- Oct 14, 2016 3:13:55 AM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 5abbad7
- Parents:
- a80e64c
- git-author:
- Paul Kienzle <pkienzle@…> (10/14/16 01:39:19)
- git-committer:
- Paul Kienzle <pkienzle@…> (10/14/16 03:13:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/bcc_paracrystal.c
r0bef47b r11ca2ab 31 31 const double temp8 = -sin_theta*cos_phi - sin_theta*sin_phi + cos_theta; 32 32 const double temp9 = -sin_theta*cos_phi + sin_theta*sin_phi - cos_theta; 33 33 34 const double temp10 = exp((-1.0/8.0)*temp1*(temp7*temp7 + temp8*temp8 + temp9*temp9)); 34 35 result = pow(1.0-(temp10*temp10),3)*temp6 … … 81 82 82 83 return answer; 83 84 85 84 } 86 85 87 86 88 double Iqxy(double qx, double qy, double dnn, 89 double d_factor, double radius,double sld, double solvent_sld, 90 double theta, double phi, double psi){ 87 double Iqxy(double qx, double qy, 88 double dnn, double d_factor, double radius, 89 double sld, double solvent_sld, 90 double theta, double phi, double psi) 91 { 92 double q, cos_a1, cos_a2, cos_a3; 93 ORIENT_ASYMMETRIC(qx, qy, theta, phi, psi, q, cos_a3, cos_a2, cos_a1); 91 94 92 double b3_x, b3_y, b1_x, b1_y, b2_x, b2_y; //b3_z, 93 //double q_z; 94 double cos_val_b3, cos_val_b2, cos_val_b1; 95 double a1_dot_q, a2_dot_q,a3_dot_q; 96 double answer; 97 double Zq, Fkq, Fkq_2; 95 const double a1 = +cos_a3 - cos_a1 + cos_a2; 96 const double a2 = +cos_a3 + cos_a1 - cos_a2; 97 const double a3 = -cos_a3 + cos_a1 + cos_a2; 98 98 99 //convert to q and make scaled values100 double q = sqrt(qx*qx+qy*qy);101 double q_x = qx/q;102 double q_y = qy/q;99 const double qd = 0.5*q*dnn; 100 const double exp_qd = exp(0.5*square(qd*d_factor)*(a1*a1 + a2*a2 + a3*a3)); 101 const double sinh_qd = 0.5*exp_qd - 0.5/exp_qd; 102 const double cosh_qd = 0.5*exp_qd + 0.5/exp_qd; 103 103 104 //convert angle degree to radian 105 theta = theta * M_PI_180; 106 phi = phi * M_PI_180; 107 psi = psi * M_PI_180; 104 const double Zq = sinh_qd/(cosh_qd - cos(qd*a1)) 105 * sinh_qd/(cosh_qd - cos(qd*a2)) 106 * sinh_qd/(cosh_qd - cos(qd*a3)); 108 107 109 const double Da = d_factor*dnn; 110 const double s1 = dnn/sqrt(0.75); 111 112 113 //the occupied volume of the lattice 114 const double latticescale = 2.0*sphere_volume(radius/s1); 115 // q vector 116 //q_z = 0.0; // for SANS; assuming qz is negligible 117 /// Angles here are respect to detector coordinate 118 /// instead of against q coordinate(PRB 36(46), 3(6), 1754(3854)) 119 // b3 axis orientation 120 b3_x = cos(theta) * cos(phi); 121 b3_y = sin(theta); 122 //b3_z = -cos(theta) * sin(phi); 123 cos_val_b3 = b3_x*q_x + b3_y*q_y;// + b3_z*q_z; 124 125 //alpha = acos(cos_val_b3); 126 // b1 axis orientation 127 b1_x = -cos(phi)*sin(psi) * sin(theta)+sin(phi)*cos(psi); 128 b1_y = sin(psi)*cos(theta); 129 cos_val_b1 = b1_x*q_x + b1_y*q_y; 130 // b2 axis orientation 131 b2_x = -sin(theta)*cos(psi)*cos(phi)-sin(psi)*sin(phi); 132 b2_y = cos(theta)*cos(psi); 133 cos_val_b2 = b2_x*q_x + b2_y*q_y; 134 135 // The following test should always pass 136 if (fabs(cos_val_b3)>1.0) { 137 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 138 cos_val_b3 = 1.0; 139 } 140 if (fabs(cos_val_b2)>1.0) { 141 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 142 cos_val_b2 = 1.0; 143 } 144 if (fabs(cos_val_b1)>1.0) { 145 //printf("bcc_ana_2D: Unexpected error: cos()>1\n"); 146 cos_val_b1 = 1.0; 147 } 148 // Compute the angle btw vector q and the a3 axis 149 a3_dot_q = 0.5*dnn*q*(cos_val_b2+cos_val_b1-cos_val_b3); 150 151 // a1 axis 152 a1_dot_q = 0.5*dnn*q*(cos_val_b3+cos_val_b2-cos_val_b1); 153 154 // a2 axis 155 a2_dot_q = 0.5*dnn*q*(cos_val_b3+cos_val_b1-cos_val_b2); 156 157 158 // Get Fkq and Fkq_2 159 Fkq = exp(-0.5*pow(Da/dnn,2.0)*(a1_dot_q*a1_dot_q+a2_dot_q*a2_dot_q+a3_dot_q*a3_dot_q)); 160 Fkq_2 = Fkq*Fkq; 161 // Call Zq=Z1*Z2*Z3 162 Zq = (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a1_dot_q)+Fkq_2); 163 Zq *= (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a2_dot_q)+Fkq_2); 164 Zq *= (1.0-Fkq_2)/(1.0-2.0*Fkq*cos(a3_dot_q)+Fkq_2); 165 166 // Use SphereForm directly from libigor 167 answer = sphere_form(q,radius,sld,solvent_sld)*Zq*latticescale; 168 169 return answer; 170 } 108 const double Fq = sphere_form(q,radius,sld,solvent_sld)*Zq; 109 //the occupied volume of the lattice 110 const double lattice_scale = 2.0*sphere_volume(sqrt(0.75)*radius/dnn); 111 return lattice_scale * Fq; 112 }
Note: See TracChangeset
for help on using the changeset viewer.