Skip to content

Commit 8384c28

Browse files
authored
Merge pull request #2331 from willend/format-union
Format McXtrace union
2 parents 9076f31 + d0e6479 commit 8384c28

1 file changed

Lines changed: 53 additions & 53 deletions

File tree

mcxtrace-comps/union/Incoherent_process.comp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -57,106 +57,107 @@ SETTING PARAMETERS(sigma=5.08,f_QE=0,gamma=0,packing_factor=1,unit_cell_volume=1
5757

5858
SHARE
5959
%{
60-
#ifndef Union
61-
#define Union $Revision: 0.8 $
60+
#ifndef Union
61+
#define Union $Revision: 0.8 $
6262

63-
#include "Union_functions.c"
64-
#include "Union_initialization.c"
63+
#include "Union_functions.c"
64+
#include "Union_initialization.c"
6565

66-
#endif
66+
#endif
6767

68-
69-
struct Incoherent_physics_storage_struct{
68+
struct Incoherent_physics_storage_struct {
7069
// Variables that needs to be transfered between any of the following places:
7170
// The initialize in this component
7271
// The function for calculating my
7372
// The function for calculating scattering
74-
73+
7574
double my_scattering;
7675
double QE_sampling_frequency;
7776
double lorentzian_width;
78-
79-
};
77+
};
8078

81-
// Function for calculating my in Incoherent case
82-
int Incoherent_physics_my(double *my,double *k_initial, union data_transfer_union data_transfer, struct focus_data_struct *focus_data) {
79+
// Function for calculating my in Incoherent case
80+
int
81+
Incoherent_physics_my (double* my, double* k_initial, union data_transfer_union data_transfer, struct focus_data_struct* focus_data) {
8382
*my = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering;
8483
return 1;
85-
};
84+
};
8685

87-
// Function for basic incoherent scattering event
88-
int Incoherent_physics_scattering(double *k_final, double *k_initial, double *weight, union data_transfer_union data_transfer, struct focus_data_struct *focus_data) {
86+
// Function for basic incoherent scattering event
87+
int
88+
Incoherent_physics_scattering (double* k_final, double* k_initial, double* weight, union data_transfer_union data_transfer,
89+
struct focus_data_struct* focus_data) {
8990

90-
//New version of incoherent scattering
91-
double k_length = sqrt(k_initial[0]*k_initial[0]+k_initial[1]*k_initial[1]+k_initial[2]*k_initial[2]);
91+
// New version of incoherent scattering
92+
double k_length = sqrt (k_initial[0] * k_initial[0] + k_initial[1] * k_initial[1] + k_initial[2] * k_initial[2]);
9293

9394
Coords k_out;
9495
// Here is the focusing system in action, get a vector
9596
double solid_angle;
96-
focus_data->focusing_function(&k_out,&solid_angle,focus_data);
97-
NORM(k_out.x,k_out.y,k_out.z);
98-
*weight *= solid_angle*0.25/PI;
99-
100-
double E_i,dE,E_f;
101-
102-
if (rand01() < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
103-
E_i = K2E*k_length;
104-
dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width*tan(PI/2*randpm1());
97+
focus_data->focusing_function (&k_out, &solid_angle, focus_data);
98+
NORM (k_out.x, k_out.y, k_out.z);
99+
*weight *= solid_angle * 0.25 / PI;
100+
101+
double E_i, dE, E_f;
102+
103+
if (rand01 () < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
104+
E_i = K2E * k_length;
105+
dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width * tan (PI / 2 * randpm1 ());
105106
E_f = E_i + dE;
106107
if (E_f <= 0)
107108
return 0;
108-
k_length = E_f*E2K;
109+
k_length = E_f * E2K;
109110
}
110-
111-
k_final[0] = k_out.x*k_length; k_final[1] = k_out.y*k_length; k_final[2] = k_out.z*k_length;
112-
return 1;
113-
};
114111

112+
k_final[0] = k_out.x * k_length;
113+
k_final[1] = k_out.y * k_length;
114+
k_final[2] = k_out.z * k_length;
115+
return 1;
116+
};
115117
%}
116118

117119
DECLARE
118120
%{
119-
// Needed for transport to the main component
120-
struct global_process_element_struct global_process_element;
121-
struct scattering_process_struct This_process;
122-
123-
#ifndef PROCESS_DETECTOR
124-
//struct pointer_to_global_process_list global_process_list = {0,NULL};
125-
#define PROCESS_DETECTOR dummy
126-
#endif
127-
128-
// Declare for this component, to do calculations on the input / store in the transported data
129-
struct Incoherent_physics_storage_struct Incoherent_storage;
130-
double effective_my_scattering;
131-
121+
// Needed for transport to the main component
122+
struct global_process_element_struct global_process_element;
123+
struct scattering_process_struct This_process;
124+
125+
#ifndef PROCESS_DETECTOR
126+
// struct pointer_to_global_process_list global_process_list = {0,NULL};
127+
#define PROCESS_DETECTOR dummy
128+
#endif
129+
130+
// Declare for this component, to do calculations on the input / store in the transported data
131+
struct Incoherent_physics_storage_struct Incoherent_storage;
132+
double effective_my_scattering;
132133
%}
133134

134135
INITIALIZE
135136
%{
136137
// Initialize done in the component
137-
effective_my_scattering = ((packing_factor/unit_cell_volume) * 100 * sigma);
138+
effective_my_scattering = ((packing_factor / unit_cell_volume) * 100 * sigma);
138139
Incoherent_storage.my_scattering = effective_my_scattering;
139-
140+
140141
Incoherent_storage.QE_sampling_frequency = f_QE;
141142
Incoherent_storage.lorentzian_width = gamma;
142143

143144
// Need to specify if this process is isotropic
144145
This_process.non_isotropic_rot_index = -1; // Yes (powder)
145-
//This_process.non_isotropic_rot_index = 1; // No (single crystal)
146+
// This_process.non_isotropic_rot_index = 1; // No (single crystal)
146147

147148
// Packing the data into a structure that is transported to the main component
148-
sprintf(This_process.name,"%s",NAME_CURRENT_COMP);
149+
sprintf (This_process.name, "%s", NAME_CURRENT_COMP);
149150
This_process.process_p_interact = interact_fraction;
150151
This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct = &Incoherent_storage;
151-
//This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering = effective_my_scattering;
152+
// This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering = effective_my_scattering;
152153
This_process.probability_for_scattering_function = &Incoherent_physics_my;
153154
This_process.scattering_function = &Incoherent_physics_scattering;
154155

155156
// This will be the same for all process's, and can thus be moved to an include.
156-
sprintf(global_process_element.name,"%s",NAME_CURRENT_COMP);
157+
sprintf (global_process_element.name, "%s", NAME_CURRENT_COMP);
157158
global_process_element.component_index = INDEX_CURRENT_COMP;
158159
global_process_element.p_scattering_process = &This_process;
159-
add_element_to_process_list(&global_process_list,global_process_element);
160+
add_element_to_process_list (&global_process_list, global_process_element);
160161
%}
161162

162163
TRACE
@@ -165,8 +166,7 @@ TRACE
165166

166167
FINALLY
167168
%{
168-
// Since the process and it's storage is a static allocation, there is nothing to deallocate
169-
169+
// Since the process and it's storage is a static allocation, there is nothing to deallocate
170170
%}
171171

172172
END

0 commit comments

Comments
 (0)