@@ -60,124 +60,126 @@ SETTING PARAMETERS(sigma=5.08, f_QE=0, gamma=0, packing_factor=1, unit_cell_volu
6060
6161SHARE
6262%{
63- #ifndef Union
64- #error "The Union_init component must be included before this Incoherent_process component"
65- #endif
63+ #ifndef Union
64+ #error "The Union_init component must be included before this Incoherent_process component"
65+ #endif
6666
67-
68- struct Incoherent_physics_storage_struct{
67+ struct Incoherent_physics_storage_struct {
6968 // Variables that needs to be transfered between any of the following places:
7069 // The initialize in this component
7170 // The function for calculating my
7271 // The function for calculating scattering
73-
72+
7473 double my_scattering;
7574 double QE_sampling_frequency;
7675 double lorentzian_width;
77-
78- };
76+ };
7977
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) {
78+ // Function for calculating my in Incoherent case
79+ int
80+ Incoherent_physics_my (double* my, double* k_initial, union data_transfer_union data_transfer, struct focus_data_struct* focus_data,
81+ _class_particle* _particle) {
8282 *my = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering;
8383 return 1;
84- };
84+ };
8585
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) {
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, _class_particle* _particle) {
8890
89- //New version of incoherent scattering
90- 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]);
9193
9294 Coords k_out;
9395 // Here is the focusing system in action, get a vector
9496 double solid_angle;
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;
98-
99- double v_i,v_f,E_i,dE,E_f;
100-
101- if (rand01() < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
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 v_i, v_f, E_i, dE, E_f;
102+
103+ if (rand01 () < data_transfer.pointer_to_a_Incoherent_physics_storage_struct->QE_sampling_frequency) {
102104 v_i = k_length * K2V;
103- E_i = VS2E* v_i* v_i;
104- dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width* tan(PI/2* randpm1());
105+ E_i = VS2E * v_i * v_i;
106+ dE = data_transfer.pointer_to_a_Incoherent_physics_storage_struct->lorentzian_width * tan (PI / 2 * randpm1 ());
105107 E_f = E_i + dE;
106108 if (E_f <= 0)
107109 return 0;
108- v_f = SE2V* sqrt(E_f);
109- k_length = v_f* V2K;
110+ v_f = SE2V * sqrt (E_f);
111+ k_length = v_f * V2K;
110112 }
111-
112- k_final[0] = k_out.x*k_length; k_final[1] = k_out.y*k_length; k_final[2] = k_out.z*k_length;
113+
114+ k_final[0] = k_out.x * k_length;
115+ k_final[1] = k_out.y * k_length;
116+ k_final[2] = k_out.z * k_length;
113117 return 1;
114- };
118+ };
115119
116- #ifndef PROCESS_DETECTOR
117- #define PROCESS_DETECTOR dummy
118- #endif
120+ #ifndef PROCESS_DETECTOR
121+ #define PROCESS_DETECTOR dummy
122+ #endif
119123
120- #ifndef PROCESS_INCOHERENT_DETECTOR
121- #define PROCESS_INCOHERENT_DETECTOR dummy
122- #endif
124+ #ifndef PROCESS_INCOHERENT_DETECTOR
125+ #define PROCESS_INCOHERENT_DETECTOR dummy
126+ #endif
123127%}
124128
125129DECLARE
126130%{
127- // Needed for transport to the main component
128- struct global_process_element_struct global_process_element;
129- struct scattering_process_struct This_process;
130-
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;
131+ // Needed for transport to the main component
132+ struct global_process_element_struct global_process_element;
133+ struct scattering_process_struct This_process;
134134
135+ // Declare for this component, to do calculations on the input / store in the transported data
136+ struct Incoherent_physics_storage_struct Incoherent_storage;
137+ double effective_my_scattering;
135138%}
136139
137140INITIALIZE
138141%{
139142 // Initialize done in the component
140- effective_my_scattering = ((packing_factor/ unit_cell_volume) * 100 * sigma);
143+ effective_my_scattering = ((packing_factor / unit_cell_volume) * 100 * sigma);
141144 Incoherent_storage.my_scattering = effective_my_scattering;
142-
145+
143146 Incoherent_storage.QE_sampling_frequency = f_QE;
144147 Incoherent_storage.lorentzian_width = gamma;
145148
146- //First initialise This_process with default values:
147- scattering_process_struct_init(&This_process);
149+ // First initialise This_process with default values:
150+ scattering_process_struct_init (&This_process);
148151
149152 // Need to specify if this process is isotropic
150153 This_process.non_isotropic_rot_index = -1; // Yes (powder)
151- //This_process.non_isotropic_rot_index = 1; // No (single crystal)
152-
154+ // This_process.non_isotropic_rot_index = 1; // No (single crystal)
155+
153156 // Need to specify if this process need to use focusing in calculation of inverse penetration depth (physics_my)
154- //This_process.needs_cross_section_focus = 1; // Yes
155- This_process.needs_cross_section_focus = -1; // No
157+ // This_process.needs_cross_section_focus = 1; // Yes
158+ This_process.needs_cross_section_focus = -1; // No
156159
157160 // The type of the process must be saved in the global enum process
158161 This_process.eProcess = Incoherent;
159162
160163 // Packing the data into a structure that is transported to the main component
161- sprintf(This_process.name,"%s",NAME_CURRENT_COMP);
164+ sprintf (This_process.name, "%s", NAME_CURRENT_COMP);
162165 This_process.process_p_interact = interact_fraction;
163166 This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct = &Incoherent_storage;
164- //This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering = effective_my_scattering;
167+ // This_process.data_transfer.pointer_to_a_Incoherent_physics_storage_struct->my_scattering = effective_my_scattering;
165168 This_process.probability_for_scattering_function = &Incoherent_physics_my;
166169 This_process.scattering_function = &Incoherent_physics_scattering;
167170
168171 // This will be the same for all process's, and can thus be moved to an include.
169- sprintf(global_process_element.name,"%s",NAME_CURRENT_COMP);
172+ sprintf (global_process_element.name, "%s", NAME_CURRENT_COMP);
170173 global_process_element.component_index = INDEX_CURRENT_COMP;
171174 global_process_element.p_scattering_process = &This_process;
172175
173- if (_getcomp_index(init) < 0) {
174- fprintf(stderr,"Incoherent_process:%s: Error identifying Union_init component, %s is not a known component name.\n",
175- NAME_CURRENT_COMP, init);
176- exit(-1);
176+ if (_getcomp_index (init) < 0) {
177+ fprintf (stderr, "Incoherent_process:%s: Error identifying Union_init component, %s is not a known component name.\n", NAME_CURRENT_COMP, init);
178+ exit (-1);
177179 }
178180
179- struct pointer_to_global_process_list * global_process_list = COMP_GETPAR3(Union_init, init, global_process_list);
180- add_element_to_process_list(global_process_list, global_process_element);
181+ struct pointer_to_global_process_list* global_process_list = COMP_GETPAR3 (Union_init, init, global_process_list);
182+ add_element_to_process_list (global_process_list, global_process_element);
181183 %}
182184
183185TRACE
@@ -186,8 +188,7 @@ TRACE
186188
187189FINALLY
188190%{
189- // Since the process and it's storage is a static allocation, there is nothing to deallocate
190-
191+ // Since the process and it's storage is a static allocation, there is nothing to deallocate
191192%}
192193
193194END
0 commit comments