Skip to content

Commit

Permalink
Updated Union process for Single crystal to have three random rotatio…
Browse files Browse the repository at this point in the history
…ns for the powder mode instead of just one.
  • Loading branch information
Mads Bertelsen committed Nov 20, 2023
1 parent 9006146 commit c06f100
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions mcstas-comps/union/Single_crystal_process.comp
Original file line number Diff line number Diff line change
Expand Up @@ -719,16 +719,18 @@ SHARE

/* Functions for "reorientation", powder and PG modes */
/* Powder, forward */
void randrotate_union(double *nx, double *ny, double *nz, double a, double b) {
double nvx, nvy, nvz;
rotate(nvx,nvy,nvz, *nx, *ny, *nz, a, 1, 0, 0);
rotate(*nx,*ny,*nz, nvx,nvy,nvz, b, 0, 1, 0);
void randrotate_union(double *nx, double *ny, double *nz, double a, double b, double c) {
double x1, y1, z1, x2, y2, z2;
rotate(x1, y1, z1, *nx,*ny,*nz, a, 1, 0, 0); /* <1> = rot(<n>,a) */
rotate(x2, y2, z2, x1, y1, z1, b, 0, 1, 0); /* <2> = rot(<1>,b) */
rotate(*nx,*ny,*nz, x2, y2, z2, c, 0, 0, 1); /* <n> = rot(<2>,c) */
}
/* Powder, back */
void randderotate_union(double *nx, double *ny, double *nz, double a, double b) {
double nvx, nvy, nvz;
rotate(nvx,nvy,nvz,*nx,*ny,*nz, -b, 0, 1, 0);
rotate(*nx, *ny, *nz, nvx,nvy,nvz, -a, 1, 0, 0);
void randderotate_union(double *nx, double *ny, double *nz, double a, double b, double c) {
double x1, y1, z1, x2, y2, z2;
rotate(x1, y1, z1, *nx,*ny,*nz, -c, 0,0,1);
rotate(x2, y2, z2, x1, y1, z1, -b, 0,1,0);
rotate(*nx,*ny,*nz, x2, y2, z2, -a, 1,0,0);
}
/* PG, forward */
void PGrotate_union(double *nx, double *ny, double *nz, double a, double csx, double csy, double csz) {
Expand Down Expand Up @@ -760,6 +762,7 @@ struct Single_crystal_physics_storage_struct{
double powder_setting; // 0 if powder mode is disabled, 1 if enabled. Values between approximates texture?
double Alpha; // random angle between 0 and 2*Pi*powder
double Beta; // random angle between -Pi/2 and Pi/2
double Gamma; // random angle between -Pi and Pi

struct hkl_info_struct_union *hkl_info_storage; // struct containing all necessary info for SC
double pack; // packing factor
Expand All @@ -775,19 +778,19 @@ int Single_crystal_physics_my(double *my, double *k_initial, union data_transfer

struct hkl_info_struct_union *hkl_info = data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->hkl_info_storage;

// Need the Powder/PG/curvature mode rotate added here

// Taken from Single_crystal and changed hkl_info to a pointer.
// The split optimization is less useful here than normally

if (data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->powder_setting) {
//orientation of crystallite is random
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Alpha = randpm1()*PI*data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->powder_setting;
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Beta = randpm1()*PI/2;
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Gamma = randpm1()*PI;

randrotate_union(&kix, &kiy, &kiz,
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Alpha,
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Beta);
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Beta,
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Gamma);
}
if (data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->PG_setting) {
// orientation of crystallite is random
Expand Down Expand Up @@ -831,8 +834,6 @@ int Single_crystal_physics_my(double *my, double *k_initial, union data_transfer
hkl_info->coh_xsect = coh_xsect;
hkl_info->nb_refl += hkl_info->tau_count;
hkl_info->nb_refl_count++;


}

/* (3). Probabilities of the different possible interactions. */
Expand Down Expand Up @@ -925,7 +926,10 @@ int Single_crystal_physics_scattering(double *k_final, double *k_initial, double

if (data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->powder_setting) {
// orientation of crystallite is no longer random
randderotate_union(&k_final[0], &k_final[1], &k_final[2], data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Alpha, data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Beta);
randderotate_union(&k_final[0], &k_final[1], &k_final[2],
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Alpha,
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Beta,
data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->Gamma);
}
if (data_transfer.pointer_to_a_Single_crystal_physics_storage_struct->PG_setting) {
// orientation of crystallite is longer random
Expand Down

0 comments on commit c06f100

Please sign in to comment.