Changeset 8698a0d in sasmodels for sasmodels/kernel_iq.cl
- Timestamp:
- Oct 17, 2017 9:53:01 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 32f87a5
- Parents:
- becded3
- git-author:
- Paul Kienzle <pkienzle@…> (10/17/17 16:23:09)
- git-committer:
- Paul Kienzle <pkienzle@…> (10/17/17 21:53:01)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/kernel_iq.cl
rd4c33d6 r8698a0d 70 70 } 71 71 72 #endif // MAGNETIC 72 //#endif // MAGNETIC 73 74 // TODO: way too hackish 75 // For the 1D kernel, CALL_IQ_[A,AC,ABC] and MAGNETIC are not defined 76 // so view_direct *IS NOT* included 77 // For the 2D kernel, CALL_IQ_[A,AC,ABC] is defined but MAGNETIC is not 78 // so view_direct *IS* included 79 // For the magnetic kernel, CALL_IQ_[A,AC,ABC] is defined, but so is MAGNETIC 80 // so view_direct *IS NOT* included 81 #else // !MAGNETIC 82 83 // ===== Implement jitter in orientation ===== 84 // To change the definition of the angles, run explore/angles.py, which 85 // uses sympy to generate the equations. 86 87 #if defined(CALL_IQ_AC) // oriented symmetric 88 static double 89 view_direct(double qx, double qy, 90 double theta, double phi, 91 ParameterTable table) 92 { 93 double sin_theta, cos_theta; 94 double sin_phi, cos_phi; 95 96 // reverse view 97 SINCOS(theta*M_PI_180, sin_theta, cos_theta); 98 SINCOS(phi*M_PI_180, sin_phi, cos_phi); 99 const double qa = qx*cos_phi*cos_theta + qy*sin_phi*cos_theta; 100 const double qb = -qx*sin_phi + qy*cos_phi; 101 const double qc = qx*sin_theta*cos_phi + qy*sin_phi*sin_theta; 102 103 // reverse jitter after view 104 SINCOS(table.theta*M_PI_180, sin_theta, cos_theta); 105 SINCOS(table.phi*M_PI_180, sin_phi, cos_phi); 106 const double dqc = qa*sin_theta - qb*sin_phi*cos_theta + qc*cos_phi*cos_theta; 107 108 // Indirect calculation of qab, from qab^2 = |q|^2 - qc^2 109 const double dqa = sqrt(-dqc*dqc + qx*qx + qy*qy); 110 111 return CALL_IQ_AC(dqa, dqc, table); 112 } 113 114 #elif defined(CALL_IQ_ABC) // oriented asymmetric 115 116 static double 117 view_direct(double qx, double qy, 118 double theta, double phi, double psi, 119 ParameterTable table) 120 { 121 double sin_theta, cos_theta; 122 double sin_phi, cos_phi; 123 double sin_psi, cos_psi; 124 125 // reverse view 126 SINCOS(theta*M_PI_180, sin_theta, cos_theta); 127 SINCOS(phi*M_PI_180, sin_phi, cos_phi); 128 SINCOS(psi*M_PI_180, sin_psi, cos_psi); 129 const double qa = qx*(sin_phi*sin_psi + cos_phi*cos_psi*cos_theta) + qy*(sin_phi*cos_psi*cos_theta - sin_psi*cos_phi); 130 const double qb = qx*(-sin_phi*cos_psi + sin_psi*cos_phi*cos_theta) + qy*(sin_phi*sin_psi*cos_theta + cos_phi*cos_psi); 131 const double qc = qx*sin_theta*cos_phi + qy*sin_phi*sin_theta; 132 133 // reverse jitter after view 134 SINCOS(table.theta*M_PI_180, sin_theta, cos_theta); 135 SINCOS(table.phi*M_PI_180, sin_phi, cos_phi); 136 SINCOS(table.psi*M_PI_180, sin_psi, cos_psi); 137 const double dqa = qa*cos_psi*cos_theta + qb*(sin_phi*sin_theta*cos_psi - sin_psi*cos_phi) + qc*(-sin_phi*sin_psi - sin_theta*cos_phi*cos_psi); 138 const double dqb = qa*sin_psi*cos_theta + qb*(sin_phi*sin_psi*sin_theta + cos_phi*cos_psi) + qc*(sin_phi*cos_psi - sin_psi*sin_theta*cos_phi); 139 const double dqc = qa*sin_theta - qb*sin_phi*cos_theta + qc*cos_phi*cos_theta; 140 141 return CALL_IQ_ABC(dqa, dqb, dqc, table); 142 } 143 #endif 144 145 #endif // !MAGNETIC 73 146 74 147 kernel … … 111 184 #endif // MAGNETIC 112 185 186 #if defined(CALL_IQ_AC) // oriented symmetric 187 const double theta = values[details->theta_par+2]; 188 const double phi = values[details->theta_par+3]; 189 #elif defined(CALL_IQ_ABC) // oriented asymmetric 190 const double theta = values[details->theta_par+2]; 191 const double phi = values[details->theta_par+3]; 192 const double psi = values[details->theta_par+4]; 193 #endif 194 113 195 // Fill in the initial variables 114 196 // values[0] is scale … … 215 297 216 298 //if (q_index == 0) {printf("step:%d of %d, pars:",step,pd_stop); for (int i=0; i < NUM_PARS; i++) printf("p%d=%g ",i, local_values.vector[i]); printf("\n"); } 299 //#if defined(CALL_IQ_AC) // oriented symmetric 300 //if (q_index == 0) {printf("step:%d of %d, pars:",step,pd_stop); printf("theta=%g dtheta=%g",theta,local_values.table.theta); printf("\n"); } 301 //#endif 217 302 218 303 #ifdef INVALID … … 267 352 } 268 353 #endif 269 scattering += CALL_IQ(q, q_index, local_values.table); 354 # if defined(CALL_IQ_A) // unoriented 355 scattering += CALL_IQ_A(sqrt(qsq), local_values.table); 356 # elif defined(CALL_IQ_AC) // oriented symmetric 357 scattering += view_direct(qx, qy, theta, phi, local_values.table); 358 # elif defined(CALL_IQ_ABC) // oriented asymmetric 359 scattering += view_direct(qx, qy, theta, phi, psi, local_values.table); 360 # endif 270 361 } 271 362 } 272 363 } 273 364 } 274 #else // !MAGNETIC 275 const double scattering = CALL_IQ(q, q_index, local_values.table); 365 #elif defined(CALL_IQ) // 1d, not MAGNETIC 366 const double scattering = CALL_IQ(q[q_index], local_values.table); 367 #else // 2d data, not magnetic 368 const double qx = q[2*q_index]; 369 const double qy = q[2*q_index+1]; 370 # if defined(CALL_IQ_A) // unoriented 371 const double scattering = CALL_IQ_A(sqrt(qx*qx+qy*qy), local_values.table); 372 # elif defined(CALL_IQ_AC) // oriented symmetric 373 const double scattering = view_direct(qx, qy, theta, phi, local_values.table); 374 # elif defined(CALL_IQ_ABC) // oriented asymmetric 375 const double scattering = view_direct(qx, qy, theta, phi, psi, local_values.table); 376 # endif 276 377 #endif // !MAGNETIC 277 378 this_result += weight0 * scattering;
Note: See TracChangeset
for help on using the changeset viewer.