Skip to content

Commit 17c87fd

Browse files
Fix for focusing problem when processes use focus to calculate cross section.
Processes can now report the need to do so, and in that case a point will be chosen. If that process is selected, that point is used, and a weight transformation corrects for the probability of that position. Also introduced control parameters to disable / enable refraction and reflection just like the Refractor component.
1 parent 2e24992 commit 17c87fd

14 files changed

+405
-327
lines changed

mcstas-comps/share/union-lib.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum process {
3333
Texture,
3434
IncoherentPhonon,
3535
NCrystal,
36+
Non,
3637
Template
3738
};
3839

@@ -465,6 +466,7 @@ struct physics_struct
465466
char name[256]; // User defined material name
466467
int interact_control;
467468
int is_vacuum;
469+
int any_process_needs_cross_section_focus;
468470
double my_a;
469471
int number_of_processes;
470472
// pointer to array of pointers to physics_sub structures that each describe a scattering process
@@ -502,6 +504,7 @@ char name[256]; // User defined process name
502504
enum process eProcess; // enum value corresponding to this process GPU
503505
double process_p_interact; // double between 0 and 1 that describes the fraction of events forced to undergo this process. -1 for disable
504506
int non_isotropic_rot_index; // -1 if process is isotrpic, otherwise is the index of the process rotation matrix in the volume
507+
int needs_cross_section_focus; // 1 if physics_my needs to call focus functions, otherwise -1
505508
Rotation rotation_matrix; // rotation matrix of process, reported by component in local frame, transformed and moved to volume struct in main
506509

507510
union data_transfer_union data_transfer; // The way to reach the storage space allocated for this process (see examples in process.comp files)

