Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mcxtrace-comps/contrib/Mirror_toroid_pothole.comp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ DECLARE

INITIALIZE
%{
if (coating && strlen (coating)) {
if (coating && strlen (coating) && strcmp (coating, "NULL")) {
char** header_parsed;
t_Table* tp = &reflec_table;
/* read 1st block data from file into tp */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ COMPONENT slit1 = Slit(
AT(0,0,0.9355) RELATIVE a1

COMPONENT popin_yag1 = PSD_monitor(
xwidth=1e-3, yheight=1e-3,filename="popin_yag1")
xwidth=1e-3, yheight=1e-3)
AT(0,0, 0.3355) RELATIVE slit1


Expand Down Expand Up @@ -165,7 +165,7 @@ COMPONENT slit2 = Slit(
xwidth=dxs2, yheight=dys2)
AT(0,0,1.2) RELATIVE focus_mirror_exit1

COMPONENT popin_yag2 = COPY(popin_yag1)(yheight=1e-2,filename="popin_yag2")
COMPONENT popin_yag2 = COPY(popin_yag1)(yheight=1e-2)
AT(0,0,0.4) RELATIVE slit2

COMPONENT mono = Bragg_crystal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*******************************************************************************/

/* Change name of instrument and input parameters with default values */
DEFINE INSTRUMENT Test_Mirrors(gamma=5, int index=1, L=2, radius=1000, E0=12.5, string coating="None")
DEFINE INSTRUMENT Test_Mirrors(gamma=5, int index=1, L=2, radius=1000, E0=12.5, string coating="NULL")

INITIALIZE %{
switch (index) {
Expand All @@ -64,12 +64,10 @@ INITIALIZE %{
case 2: printf("Using Mirror_parabolic\n"); break; // OK when rotated 180 deg around z
case 3: printf("Using Mirror_curved\n"); break; // OK
case 4: printf("Using Mirror_toroid\n"); break; // OK
case 5: printf("Using Mirror_toroid_pothole\n"); break; // OK
case 6: printf("Using Multilayer_elliptic\n"); break; // not OK
case 5: printf("Using Multilayer_elliptic\n"); break; // not OK
case 6: printf("Using Mirror_toroid_pothole\n"); break; // OK
default: exit(fprintf(stderr, "Unknown Mirror index\n"));
}
/* If "None" is given it in fact means "" */
if (!strcmp(coating,"None")) sprintf(coating,"");
%}

TRACE
Expand Down Expand Up @@ -124,17 +122,17 @@ WHEN (index==4)
AT(0,0,0) RELATIVE mirror_stage
ROTATED (0, 0, 180) RELATIVE mirror_stage

COMPONENT mt6_multilayer = Multilayer_elliptic( // default in XZ
COMPONENT mt5_multilayer = Multilayer_elliptic( // default in XZ
coating=coating, theta = gamma,
s1 = L, s2 = L, length = 0.2, width = 0.05, R0 = 1,
Emin=E0-1, Emax=E0+1, Estep=0.05)
WHEN (index==6)
WHEN (index==5)
AT(0,0,0) RELATIVE mirror_stage
ROTATED (0, 0, 0) RELATIVE mirror_stage

COMPONENT mt5_toroid_pot = Mirror_toroid_pothole( // default in XZ
COMPONENT mt6_toroid_pot = Mirror_toroid_pothole( // default in XZ
radius=0.1, radius_o=radius, xwidth=5e-2, zdepth=2e-1,R0=1, coating="") /* Does not support standard coatings it seems */
WHEN (index==5)
WHEN (index==6)
AT(0,0,0) RELATIVE mirror_stage
ROTATED (0, 0, 180) RELATIVE mirror_stage

Expand Down
2 changes: 1 addition & 1 deletion mcxtrace-comps/optics/Grating_reflect.comp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SETTING PARAMETERS (d_phi=1, R0=1, rho_l=800,

SHARE
%{
#include <complex.h>
%include "mccode-complex-lib"
%include "read_table-lib"
%}

Expand Down
2 changes: 1 addition & 1 deletion mcxtrace-comps/optics/Mirror_curved.comp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ INITIALIZE
%{
int status;

if (coating && strlen (coating)) {
if (coating && strlen (coating) && strcmp (coating, "NULL")) {
status = reflec_Init (&re, COATING_UNDEFINED, coating, NULL);
} else {
/*assume a constant reflectivity*/
Expand Down
4 changes: 2 additions & 2 deletions mcxtrace-comps/optics/Mirror_elliptic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DEPENDENCY "-std=c99"
SHARE
%{
%include "perfect_crystals-lib"
#include <complex.h>
%include "mccode-complex-lib"
%include "read_table-lib"
%include "reflectivity-lib"
%}
Expand All @@ -74,7 +74,7 @@ INITIALIZE
if (radius)
x_a = y_b = z_c = radius;

if (coating && strlen (coating)) {
if (coating && strlen (coating) && strcmp (coating, "NULL")) {
status = reflec_Init (&re, COATING_UNDEFINED, coating, NULL);
} else {
/*assume a constant reflectivity*/
Expand Down
49 changes: 20 additions & 29 deletions mcxtrace-comps/optics/Multilayer_elliptic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SETTING PARAMETERS (string coating="Ref_W_B4C.txt",

SHARE
%{
#include <complex.h>
%include "mccode-complex-lib"
%include "read_table-lib"
%include "reflectivity-lib"
/*something that would be relevant for ALL elliptical mirrors*/
Expand Down Expand Up @@ -108,7 +108,6 @@ INITIALIZE
/* calculation of the elliptical parameters according to the input mirror parameters:
ellipse major axis a/2, minor axis b/2, M-magnification factor, Z0&Y0 - position of the mirror centre in the elliptical coordinate system.*/
double Theta = DEG2RAD * theta;

if (xwidth)
width = xwidth;
if (zdepth)
Expand All @@ -132,7 +131,7 @@ INITIALIZE
status = reflec_Init (&re, COATING_UNDEFINED, coating, NULL);
} else {
/*assume a constant reflectivity*/
status = reflec_Init_const (&re, R0);
status = reflec_Init (&re, CONSTANT, NULL, &(R0));
}
} else {
kinematical = 1;
Expand All @@ -144,7 +143,7 @@ INITIALIZE

TRACE
%{
double K, vink;
double k, s;
double x_el, y_el, z_el; // beginning coordinates transformed into the ellipse system
double kx_el, ky_el, kz_el; // kvector transformed into the ellipse system, hence

Expand All @@ -154,7 +153,7 @@ TRACE
double kxn, kyn, kzn; // reflected ray's kvector

/* get the photon's coordinates and kvector in the ellipse frame */
K = sqrt (kx * kx + ky * ky + kz * kz);
k = sqrt (scalar_prod (kx, ky, kz, kx, ky, kz));

CoordTransME (&x_el, &y_el, &z_el, x, y, z, Z0, Y0, xi);
CoordTransME (&kx_el, &ky_el, &kz_el, kx, ky, kz, 0, 0, xi);
Expand Down Expand Up @@ -193,39 +192,31 @@ TRACE
nz = 1.0;
}
NORM (nx, ny, nz);
vink = scalar_prod (nx, ny, nz, kx_el, ky_el, kz_el);
kxn = kx_el - 2.0 * vink * nx;
kyn = ky_el - 2.0 * vink * ny;
kzn = kz_el - 2.0 * vink * nz;
s = scalar_prod (nx, ny, nz, kx_el, ky_el, kz_el);
kxn = kx_el - 2.0 * s * nx;
kyn = ky_el - 2.0 * s * ny;
kzn = kz_el - 2.0 * s * nz;
NORM (kxn, kyn, kzn);

double kxo, kyo, kzo;
kxo = kx;
kyo = ky, kzo = kz;
CoordTransEM (&kx, &ky, &kz, kxn, kyn, kzn, 0, 0, xi);

kx = K * kx;
ky = K * ky;
kz = K * kz;
NORM (kx, ky, kz);

double QQ, EE, Ref;
QQ = sqrt ((kx - kxo) * (kx - kxo) + (ky - kyo) * (ky - kyo) + (kz - kzo) * (kz - kzo));
EE = K * K2E;
kx = k * kx;
ky = k * ky;
kz = k * kz;

if (kinematical) {
/*
* \Lambda: thickness of bilayer - following notation in Als-Nielsen/McMorrow
* \Gamma: \Gamma*\Lambda thickness of high electron density material.
* 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);
*/
Ref = reflecq (re, QQ, 0, 0, 0);
if (Ref > 1) {
/*Reflectivity can't be >1*/
Ref = 1.0;
}
} else {
/*interpolate in table*/
Ref = reflecq (re, QQ, 0, 0, 0);
double QQ;
double Ref = R0;
QQ = sqrt ((kx - kxo) * (kx - kxo) + (ky - kyo) * (ky - kyo) + (kz - kzo) * (kz - kzo));
/* Evaluate reflectivity curve */
Ref = reflecq (re, QQ, 0, k, fabs (90 - acos (s / k) * RAD2DEG));
/*Reflectivity can't be >1*/
if (Ref > 1) {
Ref = 1.0;
}

/* apply reflectivity */
Expand Down
Loading
Loading