@@ -67,7 +67,7 @@ SETTING PARAMETERS (string coating="Ref_W_B4C.txt",
6767
6868SHARE
6969%{
70- # include < complex.h>
70+ % include "mccode- complex-lib"
7171 %include "read_table-lib"
7272 %include "reflectivity-lib"
7373 /*something that would be relevant for ALL elliptical mirrors*/
@@ -108,7 +108,6 @@ INITIALIZE
108108 /* calculation of the elliptical parameters according to the input mirror parameters:
109109 ellipse major axis a/2, minor axis b/2, M-magnification factor, Z0&Y0 - position of the mirror centre in the elliptical coordinate system.*/
110110 double Theta = DEG2RAD * theta;
111-
112111 if (xwidth)
113112 width = xwidth;
114113 if (zdepth)
@@ -132,7 +131,7 @@ INITIALIZE
132131 status = reflec_Init (&re, COATING_UNDEFINED, coating, NULL);
133132 } else {
134133 /*assume a constant reflectivity*/
135- status = reflec_Init_const (&re, R0 );
134+ status = reflec_Init (&re, CONSTANT, NULL, &(R0) );
136135 }
137136 } else {
138137 kinematical = 1;
@@ -144,7 +143,7 @@ INITIALIZE
144143
145144TRACE
146145%{
147- double K, vink ;
146+ double k, s ;
148147 double x_el, y_el, z_el; // beginning coordinates transformed into the ellipse system
149148 double kx_el, ky_el, kz_el; // kvector transformed into the ellipse system, hence
150149
@@ -154,7 +153,7 @@ TRACE
154153 double kxn, kyn, kzn; // reflected ray's kvector
155154
156155 /* get the photon's coordinates and kvector in the ellipse frame */
157- K = sqrt (kx * kx + ky * ky + kz * kz );
156+ k = sqrt (scalar_prod (kx, ky, kz, kx, ky, kz) );
158157
159158 CoordTransME (&x_el, &y_el, &z_el, x, y, z, Z0, Y0, xi);
160159 CoordTransME (&kx_el, &ky_el, &kz_el, kx, ky, kz, 0, 0, xi);
@@ -193,39 +192,31 @@ TRACE
193192 nz = 1.0;
194193 }
195194 NORM (nx, ny, nz);
196- vink = scalar_prod (nx, ny, nz, kx_el, ky_el, kz_el);
197- kxn = kx_el - 2.0 * vink * nx;
198- kyn = ky_el - 2.0 * vink * ny;
199- kzn = kz_el - 2.0 * vink * nz;
195+ s = scalar_prod (nx, ny, nz, kx_el, ky_el, kz_el);
196+ kxn = kx_el - 2.0 * s * nx;
197+ kyn = ky_el - 2.0 * s * ny;
198+ kzn = kz_el - 2.0 * s * nz;
200199 NORM (kxn, kyn, kzn);
201200
202201 double kxo, kyo, kzo;
203202 kxo = kx;
204203 kyo = ky, kzo = kz;
205204 CoordTransEM (&kx, &ky, &kz, kxn, kyn, kzn, 0, 0, xi);
206205
207- kx = K * kx;
208- ky = K * ky;
209- kz = K * kz;
206+ NORM (kx, ky, kz);
210207
211- double QQ, EE, Ref ;
212- QQ = sqrt ((kx - kxo) * (kx - kxo) + (ky - kyo) * (ky - kyo) + (kz - kzo) * (kz - kzo)) ;
213- EE = K * K2E ;
208+ kx = k * kx ;
209+ ky = k * ky ;
210+ kz = k * kz ;
214211
215- if (kinematical) {
216- /*
217- * \Lambda: thickness of bilayer - following notation in Als-Nielsen/McMorrow
218- * \Gamma: \Gamma*\Lambda thickness of high electron density material.
219- * r1(zeta) = 2 i r_0 \rho_{AB} \left(\frac{\Lambda^2 \Gamma}{\zeta}\right) \frac{\sin\left(\pi\Gamma\zeta\right)}{\pi\Gamma\zeta);
220- */
221- Ref = reflecq (re, QQ, 0, 0, 0);
222- if (Ref > 1) {
223- /*Reflectivity can't be >1*/
224- Ref = 1.0;
225- }
226- } else {
227- /*interpolate in table*/
228- Ref = reflecq (re, QQ, 0, 0, 0);
212+ double QQ;
213+ double Ref = R0;
214+ QQ = sqrt ((kx - kxo) * (kx - kxo) + (ky - kyo) * (ky - kyo) + (kz - kzo) * (kz - kzo));
215+ /* Evaluate reflectivity curve */
216+ Ref = reflecq (re, QQ, 0, k, fabs (90 - acos (s / k) * RAD2DEG));
217+ /*Reflectivity can't be >1*/
218+ if (Ref > 1) {
219+ Ref = 1.0;
229220 }
230221
231222 /* apply reflectivity */
0 commit comments