@@ -25,6 +25,7 @@ enum shape {
2525};
2626
2727enum process {
28+ Inhomogenous_incoherent ,
2829 Incoherent ,
2930 Powder ,
3031 Single_crystal ,
@@ -458,6 +459,7 @@ struct pointer_to_1d_int_list mask_intersect_list;
458459int number_of_faces ;
459460struct surface_stack_struct * * surface_stack_for_each_face ;
460461struct surface_stack_struct * internal_cut_surface_stack ;
462+
461463};
462464
463465struct physics_struct
@@ -475,10 +477,19 @@ struct scattering_process_struct *p_scattering_array;
475477int has_refraction_info ;
476478double refraction_scattering_length_density ; // [AA^-2]
477479double refraction_Qc ;
480+
481+ // Numerical integration
482+ int sampling_points ;
483+ double * cumul_transmission_prob ;
484+ double dist ;
485+ double * cumul_dists ;
486+ double * * mus ;
487+ double * total_mus ;
478488};
479489
480490union data_transfer_union {
481491 // List of pointers to storage structs for all supported physical processes
492+ struct Inhomogenous_incoherent_struct * Inhomogenous_incoherent_struct ;
482493 struct Incoherent_physics_storage_struct * pointer_to_a_Incoherent_physics_storage_struct ;
483494 struct Powder_physics_storage_struct * pointer_to_a_Powder_physics_storage_struct ;
484495 struct Single_crystal_physics_storage_struct * pointer_to_a_Single_crystal_physics_storage_struct ;
@@ -499,36 +510,46 @@ union data_transfer_union{
499510
500511struct scattering_process_struct
501512{
502- char name [256 ]; // User defined process name
503- enum process eProcess ; // enum value corresponding to this process GPU
504- double process_p_interact ; // double between 0 and 1 that describes the fraction of events forced to undergo this process. -1 for disable
505- int non_isotropic_rot_index ; // -1 if process is isotrpic, otherwise is the index of the process rotation matrix in the volume
506- int needs_cross_section_focus ; // 1 if physics_my needs to call focus functions, otherwise -1
507- Rotation rotation_matrix ; // rotation matrix of process, reported by component in local frame, transformed and moved to volume struct in main
508-
509- union data_transfer_union data_transfer ; // The way to reach the storage space allocated for this process (see examples in process.comp files)
510-
511- // probability_for_scattering_functions calculates this probability given k_i and parameters
512- int (* probability_for_scattering_function )(double * ,double * ,union data_transfer_union ,struct focus_data_struct * , _class_particle * _particle );
513- // prop, k_i, ,parameters , focus data / function
514-
515- // A scattering_function takes k_i and parameters, returns k_f
516- int (* scattering_function )(double * ,double * ,double * ,union data_transfer_union ,struct focus_data_struct * , _class_particle * _particle );
517- // k_f, k_i, weight, parameters , focus data / function
518- };
519-
520- //Utility function for initialising a scattering_process_struct with default
521- //values:
522- void scattering_process_struct_init ( struct scattering_process_struct * sps )
513+ char name [256 ]; // User defined process name
514+ enum process eProcess ; // enum value corresponding to this process GPU
515+ double process_p_interact ; // double between 0 and 1 that describes the fraction of events forced to undergo this process. -1 for disable
516+ int non_isotropic_rot_index ; // -1 if process is isotrpic, otherwise is the index of the process rotation matrix in the volume
517+ int needs_cross_section_focus ; // 1 if physics_my needs to call focus functions, otherwise -1
518+ int needs_numerical_integration ; // 1 if the process is inhomogenous and therefore needs numerical integration, otherwise -1.
519+ Rotation rotation_matrix ; // rotation matrix of process, reported by component in local frame, transformed and moved to volume struct in main
520+ double * inhomogenous_cumul_prob ; // The cumulative probability of a process in case of inhomogenous processes
521+ double * inhomogenous_distances ; // The distance of each step in which the cumulative probabilities will be calculated.
522+ double * inhomogenous_cumul_distances ; // The cumulative distances
523+ double * inhomogenous_mu ; // The different attenuation coefficients that are sampled in the numerical integration
524+ double * inhomogenous_prob ; // The probability of the process at the different sampled points.
525+ double * inhomogenous_t ; // The different times at which mu must be sampled.
526+ int sampling_points ; // Maximum number of samplings performed. If it is -1, no sampling has been done, and the arrays must be malloc'ed.
527+ union data_transfer_union data_transfer ; // The way to reach the storage space allocated for this process (see examples in process.comp files)
528+
529+ // probability_for_scattering_functions calculates this probability given k_i and parameters
530+ int (* probability_for_scattering_function )(double * , double * , union data_transfer_union , struct focus_data_struct * , _class_particle * _particle );
531+ // prop, k_i, ,parameters , focus data / function
532+
533+ // A scattering_function takes k_i and parameters, returns k_f
534+ int (* scattering_function )(double * , double * , double * , union data_transfer_union , struct focus_data_struct * , _class_particle * _particle );
535+ // k_f, k_i, weight, parameters , focus data / function
536+ };
537+
538+ // Utility function for initialising a scattering_process_struct with default
539+ // values:
540+ void scattering_process_struct_init (struct scattering_process_struct * sps )
523541{
524- memset (sps ,0 , sizeof (struct scattering_process_struct ));// catch all
542+ memset (sps , 0 , sizeof (struct scattering_process_struct )); // catch all
525543 sps -> name [0 ] = '\0' ;
526544 sps -> probability_for_scattering_function = NULL ;
527545 sps -> scattering_function = NULL ;
528546 sps -> non_isotropic_rot_index = -1 ;
529547 sps -> needs_cross_section_focus = -1 ;
548+ sps -> needs_numerical_integration = -1 ;
549+ sps -> sampling_points = -1 ;
530550}
531551
552+
532553union surface_data_transfer_union
533554{
534555 struct Mirror_surface_storage_struct * pointer_to_a_Mirror_surface_storage_struct ;
0 commit comments