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 | // ellipsoid orientation, the axis of the rotation is consistent with the ploar axis. |
---|
78 | cyl_x = sin(pars->axis_theta) * cos(pars->axis_phi); |
---|
79 | cyl_y = sin(pars->axis_theta) * sin(pars->axis_phi); |
---|
80 | cyl_z = cos(pars->axis_theta); |
---|
81 | //del sld |
---|
82 | sldcs = pars->sld_core - pars->sld_shell; |
---|
83 | sldss = pars->sld_shell- pars->sld_solvent; |
---|
84 | |
---|
85 | // q vector |
---|
86 | q_z = 0; |
---|
87 | |
---|
88 | // Compute the angle btw vector q and the |
---|
89 | // axis of the cylinder |
---|
90 | cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; |
---|
91 | |
---|
92 | // The following test should always pass |
---|
93 | if (fabs(cos_val)>1.0) { |
---|
94 | printf("cyl_ana_2D: Unexpected error: cos(alpha)>1\n"); |
---|
95 | return 0; |
---|
96 | } |
---|
97 | |
---|
98 | // Note: cos(alpha) = 0 and 1 will get an |
---|
99 | // undefined value from CylKernel |
---|
100 | alpha = acos( cos_val ); |
---|
101 | |
---|
102 | // Call the IGOR library function to get the kernel: MUST use gfn4 not gf2 because of the def of params. |
---|
103 | answer = gfn4(cos_val,pars->equat_core,pars->polar_core,pars->equat_shell,pars->polar_shell,sldcs,sldss,q); |
---|
104 | //It seems that it should be normalized somehow. How??? |
---|
105 | |
---|
106 | //normalize by cylinder volume |
---|
107 | //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl |
---|
108 | vol = 4.0*Pi/3.0*pars->equat_shell*pars->equat_shell*pars->polar_shell; |
---|
109 | answer /= vol; |
---|
110 | |
---|
111 | //convert to [cm-1] |
---|
112 | answer *= 1.0e8; |
---|
113 | |
---|
114 | //Scale |
---|
115 | answer *= pars->scale; |
---|
116 | |
---|
117 | // add in the background |
---|
118 | answer += pars->background; |
---|
119 | |
---|
120 | return answer; |
---|
121 | } |
---|
122 | |
---|
123 | |
---|