mcstas-comps/share/union-suffix.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ int physics_my(enum process choice, double *my,double *k_initial, union data_tra
5050
case NCrystal:
5151
output = NCrystal_physics_my(my, k_initial, data_transfer, focus_data, _particle);
5252
break;
53+
#endif
54+
#ifdef PROCESS_NON_DETECTOR
55+
case Non:
56+
output = Non_physics_my(my, k_initial, data_transfer, focus_data, _particle);
57+
break;
5358
#endif
5459
#ifdef PROCESS_TEMPLATE_DETECTOR
5560
case Template:
@@ -110,9 +115,14 @@ int physics_scattering(enum process choice, double *k_final, double *k_initial,
110115
output = NCrystal_physics_scattering(k_final, k_initial, weight, data_transfer, focus_data, _particle);
111116
break;
112117
#endif
118+
#ifdef PROCESS_NON_DETECTOR
119+
case Non:
120+
output = Non_physics_scattering(k_final, k_initial, weight, data_transfer, focus_data, _particle);
121+
break;
122+
#endif
113123
#ifdef PROCESS_TEMPLATE_DETECTOR
114124
case Template:
115-
output = Incoherent_physics_scattering(k_final, k_initial, weight, data_transfer, focus_data, _particle);
125+
output = Template_physics_scattering(k_final, k_initial, weight, data_transfer, focus_data, _particle);
116126
break;
117127
#endif
118128
default: printf("physics_scattering: No scattering process matches input!\n");

mcstas-comps/union/AF_HB_1D_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ INITIALIZE
316316
// Need to specify if this process is isotropic
317317
//This_process.non_isotropic_rot_index = -1; // Yes (powder)
318318
This_process.non_isotropic_rot_index = 1; // No (single crystal)
319+
320+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
321+
//This_process.needs_cross_section_focus = 1; // Yes
322+
This_process.needs_cross_section_focus = -1; // No
319323

320324
// The type of the process must be saved in the global enum process
321325
This_process.eProcess = AF_HB_1D;

mcstas-comps/union/IncoherentPhonon_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,6 +4649,10 @@ INITIALIZE
46494649
// Need to specify if this process is isotropic
46504650
This_process.non_isotropic_rot_index = -1; // Yes (powder)
46514651
//This_process.non_isotropic_rot_index = 1; // No (single crystal)
4652+
4653+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
4654+
//This_process.needs_cross_section_focus = 1; // Yes
4655+
This_process.needs_cross_section_focus = -1; // No
46524656

46534657
// The type of the process must be saved in the global enum process
46544658
This_process.eProcess = IncoherentPhonon;

mcstas-comps/union/Incoherent_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ INITIALIZE
146146
// Need to specify if this process is isotropic
147147
This_process.non_isotropic_rot_index = -1; // Yes (powder)
148148
//This_process.non_isotropic_rot_index = 1; // No (single crystal)
149+
150+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
151+
//This_process.needs_cross_section_focus = 1; // Yes
152+
This_process.needs_cross_section_focus = -1; // No
149153

150154
// The type of the process must be saved in the global enum process
151155
This_process.eProcess = Incoherent;

mcstas-comps/union/NCrystal_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ INITIALIZE
372372
// Need to specify if this process is isotropic
373373
//This_process.non_isotropic_rot_index = -1; // Yes (powder)
374374
This_process.non_isotropic_rot_index = 1; // No (single crystal)
375+
376+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
377+
//This_process.needs_cross_section_focus = 1; // Yes
378+
This_process.needs_cross_section_focus = -1; // No
375379

376380
// The type of the process must be saved in the global enum process
377381
This_process.eProcess = NCrystal;

mcstas-comps/union/Non_process.comp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ int Non_physics_scattering(double *k_final, double *k_initial, double *weight, u
101101
// These lines help with future error correction, and tell other Union components
102102
// that at least one process have been defined.
103103
#ifndef PROCESS_DETECTOR
104-
// Obsolete
105-
//struct pointer_to_global_process_list global_process_list = {0,NULL};
106104
#define PROCESS_DETECTOR dummy
107105
#endif
108106

107+
#ifndef PROCESS_NON_DETECTOR
108+
#define PROCESS_NON_DETECTOR dummy
109+
#endif
110+
109111
%}
110112

111113
DECLARE
@@ -130,6 +132,13 @@ INITIALIZE
130132
// Need to specify if this process is isotropic
131133
This_process.non_isotropic_rot_index = -1; // Yes (powder)
132134
//This_process.non_isotropic_rot_index = 1; // No (single crystal)
135+
136+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
137+
//This_process.needs_cross_section_focus = 1; // Yes
138+
This_process.needs_cross_section_focus = -1; // No
139+
140+
// The type of the process must be saved in the global enum process
141+
This_process.eProcess = Non;
133142

134143
// Packing the data into a structure that is transported to the main component
135144
This_process.data_transfer.pointer_to_a_Non_physics_storage_struct = &Non_storage;

mcstas-comps/union/PhononSimple_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ INITIALIZE
515515
// Need to specify if this process is isotropic
516516
//This_process.non_isotropic_rot_index = -1; // Yes (powder)
517517
This_process.non_isotropic_rot_index = 1; // No (single crystal)
518+
519+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
520+
This_process.needs_cross_section_focus = 1; // Yes
521+
//This_process.needs_cross_section_focus = -1; // No
518522

519523
// The type of the process must be saved in the global enum process
520524
This_process.eProcess = PhononSimple;

mcstas-comps/union/Powder_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,10 @@ INITIALIZE
749749
// Need to specify if this process is isotropic
750750
This_process.non_isotropic_rot_index = -1; // Yes (powder)
751751
//This_process.non_isotropic_rot_index = 1; // No (single crystal)
752+
753+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
754+
//This_process.needs_cross_section_focus = 1; // Yes
755+
This_process.needs_cross_section_focus = -1; // No
752756

753757
// The type of the process must be saved in the global enum process
754758
This_process.eProcess = Powder;

mcstas-comps/union/Single_crystal_process.comp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ INITIALIZE
10771077
// Need to specify if this process is isotropic
10781078
//This_process.non_isotropic_rot_index = -1; // Yes (powder)
10791079
This_process.non_isotropic_rot_index = 1; // No (single crystal)
1080+
1081+
// Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
1082+
//This_process.needs_cross_section_focus = 1; // Yes
1083+
This_process.needs_cross_section_focus = -1; // No
10801084

10811085
// The type of the process must be saved in the global enum process
10821086
This_process.eProcess = Single_crystal;

0 commit comments

Comments
 (0)