From f9f20b0e654b03eb03cf469b3d3e5fd8ef1ee235 Mon Sep 17 00:00:00 2001 From: antoinepado Date: Fri, 30 Oct 2026 02:21:00 +0100 Subject: [PATCH 01/12] Fix mirror curved --- mcxtrace-comps/optics/Mirror_curved.comp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mcxtrace-comps/optics/Mirror_curved.comp b/mcxtrace-comps/optics/Mirror_curved.comp index f5e0d6c27d..03631212c0 100644 --- a/mcxtrace-comps/optics/Mirror_curved.comp +++ b/mcxtrace-comps/optics/Mirror_curved.comp @@ -73,38 +73,44 @@ INITIALIZE TRACE %{ - double l0, l1, dl, alpha, n, nx, nz, s, k, knx, knz; + double l0, l1, dl, alpha, n, nx, nz, s, k, knx, knz, k_total; /* dl init - cppcheck complains about algorithm below */ dl=0; /*do we hit the mirror within range?*/ // PROP_Z0; k = sqrt (scalar_prod (kx, 0, kz, kx, 0, kz)); + k_total = sqrt (scalar_prod (kx, ky, kz, kx, ky, kz)); knx = kx / k; knz = kz / k; if (solve_2nd_order (&l0, &l1, knx* knx + knz * knz, 2 * (x * knx + z * knz - radius * knx), x* x - 2 * x * radius + z * z)) { if (l0 < 0 && l1 > 0) { - dl = l1; + if (fabs (x + knx * l1) < fabs (radius)) { + dl = l1; + } } else if (l1 < 0 && l0 > 0) { - dl = l0; + if (fabs (x + knx * l0) < fabs (radius)) { + dl = l0; + } } else if (l0 > 0 && l1 > 0) { - if (fabs (z + knz * l0) < zdepth / 2.0 && fabs (x + knx * l0) < fabs (radius)) { + if (fabs (radius * asin ((z + knz * l0) / radius)) < zdepth / 2.0 && fabs (y + (ky / k) * l0) < yheight / 2.0 && fabs (x + knx * l0) < fabs (radius)) { /*this means that the first positive match is on the mirror z-wise - this should be picked. This would work even if mirror is hit from behind*/ dl = l0; - } else { + } else if (fabs (radius * asin ((z + knz * l1) / radius)) < zdepth / 2.0 && fabs (y + (ky / k) * l1) < yheight / 2.0 && fabs (x + knx * l1) < fabs (radius)) { dl = l1; } } else { /*particle misses the mirror completely (l0<0 and l1<0)*/ RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); } - + + if(dl != 0){ /*correction for only solving in xz-plane*/ dl *= sqrt (scalar_prod (kx, ky, kz, kx, ky, kz) / scalar_prod (kx, 0, kz, kx, 0, kz)); PROP_DL (dl); alpha = asin (z / radius); - if ((zdepth < radius * alpha) || (fabs (y) > yheight / 2.0)) { + if ((zdepth / 2.0 < fabs (radius * alpha)) || (fabs (y) > yheight / 2.0)) { RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); } else { SCATTER; @@ -122,10 +128,11 @@ TRACE double Q; /*length of wavevector transfer may be compute from s and n_ above*/ Q = fabs (2 * s * sqrt (nx * nx + nz * nz)); - cdouble R = refleccq (re, Q, 0, k, fabs (90 - acos (s / k) * RAD2DEG)); + cdouble R = refleccq (re, Q, 0, k_total, fabs (90 - acos (s / k_total) * RAD2DEG)); p *= sqrt (creal (cmul(R, conj (R)))); phi += atan2 (cimag (R), creal (R)); } + } } else if (fabs (kx) < DBL_EPSILON && fabs (kz) < DBL_EPSILON && ky != 0) { /*This to catch the extreme case where k//y.*/ if (y == 0) { From 7036522a4e977b741a27631a1a07fcf606ca0ea5 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 08:55:01 +0100 Subject: [PATCH 02/12] McXtrace Mirror_curved: indent the hit block (style only) Co-Authored-By: Claude Opus 5.5 --- mcxtrace-comps/optics/Mirror_curved.comp | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/mcxtrace-comps/optics/Mirror_curved.comp b/mcxtrace-comps/optics/Mirror_curved.comp index 03631212c0..0125303bfc 100644 --- a/mcxtrace-comps/optics/Mirror_curved.comp +++ b/mcxtrace-comps/optics/Mirror_curved.comp @@ -103,35 +103,35 @@ TRACE /*particle misses the mirror completely (l0<0 and l1<0)*/ RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); } - - if(dl != 0){ - /*correction for only solving in xz-plane*/ - dl *= sqrt (scalar_prod (kx, ky, kz, kx, ky, kz) / scalar_prod (kx, 0, kz, kx, 0, kz)); - - PROP_DL (dl); - alpha = asin (z / radius); - if ((zdepth / 2.0 < fabs (radius * alpha)) || (fabs (y) > yheight / 2.0)) { - RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); - } else { - SCATTER; - /*reflection*/ - nx = radius - x; - nz = -z; - n = sqrt (nx * nx + nz * nz); - nx /= n; - nz /= n; - - s = scalar_prod (kx, 0, kz, nx, 0, nz); - kx = kx - 2 * s * nx; - kz = kz - 2 * s * nz; - - double Q; - /*length of wavevector transfer may be compute from s and n_ above*/ - Q = fabs (2 * s * sqrt (nx * nx + nz * nz)); - cdouble R = refleccq (re, Q, 0, k_total, fabs (90 - acos (s / k_total) * RAD2DEG)); - p *= sqrt (creal (cmul(R, conj (R)))); - phi += atan2 (cimag (R), creal (R)); - } + + if (dl != 0) { + /*correction for only solving in xz-plane*/ + dl *= sqrt (scalar_prod (kx, ky, kz, kx, ky, kz) / scalar_prod (kx, 0, kz, kx, 0, kz)); + + PROP_DL (dl); + alpha = asin (z / radius); + if ((zdepth / 2.0 < fabs (radius * alpha)) || (fabs (y) > yheight / 2.0)) { + RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); + } else { + SCATTER; + /*reflection*/ + nx = radius - x; + nz = -z; + n = sqrt (nx * nx + nz * nz); + nx /= n; + nz /= n; + + s = scalar_prod (kx, 0, kz, nx, 0, nz); + kx = kx - 2 * s * nx; + kz = kz - 2 * s * nz; + + double Q; + /*length of wavevector transfer may be compute from s and n_ above*/ + Q = fabs (2 * s * sqrt (nx * nx + nz * nz)); + cdouble R = refleccq (re, Q, 0, k_total, fabs (90 - acos (s / k_total) * RAD2DEG)); + p *= sqrt (creal (cmul(R, conj (R)))); + phi += atan2 (cimag (R), creal (R)); + } } } else if (fabs (kx) < DBL_EPSILON && fabs (kz) < DBL_EPSILON && ky != 0) { /*This to catch the extreme case where k//y.*/ From afa248519824916394115263c3928f1d56856ef1 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 08:59:05 +0100 Subject: [PATCH 03/12] McXtrace SOLEIL_PX1, SOLEIL_SWING: KB mirror grazing angle is in rad, ROTATED needs deg The [rad] grazing angle (4.1 / 4 mrad) was passed directly to ROTATED, which takes degrees, so the KB mirrors were tilted by ~0.07 mrad and the beam landed 0.4-0.7 m off the mirror centre. The old Mirror_curved bounds check hid this by accepting hits beyond the mirror. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr | 8 ++++---- .../examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr index 5e59ebed65..7ccec44ac7 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr @@ -213,14 +213,14 @@ COMPONENT PX1_vfm = Mirror_curved( width=0.1, radius=PX1_vfm_radius) AT (0,0,0) RELATIVE PX1_vfm_location -ROTATED (0,-PX1_mirror_grazing_angle,0) RELATIVE PX1_vfm_in_xz_plane +ROTATED (0,-PX1_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX1_vfm_in_xz_plane EXTEND %{ flag_vfm=SCATTERED; %} COMPONENT PX1_vfm_takeoff = COPY(PX1_vfm_location) AT (0,0,0) RELATIVE PX1_vfm_in_xz_plane -ROTATED (-2*PX1_mirror_grazing_angle, 0, 0) RELATIVE PX1_vfm_location +ROTATED (-2*PX1_mirror_grazing_angle*RAD2DEG, 0, 0) RELATIVE PX1_vfm_location // KB 2nd mirror: horizontal focusing, at 1.95 m from the sample COMPONENT PX1_hfm_location = COPY(PX1_vfm_location) @@ -232,14 +232,14 @@ COMPONENT PX1_hfm = Mirror_curved( width=0.1, radius=PX1_hfm_radius) AT (0,0,0) RELATIVE PX1_hfm_location -ROTATED (0,-PX1_mirror_grazing_angle,0) RELATIVE PX1_hfm_location +ROTATED (0,-PX1_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX1_hfm_location EXTEND %{ flag_hfm=SCATTERED; %} COMPONENT PX1_hfm_takeoff = COPY(PX1_vfm_location) AT (0,0,0) RELATIVE PX1_hfm_location -ROTATED (0,-2*PX1_mirror_grazing_angle,0) RELATIVE PX1_hfm_location +ROTATED (0,-2*PX1_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX1_hfm_location // Sample ---------------------------------------------------------------------- // We centre the beam after the KB. Sample position (SG) at 23.846 m. diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr index a367111423..3a8e840731 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr @@ -37,7 +37,7 @@ * SWING_E0: [keV] Nominal energy at the Wiggler. * SWING_dE: [keV] Energy half-bandwidth at the Wiggler * SWING_dcm_theta: [deg] Rotation angle of the DCM. 0=set from energy SWING_E0 -* SWING_mirror_grazing_angle: [deg] Tilt angle of the mirrors. +* SWING_mirror_grazing_angle: [rad] Tilt angle of the mirrors (4 mrad). * SWING_hfm_radius: [m] Horizontally focusing mirror radius. * SWING_vfm_radius: [m] Vertically focusing mirror radius. * SWING_sample: [str] Sample given as a PDB file, or NULL for a 100A dilute Sphere model. @@ -190,14 +190,14 @@ COMPONENT SWING_vfm = Mirror_curved( width=0.1, radius=SWING_vfm_radius) AT (0,0,0) RELATIVE SWING_vfm_location -ROTATED(0,-SWING_mirror_grazing_angle,0) RELATIVE SWING_vfm_in_xz_plane +ROTATED(0,-SWING_mirror_grazing_angle*RAD2DEG,0) RELATIVE SWING_vfm_in_xz_plane EXTEND %{ SWING_flag_vfm=SCATTERED; %} COMPONENT SWING_vfm_takeoff = COPY(SWING_vfm_location) AT (0,0,0) RELATIVE SWING_vfm_in_xz_plane -ROTATED (-2*SWING_mirror_grazing_angle, 0, 0) RELATIVE SWING_vfm_location +ROTATED (-2*SWING_mirror_grazing_angle*RAD2DEG, 0, 0) RELATIVE SWING_vfm_location // KB 2nd mirror (YZ) at 1m from sample, shift height=4.8 mm COMPONENT SWING_hfm_location = COPY(SWING_vfm_location) @@ -210,14 +210,14 @@ COMPONENT SWING_hfm = Mirror_curved( width=0.1, radius=SWING_hfm_radius) AT (0,0,0) RELATIVE SWING_hfm_location -ROTATED (0,-SWING_mirror_grazing_angle,0) RELATIVE SWING_hfm_location +ROTATED (0,-SWING_mirror_grazing_angle*RAD2DEG,0) RELATIVE SWING_hfm_location EXTEND %{ SWING_flag_hfm=SCATTERED; %} COMPONENT SWING_hfm_takeoff = COPY(SWING_vfm_location) AT (0,0,0) RELATIVE SWING_hfm_location -ROTATED (0,-2*SWING_mirror_grazing_angle,0) RELATIVE SWING_hfm_location +ROTATED (0,-2*SWING_mirror_grazing_angle*RAD2DEG,0) RELATIVE SWING_hfm_location EXTEND %{ if (!SWING_flag_hfm || !SWING_flag_vfm) ABSORB; %} From 94a3e01f6f93b7274713bfc2c29662149e9cdfdb Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:17:24 +0100 Subject: [PATCH 04/12] McXtrace Mirror_curved: undo propagation by hand on a miss, so EXTEND ABSORB wins RESTORE_XRAY makes the runtime call particle_restore() after TRACE and EXTEND, and that clears ABSORBED. An instrument's EXTEND %{ if (!SCATTERED) ABSORB; %} was therefore cancelled for every ray the mirror rejected, and those rays continued unreflected (61% of the beam after SOLEIL_SAMBA M1). Put x, y, z, t, phi back by hand instead; the ray state on a miss is unchanged, but absorption in EXTEND now holds. Results are unchanged for instruments without such an EXTEND block (Test_Mirrors, MAXIV_Bloch, SOLEIL_DISCO identical to the digit). Co-Authored-By: Claude Opus 5.5 --- mcxtrace-comps/optics/Mirror_curved.comp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mcxtrace-comps/optics/Mirror_curved.comp b/mcxtrace-comps/optics/Mirror_curved.comp index 0125303bfc..f41b6d4227 100644 --- a/mcxtrace-comps/optics/Mirror_curved.comp +++ b/mcxtrace-comps/optics/Mirror_curved.comp @@ -99,19 +99,20 @@ TRACE } else if (fabs (radius * asin ((z + knz * l1) / radius)) < zdepth / 2.0 && fabs (y + (ky / k) * l1) < yheight / 2.0 && fabs (x + knx * l1) < fabs (radius)) { dl = l1; } - } else { - /*particle misses the mirror completely (l0<0 and l1<0)*/ - RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); } + /* else: particle misses the mirror completely (l0<0 and l1<0), dl stays 0 */ if (dl != 0) { /*correction for only solving in xz-plane*/ dl *= sqrt (scalar_prod (kx, ky, kz, kx, ky, kz) / scalar_prod (kx, 0, kz, kx, 0, kz)); + /* undo the propagation by hand on a miss rather than RESTORE_XRAY: the runtime's restore + clears ABSORBED, which would cancel an ABSORB in the instrument EXTEND block */ + double x0 = x, y0 = y, z0 = z, t0 = t, phi0 = phi; PROP_DL (dl); alpha = asin (z / radius); if ((zdepth / 2.0 < fabs (radius * alpha)) || (fabs (y) > yheight / 2.0)) { - RESTORE_XRAY (INDEX_CURRENT_COMP, x, y, z, kx, ky, kz, phi, t, Ex, Ey, Ez, p); + x = x0; y = y0; z = z0; t = t0; phi = phi0; } else { SCATTER; /*reflection*/ From 679cc3d0714f6618145db1ec19b6303a91788d30 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:18:42 +0100 Subject: [PATCH 05/12] McXtrace examples: Si lattice constant is 5.4309 AA, not 5.4909 The DCM Bragg angle in Template_DCM and the SOLEIL beamlines copied from it used a = 5.4909 AA, a typo for silicon's 5.4309 AA (the value Bragg_crystal itself uses via V=160.1826 AA^3). The monochromators were set for a d-spacing 1.1% too large, i.e. detuned by ~1.4 mrad at 15 keV, outside a 0.1 keV source band. Numerical change: DCM throughput of all these instruments. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_DIFFABS/SOLEIL_DIFFABS.instr | 2 +- .../examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_LUCIA/SOLEIL_LUCIA.instr | 2 +- .../examples/SOLEIL/SOLEIL_PSICHE/SOLEIL_PSICHE.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr | 2 +- .../examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_SIXS/SOLEIL_SIXS.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr | 2 +- .../examples/Tests_optics/Template_DCM/Template_DCM.instr | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_DIFFABS/SOLEIL_DIFFABS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_DIFFABS/SOLEIL_DIFFABS.instr index 3c25784a1f..f16444bada 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_DIFFABS/SOLEIL_DIFFABS.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_DIFFABS/SOLEIL_DIFFABS.instr @@ -75,7 +75,7 @@ INITIALIZE // DCM { - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing double d = DM/sqrt(3); // <111> reflection |<111>|=3 DIFFABS_dcm_gap = 0.01; // gap between the 2 monochromator crystals diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr index 0c8e1a29e9..d00806b4a8 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr @@ -138,7 +138,7 @@ INITIALIZE %{ { // --- DCM Si(111) Bragg angle from GALAXIES_E0 - double DM = 5.4909; // Si d-spacing + double DM = 5.4309; // Si d-spacing double d111 = DM/sqrt(3); double sin_theta = 2*PI/E2K/GALAXIES_E0 / 2 / d111; if (fabs(sin_theta) >= 1) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_LUCIA/SOLEIL_LUCIA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_LUCIA/SOLEIL_LUCIA.instr index d26d305dc5..d0701b1f9f 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_LUCIA/SOLEIL_LUCIA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_LUCIA/SOLEIL_LUCIA.instr @@ -47,7 +47,7 @@ DECLARE INITIALIZE %{ { - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing double d = DM/sqrt(3); // <111> reflection |<111>|=3 LUCIA_dcm_gap = 0.02; // gap between the 2 monochromator crystals diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PSICHE/SOLEIL_PSICHE.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PSICHE/SOLEIL_PSICHE.instr index e345b9beb1..7136ee6401 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PSICHE/SOLEIL_PSICHE.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PSICHE/SOLEIL_PSICHE.instr @@ -53,7 +53,7 @@ DECLARE INITIALIZE %{ { - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing double d = DM/sqrt(3); // <111> reflection |<111>|=3 PSICHE_dcm_gap = 0.02; // gap between the 2 monochromator crystals PSICHE_dcm_scatter = PSICHE_DCM_present; diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr index f3e96f61a1..a3e8ccfe56 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr @@ -64,7 +64,7 @@ INITIALIZE %{ { // 1. Monochromator Setup (Si 111) - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing SAMBA_d_si = DM/sqrt(3); // Si(111) d-spacing SAMBA_dcm_gap = 0.01; // gap between the 2 monochromator crystals diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr index 2ad3ecd670..b1b01b9280 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr @@ -62,7 +62,7 @@ INITIALIZE %{ { // 1. Monochromator Setup (Si 111) - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing double d = DM/sqrt(3); // <111> reflection |<111>|=3 double sin_theta = 2*PI/E2K/SIRIUS_E0 / 2 / d; SIRIUS_DCM_theta = asin(sin_theta)*RAD2DEG; diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIXS/SOLEIL_SIXS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIXS/SOLEIL_SIXS.instr index b890995dd9..4b2a69f1d3 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIXS/SOLEIL_SIXS.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIXS/SOLEIL_SIXS.instr @@ -81,7 +81,7 @@ USERVARS INITIALIZE %{ { - double DM= 5.4909; // Si d-spacing for the Monochromator + double DM= 5.4309; // Si d-spacing for the Monochromator double d = DM/sqrt(3); // <111> reflection |<111>|=3 SIXS_dcm_gap = 0.02; // gap between the 2 monochromator crystals diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr index 3a8e840731..d56af5c213 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr @@ -69,7 +69,7 @@ USERVARS INITIALIZE %{ { - double DM= 5.4909; // Si d-spacing for the Monochromator + double DM= 5.4309; // Si d-spacing for the Monochromator double d = DM/sqrt(3); // <111> reflection |<111>|=3 SWING_dcm_gap = 0.02; // gap between the 2 monochromator crystals diff --git a/mcxtrace-comps/examples/Tests_optics/Template_DCM/Template_DCM.instr b/mcxtrace-comps/examples/Tests_optics/Template_DCM/Template_DCM.instr index cf2e2374bc..1f74ec73e5 100644 --- a/mcxtrace-comps/examples/Tests_optics/Template_DCM/Template_DCM.instr +++ b/mcxtrace-comps/examples/Tests_optics/Template_DCM/Template_DCM.instr @@ -35,7 +35,7 @@ DECLARE INITIALIZE %{ - double DM= 5.4909; // Si d-spacing + double DM= 5.4309; // Si d-spacing double d = DM/sqrt(3); // <111> reflection |<111>|=3 dcm_gap = 0.02; // gap between the 2 monochromator crystals From b10e66284825d739cf8f0fba5605cccb463b8614 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:19:21 +0100 Subject: [PATCH 06/12] McXtrace SOLEIL_SAMBA: fix mirror radii and takeoff directions - M1/M2 radii used the angle while still in mrad as if in degrees (R=535 m instead of 9333 m), so M1 did not collimate. - The M1/M2 takeoff arms were rotated by the grazing angle; the reflected beam leaves at twice that, so the DCM axis was 3 mrad off the beam. With the Si lattice fix, the DCM now passes the collimated beam (2.8e11 vs 2.6e10) and both mirrors are centred on the beam. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr index a3e8ccfe56..ea4b1a4b45 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr @@ -77,8 +77,8 @@ INITIALIZE // R_M * sin(theta_M) = 2 * d (where d is distance to focus) // For collimation/focusing, we use the provided approximate values or angles. // Here we allow the user to set angles, and we estimate radius. - SAMBA_M1_radius = (2.0 * 14.0) / sin(SAMBA_M1_angle * DEG2RAD); - SAMBA_M2_radius = (2.0 * 11.5) / sin(SAMBA_M2_angle * DEG2RAD); + SAMBA_M1_radius = (2.0 * 14.0) / sin(SAMBA_M1_angle / 1000); // angle still in mrad here + SAMBA_M2_radius = (2.0 * 11.5) / sin(SAMBA_M2_angle / 1000); MPI_MASTER( printf("%s: SAMBA_E0=%g [keV] SAMBA_DCM_theta=%g [deg]\n", NAME_INSTRUMENT, SAMBA_E0, SAMBA_DCM_theta); @@ -124,7 +124,7 @@ EXTEND %{ COMPONENT SAMBA_M1_out = Monitor_nD(xwidth=0.02, yheight=0.02, options="x y", restore_xray=1) AT (0, 0, 0) RELATIVE SAMBA_M1_rotated -ROTATED (-SAMBA_M1_angle, 0, 0) RELATIVE SAMBA_M1_location +ROTATED (-2*SAMBA_M1_angle, 0, 0) RELATIVE SAMBA_M1_location // reflected beam: 2x grazing angle // ----------------------------------------------------------------------------- // OPTICS 2: Sagittal Focusing DCM (MDC1 at 16m, MDC2 at 17m) @@ -199,7 +199,7 @@ EXTEND %{ COMPONENT SAMBA_M2_out = Monitor_nD(xwidth=0.02, yheight=0.02, options="x y", restore_xray=1) AT (0, 0, 0) RELATIVE SAMBA_M2_rotated -ROTATED (SAMBA_M2_angle, 0, 0) RELATIVE SAMBA_M2_loc +ROTATED (2*SAMBA_M2_angle, 0, 0) RELATIVE SAMBA_M2_loc // reflected beam: 2x grazing angle // ----------------------------------------------------------------------------- // SAMPLE STAGE (at 30 m) From 68e73515131aeb2c1b060a3178f1507894d2d6c7 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:22:55 +0100 Subject: [PATCH 07/12] McXtrace SOLEIL_SIRIUS: collimating M1, takeoff directions, horizontal deflection mirror - M1 radius was a placeholder 1000 m; use the collimating radius 2*14 m/sin(theta) like SOLEIL_SAMBA (9333 m), as the DCM comment intends. - M1 and deflection-mirror takeoff arms were rotated by the grazing angle; the reflected beam leaves at twice that. - The deflection Mirror was given yheight, which puts it in the YZ plane, while it is tilted about x as a horizontal mirror: the beam ran parallel to it and was all absorbed. Use zdepth (same 5 cm length). Note: a 5 cm mirror at 2 mrad only accepts ~0.1 mm of beam height. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr index b1b01b9280..7ef4dc20a3 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr @@ -69,7 +69,7 @@ INITIALIZE SIRIUS_dcm_gap = 0.01; // gap between the 2 monochromator crystals // 2. Mirror Radii (Approximation based on typical vertical focusing) - SIRIUS_M1_radius = 1000.0; + SIRIUS_M1_radius = (2.0 * 14.0) / sin(SIRIUS_M1_angle / 1000); // collimating M1 at 14 m, angle still in mrad here SIRIUS_M2_radius = 1000.0; SIRIUS_def_mirror_radius = 1000.0; @@ -119,7 +119,7 @@ EXTEND %{ COMPONENT SIRIUS_M1_out = Arm() AT (0, 0, 0) RELATIVE SIRIUS_M1_rot -ROTATED (-SIRIUS_M1_angle, 0, 0) RELATIVE SIRIUS_M1_loc +ROTATED (-2*SIRIUS_M1_angle, 0, 0) RELATIVE SIRIUS_M1_loc // reflected beam: 2x grazing angle // ----------------------------------------------------------------------------- // OPTICS 2: Fixed-exit Double Crystal Monochromator (DCM) @@ -187,7 +187,7 @@ AT (0, 0, 0) RELATIVE SIRIUS_def_loc ROTATED (-SIRIUS_def_angle, 0, 0) RELATIVE SIRIUS_def_loc COMPONENT SIRIUS_def_mirror = Mirror( - xwidth=0.1, yheight=0.05) + xwidth=0.1, zdepth=0.05) // horizontal mirror (XZ plane), deflecting vertically AT (0, 0, 0) RELATIVE SIRIUS_def_rot EXTEND %{ if (!SCATTERED) ABSORB; @@ -195,7 +195,7 @@ EXTEND %{ COMPONENT SIRIUS_def_out = Arm() AT (0, 0, 0) RELATIVE SIRIUS_def_rot -ROTATED (-SIRIUS_def_angle, 0, 0) RELATIVE SIRIUS_def_loc +ROTATED (-2*SIRIUS_def_angle, 0, 0) RELATIVE SIRIUS_def_loc // reflected beam: 2x grazing angle // ----------------------------------------------------------------------------- // SAMPLE STAGE From dceb4b125feba6468f43f9576709d78fd9458a92 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:28:36 +0100 Subject: [PATCH 08/12] McXtrace SOLEIL_CRISTAL: set the DCM at the refraction-corrected Bragg angle With the narrow source band, the kinematic angle only passed rays ~28 urad off axis, so the beam landed 0.5 mm low and off the 0.3 m flat mirrors. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr index 34ffba5f9a..dd985fe220 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr @@ -91,7 +91,13 @@ INITIALIZE "%s: ERROR: Si(111) can not reflect CRISTAL_E0=%g keV (valid range ~5-30 keV). Aborting.\n", NAME_INSTRUMENT, CRISTAL_E0)); - CRISTAL_DCM_theta = asin(sin_theta)*RAD2DEG; + CRISTAL_DCM_theta = asin(sin_theta); + // refraction shifts the Si(111) reflection above the kinematic Bragg angle by 2*delta/sin(2 theta); + // with the narrow source band the DCM would otherwise only pass rays ~20 urad off axis + double lambda = 12.398/CRISTAL_E0*1e-10; // [m] + double n_e = 14*8/(5.4309e-10*5.4309e-10*5.4309e-10); // Si electron density [1/m^3] + double delta = 2.8179403e-15*lambda*lambda*n_e/(2*PI); + CRISTAL_DCM_theta = (CRISTAL_DCM_theta + 2*delta/sin(2*CRISTAL_DCM_theta))*RAD2DEG; } MPI_MASTER( From d83065966eefd94689282c2b179e832706ec4ccd Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:31:48 +0100 Subject: [PATCH 09/12] McXtrace SOLEIL_PUMA: mirror radii from the grazing angle, roll the KB VFM - The angles are total deflections; the radii used sin(deflection), not sin(grazing angle), so all three mirrors were bent twice too much. - Mirror_curved deflects in its XZ plane, so the pitched KB VFM did not reflect at all. Roll it by -90 deg (concave side) to focus vertically. - Drop the hand-tuned sample offset that compensated for this. Co-Authored-By: Claude Opus 5.5 --- .../examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr index 4db142ef58..8cdf8ee35c 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr @@ -67,7 +67,7 @@ INITIALIZE { // HFM mirror double p_HFM = 21.0; - PUMA_HFM_radius = 2*p_HFM*PUMA_HFM_focal / ((p_HFM+PUMA_HFM_focal) * (sin(PUMA_HFM_angle*DEG2RAD))); + PUMA_HFM_radius = 2*p_HFM*PUMA_HFM_focal / ((p_HFM+PUMA_HFM_focal) * (sin(PUMA_HFM_angle/2*DEG2RAD))); // grazing angle is half the deflection // DCM double DM = 5.4309; @@ -94,11 +94,11 @@ INITIALIZE // KB VFM double p_KB_VFM = 62.515, q_KB_VFM = 0.785; - PUMA_KB_VFM_radius = 2*p_KB_VFM*q_KB_VFM / ((p_KB_VFM+q_KB_VFM) * (sin(PUMA_KB_angle*DEG2RAD))); + PUMA_KB_VFM_radius = 2*p_KB_VFM*q_KB_VFM / ((p_KB_VFM+q_KB_VFM) * (sin(PUMA_KB_angle/2*DEG2RAD))); // KB HFM double p_KB_HFM = 62.975, q_KB_HFM = 0.325; - PUMA_KB_HFM_radius = 2*p_KB_HFM*q_KB_HFM / ((p_KB_HFM+q_KB_HFM) * (sin(PUMA_KB_angle*DEG2RAD))); + PUMA_KB_HFM_radius = 2*p_KB_HFM*q_KB_HFM / ((p_KB_HFM+q_KB_HFM) * (sin(PUMA_KB_angle/2*DEG2RAD))); } %} @@ -284,7 +284,7 @@ COMPONENT PUMA_mirror_KB_VFM = Mirror_curved( width = 0.04, coating = PUMA_KB_coating // Rh or B4C ) AT(0, 0, 0)RELATIVE PUMA_KB_VFM_rotated -ROTATED (0, 0, 0) RELATIVE PUMA_KB_VFM_rotated +ROTATED (0, 0, -90) RELATIVE PUMA_KB_VFM_rotated // Mirror_curved deflects in its XZ plane: roll it to focus vertically EXTEND %{ if (!SCATTERED) ABSORB; %} @@ -345,7 +345,7 @@ AT (0, 0, 0) RELATIVE PREVIOUS /* -------------------------------------------------- Sample */ COMPONENT PUMA_sample_location = Arm() -AT (-7.88e-5, 0.002366 , (63.3 - 62.975)) RELATIVE PREVIOUS +AT (0, 0, (63.3 - 62.975)) RELATIVE PREVIOUS // Monitors COMPONENT PUMA_mon_sample_xy = PSD_monitor( From 9233cb82c38970a37a1efdbe16917b3af2d8acaf Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 09:37:33 +0100 Subject: [PATCH 10/12] McXtrace SOLEIL_PX2a: mirror grazing angle is in rad, fix HPM side and example - As in PX1/SWING, the [rad] grazing angle went straight into ROTATED. - With a real 4 mrad tilt the pre-focusing Mirror_toroid must be pitched the other way (it is hit from +y), and its takeoff follows the reflection. - Re-centre the sample stage on the beam after the KB. - The %Example used unknown parameters (sample=, PX2a_SPLITs=) and had no Detector: label, so it never ran. Co-Authored-By: Claude Opus 5.5 --- .../SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr index 00335b7a74..02d4eae292 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr @@ -28,13 +28,13 @@ * This is a simplified model with an Undulator, mirrors, a double crystal * monochromator, a sample stage and a detector. * -* %Example: PX2a_E0=12.65 sample="Mo.lau" PX2a_SPLITs=1500 PX2a_sample_monitor_I=1.53453e+20 +* %Example: PX2a_E0=12.65 PX2a_sample="Mo.lau" splits=1500 Detector: PX2a_sample_monitor_I=1.53453e+20 * * %Parameters * PX2a_E0: [keV] Energy selected at the Undulator. * PX2a_hfm_radius: [m] horizontally focusing mirror radius * PX2a_vfm_radius: [m] vertically focusing mirror radius -* PX2a_mirror_grazing_angle: [deg] Tilt angle of the mirrors. +* PX2a_mirror_grazing_angle: [rad] Tilt angle of the mirrors (4 mrad). * PX2a_sample:[str] Sample structure file, LAU/CIF format. * PX2a_rotX: [deg] Sample rotation around X * PX2a_rotY: [deg] Sample rotation around Y @@ -155,11 +155,11 @@ COMPONENT PX2a_hpm = Mirror_toroid( radius = 495, radius_o = 1000) AT (0,0,0) RELATIVE PX2a_hpm_in_yz_plane -ROTATED (PX2a_mirror_grazing_angle, 0, 0) RELATIVE PX2a_hpm_in_yz_plane +ROTATED (-PX2a_mirror_grazing_angle*RAD2DEG, 0, 0) RELATIVE PX2a_hpm_in_yz_plane // Mirror_toroid is hit from +y COMPONENT PX2a_hpm_takeoff = Arm() AT (0,0,0) RELATIVE PX2a_hpm_location -ROTATED (0, 2*PX2a_mirror_grazing_angle, 0) RELATIVE PX2a_hpm_location +ROTATED (0, -2*PX2a_mirror_grazing_angle*RAD2DEG, 0) RELATIVE PX2a_hpm_location // KB pair --------------------------------------------------------------------- // could use Mirror_elliptic @@ -180,14 +180,14 @@ COMPONENT PX2a_vfm = Mirror_curved( width=0.1, radius=PX2a_vfm_radius) AT (0,0,0) RELATIVE PX2a_vfm_location -ROTATED(0,-PX2a_mirror_grazing_angle,0) RELATIVE PX2a_vfm_in_xz_plane +ROTATED(0,-PX2a_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX2a_vfm_in_xz_plane EXTEND %{ PX2a_flag_vfm=SCATTERED; %} COMPONENT PX2a_vfm_takeoff = COPY(PX2a_vfm_location) AT (0,0,0) RELATIVE PX2a_vfm_in_xz_plane -ROTATED (-2*PX2a_mirror_grazing_angle, 0, 0) RELATIVE PX2a_vfm_location +ROTATED (-2*PX2a_mirror_grazing_angle*RAD2DEG, 0, 0) RELATIVE PX2a_vfm_location // KB 2nd mirror (YZ) at 1m from sample, shift height=4.8 mm COMPONENT PX2a_hfm_location = COPY(PX2a_vfm_location) @@ -200,19 +200,19 @@ COMPONENT PX2a_hfm = Mirror_curved( width=0.1, radius=PX2a_hfm_radius) AT (0,0,0) RELATIVE PX2a_hfm_location -ROTATED (0,-PX2a_mirror_grazing_angle,0) RELATIVE PX2a_hfm_location +ROTATED (0,-PX2a_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX2a_hfm_location EXTEND %{ PX2a_flag_hfm=SCATTERED; %} COMPONENT PX2a_hfm_takeoff = COPY(PX2a_vfm_location) AT (0,0,0) RELATIVE PX2a_hfm_location -ROTATED (0,-2*PX2a_mirror_grazing_angle,0) RELATIVE PX2a_hfm_location +ROTATED (0,-2*PX2a_mirror_grazing_angle*RAD2DEG,0) RELATIVE PX2a_hfm_location // Sample ---------------------------------------------------------------------- // we centre the beam after the KB. COMPONENT PX2a_sample_stage = Arm() -AT (1e-3,-1.1e-3,1) RELATIVE PX2a_hfm_takeoff +AT (0.64e-3,-0.21e-3,1) RELATIVE PX2a_hfm_takeoff EXTEND %{ if (!PX2a_flag_hfm || !PX2a_flag_vfm) ABSORB; %} From c10bab28151dcc26715598b1a8c8f6f6f6212dd4 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 10:08:32 +0100 Subject: [PATCH 11/12] McXtrace examples: update %Example targets after the Mirror_curved fix and instrument repairs Inverse-variance weighted mean of 3 x n (seeds 1001, 2002, 3003) and 1 x 10n (seed 4004, capped at 3e7), using this branch's components. Only targets that moved by more than 5% are changed. The large jumps (GALAXIES, SWING, SAMBA, SIRIUS, PX1) come from the Si lattice constant and mirror alignment fixes, which put the DCMs at Bragg and the beams on the mirrors. Co-Authored-By: Claude Opus 5.5 --- mcxtrace-comps/examples/MAXIV/MAXIV_Bloch/MAXIV_Bloch.instr | 2 +- .../examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_DISCO/SOLEIL_DISCO.instr | 2 +- .../examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr | 2 +- .../examples/SOLEIL/SOLEIL_NANOSCOPIUM/SOLEIL_NANOSCOPIUM.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_ROCK/SOLEIL_ROCK.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr | 2 +- .../examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr | 2 +- mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr | 2 +- mcxtrace-comps/examples/XFEL/XFEL_SPB/XFEL_SPB.instr | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mcxtrace-comps/examples/MAXIV/MAXIV_Bloch/MAXIV_Bloch.instr b/mcxtrace-comps/examples/MAXIV/MAXIV_Bloch/MAXIV_Bloch.instr index 7d12ddda55..81f97e3da2 100644 --- a/mcxtrace-comps/examples/MAXIV/MAXIV_Bloch/MAXIV_Bloch.instr +++ b/mcxtrace-comps/examples/MAXIV/MAXIV_Bloch/MAXIV_Bloch.instr @@ -20,7 +20,7 @@ * P2 parameters are used when the strain of the beamline is the FOI, i.e what happens when the distances change. * * %Example: E0=0.03 dE=0 undK=0 Nper=187 zm_mirror1=14 theta_mirror1=3 R0_M1=1 zm_mirror2=2 R0_M2=1 grating_mode=0 zm_mirror3=1 theta_mirror3=3 R0_M3=1 zm_ExitSlit=9 xwidth_ExSlit=0.005 yheight_ExSlit=0.005 zm_mirror4=19 theta_mirror4=3 R0_M4=1 SourceChoice=0 cff=2.25 m=3 Exitslit_yshift=2 Detector: M4Before_e_monitor_I=5.64942e-20 -* %Example: E0=0.6 Detector: M4Before_e_monitor_I=1.80435e-21 +* %Example: E0=0.6 Detector: M4Before_e_monitor_I=2.6528e-21 * * %Parameters: * E0: [keV] The central energy to sample from source model. diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr index dd985fe220..089c7756f4 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_CRISTAL/SOLEIL_CRISTAL.instr @@ -25,7 +25,7 @@ * modelled; hutch diagnostics such as xbpm, beam imagers and attenuators are * omitted for simplicity. * -* %Example: CRISTAL_E0=12 Detector: CRISTAL_detector_diffraction_I=700000.0 +* %Example: CRISTAL_E0=12 Detector: CRISTAL_detector_diffraction_I=6.2037e+05 * * %Parameters * CRISTAL_E0: [keV] Central energy of the beam diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_DISCO/SOLEIL_DISCO.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_DISCO/SOLEIL_DISCO.instr index 43a787d493..ee4758d2ba 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_DISCO/SOLEIL_DISCO.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_DISCO/SOLEIL_DISCO.instr @@ -18,7 +18,7 @@ * 5306.77,5738.39,6151.91,6565.99,6979.47,7395.13,7786.17,8199.52, * 8631.53,9051.46,9483.21,9913.98,10299.5 } * -* %Example: DISCO_grazing_angle_one=22.5 -n 1e5 Detector: DISCO_second_HFP_I=1.445e+16 +* %Example: DISCO_grazing_angle_one=22.5 -n 1e5 Detector: DISCO_second_HFP_I=1.104e+16 * * %Parameters * DISCO_grazing_angle_one: [deg] Mirrors M1/M2 rotation angle diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr index d00806b4a8..5f10581f56 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_GALAXIES/SOLEIL_GALAXIES.instr @@ -48,7 +48,7 @@ * - M2B focus: 75 x 35 um^2 FWHM (H x V), ~6e13 ph/s @ 8 keV * - KB focus: 14 x 9 um^2 FWHM (open sec. slits), 5x7 um^2 (30x30 um^2 slits) * -* %Example: GALAXIES_E0=10 Detector: GALAXIES_mon_dcm_xy_I=6.05992e+12 +* %Example: GALAXIES_E0=10 Detector: GALAXIES_mon_dcm_xy_I=1.1407e+19 * * %Parameters * GALAXIES_E0: [keV] Nominal energy (2.3 - 12). diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_NANOSCOPIUM/SOLEIL_NANOSCOPIUM.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_NANOSCOPIUM/SOLEIL_NANOSCOPIUM.instr index 80a64ba631..a60d9a5d15 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_NANOSCOPIUM/SOLEIL_NANOSCOPIUM.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_NANOSCOPIUM/SOLEIL_NANOSCOPIUM.instr @@ -33,7 +33,7 @@ * 154.961 | Mirror KB2 (elliptic) : horizontal focus * 155.140 | Nano-probe 2 * -* %Example: NANO_E0=11 Detector: NANO_e_dcm_out_I=4.09492e+10 +* %Example: NANO_E0=11 Detector: NANO_e_dcm_out_I=9.8902e+10 * * %Parameters * NANO_E0 [keV] Energy selected at the Undulator. diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr index 8cdf8ee35c..163c2ef362 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr @@ -20,7 +20,7 @@ * spectroscopy (XANES), X-ray diffraction (XRD), and * X-ray-excited optical luminescence spectroscopy (XEOL) * -* %Example: PUMA_E0=10 Detector: PUMA_mon_sample_e_I=1.82885e+12 +* %Example: PUMA_E0=10 Detector: PUMA_mon_sample_e_I=1.1836e+11 * * %Parameters * PUMA_E0: [keV] Central energy selected by the DCM. Set to 0 to derive it from PUMA_DCM_theta. diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr index 7ccec44ac7..3417125caf 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr @@ -87,7 +87,7 @@ * - Electron beam sizes are nominal SOLEIL short straight section values * (beta_x=2.19 m, beta_y=1.09 m, emittance 3.74 nm rad, 1% coupling). * -* %Example: PX1_E0=12.67 Detector: PX1_sample_monitor_I=1.232e+20 +* %Example: PX1_E0=12.67 Detector: PX1_sample_monitor_I=1.8992e+21 * * %Parameters * PX1_E0: [keV] Energy selected at the Undulator (reference energy 12.67 keV, standard range 6.5-15 keV). diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr index 02d4eae292..84104217fb 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr @@ -28,7 +28,7 @@ * This is a simplified model with an Undulator, mirrors, a double crystal * monochromator, a sample stage and a detector. * -* %Example: PX2a_E0=12.65 PX2a_sample="Mo.lau" splits=1500 Detector: PX2a_sample_monitor_I=1.53453e+20 +* %Example: PX2a_E0=12.65 PX2a_sample="Mo.lau" splits=1500 Detector: PX2a_sample_monitor_I=3.7789e+20 * * %Parameters * PX2a_E0: [keV] Energy selected at the Undulator. diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_ROCK/SOLEIL_ROCK.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_ROCK/SOLEIL_ROCK.instr index 7cd24dd0c8..8255ae1bc7 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_ROCK/SOLEIL_ROCK.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_ROCK/SOLEIL_ROCK.instr @@ -44,7 +44,7 @@ * Manganese and chrome ROCK_scan: mxrun SOLEIL_ROCK.instr ROCK_E0=5.700,6.800 ROCK_scan=1 ROCK_sample_file=MnCr ROCK_cc=2 -N100 * Pretty energy repartition monitor result: mxrun SOLEIL_ROCK.instr ROCK_E0=17.000 ROCK_cc=2 -n1e8 * -* %Example: ROCK_E0=15.918 Detector: ROCK_fluo_monitor_I=1.61e+11 +* %Example: ROCK_E0=15.918 Detector: ROCK_fluo_monitor_I=1.4117e+11 * * %Parameters * ROCK_E0: [keV] Energy to hit, i.e. selected by the channel-cut monochromator diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr index ea4b1a4b45..8ad56a1a13 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SAMBA/SOLEIL_SAMBA.instr @@ -34,7 +34,7 @@ * 30 | Sample Stage (XAS configuration) * 35 | Sample Stage (SEXAFS configuration) * -* %Example: SAMBA_E0=15 Detector: SAMBA_det_fluo_I=5.69e+10 +* %Example: SAMBA_E0=15 Detector: SAMBA_det_fluo_I=3.4637e+12 * * %Parameters * SAMBA_E0: [keV] Central energy diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr index 7ef4dc20a3..4c13149190 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr @@ -28,7 +28,7 @@ * 30 | Sample Stage (XAS configuration) * 35 | Sample Stage (SEXAFS configuration) * -* %Example: SIRIUS_E0=8 Detector: SIRIUS_def_loc_I=6.69e+09 +* %Example: SIRIUS_E0=8 Detector: SIRIUS_def_loc_I=1.3905e+12 * * %Parameters * SIRIUS_E0: [keV] Central energy (1.4 - 13 keV) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr index d56af5c213..30ad1463dc 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr @@ -31,7 +31,7 @@ * 32 | Sample location * 32.5-39 | Detector 162.5 x 155.2 mm * -* %Example: SWING_E0=13 Detector: SWING_Eiger4M_I=128310 +* %Example: SWING_E0=13 Detector: SWING_Eiger4M_I=1.5393e+12 * * %Parameters * SWING_E0: [keV] Nominal energy at the Wiggler. diff --git a/mcxtrace-comps/examples/XFEL/XFEL_SPB/XFEL_SPB.instr b/mcxtrace-comps/examples/XFEL/XFEL_SPB/XFEL_SPB.instr index ee9e41433f..d4c99e4455 100644 --- a/mcxtrace-comps/examples/XFEL/XFEL_SPB/XFEL_SPB.instr +++ b/mcxtrace-comps/examples/XFEL/XFEL_SPB/XFEL_SPB.instr @@ -17,7 +17,7 @@ * This model includes the long beam transport from the source all the way into * experimental hutch. * -* %Example: XFEL_SPB.instr preCRL=0 L0=1.3051 DL=0.01 Detector: detector_I=0.00194989 +* %Example: XFEL_SPB.instr preCRL=0 L0=1.3051 DL=0.01 Detector: detector_I=0.00099303 * * %Parameters * L0: [AA] The central wavelength to be simulated. From f64d8d76363e531479b834b5c0dcfbb44d76fcbb Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Fri, 30 Oct 2026 11:41:46 +0100 Subject: [PATCH 12/12] McXtrace SOLEIL_PUMA: raise example ncount to 1e7 and update target The KB now focuses onto the 0.5 mm sample monitor, and a few high-weight rays dominate: 1e6 runs scatter by 12% (CI got 121% of the weighted target, which the lowest seed had pulled down). At 1e7 four seeds give 1.12-1.35e11; the target is their mean. Co-Authored-By: Claude Opus 5.5 --- mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr index 163c2ef362..a3ef737979 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr @@ -20,7 +20,7 @@ * spectroscopy (XANES), X-ray diffraction (XRD), and * X-ray-excited optical luminescence spectroscopy (XEOL) * -* %Example: PUMA_E0=10 Detector: PUMA_mon_sample_e_I=1.1836e+11 +* %Example: PUMA_E0=10 -n 1e7 Detector: PUMA_mon_sample_e_I=1.2410e+11 * * %Parameters * PUMA_E0: [keV] Central energy selected by the DCM. Set to 0 to derive it from PUMA_DCM_theta.