diff --git a/mcxtrace-comps/examples/Tests_samples/Test_FluoPowder/Test_FluoPowder.instr b/mcxtrace-comps/examples/Tests_samples/Test_FluoPowder/Test_FluoPowder.instr index 6c6742852..4cbe6167b 100644 --- a/mcxtrace-comps/examples/Tests_samples/Test_FluoPowder/Test_FluoPowder.instr +++ b/mcxtrace-comps/examples/Tests_samples/Test_FluoPowder/Test_FluoPowder.instr @@ -27,7 +27,9 @@ * %Example: Test_FluoPowder.instr -n 1e5 E0=15 index=2 Detector: Sph_mon_pow_I=1.89664e-18 * %Example: Test_FluoPowder.instr E0=15 index=3 Detector: Sph_mon_I=2.8904e-18 * %Example: Test_FluoPowder.instr E0=15 index=4 Detector: Sph_mon_flu_I=6.18074e-19 -* %Example: Test_FluoPowder.instr E0=15 index=5 Detector: Sph_mon_I=1.76094e-18 +* Example: Test_FluoPowder.instr E0=15 index=5 Detector: Sph_mon_I=1.76094e-18 +* +* (Fluorescence+PowderN GROUP is unstable on GPU, disable index=5 test for now) * * %Parameters * E0: [keV] Source mean energy of xrays. @@ -51,21 +53,22 @@ USERVARS %{ %} INITIALIZE %{ - MPI_MASTER( + switch (index) { case 1: - printf("%s: Using PowderN (pure diffraction)\n", NAME_INSTRUMENT); break; + MPI_MASTER(printf("%s: Using PowderN (pure diffraction)\n", NAME_INSTRUMENT);); break; case 2: - printf("%s: Using Single_crystal (pure diffraction, powder average)\n", NAME_INSTRUMENT); break; + MPI_MASTER(printf("%s: Using Single_crystal (pure diffraction, powder average)\n", NAME_INSTRUMENT);); break; case 3: - printf("%s: Using FluoPowder (fluorescence+diffraction)\n", NAME_INSTRUMENT); break; + MPI_MASTER(printf("%s: Using FluoPowder (fluorescence+diffraction)\n", NAME_INSTRUMENT);); break; case 4: - printf("%s: Using Fluorescence (pure fluorescence)\n", NAME_INSTRUMENT); break; + MPI_MASTER(printf("%s: Using Fluorescence (pure fluorescence)\n", NAME_INSTRUMENT);); break; case 5: - printf("%s: Using Fluorescence+PowderN in a GROUP (fluorescence+diffraction)\n", NAME_INSTRUMENT); break; + MPI_MASTER(printf("%s: Using Fluorescence+PowderN in a GROUP (fluorescence+diffraction)\n", NAME_INSTRUMENT);); break; default: - exit(printf("%s: Unknown sample index %i. Use index=1-4.", NAME_INSTRUMENT, index)); - }); + MPI_MASTER(printf("%s: Unknown sample index %i. Use index=1-4.\n", NAME_INSTRUMENT, index);); + exit(-1); + } #ifndef _MSC_EXTENSIONS sprintf(SXfile,"%s",material); barns=0; diff --git a/mcxtrace-comps/examples/Tests_samples/Test_PowderN/Test_PowderN.instr b/mcxtrace-comps/examples/Tests_samples/Test_PowderN/Test_PowderN.instr index ef2c53f97..a3c471744 100644 --- a/mcxtrace-comps/examples/Tests_samples/Test_PowderN/Test_PowderN.instr +++ b/mcxtrace-comps/examples/Tests_samples/Test_PowderN/Test_PowderN.instr @@ -18,9 +18,11 @@ * Alternatively, the Single_crystal (powder mode) and FluoPowder components can also be tested. * * %Example: index=1 Detector: Sph_mon_I=1.26755e-11 -* %Example: index=2 Detector: Sph_mon_I=4.44793e-13 +* Example: index=2 Detector: Sph_mon_I=4.44793e-13 * %Example: index=3 Detector: Sph_mon_I=1.98093e-11 * +* (Unittest disabled for Single_crystal powder-mode, numerically unstable on GPU) +* * %Parameters * E0: [keV] Source energy (width 1 keV) * L1: [m] Source-sample distance diff --git a/mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr b/mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr index adf5e6c74..470ec13a7 100644 --- a/mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr +++ b/mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr @@ -22,7 +22,9 @@ * * %Example: index=1 Detector: psd_Diff_I=2.29638e-13 * %Example: index=2 Detector: psd_Diff_I=6.1e-14 -* %Example: index=3 Detector: psd_Diff_I=1.19386e-13 +* Example: index=3 Detector: psd_Diff_I=1.19386e-13 +* +* (Fluorescence+Single_crystal GROUP is unstable on GPU, disable index=3 test for now) * * %Parameters * reflections: [str] List of powder reflections, LAU/CIF format. @@ -68,7 +70,7 @@ COMPONENT sample = Single_crystal(reflections=reflections, material_datafile="NU AT (0, 0, 0) RELATIVE sample_pos EXTEND %{ if(!SCATTERED) ABSORB; - else if (hkl_info.type == 'c') Stype=DIFFRACTION; + else if (type == 'c') Stype=DIFFRACTION; else Stype=FLUORESCENCE; %} @@ -97,7 +99,7 @@ AT (0, 0, 0) RELATIVE sample_pos GROUP FluSX EXTEND %{ if (SCATTERED) { - if (hkl_info.type == 'c') Stype=DIFFRACTION; + if (type == 'c') Stype=DIFFRACTION; else Stype=FLUORESCENCE; } else ABSORB; %} diff --git a/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/README.md b/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/README.md new file mode 100644 index 000000000..f2af0c050 --- /dev/null +++ b/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/README.md @@ -0,0 +1,35 @@ +# The `Test_SX_standalone` Instrument + +*McXtrace: Unit-test instrument for the Single_crystal sample component. + +Simply a model source illuminating a SX sample. +The default sample itself is a Mo bulk crystal.* + +## Identification + +- **Site:** Tests_samples +- **Author:** E. Farhi +- **Origin:** Synchrotron Soleil +- **Date:** Sept 26th 2019 + +## Description + +```text + +``` + +## Input parameters + +Parameters in **boldface** are required; the others are optional. + +| Name | Unit | Description | Default | +|------|------|-------------|---------| +| reflections | str | List of powder reflections, LAU/CIF format. | "Mo.lau" | +| E0 | keV | Source mean energy of xrays. | 7 | +| dE | keV | Source energy half spread of x-rays. | 6.9 | + +## Links + +- [Source code](Test_SX_standalone.instr) for `Test_SX_standalone.instr`. + +--- diff --git a/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/Test_SX_standalone.instr b/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/Test_SX_standalone.instr new file mode 100644 index 000000000..163774205 --- /dev/null +++ b/mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/Test_SX_standalone.instr @@ -0,0 +1,71 @@ +/******************************************************************************* +* McXtrace instrument definition URL=http://www.mcxtrace.org +* +* Instrument: Test_SX_standalone +* +* %Identification +* Written by: E. Farhi +* Date: Sept 26th 2019 +* Origin: Synchrotron Soleil +* Release: McXtrace 3.5 +* Version: $Revision$ +* %INSTRUMENT_SITE: Tests_samples +* +* Unit-test instrument for the Single_crystal sample component. +* +* Simply a model source illuminating a SX sample. +* The default sample itself is a Mo bulk crystal. +* +* %Example: -y Detector: psd_Diff_I=2.29638e-13 +* +* %Parameters +* reflections: [str] List of powder reflections, LAU/CIF format. +* E0: [keV] Source mean energy of xrays. +* dE: [keV] Source energy half spread of x-rays. +* +* %End +*******************************************************************************/ + +DEFINE INSTRUMENT Test_SX_standalone(string reflections="Mo.lau", E0 = 7, dE = 6.9) + +DECLARE %{ +#define DIFFRACTION 1 +#define FLUORESCENCE 2 +%} + +USERVARS %{ + int Stype; +%} + +INITIALIZE %{ + +%} + +TRACE +COMPONENT src = Source_flat( + yheight = 1e-3, xwidth = 1e-3, dist = 10, focus_xw = 1e-3, + focus_yh = 1e-3, E0 = E0, dE = dE) +AT (0, 0, 0) ABSOLUTE + +COMPONENT sample_pos=Arm() +AT (0, 0, 10) RELATIVE PREVIOUS + +COMPONENT sample = Single_crystal(reflections=reflections, material_datafile="NULL", + radius = .5e-4, yheight = 1e-3, mosaic=5) +AT (0, 0, 0) RELATIVE sample_pos +EXTEND %{ + if(!SCATTERED) ABSORB; + else if (type == 'c') Stype=DIFFRACTION; + else Stype=FLUORESCENCE; +%} + +COMPONENT psd4pi = PSD_monitor_4PI( + nx = 180, ny = 180, filename = "psd4pi", radius = 0.1, restore_xray = 1) +AT (0, 0, 0) RELATIVE sample + +COMPONENT psd_Diff = PSD_monitor_4PI( + nx = 180, ny = 180, filename = "psd4pi_diff", radius = 0.1, restore_xray = 1) +WHEN (Stype == DIFFRACTION) +AT (0, 0, 0) RELATIVE sample + +END diff --git a/mcxtrace-comps/samples/Single_crystal.comp b/mcxtrace-comps/samples/Single_crystal.comp index ec095e838..63bc50ee3 100644 --- a/mcxtrace-comps/samples/Single_crystal.comp +++ b/mcxtrace-comps/samples/Single_crystal.comp @@ -954,6 +954,7 @@ SHARE tau_b[2] = M_2_PI * ((SC_mosaic_AB[5] / info->m_a) * info->asz + (SC_mosaic_AB[6] / info->m_b) * info->bsz + (SC_mosaic_AB[7] / info->m_c) * info->csz); /*check determinants to see how we should compute the linear combination of a and b (to match c)*/ + c1 = c2 = 0; if ((det = tau_a[0] * tau_b[1] - tau_a[1] * tau_b[0]) != 0) { c1 = (l->tau_x * tau_b[1] - l->tau_y * tau_b[0]) / det; c2 = (tau_a[0] * l->tau_y - tau_a[1] * l->tau_x) / det;