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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions mcxtrace-comps/examples/Tests_samples/Test_SX/Test_SX.instr
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
%}

Expand Down Expand Up @@ -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;
%}
Expand Down
35 changes: 35 additions & 0 deletions mcxtrace-comps/examples/Tests_samples/Test_SX_standalone/README.md
Original file line number Diff line number Diff line change
@@ -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`.

---
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions mcxtrace-comps/samples/Single_crystal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading