[27fea3f] | 1 | /** |
---|
| 2 | * Scattering model for a hollow cylinder |
---|
| 3 | * @author:gervaise alina / UTK |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #include "hollow_cylinder.h" |
---|
| 7 | #include "libCylinder.h" |
---|
| 8 | #include <math.h> |
---|
| 9 | #include <stdio.h> |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * Function to evaluate 1D scattering function |
---|
| 14 | * @param pars: parameters of the hollow cylinder |
---|
| 15 | * @param q: q-value |
---|
| 16 | * @return: function value |
---|
| 17 | */ |
---|
| 18 | double hollow_cylinder_analytical_1D(HollowCylinderParameters *pars, double q) { |
---|
[f10063e] | 19 | double dp[7]; |
---|
[e2afadf] | 20 | |
---|
[27fea3f] | 21 | dp[0] = pars->scale; |
---|
| 22 | dp[1] = pars->core_radius; |
---|
[e2afadf] | 23 | dp[2] = pars->radius; |
---|
[27fea3f] | 24 | dp[3] = pars->length; |
---|
[f10063e] | 25 | dp[4] = pars->sldCyl; |
---|
| 26 | dp[5] = pars->sldSolv; |
---|
| 27 | dp[6] = pars->background; |
---|
[e2afadf] | 28 | |
---|
[27fea3f] | 29 | return HollowCylinder(dp, q); |
---|
| 30 | } |
---|
[e2afadf] | 31 | |
---|
[27fea3f] | 32 | /** |
---|
| 33 | * Function to evaluate 2D scattering function |
---|
| 34 | * @param pars: parameters of the Hollow cylinder |
---|
| 35 | * @param q: q-value |
---|
| 36 | * @return: function value |
---|
| 37 | */ |
---|
| 38 | double hollow_cylinder_analytical_2DXY(HollowCylinderParameters *pars, double qx, double qy) { |
---|
| 39 | double q; |
---|
| 40 | q = sqrt(qx*qx+qy*qy); |
---|
| 41 | return hollow_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q); |
---|
[e2afadf] | 42 | } |
---|
[27fea3f] | 43 | |
---|
| 44 | /** |
---|
| 45 | * Function to evaluate 2D scattering function |
---|
| 46 | * @param pars: parameters of the hollow cylinder |
---|
| 47 | * @param q: q-value |
---|
| 48 | * @param phi: angle phi |
---|
| 49 | * @return: function value |
---|
| 50 | */ |
---|
| 51 | double hollow_cylinder_analytical_2D(HollowCylinderParameters *pars, double q, double phi) { |
---|
| 52 | return hollow_cylinder_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); |
---|
[e2afadf] | 53 | } |
---|
[27fea3f] | 54 | |
---|
| 55 | /** |
---|
| 56 | * Function to evaluate 2D scattering function |
---|
| 57 | * @param pars: parameters of the hollow cylinder |
---|
| 58 | * @param q: q-value |
---|
| 59 | * @param q_x: q_x / q |
---|
| 60 | * @param q_y: q_y / q |
---|
| 61 | * @return: function value |
---|
| 62 | */ |
---|
| 63 | double hollow_cylinder_analytical_2D_scaled(HollowCylinderParameters *pars, double q, double q_x, double q_y) { |
---|
| 64 | double cyl_x, cyl_y, cyl_z; |
---|
| 65 | double q_z; |
---|
| 66 | double alpha,vol, cos_val; |
---|
| 67 | double answer; |
---|
[e2afadf] | 68 | |
---|
[27fea3f] | 69 | // Cylinder orientation |
---|
| 70 | cyl_x = sin(pars->axis_theta) * cos(pars->axis_phi); |
---|
| 71 | cyl_y = sin(pars->axis_theta) * sin(pars->axis_phi); |
---|
| 72 | cyl_z = cos(pars->axis_theta); |
---|
[e2afadf] | 73 | |
---|
[27fea3f] | 74 | // q vector |
---|
| 75 | q_z = 0; |
---|
[e2afadf] | 76 | |
---|
[27fea3f] | 77 | // Compute the angle btw vector q and the |
---|
| 78 | // axis of the cylinder |
---|
| 79 | cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; |
---|
[e2afadf] | 80 | |
---|
[27fea3f] | 81 | // The following test should always pass |
---|
| 82 | if (fabs(cos_val)>1.0) { |
---|
| 83 | printf("core_shell_cylinder_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val); |
---|
| 84 | return 0; |
---|
| 85 | } |
---|
[e2afadf] | 86 | |
---|
[27fea3f] | 87 | alpha = acos( cos_val ); |
---|
[e2afadf] | 88 | |
---|
[27fea3f] | 89 | // Call the IGOR library function to get the kernel |
---|
[e2afadf] | 90 | answer = HolCylKernel(q, pars->core_radius, pars->radius, pars->length, cos_val); |
---|
| 91 | |
---|
[f10063e] | 92 | // Multiply by contrast^2 |
---|
| 93 | answer *= (pars->sldCyl - pars->sldSolv)*(pars->sldCyl - pars->sldSolv); |
---|
| 94 | |
---|
[27fea3f] | 95 | //normalize by cylinder volume |
---|
[f10063e] | 96 | vol=acos(-1.0)*((pars->radius*pars->radius)-(pars->core_radius *pars->core_radius)) |
---|
[27fea3f] | 97 | *(pars->length); |
---|
[2339249f] | 98 | answer /= vol; |
---|
[e2afadf] | 99 | |
---|
[27fea3f] | 100 | //convert to [cm-1] |
---|
| 101 | answer *= 1.0e8; |
---|
[e2afadf] | 102 | |
---|
[27fea3f] | 103 | //Scale |
---|
| 104 | answer *= pars->scale; |
---|
[e2afadf] | 105 | |
---|
[27fea3f] | 106 | // add in the background |
---|
| 107 | answer += pars->background; |
---|
[e2afadf] | 108 | |
---|
[27fea3f] | 109 | return answer; |
---|
| 110 | } |
---|