From b118ba8010f783d77bfda719db848b77309d1a3f Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 28 Jun 2026 11:05:50 +0200 Subject: [PATCH 1/2] Ensure 1e7 for any run of this instr, results not stable below --- .../examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr index d31566fda..75695a7aa 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr @@ -28,8 +28,8 @@ * This is a simplified model with an Undulator, mirrors, a double crystal * monochromator, a sample stage and a detector. * -* %Example: E0=12.65 sample="Mo.lau" SPLITs=1500 Detector: Eiger9M_I=2.8e+11 -* %Example: E0=12.65 sample="adrenaline.lau" SPLITs=4200 Detector: Eiger9M_I=1.8e+15 +* %Example: E0=12.65 sample="Mo.lau" SPLITs=1500 Detector: psd4pi_I=2e+12 +* %Example: E0=12.65 sample="adrenaline.lau" SPLITs=4200 Detector: psd4pi_I=5e+15 * * %Parameters * E0: [keV] Energy selected at the Undulator. @@ -70,7 +70,13 @@ INITIALIZE exit(fprintf(stderr, "ERROR: Monochromator can not reach this energy (arg=%g > 1)\n", arg)); calculated_angle = RAD2DEG*asin(arg); - + /* Ensure that we are running with at least 1e7 neutrons if not 'displaying' */ + if (!mcdotrace) { + if (mcget_ncount()<1e7) { + MPI_MASTER(printf("This instrument needs higher statistics to converge. Increasing your ncount=%llu to 1e7\n",mcget_ncount())); + mcset_ncount(1e7); + } + } %} TRACE From c24ecb9c62bdc68bc5be4224e39872082a3a53d5 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 28 Jun 2026 13:12:41 +0200 Subject: [PATCH 2/2] Various tricks in the hope of stabilising instr output --- .../SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr index 75695a7aa..30ed88f01 100644 --- a/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr +++ b/mcxtrace-comps/examples/SOLEIL/SOLEIL_PX2a/SOLEIL_PX2a.instr @@ -28,8 +28,8 @@ * This is a simplified model with an Undulator, mirrors, a double crystal * monochromator, a sample stage and a detector. * -* %Example: E0=12.65 sample="Mo.lau" SPLITs=1500 Detector: psd4pi_I=2e+12 -* %Example: E0=12.65 sample="adrenaline.lau" SPLITs=4200 Detector: psd4pi_I=5e+15 +* %Example: E0=12.65 sample="Mo.lau" SPLITs=1500 Detector: psd4pi_I=1.75e+12 +* %Example: E0=12.65 sample="adrenaline.lau" SPLITs=4200 Detector: psd4pi_I=4.4e+15 * * %Parameters * E0: [keV] Energy selected at the Undulator. @@ -52,7 +52,7 @@ DEFINE INSTRUMENT SOLEIL_PX2a( mirror_grazing_angle=4e-3, string sample="adrenaline.lau", rotX=0, rotY=0, rotZ=0, SPLITs=10) - +DEPENDENCY " -DMCSX_REFL_SLIST_SIZE=1024 " DECLARE %{ double calculated_angle; @@ -70,11 +70,15 @@ INITIALIZE exit(fprintf(stderr, "ERROR: Monochromator can not reach this energy (arg=%g > 1)\n", arg)); calculated_angle = RAD2DEG*asin(arg); - /* Ensure that we are running with at least 1e7 neutrons if not 'displaying' */ + /* Ensure that we are running with at least 1e7 neutrons/core if not 'displaying' */ + #ifndef USE_MPI + #define mpi_node_count 1 + #endif if (!mcdotrace) { - if (mcget_ncount()<1e7) { - MPI_MASTER(printf("This instrument needs higher statistics to converge. Increasing your ncount=%llu to 1e7\n",mcget_ncount())); - mcset_ncount(1e7); + if (mcget_ncount()<=1e7) { + MPI_MASTER(printf("This instrument needs higher statistics to converge. Increasing your ncount=%llu to ",mcget_ncount())); + mcset_ncount(mpi_node_count*1e7); + MPI_MASTER(printf("%llu\n",mcget_ncount())); } } %} @@ -215,7 +219,7 @@ COMPONENT sample_monitor = Monitor_nD( AT (0, 0, 0) RELATIVE sample_stage SPLIT SPLITs COMPONENT sample = Single_crystal(reflections=sample, material_datafile="NULL", - radius = .5e-4, yheight = 5e-3, p_transmit = 0, mosaic=0.1) + radius = .5e-4, yheight = 5e-3, p_transmit = 0, mosaic=0.1, order=1) AT (0, 0, 0) RELATIVE sample_stage ROTATED (rotX,rotY,rotZ) RELATIVE sample_stage EXTEND %{