1 | /** |
---|
2 | * Scattering model for a prolate |
---|
3 | * @author: UTK |
---|
4 | */ |
---|
5 | |
---|
6 | #include "spheroid.h" |
---|
7 | #include <math.h> |
---|
8 | #include "libCylinder.h" |
---|
9 | #include <stdio.h> |
---|
10 | #include <stdlib.h> |
---|
11 | |
---|
12 | /** |
---|
13 | * Function to evaluate 1D scattering function |
---|
14 | * @param pars: parameters of the prolate |
---|
15 | * @param q: q-value |
---|
16 | * @return: function value |
---|
17 | */ |
---|
18 | double spheroid_analytical_1D(SpheroidParameters *pars, double q) { |
---|
19 | double dp[9]; |
---|
20 | |
---|
21 | // Fill paramater array |
---|
22 | dp[0] = pars->scale; |
---|
23 | dp[1] = pars->equat_core; |
---|
24 | dp[2] = pars->polar_core; |
---|
25 | dp[3] = pars->equat_shell; |
---|
26 | dp[4] = pars->polar_shell; |
---|
27 | dp[5] = pars->sld_core; |
---|
28 | dp[6] = pars->sld_shell; |
---|
29 | dp[7] = pars->sld_solvent; |
---|
30 | dp[8] = pars->background; |
---|
31 | |
---|
32 | // Call library function to evaluate model |
---|
33 | return OblateForm(dp, q); |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | * Function to evaluate 2D scattering function |
---|
38 | * @param pars: parameters of the prolate |
---|
39 | * @param q: q-value |
---|
40 | * @return: function value |
---|
41 | */ |
---|
42 | double spheroid_analytical_2DXY(SpheroidParameters *pars, double qx, double qy) { |
---|
43 | double q; |
---|
44 | q = sqrt(qx*qx+qy*qy); |
---|
45 | return spheroid_analytical_2D_scaled(pars, q, qx/q, qy/q); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | /** |
---|
50 | * Function to evaluate 2D scattering function |
---|
51 | * @param pars: parameters of the prolate |
---|
52 | * @param q: q-value |
---|
53 | * @param phi: angle phi |
---|
54 | * @return: function value |
---|
55 | */ |
---|
56 | double spheroid_analytical_2D(SpheroidParameters *pars, double q, double phi) { |
---|
57 | return spheroid_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * Function to evaluate 2D scattering function |
---|
62 | * @param pars: parameters of the prolate |
---|
63 | * @param q: q-value |
---|
64 | * @param q_x: q_x / q |
---|
65 | * @param q_y: q_y / q |
---|
66 | * @return: function value |
---|
67 | */ |
---|
68 | double spheroid_analytical_2D_scaled(SpheroidParameters *pars, double q, double q_x, double q_y) { |
---|
69 | |
---|
70 | double cyl_x, cyl_y, cyl_z; |
---|
71 | double q_z; |
---|
72 | double alpha, vol, cos_val; |
---|
73 | double answer; |
---|
74 | double Pi = 4.0*atan(1.0); |
---|
75 | double sldcs,sldss; |
---|
76 | |
---|
77 | //convert angle degree to radian |
---|
78 | double theta = pars->axis_theta * Pi/180.0; |
---|
79 | double phi = pars->axis_phi * Pi/180.0; |
---|
80 | |
---|
81 | |
---|
82 | // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. |
---|
83 | cyl_x = sin(theta) * cos(phi); |
---|
84 | cyl_y = sin(theta) * sin(phi); |
---|
85 | cyl_z = cos(theta); |
---|
86 | //del sld |
---|
87 | sldcs = pars->sld_core - pars->sld_shell; |
---|
88 | sldss = pars->sld_shell- pars->sld_solvent; |
---|
89 | |
---|
90 | // q vector |
---|
91 | q_z = 0; |
---|
92 | |
---|
93 | // Compute the angle btw vector q and the |
---|
94 | // axis of the cylinder |
---|
95 | cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; |
---|
96 | |
---|
97 | // The following test should always pass |
---|
98 | if (fabs(cos_val)>1.0) { |
---|
99 | printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n"); |
---|
100 | return 0; |
---|
101 | } |
---|
102 | |
---|
103 | // Note: cos(alpha) = 0 and 1 will get an |
---|
104 | // undefined value from CylKernel |
---|
105 | alpha = acos( cos_val ); |
---|
106 | |
---|
107 | // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params. |
---|
108 | answer = gfn4(cos_val,pars->equat_core,pars->polar_core,pars->equat_shell,pars->polar_shell,sldcs,sldss,q); |
---|
109 | //It seems that it should be normalized somehow. How??? |
---|
110 | |
---|
111 | //normalize by cylinder volume |
---|
112 | //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl |
---|
113 | vol = 4.0*Pi/3.0*pars->equat_shell*pars->equat_shell*pars->polar_shell; |
---|
114 | answer /= vol; |
---|
115 | |
---|
116 | //convert to [cm-1] |
---|
117 | answer *= 1.0e8; |
---|
118 | |
---|
119 | //Scale |
---|
120 | answer *= pars->scale; |
---|
121 | |
---|
122 | // add in the background |
---|
123 | answer += pars->background; |
---|
124 | |
---|
125 | return answer; |
---|
126 | } |
---|
127 | |
---|
128 | |
---|