Skip to content

Commit f7cb486

Browse files
committed
Manual (halfway) merge based on comp from main
1 parent 1bfef9a commit f7cb486

1 file changed

Lines changed: 34 additions & 37 deletions

File tree

mcxtrace-comps/union/Incoherent_process.comp

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
*
33
* McXtrace, X-ray tracing package
44
* Copyright, All rights reserved
5+
* DTU Physics, Kgs. Lyngby, Denmark
6+
* Synchrotron SOLEIL, Saint-Aubin, France
57
*
6-
* %I
8+
* %Identification
79
* Written by: Mads Bertelsen and Erik B Knudsen
810
* Date: 20.08.15
911
* Version: $Revision: 0.1 $
1012
* Origin: ESS DMSC & DTU Physics
1113
*
1214
* A sample component to separate geometry and phsysics
1315
*
14-
* %D
16+
* %Description
1517
*
1618
* This Union_process is based on the Incoherent.comp component originally written
1719
* by Kim Lefmann and Kristian Nielsen
@@ -33,7 +35,7 @@
3335
* Algorithm:
3436
* Described elsewhere
3537
*
36-
* %P
38+
* %Parameters
3739
* INPUT PARAMETERS:
3840
* sigma: [barns] Incoherent scattering cross section
3941
* f_QE: [1] Fraction of quasielastic scattering (rest is elastic)
@@ -43,7 +45,7 @@
4345
* Interact_fraction: [1] How large a part of the scattering events should use this process 0-1 (sum of all processes in material = 1)
4446
* init: [string] name of Union_init component (typically "init", default)
4547
*
46-
* OUTPUT PARAMETERS:
48+
* CALCULATED PARAMETERS:
4749
*
4850
* %L
4951
* The test/example instrument <a href="../examples/Test_Phonon.instr">Test_Phonon.instr</a>.
@@ -52,24 +54,19 @@
5254
******************************************************************************/
5355

5456
DEFINE COMPONENT Incoherent_process
55-
DEFINITION PARAMETERS ()
5657
SETTING PARAMETERS(sigma=5.08, f_QE=0, gamma=0, packing_factor=1, unit_cell_volume=13.8, interact_fraction=-1, string init="init")
57-
OUTPUT PARAMETERS ()
58-
59-
/* X-ray parameters: (x,y,z,kx,ky,kz,phi,t,Ex,Ey,Ez,p) */
6058

6159
SHARE
6260
%{
63-
#ifndef Union
64-
#define Union $Revision: 0.8 $
65-
61+
#ifndef Union
62+
#define Union $Revision: 0.8 $
6663

67-
%include "union-init.c"
6864

69-
#endif
65+
%include "union-init.c"
7066

67+
#endif
7168

72-
struct Incoherent_physics_storage_struct{
69+
struct Incoherent_physics_storage_struct {
7370
// Variables that needs to be transfered between any of the following places:
7471
// The initialize in this component
7572
// The function for calculating my
@@ -78,40 +75,41 @@ struct Incoherent_physics_storage_struct{
7875
double my_scattering;
7976
double QE_sampling_frequency;
8077
double lorentzian_width;
78+
};
8179

82-
};
83-
84-
// Function for calculating my in Incoherent case
85-
int Incoherent_physics_my(double *my,double *k_initial, union data_transfer_union data_transfer, struct focus_data_struct *focus_data, _class_particle *_particle) {
80+
// Function for calculating my in Incoherent case
81+
int Incoherent_physics_my(double *my,double *k_initial, union data_transfer_union data_transfer, struct focus_data_struct *focus_data, _class_particle *_particle) {
8682
*my = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering;
8783
return 1;
88-
};
84+
};
8985

90-
// Function for basic incoherent scattering event
91-
int Incoherent_physics_scattering(double *k_final, double *k_initial, double *weight, union data_transfer_union data_transfer, struct focus_data_struct *focus_data, _class_particle *_particle) {
86+
// Function for basic incoherent scattering event
87+
int Incoherent_physics_scattering (double *k_final, double *k_initial, double *weight, union data_transfer_union data_transfer, struct focus_data_struct *focus_data, _class_particle *_particle) {
9288

9389
//New version of incoherent scattering
9490
double k_length = sqrt(k_initial[0]*k_initial[0]+k_initial[1]*k_initial[1]+k_initial[2]*k_initial[2]);
9591

9692
Coords k_out;
9793
// Here is the focusing system in action, get a vector
9894
double solid_angle;
99-
focus_data->focusing_function(&k_out,&solid_angle,focus_data);
100-
NORM(k_out.x,k_out.y,k_out.z);
101-
*weight *= solid_angle*0.25/PI;
95+
focus_data->focusing_function (&k_out, &solid_angle, focus_data);
96+
NORM (k_out.x, k_out.y, k_out.z);
97+
*weight *= solid_angle * 0.25 / PI;
10298

103-
double E_i,dE,E_f;
99+
double E_i, dE, E_f;
104100

105-
if (rand01() < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
106-
E_i = K2E*k_length;
107-
dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width*tan(PI/2*randpm1());
101+
if (rand01 () < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
102+
E_i = K2E * k_length;
103+
dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width * tan (PI / 2 * randpm1 ());
108104
E_f = E_i + dE;
109105
if (E_f <= 0)
110106
return 0;
111107
k_length = E_f*E2K;
112108
}
113109

114-
k_final[0] = k_out.x*k_length; k_final[1] = k_out.y*k_length; k_final[2] = k_out.z*k_length;
110+
k_final[0] = k_out.x * k_length;
111+
k_final[1] = k_out.y * k_length;
112+
k_final[2] = k_out.z * k_length;
115113
return 1;
116114
};
117115

@@ -126,13 +124,13 @@ int Incoherent_physics_scattering(double *k_final, double *k_initial, double *we
126124

127125
DECLARE
128126
%{
129-
// Needed for transport to the main component
130-
struct global_process_element_struct global_process_element;
131-
struct scattering_process_struct This_process;
127+
// Needed for transport to the main component
128+
struct global_process_element_struct global_process_element;
129+
struct scattering_process_struct This_process;
132130

133-
// Declare for this component, to do calculations on the input / store in the transported data
134-
struct Incoherent_physics_storage_struct Incoherent_storage;
135-
double effective_my_scattering;
131+
// Declare for this component, to do calculations on the input / store in the transported data
132+
struct Incoherent_physics_storage_struct Incoherent_storage;
133+
double effective_my_scattering;
136134

137135
%}
138136

@@ -181,8 +179,7 @@ TRACE
181179

182180
FINALLY
183181
%{
184-
// Since the process and it's storage is a static allocation, there is nothing to deallocate
185-
182+
// Since the process and it's storage is a static allocation, there is nothing to deallocate
186183
%}
187184

188185
END

0 commit comments

Comments
 (0)