diff --git a/mcstas-comps/contrib/Monochromator_bent.comp b/mcstas-comps/contrib/Monochromator_bent.comp index b565ede63..66643864d 100755 --- a/mcstas-comps/contrib/Monochromator_bent.comp +++ b/mcstas-comps/contrib/Monochromator_bent.comp @@ -13,6 +13,7 @@ * Origin: ILL/NBI * * A bent crystal monochromator. Based on the model implemented by Jan Šaroun in NIMA 529 (2004) pp 162-165. +* An article describing the component has been written and can be seen in Quantum Beam Sci. 2026, 10, 6. https://doi.org/10.3390/qubs10010006 * Mosacity and bending radius can be set. * * %D @@ -49,11 +50,13 @@ * x_rot: [vector] Rotation around x-axis for each crystal * y_rot: [vector] Rotation around y-axis for each crystal * z_rot: [vector] Rotation around z-axis for each crystal NOTE: Rotations happen around x, then y, then z. +* n_reflections: [ ] The maximum number of reflections a neutron can undergo in the crystal array. * verbose: [ ] Verbosity of the monochromator. Used for debugging. * draw_as_rectangles: [ ] Draw the monochromators as boxes. DOES NOT WORK WHEN USING _rot parameters. * * %L * Jan Šaroun NIM A Volume 529, Issue 1-3 (2004), pp162-165 +* Christensen, D.L.; Cabeza, S.; Pirling, T.; Lefmann, K.; Ĺ aroun, J. Simulating Neutron Diffraction from Deformed Mosaic Crystals in McStas. Quantum Beam Sci. 2026, 10, 6. https://doi.org/10.3390/qubs10010006 * * %E *******************************************************************************/ @@ -77,6 +80,7 @@ SETTING PARAMETERS (zwidth=0.2, vector x_rot=NULL, vector y_rot=NULL, vector z_rot=NULL, + int n_reflections=100, int verbose=0, int draw_as_rectangles=0) // Neutron parameters: (x,y,z,vx,vy,vz,t,sx,sy,sz,p) @@ -1317,7 +1321,6 @@ DECLARE int counter; int counter2; double curvature; - int MAX_REFLECTIONS; struct neutron_values neutron; struct Monochromator_array mono_arr; @@ -1518,7 +1521,6 @@ INITIALIZE neutron.direction = 1; // Default direction is going away from the instrument counter = 0; counter2 = 0; - MAX_REFLECTIONS = 100; // Chosen maximum number of reflections // Free the position and rotations memories if (x_pos_mem_flag) @@ -1557,7 +1559,7 @@ TRACE calculate_probabilities_of_reflection (&mono_arr, &neutron, _particle); choose_crystal_to_reflect_from (&mono_arr, &neutron, &optimize, _particle); check_if_neutron_should_pass_through (&mono_arr, &neutron, &p, &weight_init); - if (neutron.reflections > MAX_REFLECTIONS) { + if (neutron.reflections > n_reflections) { neutron.transmit_neutron = 1; } if (neutron.transmit_neutron) { diff --git a/mcstas-comps/contrib/Monochromator_bent_complex.comp b/mcstas-comps/contrib/Monochromator_bent_complex.comp index 0db3bc0b8..adb6ba6e3 100755 --- a/mcstas-comps/contrib/Monochromator_bent_complex.comp +++ b/mcstas-comps/contrib/Monochromator_bent_complex.comp @@ -73,6 +73,7 @@ SETTING PARAMETERS (vector zwidth=NULL, int n_crystals=1, int optimize=0, int verbose=0, + int n_reflections=100, int draw_as_rectangles=0) // Neutron parameters: (x,y,z,vx,vy,vz,t,sx,sy,sz,p) NOACC @@ -107,7 +108,6 @@ DECLARE int counter; int counter2; double curvature; - int MAX_REFLECTIONS; struct neutron_values neutron; struct Monochromator_array mono_arr; %} @@ -291,7 +291,6 @@ INITIALIZE neutron.direction = 1; // Default direction is going away from the instrument counter = 0; counter2 = 0; - MAX_REFLECTIONS = 100; // Chosen maximum number of reflections %} TRACE INHERIT Monochromator_bent diff --git a/mcstas-comps/examples/ILL/ILL_SALSA/ILL_SALSA.instr b/mcstas-comps/examples/ILL/ILL_SALSA/ILL_SALSA.instr index e0da94a8b..c133fb41f 100644 --- a/mcstas-comps/examples/ILL/ILL_SALSA/ILL_SALSA.instr +++ b/mcstas-comps/examples/ILL/ILL_SALSA/ILL_SALSA.instr @@ -128,12 +128,23 @@ INITIALIZE Rh_H22_6 = L_H22_6 /gRh*RAD2DEG; } printf("Instrument: ILL_H22 (H22@ILL thermal guide).\n"); - mono_sandwich_x = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); + mono_sandwich_x = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); mono_sandwich_y = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); mono_sandwich_z = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); mono_sandwich_rot_x = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); mono_sandwich_rot_y = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); mono_sandwich_rot_z = (double*)malloc(lamellas*monochromator_slabs*sizeof(double)); + if (NULL == mono_sandwich_x || NULL == mono_sandwich_y || NULL == mono_sandwich_z + || NULL == mono_sandwich_rot_x || NULL == mono_sandwich_rot_y || NULL == mono_sandwich_rot_z){ + free(mono_sandwich_x); + free(mono_sandwich_y); + free(mono_sandwich_z); + free(mono_sandwich_rot_x); + free(mono_sandwich_rot_y); + free(mono_sandwich_rot_z); + printf("ERROR: monochromator not properly allocated. Exiting\n"); + exit(-1); + } //FOCUSING MONOCHROMATOR ARRRAY double gap = 0.0001; double total_mono_height = 0.209;