Skip to content

Commit

Permalink
Allow Bent to compile on GPU/OpenACC
Browse files Browse the repository at this point in the history
  • Loading branch information
willend committed Sep 4, 2024
1 parent b8ea4ee commit 47a6cb2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mcstas-comps/contrib/Monochromator_bent.comp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ SHARE
return x*x;
}
// Function to generate numbers in a uniform distribution
double random_normal_distribution(double* sigma){
double random_normal_distribution(double* sigma, _class_particle* _particle){
double u1, u2;
u1 = rand01();
u2 = rand01();
Expand Down Expand Up @@ -632,7 +632,7 @@ SHARE
/////////////// Function that finds at what time the neutron reflects
///////////////////////////////////////////////////////////////////////////
void find_time_of_reflection(struct Monochromator_values* mono,
struct neutron_values* neutron, int direction, int i){
struct neutron_values* neutron, int direction, int i, _class_particle* _particle){
if (mono->type==bent){
// Note: This equation can also be solved precisely as a quadratic equation in Bragg's law.
neutron->TOR[i] = -neutron->eps_zero[i]/(neutron->ki_size*neutron->beta[i]);
Expand Down Expand Up @@ -674,10 +674,10 @@ SHARE
/////////////// block
///////////////////////////////////////////////////////////////////////////
void choose_mosaic_block_angle(struct Monochromator_values* mono, struct neutron_values* neutron,
int direction, int i){
int direction, int i, _class_particle* _particle){
if (mono->type==bent_mosaic){
neutron->vert_angle[i] = random_normal_distribution(&mono->mosaicity_vertical);
neutron->horiz_angle[i] = random_normal_distribution(&mono->mosaicity_horizontal);
neutron->vert_angle[i] = random_normal_distribution(&mono->mosaicity_vertical, _particle);
neutron->horiz_angle[i] = random_normal_distribution(&mono->mosaicity_horizontal, _particle);
}
else {
neutron->vert_angle[i] = 0;
Expand Down Expand Up @@ -759,7 +759,7 @@ SHARE
/////////////// as well as the Bragg angle gradient for each lamella
///////////////////////////////////////////////////////////////////////////
void scan_lamellas(struct Monochromator_values* monochromator, struct neutron_values* neutron,
int current_lamella, int direction, int neutron_just_reflected){
int current_lamella, int direction, int neutron_just_reflected, _class_particle* _particle){
double t0, inner_t1, outer_t1;
double kinematic_reflectivity;
double r[3] = {neutron->r[0], neutron->r[1], neutron->r[2]};
Expand All @@ -769,14 +769,14 @@ SHARE
for (int i = current_lamella; i < monochromator->lamellas && i >= 0;){
get_crossing_times_of_lamellas(monochromator, neutron, direction, i);
transport_neutron_to_lamella_coordinates(monochromator, neutron, direction, i);
choose_mosaic_block_angle(monochromator, neutron, direction, i);
choose_mosaic_block_angle(monochromator, neutron, direction, i, _particle);
mos_temp = neutron->horiz_angle[i];
neutron->horiz_angle[i] = 0;
calculate_local_scattering_vector(monochromator, neutron, direction, &i);
calculate_epszero_and_beta(monochromator, neutron, direction, i);
neutron->horiz_angle[i] = mos_temp;
find_propability_of_reflection(monochromator, neutron, direction, i);
find_time_of_reflection(monochromator, neutron, direction, i);
find_time_of_reflection(monochromator, neutron, direction, i, _particle);
propagate_neutrons_to_point_of_reflection(neutron, i);
// Assign probabilities in arrays
if (!neutron_is_inside_monochromator(monochromator, neutron, i) ||
Expand Down Expand Up @@ -956,7 +956,7 @@ TRACE
if (!neutron_just_reflected) init_v_size = neutron.v_size;
// scan_lamellas calculates time of reflection, entry/exit times, probability of reflection,
//* accumulating_propability of reflection, as well as the Bragg angle gradient for each lamella
scan_lamellas(&monochromator, &neutron, current_lamella, direction, neutron_just_reflected);
scan_lamellas(&monochromator, &neutron, current_lamella, direction, neutron_just_reflected, _particle);
// Choose reflection condition depending on the whether the neutron is incoming or outgoing.
if (direction>0){
reflect_condition = neutron.accu_probs[monochromator.lamellas - 1]*rand01();
Expand Down

0 comments on commit 47a6cb2

Please sign in to comment.