Changeset 756 for sans/XOP_Dev/SANSAnalysis/XOP
- Timestamp:
- Oct 19, 2010 1:16:24 PM (12 years ago)
- Location:
- sans/XOP_Dev/SANSAnalysis/XOP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/XOP_Dev/SANSAnalysis/XOP/SANSAnalysis.c
r592 r756 328 328 return((long)CSParallelepipedX); // This function is called using the direct method. 329 329 break; 330 330 case 95: //One Yukawa 331 return((long)OneYukawaX); // This function is called using the direct method. 332 break; 333 case 96: // Two Yukawa 334 return((long)TwoYukawaX); // This function is called using the direct method. 335 break; 331 336 } 332 337 return NIL; -
sans/XOP_Dev/SANSAnalysis/XOP/SANSAnalysis.r
r592 r756 840 840 NT_FP64, /* double precision x */ 841 841 }, 842 "OneYukawaX", /* function name */ 843 F_UTIL | F_EXTERNAL, // the one and two-Yukawa are different than other fitting functions 844 NT_FP64, // they are inherently AAO, and due to memory usage, likely can't be threaded. 845 { // so they are NOT declared threadsafe 846 NT_FP64 + WAVE_TYPE, /* double precision wave (coefficient wave) */ 847 NT_FP64 + WAVE_TYPE, /* double precision wave (Q wave) */ 848 NT_FP64 + WAVE_TYPE, /* double precision wave (SQ wave - returned) */ 849 }, 850 851 "TwoYukawaX", /* function name */ 852 F_UTIL | F_EXTERNAL, // the one and two-Yukawa are different than other fitting functions 853 NT_FP64, // they are inherently AAO, and due to memory usage, likely can't be threaded. 854 { // so they are NOT declared threadsafe 855 NT_FP64 + WAVE_TYPE, /* double precision wave (coefficient wave) */ 856 NT_FP64 + WAVE_TYPE, /* double precision wave (Q wave) */ 857 NT_FP64 + WAVE_TYPE, /* double precision wave (SQ wave - returned) */ 858 }, 859 860 842 861 843 862 -
sans/XOP_Dev/SANSAnalysis/XOP/StructureFactor.c
r188 r756 10 10 #include "libSANSAnalysis.h" 11 11 #include "StructureFactor.h" 12 #include "2Y_OneYukawa.h" 13 #include "2Y_TwoYukawa.h" 12 14 13 15 … … 187 189 188 190 191 // 192 // 193 int 194 OneYukawaX(FitParamsPtr_Yuk p) 195 { 196 double *sq; //pointer to sq wave 197 double *qw; //pointer to q wave 198 double *cw; //pointer to coef wave 199 long npnts,i; //number of points in waves 200 201 202 double a, b, c, d; 203 int debug = 0,check,ok; //always keep this to zero... 204 //default parameters 205 double Z,K,phi,radius; 206 char buf[256]; 207 208 /* check that wave handles are all valid */ 209 if (p->SQHandle == NIL) { 210 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 211 return(NON_EXISTENT_WAVE); 212 } 213 if (p->QHandle == NIL) { 214 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 215 return(NON_EXISTENT_WAVE); 216 } 217 if (p->CoefHandle == NIL) { 218 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 219 return(NON_EXISTENT_WAVE); 220 } 221 222 //get the wave data 223 sq = WaveData(p->SQHandle); 224 qw = WaveData(p->QHandle); 225 cw = WaveData(p->CoefHandle); 226 npnts = WavePoints(p->QHandle); // Number of points in q wave. 227 228 phi = cw[0]; 229 radius = cw[1]; 230 K = cw[2]; 231 Z = cw[3]; 232 233 if(fabs(Z) < 0.1) Z = 0.1; // values near zero are very bad for the calculation 234 235 // sprintf(buf, "Input OK, phi,radius,K,Z = %g %g %g %g\r",phi,radius,K,Z); 236 // XOPNotice(buf); 237 238 debug = 0; 239 ok = Y_SolveEquations( Z, K, phi, &a, &b, &c, &d, debug ); 240 241 if( ok ) 242 { 243 // sprintf(buf, "Y_SolveEquations OK\r"); 244 // XOPNotice(buf); 245 246 check = Y_CheckSolution( Z, K, phi, a, b, c, d ); 247 if(debug) { 248 sprintf(buf, "solution = (%g, %g, %g, %g) check = %d\r", a, b, c, d, check ); 249 XOPNotice(buf); 250 } 251 } 252 253 // sprintf(buf, "Y_CheckSolution OK\r"); 254 // XOPNotice(buf); 255 256 // loop through and calculate the S(q), or return 1 if the solution failed 257 // if(check) { //from the converted c-code 258 259 if(ok) { //less restrictive, if a solution found, return it, even if the equations aren't quite satisfied 260 261 for (i = 0; i < npnts; i++) { 262 sq[i] = SqOneYukawa(qw[i]*radius*2.0, Z, K, phi, a, b, c, d); 263 } 264 } else { 265 for (i = 0; i < npnts; i++) { 266 sq[i] = 1; 267 } 268 } 269 270 // mark the returned wave as updated so that the graph etc. automatically updates 271 WaveHandleModified(p->SQHandle); 272 273 p->retVal = 0; 274 275 return 0; 276 } 277 278 279 int 280 TwoYukawaX(FitParamsPtr_Yuk p) 281 { 282 double *sq; //pointer to sq wave 283 double *qw; //pointer to q wave 284 double *cw; //pointer to coef wave 285 long npnts,i; //number of points in waves 286 287 288 double a, b, c1, c2, d1, d2; 289 int debug = 0,check,ok; //always keep this to zero... 290 //default parameters 291 double Z1,K1,Z2,K2,phi,radius; 292 char buf[256]; 293 294 /* check that wave handles are all valid */ 295 if (p->SQHandle == NIL) { 296 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 297 return(NON_EXISTENT_WAVE); 298 } 299 if (p->QHandle == NIL) { 300 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 301 return(NON_EXISTENT_WAVE); 302 } 303 if (p->CoefHandle == NIL) { 304 SetNaN64(&p->retVal); /* return NaN if wave is not valid */ 305 return(NON_EXISTENT_WAVE); 306 } 307 308 //get the wave data 309 sq = WaveData(p->SQHandle); 310 qw = WaveData(p->QHandle); 311 cw = WaveData(p->CoefHandle); 312 npnts = WavePoints(p->QHandle); // Number of points in q wave. 313 314 phi = cw[0]; 315 radius = cw[1]; 316 K1 = cw[2]; 317 Z1 = cw[3]; 318 K2 = cw[4]; 319 Z2 = cw[5]; 320 321 if(fabs(Z1) < 0.001) Z1 = 0.001; // values near zero are very bad for the calculation 322 if(fabs(Z2) < 0.001) Z2 = 0.001; // values near zero are very bad for the calculation 323 if(fabs(K1) < 0.001) K1 = 0.001; // values near zero are very bad for the calculation 324 if(fabs(K2) < 0.001) K2 = 0.001; // values near zero are very bad for the calculation 325 326 327 // sprintf(buf, "Input OK, phi,radius,K1,Z1,K2,Z2 = %g %g %g %g %g %g\r",phi,radius,K1,Z1,K2,Z2); 328 // XOPNotice(buf); 329 330 debug = 0; 331 332 ok = TY_SolveEquations( Z1, Z2, K1, K2, phi, &a, &b, &c1, &c2, &d1, &d2, debug ); 333 if( ok ) 334 { 335 // sprintf(buf, "TY_SolveEquations OK \r"); 336 // XOPNotice(buf); 337 338 339 check = TY_CheckSolution( Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2 ); 340 if(debug) { 341 sprintf(buf, "solution = (%g, %g, %g, %g, %g, %g) check = %d\r", a, b, c1, c2, d1, d2, check ); 342 XOPNotice(buf); 343 } 344 } 345 // sprintf(buf, "TY_CheckSolution OK \r"); 346 // XOPNotice(buf); 347 348 // loop through and calculate the S(q), or return 1 if the solution failed 349 // if(check) { //from the converted c-code 350 351 if(ok) { //less restrictive, if a solution found, return it, even if the equations aren't quite satisfied 352 353 354 for (i = 0; i < npnts; i++) { 355 sq[i] = SqTwoYukawa(qw[i]*radius*2.0, Z1, Z2, K1, K2, phi, a, b, c1, c2, d1, d2); 356 } 357 } else { 358 for (i = 0; i < npnts; i++) { 359 sq[i] = 1; 360 } 361 } 362 363 // mark the returned wave as updated so that the graph etc. automatically updates 364 WaveHandleModified(p->SQHandle); 365 366 p->retVal = 0; 367 368 return 0; 369 } 370 371 372 373 374 189 375 ///////////end of XOP 190 376 -
sans/XOP_Dev/SANSAnalysis/XOP/StructureFactor.h
r188 r756 10 10 }DiamParams, *DiamParamsPtr; 11 11 12 typedef struct FitParams_Yuk { 13 waveHndl SQHandle; // Sq returned as a wave. 14 waveHndl QHandle; //independent variable, Q 15 waveHndl CoefHandle; // Coefficient wave. 16 double retVal; 17 } FitParams_Yuk, *FitParamsPtr_Yuk; 18 19 12 20 #include "XOPStructureAlignmentReset.h" 13 21 … … 19 27 int DiamCylX(DiamParamsPtr p); 20 28 int DiamEllipX(DiamParamsPtr p); 29 30 // two-Yukawa SQ 31 int OneYukawaX(FitParamsPtr_Yuk p); 32 int TwoYukawaX(FitParamsPtr_Yuk p);
Note: See TracChangeset
for help on using the changeset viewer.