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 34ffba5f9a..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 @@ -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( 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_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 0c8e1a29e9..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). @@ -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_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_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_PUMA/SOLEIL_PUMA.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PUMA/SOLEIL_PUMA.instr index 4db142ef58..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.82885e+12 +* %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. @@ -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( diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX1/SOLEIL_PX1.instr index 5e59ebed65..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). @@ -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_PX2a/SOLEIL_PX2a.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr index 00335b7a74..84104217fb 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=3.7789e+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; %} 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 f3e96f61a1..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 @@ -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 @@ -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) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SIRIUS/SOLEIL_SIRIUS.instr index 2ad3ecd670..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) @@ -62,14 +62,14 @@ 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; 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 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 a367111423..30ad1463dc 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_SWING/SOLEIL_SWING.instr @@ -31,13 +31,13 @@ * 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. * 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. @@ -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 @@ -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; %} 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 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. diff --git a/mcxtrace-comps/optics/Mirror_curved.comp b/mcxtrace-comps/optics/Mirror_curved.comp index f5e0d6c27d..f41b6d4227 100644 --- a/mcxtrace-comps/optics/Mirror_curved.comp +++ b/mcxtrace-comps/optics/Mirror_curved.comp @@ -73,58 +73,66 @@ 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); } - - /*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)) { - 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, fabs (90 - acos (s / k) * RAD2DEG)); - p *= sqrt (creal (cmul(R, conj (R)))); - phi += atan2 (cimag (R), creal (R)); + /* 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)) { + x = x0; y = y0; z = z0; t = t0; phi = phi0; + } 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.*/