1 | /* |
---|
2 | * test2D.c |
---|
3 | * Return 2D I for cylinders |
---|
4 | * |
---|
5 | * A Jackson, May 2007 |
---|
6 | */ |
---|
7 | |
---|
8 | #include "../lib/libSANSAnalysis.h" |
---|
9 | #include <math.h> |
---|
10 | #include <stdio.h> |
---|
11 | |
---|
12 | int main(){ |
---|
13 | double qx[128],qy[128],i[128][128]; |
---|
14 | // Model params: |
---|
15 | // params[0]: scale factor |
---|
16 | // params[1]: radius of the cylinder [A] |
---|
17 | // params[2]: length of the cylinder [A] |
---|
18 | // params[3]: contrast [A-2] |
---|
19 | // params[4]: background [cm-1] |
---|
20 | // params[5]: angle theta of the cylinder axis and beam [rad] |
---|
21 | // params[6]: angle phi of the cylinder axis and x-axis (horizontal) |
---|
22 | // params[7]: standard deviation of theta |
---|
23 | // params[8]: standard deviation of phi |
---|
24 | // params[9]: standard deviation of radius |
---|
25 | double params[] = {1,50,500,3e-6,0.01,0,0,0,0,0}; |
---|
26 | int ii,jj; |
---|
27 | |
---|
28 | double q,phi; |
---|
29 | |
---|
30 | for (ii = 0; ii < 128; ii++){ |
---|
31 | qx[ii] = -0.50 + (0.5)*2*ii/128; |
---|
32 | // fprintf(stderr, "Qx = %g\n", qx[ii]); |
---|
33 | for (jj = 0; jj < 128; jj++){ |
---|
34 | qy[jj] = -0.50 + (0.5)*2*jj/128; |
---|
35 | //Call the form factor calculation |
---|
36 | q = hypot(qx[ii],qy[jj]); |
---|
37 | phi = atan2(qy[jj],qx[ii]); |
---|
38 | // fprintf(stderr, "Qx = %g; Qy = %g ==> Q = %g; Phi = %g", qx[ii], qy[jj], q, phi); |
---|
39 | i[ii][jj] = dist_cylinder_2D(params,qx[ii],qy[jj]); |
---|
40 | // fprintf(stderr, " ==> I(Q) = %g\n", i[ii][jj]); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | for (jj = 0; jj < 128; jj++){ |
---|
45 | for (ii = 0; ii < 128; ii++){ |
---|
46 | printf("%g ",i[ii][jj]); |
---|
47 | } |
---|
48 | printf("\n"); |
---|
49 | } |
---|
50 | |
---|
51 | return 0; |
---|
52 | } |
---|