Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of Single_crystal reuse optimization #1726

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -21,9 +21,15 @@
* %Example: SAMPLE=2 SPLITS=1 Detector: PSD_I=1
* %Example: SAMPLE=2 SPLITS=10 Detector: PSD_I=10
* %Example: SAMPLE=2 SPLITS=100 Detector: PSD_I=100
* %Example: SAMPLE=3 SPLITS=1 Detector: PSD_I=1
* %Example: SAMPLE=3 SPLITS=10 Detector: PSD_I=10
* %Example: SAMPLE=3 SPLITS=100 Detector: PSD_I=100
* %Example: SAMPLE=3 SPLITS=1 Detector: PSD_I=0.999001
* %Example: SAMPLE=3 SPLITS=1 Detector: PSD_transmission_I=0.00071068
* %Example: SAMPLE=3 SPLITS=1 Detector: PSD_scattered_I=0.00182805
* %Example: SAMPLE=3 SPLITS=10 Detector: PSD_I=9.99001
* %Example: SAMPLE=3 SPLITS=10 Detector: PSD_transmission_I=0.007122
* %Example: SAMPLE=3 SPLITS=10 Detector: PSD_scattered_I=0.0183156
* %Example: SAMPLE=3 SPLITS=100 Detector: PSD_I=99.9001
* %Example: SAMPLE=3 SPLITS=100 Detector: PSD_transmission_I=0.070845
* %Example: SAMPLE=3 SPLITS=100 Detector: PSD_scattered_I=0.182056
*
* %P
* SPLITS: [1] Number of SPLIT to do
Expand Down Expand Up @@ -82,16 +88,30 @@ EXTEND %{
p = INSTRUMENT_GETPAR(Pp0);
%}

COMPONENT SX = Single_crystal(radius=0.01,reflections="Al.lau",mosaic=20)
COMPONENT SX = Single_crystal(radius=0.01,reflections="Al.lau",mosaic=20,order=1)
WHEN (SAMPLE==3) AT (0,0,0.1) RELATIVE Slit
EXTEND %{
if(!SCATTERED) ABSORB;
p = INSTRUMENT_GETPAR(Pp0);
%}


COMPONENT PSD = PSD_monitor_4PI(radius=1, filename="splits", nx=100, ny=100)
COMPONENT PSD = PSD_monitor_4PI(radius=1, filename="splits", nx=100, ny=100, restore_neutron=1)
AT (0,0,0) RELATIVE Incoh

COMPONENT PSD_transmission = PSD_monitor(xwidth=0.01, yheight=0.01, filename="splits_transmission", nx=100, ny=100, restore_neutron=1)
AT (0,0,0.1) RELATIVE Incoh

COMPONENT detector_direction_1 = Arm()
AT (0,0,0) RELATIVE Incoh
ROTATED (0, 29.65, 0) RELATIVE Incoh

COMPONENT detector_direction_2 = Arm()
AT (0,0,0) RELATIVE Incoh
ROTATED (26.3, 0, 0) RELATIVE detector_direction_1

COMPONENT PSD_scattered = PSD_monitor(xwidth=0.02, yheight=0.02, filename="splits_scattered", nx=100, ny=100, restore_neutron=1)
AT (0,0,0.5) RELATIVE detector_direction_2

FINALLY
%{
Expand Down
15 changes: 12 additions & 3 deletions mcstas-comps/samples/Single_crystal.comp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ DECLARE
struct hkl_info_struct hkl_info;
off_struct offdata;
struct hkl_data *hkl_list;
struct tau_data tau_list_initial[MCSX_REFL_SLIST_SIZE];
struct tau_data tau_list[MCSX_REFL_SLIST_SIZE];
%}

Expand Down Expand Up @@ -1297,7 +1298,7 @@ TRACE
itype = 0;

#ifndef OPENACC
T = tau_list;
T = tau_list_initial;
hkl_info.type = type;
#endif
do { /* Loop over multiple scattering events */
Expand Down Expand Up @@ -1390,10 +1391,17 @@ TRACE


/* (2). Intersection of Ewald sphere with reciprocal lattice points */

double coh_xsect = 0, coh_refl = 0;
/* in case we use 'SPLIT' then consecutive neutrons can be identical when entering here
and we may skip the hkl_search call */
and we may skip the hkl_search call. One tau_list is reserved for data for the initial
ray results so that it potentially can be reused later. */
if (event_counter==0) {
T = tau_list_initial;
} else {
T = tau_list;
}

#ifndef OPENACC
if (order==1 && fabs(kix - hkl_info.kix) < deltak
&& fabs(kiy - hkl_info.kiy) < deltak
Expand All @@ -1404,6 +1412,7 @@ TRACE
coh_refl = hkl_info.coh_refl;
coh_xsect = hkl_info.coh_xsect;
tau_count = hkl_info.tau_count;
T = tau_list_initial;

} else {
#endif
Expand Down
Loading