From 685b31b0a8308bf6c846269af51aa41f0ffcac7e Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sun, 22 Aug 2021 13:28:19 -0700 Subject: [PATCH 01/45] Added tagged BCA output. Now particles carry tags and weights through calculation. --- src/bca.rs | 22 +++-- src/input.rs | 4 +- src/lib.rs | 236 +++++++++++++++++++++++++++++++++++++++++++++++- src/particle.rs | 19 +++- src/structs.rs | 2 +- 5 files changed, 267 insertions(+), 16 deletions(-) diff --git a/src/bca.rs b/src/bca.rs index 7ceaa15..82ed92a 100644 --- a/src/bca.rs +++ b/src/bca.rs @@ -377,15 +377,19 @@ pub fn choose_collision_partner(particle_1: &particle::Particle, ma //Choose recoil Z, M let (species_index, Z_recoil, M_recoil, Ec_recoil, Es_recoil, interaction_index) = material.choose(x_recoil, y_recoil, z_recoil); - - return (species_index, - particle::Particle::new( - M_recoil, Z_recoil, 0., Ec_recoil, Es_recoil, - x_recoil, y_recoil, z_recoil, - cosx, cosy, cosz, - false, options.track_recoil_trajectories, interaction_index - ) - ) + let mut new_particle = particle::Particle::new( + M_recoil, Z_recoil, 0., Ec_recoil, Es_recoil, + x_recoil, y_recoil, z_recoil, + cosx, cosy, cosz, + false, options.track_recoil_trajectories, interaction_index + ); + + // Carry through tag, weight, and tracked vector from originating particle + new_particle.weight = particle_1.weight; + new_particle.tag = particle_1.tag; + new_particle.tracked_vector = particle_1.tracked_vector; + + return (species_index, new_particle) } /// Calculate the distance of closest approach of two particles given a particular binary collision geometry. diff --git a/src/input.rs b/src/input.rs index 42a6779..9e4331a 100644 --- a/src/input.rs +++ b/src/input.rs @@ -395,7 +395,9 @@ where ::InputFileFormat: Deserialize<'static> + 'static { ux: cosx, uy: cosy, uz: cosz, - interaction_index + interaction_index, + weight: 1.0, + tag: 0, } ); } diff --git a/src/lib.rs b/src/lib.rs index bb3ba11..8159374 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,6 +123,226 @@ pub struct InputCompoundBCA { pub Eb2: *mut f64, } +#[derive(Debug)] +#[repr(C)] +pub struct InputTaggedBCA { + pub len: usize, + /// x y z + pub positions: *mut [f64; 3], + /// vx, vy, vz + pub velocities: *mut [f64; 3], + pub Z1: f64, + pub m1: f64, + pub Ec1: f64, + pub Es1: f64, + pub num_species_target: usize, + pub Z2: *mut f64, + pub m2: *mut f64, + pub n2: *mut f64, + pub Ec2: *mut f64, + pub Es2: *mut f64, + pub Eb2: *mut f64, + pub tags: *mut i32, + pub weights: *mut f64, +} + +#[derive(Debug)] +#[repr(C)] +pub struct OutputTaggedBCA { + pub len: usize, + pub particles: *mut [f64; 9], + pub weights: *mut f64, + pub tags: *mut i32 +} + +#[no_mangle] +pub extern "C" fn compound_tagged_bca_list_c(input: InputTaggedBCA) -> OutputTaggedBCA { + + let mut total_output = vec![]; + let mut output_tags = vec![]; + let mut output_weights = vec![]; + + #[cfg(feature = "distributions")] + let options = Options { + name: "test".to_string(), + track_trajectories: false, + track_recoils: true, + track_recoil_trajectories: false, + write_buffer_size: 8000, + weak_collision_order: 3, + suppress_deep_recoils: false, + high_energy_free_flight_paths: false, + electronic_stopping_mode: ElectronicStoppingMode::INTERPOLATED, + mean_free_path_model: MeanFreePathModel::LIQUID, + interaction_potential: vec![vec![InteractionPotential::KR_C]], + scattering_integral: vec![vec![ScatteringIntegral::MENDENHALL_WELLER]], + num_threads: 1, + num_chunks: 1, + use_hdf5: false, + root_finder: vec![vec![Rootfinder::DEFAULTNEWTON]], + track_displacements: false, + track_energy_losses: false, + energy_min: 0.0, + energy_max: 10.0, + energy_num: 11, + angle_min: 0.0, + angle_max: 90.0, + angle_num: 11, + x_min: 0.0, + y_min: -10.0, + z_min: -10.0, + x_max: 10.0, + y_max: 10.0, + z_max: 10.0, + x_num: 11, + y_num: 11, + z_num: 11, + }; + + #[cfg(not(feature = "distributions"))] + let options = Options { + name: "test".to_string(), + track_trajectories: false, + track_recoils: true, + track_recoil_trajectories: false, + write_buffer_size: 8000, + weak_collision_order: 3, + suppress_deep_recoils: false, + high_energy_free_flight_paths: false, + electronic_stopping_mode: ElectronicStoppingMode::INTERPOLATED, + mean_free_path_model: MeanFreePathModel::LIQUID, + interaction_potential: vec![vec![InteractionPotential::KR_C]], + scattering_integral: vec![vec![ScatteringIntegral::MENDENHALL_WELLER]], + num_threads: 1, + num_chunks: 1, + use_hdf5: false, + root_finder: vec![vec![Rootfinder::DEFAULTNEWTON]], + track_displacements: false, + track_energy_losses: false, + }; + + let Z2 = unsafe { slice::from_raw_parts(input.Z2, input.num_species_target).to_vec() }; + let m2 = unsafe { slice::from_raw_parts(input.m2, input.num_species_target).to_vec() }; + let n2 = unsafe { slice::from_raw_parts(input.n2, input.num_species_target).to_vec() }; + let Ec2 = unsafe { slice::from_raw_parts(input.Ec2, input.num_species_target).to_vec() }; + let Es2 = unsafe { slice::from_raw_parts(input.Es2, input.num_species_target).to_vec() }; + let Eb2 = unsafe { slice::from_raw_parts(input.Eb2, input.num_species_target).to_vec() }; + let positions = unsafe { slice::from_raw_parts(input.positions, input.num_species_target).to_vec() }; + let tags = unsafe { slice::from_raw_parts(input.tags, input.num_species_target).to_vec() }; + let weights = unsafe { slice::from_raw_parts(input.weights, input.num_species_target).to_vec() }; + + let x = -2.*(n2.iter().sum::()*10E30).powf(-1./3.); + let y = 0.0; + let z = 0.0; + + let material_parameters = material::MaterialParameters { + energy_unit: "EV".to_string(), + mass_unit: "AMU".to_string(), + Eb: Eb2, + Es: Es2, + Ec: Ec2, + Z: Z2, + m: m2, + interaction_index: vec![0; input.num_species_target], + surface_binding_model: SurfaceBindingModel::AVERAGE, + bulk_binding_model: BulkBindingModel::INDIVIDUAL, + }; + + let geometry_input = geometry::Mesh0DInput { + length_unit: "ANGSTROM".to_string(), + densities: n2, + electronic_stopping_correction_factor: 1.0 + }; + + let m = material::Material::::new(&material_parameters, &geometry_input); + + let velocities = unsafe { slice::from_raw_parts(input.velocities, input.len) }; + + let mut index: usize = 0; + for velocity in velocities { + + let vx = velocity[0]; + let vy = velocity[1]; + let vz = velocity[2]; + + let v = (vx*vx + vy*vy + vz*vz).sqrt(); + + let E1 = 0.5*input.m1*AMU*v*v; + + let ux = vx/v; + let uy = vy/v; + let uz = vz/v; + + let p = particle::Particle { + m: input.m1*AMU, + Z: input.Z1, + E: E1, + Ec: input.Ec1*EV, + Es: input.Es1*EV, + pos: Vector::new(x, y, z), + dir: Vector::new(ux, uy, uz), + pos_origin: Vector::new(x, y, z), + pos_old: Vector::new(x, y, z), + dir_old: Vector::new(ux, uy, uz), + energy_origin: E1, + asymptotic_deflection: 0.0, + stopped: false, + left: false, + incident: true, + first_step: true, + trajectory: vec![], + energies: vec![], + track_trajectories: false, + number_collision_events: 0, + backreflected: false, + interaction_index : 0, + weight: weights[index], + tag: tags[index], + tracked_vector: Vector::new(positions[index][0], positions[index][1], positions[index][2]), + }; + + let output = bca::single_ion_bca(p, &m, &options); + + for particle in output { + + if (particle.left) | (particle.incident) { + total_output.push( + [ + particle.Z, + particle.m/AMU, + particle.E/EV, + + particle.tracked_vector.x/ANGSTROM, + particle.tracked_vector.y/ANGSTROM, + particle.tracked_vector.z/ANGSTROM, + + particle.dir.x, + particle.dir.y, + particle.dir.z + ] + ); + output_tags.push(particle.tag); + output_weights.push(particle.weight); + } + } + index += 1; + } + + let len = total_output.len(); + let particles = total_output.as_mut_ptr(); + let tags_ptr = output_tags.as_mut_ptr(); + let weights_ptr = output_weights.as_mut_ptr(); + + std::mem::forget(total_output); + OutputTaggedBCA { + len, + particles, + tags: tags_ptr, + weights: weights_ptr + } +} + + #[no_mangle] pub extern "C" fn simple_bca_list_c(input: InputSimpleBCA) -> OutputBCA { @@ -250,7 +470,10 @@ pub extern "C" fn simple_bca_list_c(input: InputSimpleBCA) -> OutputBCA { track_trajectories: false, number_collision_events: 0, backreflected: false, - interaction_index : 0 + interaction_index : 0, + weight: 1.0, + tag: 0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), }; @@ -420,7 +643,10 @@ pub extern "C" fn compound_bca_list_c(input: InputCompoundBCA) -> OutputBCA { track_trajectories: false, number_collision_events: 0, backreflected: false, - interaction_index : 0 + interaction_index : 0, + weight: 1.0, + tag: 0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), }; @@ -456,6 +682,7 @@ pub extern "C" fn compound_bca_list_c(input: InputCompoundBCA) -> OutputBCA { } } + #[no_mangle] pub extern "C" fn simple_bca_c(x: f64, y: f64, z: f64, ux: f64, uy: f64, uz: f64, E1: f64, Z1: f64, m1: f64, Ec1: f64, Es1: f64, Z2: f64, m2: f64, Ec2: f64, Es2: f64, n2: f64, Eb2: f64) -> OutputBCA { let mut output = simple_bca(x, y, z, ux, uy, uz, E1, Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, n2, Eb2); @@ -585,7 +812,10 @@ pub fn simple_bca(x: f64, y: f64, z: f64, ux: f64, uy: f64, uz: f64, E1: f64, Z1 track_trajectories: false, number_collision_events: 0, backreflected: false, - interaction_index : 0 + interaction_index : 0, + weight: 1.0, + tag: 0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), }; let material_parameters = material::MaterialParameters { diff --git a/src/particle.rs b/src/particle.rs index 7c73721..d9c5793 100644 --- a/src/particle.rs +++ b/src/particle.rs @@ -18,7 +18,9 @@ pub struct ParticleParameters { pub Es: Vec, pub pos: Vec<(f64, f64, f64)>, pub dir: Vec<(f64, f64, f64)>, - pub interaction_index: Vec + pub interaction_index: Vec, + pub weight: f64, + pub tag: i32, } #[cfg(not(feature = "hdf5_input"))] @@ -35,7 +37,9 @@ pub struct ParticleParameters { pub Es: Vec, pub pos: Vec<(f64, f64, f64)>, pub dir: Vec<(f64, f64, f64)>, - pub interaction_index: Vec + pub interaction_index: Vec, + pub weight: f64, + pub tag: i32, } /// HDF5 version of particle input. @@ -55,6 +59,8 @@ pub struct ParticleInput { pub uy: f64, pub uz: f64, pub interaction_index: usize, + pub weight: f64, + pub tag: i32, } /// Particle object. Particles in rustbca include incident ions and material atoms. @@ -82,6 +88,9 @@ pub struct Particle { pub number_collision_events: usize, pub backreflected: bool, pub interaction_index: usize, + pub weight: f64, + pub tag: i32, + pub tracked_vector: Vector, } impl Particle { /// Construct a particle object from input. @@ -118,6 +127,9 @@ impl Particle { number_collision_events: 0, backreflected: false, interaction_index: input.interaction_index, + weight: 1.0, + tag: 0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), } } @@ -148,6 +160,9 @@ impl Particle { number_collision_events: 0, backreflected: false, interaction_index, + weight: 1.0, + tag: 0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), } } diff --git a/src/structs.rs b/src/structs.rs index 8aa611a..2b9eb90 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,5 +1,5 @@ /// 3D vector. -#[derive(Clone)] +#[derive(Clone, Copy)] pub struct Vector { pub x: f64, pub y: f64, From 2893e51bb0ea008c32a534efe6557940e87c4712 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sun, 22 Aug 2021 13:40:50 -0700 Subject: [PATCH 02/45] Updated hdf5 section with new particle data. --- src/input.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/input.rs b/src/input.rs index 9e4331a..c1b531a 100644 --- a/src/input.rs +++ b/src/input.rs @@ -351,7 +351,10 @@ where ::InputFileFormat: Deserialize<'static> + 'static { ux: cosx, uy: cosy, uz: cosz, - interaction_index: interaction_index + interaction_index: interaction_index, + tag: 0, + weight: 1.0, + tracked_vector: Vector::new(0.0, 0.0, 0.0), } ); } From f9549abeddfb774afabd36b7037977c5f74bc3c3 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sun, 22 Aug 2021 13:50:50 -0700 Subject: [PATCH 03/45] small fix to hdf5 particle input. --- src/input.rs | 1 - src/tests.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/input.rs b/src/input.rs index c1b531a..43cb185 100644 --- a/src/input.rs +++ b/src/input.rs @@ -354,7 +354,6 @@ where ::InputFileFormat: Deserialize<'static> + 'static { interaction_index: interaction_index, tag: 0, weight: 1.0, - tracked_vector: Vector::new(0.0, 0.0, 0.0), } ); } diff --git a/src/tests.rs b/src/tests.rs index f93667b..ea34548 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -249,8 +249,6 @@ fn test_distributions() { let cosz = 0.0; let mut particle = particle::Particle::new(mass, Z, E, Ec, Es, x, y, z, cosx, cosy, cosz, false, false, 0); - - let mut distributions = output::Distributions::new(&options); assert_eq!(distributions.x_range[0], 0.); assert_eq!(distributions.x_range[distributions.x_range.len() - 1], 10.); From bb5c48ab773188f97acabb1eab3be5afb0b48da5 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sun, 22 Aug 2021 14:03:54 -0700 Subject: [PATCH 04/45] Fixes to input deck - no need to have weight/tag in toml right now. --- src/particle.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/particle.rs b/src/particle.rs index d9c5793..f82b917 100644 --- a/src/particle.rs +++ b/src/particle.rs @@ -19,8 +19,6 @@ pub struct ParticleParameters { pub pos: Vec<(f64, f64, f64)>, pub dir: Vec<(f64, f64, f64)>, pub interaction_index: Vec, - pub weight: f64, - pub tag: i32, } #[cfg(not(feature = "hdf5_input"))] @@ -38,8 +36,6 @@ pub struct ParticleParameters { pub pos: Vec<(f64, f64, f64)>, pub dir: Vec<(f64, f64, f64)>, pub interaction_index: Vec, - pub weight: f64, - pub tag: i32, } /// HDF5 version of particle input. From 076c1e372a6a81e0bb3283588079be0990c277bd Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sun, 22 Aug 2021 14:29:37 -0700 Subject: [PATCH 05/45] Update to RustBCA.h. --- RustBCA.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/RustBCA.h b/RustBCA.h index f8cd52d..e89188b 100644 --- a/RustBCA.h +++ b/RustBCA.h @@ -97,8 +97,38 @@ struct InputCompoundBCA { double *Eb2; }; +struct OutputTaggedBCA { + uintptr_t len; + double (*particles)[9]; + double *weights; + int32_t *tags; +}; + +struct InputTaggedBCA { + uintptr_t len; + /// x y z + double (*positions)[3]; + /// vx, vy, vz + double (*velocities)[3]; + double Z1; + double m1; + double Ec1; + double Es1; + uintptr_t num_species_target; + double *Z2; + double *m2; + double *n2; + double *Ec2; + double *Es2; + double *Eb2; + int32_t *tags; + double *weights; +}; + extern "C" { +OutputTaggedBCA compound_tagged_bca_list_c(InputTaggedBCA input); + OutputBCA simple_bca_list_c(InputSimpleBCA input); OutputBCA compound_bca_list_c(InputCompoundBCA input); From 378ffd823d1d57754fd1d03bfcaf3d574c666219 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Thu, 16 Sep 2021 15:07:07 -0700 Subject: [PATCH 06/45] Added single ion reflection routine for compound targets. --- src/lib.rs | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bb3ba11..526722f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,9 @@ use std::fs::OpenOptions; use std::io::prelude::*; use std::io::BufWriter; +//C integer +use std::os::raw::c_int; + //standard slice use std::slice; @@ -123,6 +126,109 @@ pub struct InputCompoundBCA { pub Eb2: *mut f64, } +#[no_mangle] +pub extern "C" fn print_integer(i: f64) { + + println!("{}", i); +} + +#[no_mangle] +pub extern "C" fn reflect_single_ion_c(num_species_target: &mut i32, ux: &mut f64, uy: &mut f64, uz: &mut f64, E1: &mut f64, Z1: &mut f64, m1: &mut f64, Ec1: &mut f64, Es1: &mut f64, Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64) { + + assert!(ux*ux + uy*uy + uz*uz <= 1.0); + assert!(E1 > 0.0); + + let options = Options { + name: "test".to_string(), + track_trajectories: false, + track_recoil_trajectories: false, + track_recoils: false, + write_buffer_size: 8000, + weak_collision_order: 3, + suppress_deep_recoils: false, + high_energy_free_flight_paths: false, + electronic_stopping_mode: ElectronicStoppingMode::INTERPOLATED, + mean_free_path_model: MeanFreePathModel::LIQUID, + interaction_potential: vec![vec![InteractionPotential::KR_C]], + scattering_integral: vec![vec![ScatteringIntegral::MENDENHALL_WELLER]], + num_threads: 1, + num_chunks: 1, + use_hdf5: false, + root_finder: vec![vec![Rootfinder::DEFAULTNEWTON]], + track_displacements: false, + track_energy_losses: false, + }; + + + let Z2 = unsafe { slice::from_raw_parts(Z2, *num_species_target as usize).to_vec() }; + let m2 = unsafe { slice::from_raw_parts(m2, *num_species_target as usize).to_vec() }; + let n2 = unsafe { slice::from_raw_parts(n2, *num_species_target as usize).to_vec() }; + let Ec2 = unsafe { slice::from_raw_parts(Ec2, *num_species_target as usize).to_vec() }; + let Es2 = unsafe { slice::from_raw_parts(Es2, *num_species_target as usize).to_vec() }; + let Eb2 = unsafe { slice::from_raw_parts(Eb2, *num_species_target as usize).to_vec() }; + + let x = -2.*(n2.iter().sum::()*10E30).powf(-1./3.); + let y = 0.0; + let z = 0.0; + + let material_parameters = material::MaterialParameters { + energy_unit: "EV".to_string(), + mass_unit: "AMU".to_string(), + Eb: Eb2, + Es: Es2, + Ec: Ec2, + Z: Z2, + m: m2, + interaction_index: vec![0; *num_species_target as usize], + surface_binding_model: SurfaceBindingModel::AVERAGE, + bulk_binding_model: BulkBindingModel::INDIVIDUAL, + }; + + let geometry_input = geometry::Mesh0DInput { + length_unit: "ANGSTROM".to_string(), + densities: n2, + electronic_stopping_correction_factor: 1.0 + }; + + let m = material::Material::::new(&material_parameters, &geometry_input); + + let p = particle::Particle { + m: *m1*AMU, + Z: *Z1, + E: *E1*EV, + Ec: *Ec1*EV, + Es: *Es1*EV, + pos: Vector::new(x, y, z), + dir: Vector::new(*ux, *uy, *uz), + pos_origin: Vector::new(x, y, z), + pos_old: Vector::new(x, y, z), + dir_old: Vector::new(*ux, *uy, *uz), + energy_origin: *E1, + asymptotic_deflection: 0.0, + stopped: false, + left: false, + incident: true, + first_step: true, + trajectory: vec![], + energies: vec![], + track_trajectories: false, + number_collision_events: 0, + backreflected: false, + interaction_index : 0 + }; + + let output = bca::single_ion_bca(p, &m, &options); + + *ux = output[0].dir.x; + *uy = output[0].dir.y; + *uz = output[0].dir.z; + if output[0].pos.x >= 0.0 { + *E1 = 0.0 + } else { + *E1 = output[0].E; + } +} + #[no_mangle] pub extern "C" fn simple_bca_list_c(input: InputSimpleBCA) -> OutputBCA { From 2785b4fa670e93bd2d95fa3338503fc107bd95d3 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Thu, 16 Sep 2021 15:16:53 -0700 Subject: [PATCH 07/45] Included Fortran module with interface to reflection_single_ion. --- rustbca.f90 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 rustbca.f90 diff --git a/rustbca.f90 b/rustbca.f90 new file mode 100644 index 0000000..194e0aa --- /dev/null +++ b/rustbca.f90 @@ -0,0 +1,18 @@ +module rustbca + + interface + + subroutine reflect_single_ion_c(num_species_target, ux, uy, uz, E1, & + Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, Eb2, n2) bind(c) + + use, intrinsic :: iso_c_binding + real(c_double), intent(inout) :: ux, uy, uz, E1 + real(c_double), intent(in) :: Z1, m1, Ec1, Es1 + integer(c_int), intent(in) :: num_species_target + real(c_double), intent(in), dimension(*) :: Z2, m2, Ec2, Es2, Eb2, n2 + + end subroutine reflect_single_ion_c + + end interface + +end module rustbca \ No newline at end of file From d74912e6ec8d485b3fc5f1831797239e465764ae Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Thu, 16 Sep 2021 16:07:32 -0700 Subject: [PATCH 08/45] Added docstrings to rustbca module. --- rustbca.f90 | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/rustbca.f90 b/rustbca.f90 index 194e0aa..e898f7b 100644 --- a/rustbca.f90 +++ b/rustbca.f90 @@ -5,6 +5,24 @@ module rustbca subroutine reflect_single_ion_c(num_species_target, ux, uy, uz, E1, & Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, Eb2, n2) bind(c) + !Runs a single ion BCA trajectory with no recoils + !Args: + ! num_species_target (integer): number of species in target + ! ux (real): x-direction of incident ion, x-direction of reflected ion + ! uy (real): y-direction of incident ion, y-direction of reflected ion + ! uz (real): z-direction of incident ion, z-direction of reflected ion + ! E1 (real): initial energy of incident ion in eV + ! Z1 (real): atomic number of incident ion + ! m1 (real): atomic mass of incident ion in eV + ! Ec1 (real): cutoff energy of incident ion in eV + ! Es1 (real): surface binding energy of incident ion in eV + ! Z2 (array(real)): list of atomic numbers of target speciesd + ! m2 (array(real)): list of atomic masses of target species in amu + ! Ec2 (array(real)): list of cutoff energies of target species in eV + ! Es2 (array(real)): list of surface binding energies of target species in eV + ! Eb2 (array(real)): list of bulk binding energies of target species in eV + ! n2 (array(real)): list of number densities of target species in 1/angstrom^3 + use, intrinsic :: iso_c_binding real(c_double), intent(inout) :: ux, uy, uz, E1 real(c_double), intent(in) :: Z1, m1, Ec1, Es1 @@ -15,4 +33,23 @@ end subroutine reflect_single_ion_c end interface + contains + + subroutine transform_to_local_angle(ux, uy, uz, alpha) + + !Rotates a vector in 2D + !Args: + ! ux (real): x-direction + ! uy (real): y-direction + ! uz (real): z-direction + ! alpha (real): local surface angle measured counter-clockwise from x-axis in radians + + real(8), intent(inout) :: ux, uy, uz + real(8), intent(in) :: alpha + + ux = ux*cos(alpha) - uy*sin(alpha) + uy = ux*sin(alpha) + uy*cos(alpha) + + end subroutine transform_to_local_angle + end module rustbca \ No newline at end of file From abe3612262e2fe8e850cb8a4347bafbd2d6a2383 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Fri, 17 Sep 2021 15:36:03 -0700 Subject: [PATCH 09/45] list input for Fortran. --- rustbca.f90 | 17 ++++- src/lib.rs | 185 +++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 191 insertions(+), 11 deletions(-) diff --git a/rustbca.f90 b/rustbca.f90 index e898f7b..b0b3356 100644 --- a/rustbca.f90 +++ b/rustbca.f90 @@ -1,4 +1,6 @@ module rustbca + + use, intrinsic :: iso_c_binding interface @@ -30,7 +32,20 @@ subroutine reflect_single_ion_c(num_species_target, ux, uy, uz, E1, & real(c_double), intent(in), dimension(*) :: Z2, m2, Ec2, Es2, Eb2, n2 end subroutine reflect_single_ion_c - + + function compound_bca_list_fortran(num_incident_ions, ux, uy, uz, E1, & + Z1, m1, Ec1, Es1, & + num_species_target, Z2, m2, Ec2, Es2, Eb2, n2, & + num_emitted_particles) bind(c) result(output) + + use, intrinsic :: iso_c_binding + integer(c_int), intent(in) :: num_incident_ions, num_species_target + integer(c_int), intent(out) :: num_emitted_particles + real(c_double), intent(in), dimension(*) :: ux, uy, uz, E1, Z1, m1, Ec1, Es1 + real(c_double), intent(in), dimension(*) :: Z2, m2, Ec2, Es2, EB2, n2 + type(c_ptr) :: output + end function compound_bca_list_fortran + end interface contains diff --git a/src/lib.rs b/src/lib.rs index 526722f..5a17748 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,16 +127,9 @@ pub struct InputCompoundBCA { } #[no_mangle] -pub extern "C" fn print_integer(i: f64) { +pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut f64, uy: &mut f64, uz: &mut f64, E1: &mut f64, Z1: &mut f64, m1: &mut f64, Ec1: &mut f64, Es1: &mut f64, Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64) { - println!("{}", i); -} - -#[no_mangle] -pub extern "C" fn reflect_single_ion_c(num_species_target: &mut i32, ux: &mut f64, uy: &mut f64, uz: &mut f64, E1: &mut f64, Z1: &mut f64, m1: &mut f64, Ec1: &mut f64, Es1: &mut f64, Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64) { - - assert!(ux*ux + uy*uy + uz*uz <= 1.0); - assert!(E1 > 0.0); + assert!(E1 > &mut 0.0); let options = Options { name: "test".to_string(), @@ -159,7 +152,6 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut i32, ux: &mut f6 track_energy_losses: false, }; - let Z2 = unsafe { slice::from_raw_parts(Z2, *num_species_target as usize).to_vec() }; let m2 = unsafe { slice::from_raw_parts(m2, *num_species_target as usize).to_vec() }; let n2 = unsafe { slice::from_raw_parts(n2, *num_species_target as usize).to_vec() }; @@ -562,6 +554,179 @@ pub extern "C" fn compound_bca_list_c(input: InputCompoundBCA) -> OutputBCA { } } +#[no_mangle] +pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, + ux: *mut f64, uy: *mut f64, uz: *mut f64, E1: *mut f64, + Z1: *mut f64, m1: *mut f64, Ec1: *mut f64, Es1: *mut f64, + num_species_target: &mut c_int, + Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64, + num_emitted_particles: &mut c_int + ) -> *const [f64; 6] { + + //println!("{} {}", num_incident_ions, num_species_target); + + let mut total_output = vec![]; + + #[cfg(feature = "distributions")] + let options = Options { + name: "test".to_string(), + track_trajectories: false, + track_recoils: true, + track_recoil_trajectories: false, + write_buffer_size: 8000, + weak_collision_order: 3, + suppress_deep_recoils: false, + high_energy_free_flight_paths: false, + electronic_stopping_mode: ElectronicStoppingMode::INTERPOLATED, + mean_free_path_model: MeanFreePathModel::LIQUID, + interaction_potential: vec![vec![InteractionPotential::KR_C]], + scattering_integral: vec![vec![ScatteringIntegral::MENDENHALL_WELLER]], + num_threads: 1, + num_chunks: 1, + use_hdf5: false, + root_finder: vec![vec![Rootfinder::DEFAULTNEWTON]], + track_displacements: false, + track_energy_losses: false, + energy_min: 0.0, + energy_max: 10.0, + energy_num: 11, + angle_min: 0.0, + angle_max: 90.0, + angle_num: 11, + x_min: 0.0, + y_min: -10.0, + z_min: -10.0, + x_max: 10.0, + y_max: 10.0, + z_max: 10.0, + x_num: 11, + y_num: 11, + z_num: 11, + }; + + #[cfg(not(feature = "distributions"))] + let options = Options { + name: "test".to_string(), + track_trajectories: false, + track_recoils: true, + track_recoil_trajectories: false, + write_buffer_size: 8000, + weak_collision_order: 3, + suppress_deep_recoils: false, + high_energy_free_flight_paths: false, + electronic_stopping_mode: ElectronicStoppingMode::INTERPOLATED, + mean_free_path_model: MeanFreePathModel::LIQUID, + interaction_potential: vec![vec![InteractionPotential::KR_C]], + scattering_integral: vec![vec![ScatteringIntegral::MENDENHALL_WELLER]], + num_threads: 1, + num_chunks: 1, + use_hdf5: false, + root_finder: vec![vec![Rootfinder::DEFAULTNEWTON]], + track_displacements: false, + track_energy_losses: false, + }; + + let ux = unsafe { slice::from_raw_parts(ux, *num_incident_ions as usize).to_vec() }; + let uy = unsafe { slice::from_raw_parts(uy, *num_incident_ions as usize).to_vec() }; + let uz = unsafe { slice::from_raw_parts(uz, *num_incident_ions as usize).to_vec() }; + let Z1 = unsafe { slice::from_raw_parts(Z1, *num_incident_ions as usize).to_vec() }; + let m1 = unsafe { slice::from_raw_parts(m1, *num_incident_ions as usize).to_vec() }; + let E1 = unsafe { slice::from_raw_parts(E1, *num_incident_ions as usize).to_vec() }; + let Ec1 = unsafe { slice::from_raw_parts(Ec1, *num_incident_ions as usize).to_vec() }; + let Es1 = unsafe { slice::from_raw_parts(Es1, *num_incident_ions as usize).to_vec() }; + + //println!("ux: {} uy: {} uz: {} Z1: {} m1: {} E1: {} Ec1: {} Es1: {}", ux[0], uy[0], uz[0], Z1[0], m1[0], E1[0], Ec1[0], Es1[0]); + + let Z2 = unsafe { slice::from_raw_parts(Z2, *num_species_target as usize).to_vec() }; + let m2 = unsafe { slice::from_raw_parts(m2, *num_species_target as usize).to_vec() }; + let n2 = unsafe { slice::from_raw_parts(n2, *num_species_target as usize).to_vec() }; + let Ec2 = unsafe { slice::from_raw_parts(Ec2, *num_species_target as usize).to_vec() }; + let Es2 = unsafe { slice::from_raw_parts(Es2, *num_species_target as usize).to_vec() }; + let Eb2 = unsafe { slice::from_raw_parts(Eb2, *num_species_target as usize).to_vec() }; + + //println!("Z2: {} m2: {} n2: {} Ec2: {} Es2: {} Eb2: {}", Z2[0], m2[0], n2[0], Ec2[0], Es2[0], Eb2[0]); + + let x = -2.*(n2.iter().sum::()*10E30).powf(-1./3.); + let y = 0.0; + let z = 0.0; + + let material_parameters = material::MaterialParameters { + energy_unit: "EV".to_string(), + mass_unit: "AMU".to_string(), + Eb: Eb2, + Es: Es2, + Ec: Ec2, + Z: Z2, + m: m2, + interaction_index: vec![0; *num_species_target as usize], + surface_binding_model: SurfaceBindingModel::AVERAGE, + bulk_binding_model: BulkBindingModel::INDIVIDUAL, + }; + + let geometry_input = geometry::Mesh0DInput { + length_unit: "ANGSTROM".to_string(), + densities: n2, + electronic_stopping_correction_factor: 1.0 + }; + + let m = material::Material::::new(&material_parameters, &geometry_input); + + for (((((((E1_, ux_), uy_), uz_), Z1_), Ec1_), Es1_), m1_) in E1.iter().zip(ux).zip(uy).zip(uz).zip(Z1).zip(Ec1).zip(Es1).zip(m1) { + + let p = particle::Particle { + m: m1_*AMU, + Z: Z1_, + E: *E1_*EV, + Ec: Ec1_*EV, + Es: Es1_*EV, + pos: Vector::new(x, y, z), + dir: Vector::new(ux_, uy_, uz_), + pos_origin: Vector::new(x, y, z), + pos_old: Vector::new(x, y, z), + dir_old: Vector::new(ux_, uy_, uz_), + energy_origin: *E1_*EV, + asymptotic_deflection: 0.0, + stopped: false, + left: false, + incident: true, + first_step: true, + trajectory: vec![], + energies: vec![], + track_trajectories: false, + number_collision_events: 0, + backreflected: false, + interaction_index : 0 + }; + + let output = bca::single_ion_bca(p, &m, &options); + + for particle in output { + + if (particle.left) | (particle.incident) { + total_output.push( + [ + particle.Z, + particle.m/AMU, + particle.E/EV, + particle.dir.x, + particle.dir.y, + particle.dir.z + ] + ); + } + } + } + + let len = total_output.len(); + + let particles = total_output.as_mut_ptr(); + + std::mem::forget(total_output); + + *num_emitted_particles = len as c_int; + particles +} + #[no_mangle] pub extern "C" fn simple_bca_c(x: f64, y: f64, z: f64, ux: f64, uy: f64, uz: f64, E1: f64, Z1: f64, m1: f64, Ec1: f64, Es1: f64, Z2: f64, m2: f64, Ec2: f64, Es2: f64, n2: f64, Eb2: f64) -> OutputBCA { let mut output = simple_bca(x, y, z, ux, uy, uz, E1, Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, n2, Eb2); From ad530a24adf43bd9a061385e794b63479bf89fec Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 10:38:59 -0700 Subject: [PATCH 10/45] Added particle tracking components. --- src/lib.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5a17748..efb4708 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -206,7 +206,10 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut track_trajectories: false, number_collision_events: 0, backreflected: false, - interaction_index : 0 + interaction_index : 0, + weight: 1.0, + tag: 0, + tracked_vector: vec![], }; let output = bca::single_ion_bca(p, &m, &options); @@ -555,7 +558,7 @@ pub extern "C" fn compound_bca_list_c(input: InputCompoundBCA) -> OutputBCA { } #[no_mangle] -pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, +pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, track_recoils: &mut bool, ux: *mut f64, uy: *mut f64, uz: *mut f64, E1: *mut f64, Z1: *mut f64, m1: *mut f64, Ec1: *mut f64, Es1: *mut f64, num_species_target: &mut c_int, @@ -571,7 +574,7 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, let options = Options { name: "test".to_string(), track_trajectories: false, - track_recoils: true, + track_recoils: *track_recoils, track_recoil_trajectories: false, write_buffer_size: 8000, weak_collision_order: 3, @@ -608,7 +611,7 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, let options = Options { name: "test".to_string(), track_trajectories: false, - track_recoils: true, + track_recoils: *track_recoils, track_recoil_trajectories: false, write_buffer_size: 8000, weak_collision_order: 3, @@ -659,7 +662,7 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, Z: Z2, m: m2, interaction_index: vec![0; *num_species_target as usize], - surface_binding_model: SurfaceBindingModel::AVERAGE, + surface_binding_model: SurfaceBindingModel::INDIVIDUAL, bulk_binding_model: BulkBindingModel::INDIVIDUAL, }; @@ -695,7 +698,10 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, track_trajectories: false, number_collision_events: 0, backreflected: false, - interaction_index : 0 + interaction_index : 0, + weight: 1.0, + tag: 0, + tracked_vector: vec![], }; let output = bca::single_ion_bca(p, &m, &options); @@ -718,7 +724,6 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, } let len = total_output.len(); - let particles = total_output.as_mut_ptr(); std::mem::forget(total_output); From 8f2c2ec1de5dea4bf81fd5712d558eb3504734a4 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 10:43:50 -0700 Subject: [PATCH 11/45] Fix to tracking components. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index efb4708..d55f279 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,7 +209,7 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut interaction_index : 0, weight: 1.0, tag: 0, - tracked_vector: vec![], + tracked_vector: Vector::new(), }; let output = bca::single_ion_bca(p, &m, &options); @@ -701,7 +701,7 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, track interaction_index : 0, weight: 1.0, tag: 0, - tracked_vector: vec![], + tracked_vector: Vector::new(), }; let output = bca::single_ion_bca(p, &m, &options); From 3c8c6d2fa04cb08618b1b6658eee7a47faa97c35 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 10:47:41 -0700 Subject: [PATCH 12/45] Further fixes. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d55f279..6753729 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,7 +209,7 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut interaction_index : 0, weight: 1.0, tag: 0, - tracked_vector: Vector::new(), + tracked_vector: Vector::new(0.0, 0.0, 0.0), }; let output = bca::single_ion_bca(p, &m, &options); @@ -701,7 +701,7 @@ pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, track interaction_index : 0, weight: 1.0, tag: 0, - tracked_vector: Vector::new(), + tracked_vector: Vector::new(0.0, 0.0, 0.0) }; let output = bca::single_ion_bca(p, &m, &options); From 327060f16a5ca7c19758e72825c69273432b4593 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 10:57:23 -0700 Subject: [PATCH 13/45] Further fixes. --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 6753729..f35026e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -127,6 +127,7 @@ pub struct InputCompoundBCA { } #[no_mangle] +#[cfg(not(feature = "distributions"))] pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut f64, uy: &mut f64, uz: &mut f64, E1: &mut f64, Z1: &mut f64, m1: &mut f64, Ec1: &mut f64, Es1: &mut f64, Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64) { assert!(E1 > &mut 0.0); From 8d187d1cea34707dead447a378c2f76b8dd427bb Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 11:11:55 -0700 Subject: [PATCH 14/45] Updates to Fortran wrappers. --- rustbca.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rustbca.f90 b/rustbca.f90 index b0b3356..0092349 100644 --- a/rustbca.f90 +++ b/rustbca.f90 @@ -33,12 +33,13 @@ subroutine reflect_single_ion_c(num_species_target, ux, uy, uz, E1, & end subroutine reflect_single_ion_c - function compound_bca_list_fortran(num_incident_ions, ux, uy, uz, E1, & + function compound_bca_list_fortran(num_incident_ions, track_recoils, ux, uy, uz, E1, & Z1, m1, Ec1, Es1, & num_species_target, Z2, m2, Ec2, Es2, Eb2, n2, & num_emitted_particles) bind(c) result(output) use, intrinsic :: iso_c_binding + logical(c_bool), intent(in) :: track_recoils integer(c_int), intent(in) :: num_incident_ions, num_species_target integer(c_int), intent(out) :: num_emitted_particles real(c_double), intent(in), dimension(*) :: ux, uy, uz, E1, Z1, m1, Ec1, Es1 From de118976414800b802f62d4a7c4f8b884d81ead2 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 20 Sep 2021 13:44:47 -0700 Subject: [PATCH 15/45] Added docstring to fortran bca function. --- rustbca.f90 | 60 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/rustbca.f90 b/rustbca.f90 index 0092349..681a78c 100644 --- a/rustbca.f90 +++ b/rustbca.f90 @@ -10,20 +10,20 @@ subroutine reflect_single_ion_c(num_species_target, ux, uy, uz, E1, & !Runs a single ion BCA trajectory with no recoils !Args: ! num_species_target (integer): number of species in target - ! ux (real): x-direction of incident ion, x-direction of reflected ion - ! uy (real): y-direction of incident ion, y-direction of reflected ion - ! uz (real): z-direction of incident ion, z-direction of reflected ion - ! E1 (real): initial energy of incident ion in eV - ! Z1 (real): atomic number of incident ion - ! m1 (real): atomic mass of incident ion in eV - ! Ec1 (real): cutoff energy of incident ion in eV - ! Es1 (real): surface binding energy of incident ion in eV - ! Z2 (array(real)): list of atomic numbers of target speciesd - ! m2 (array(real)): list of atomic masses of target species in amu - ! Ec2 (array(real)): list of cutoff energies of target species in eV - ! Es2 (array(real)): list of surface binding energies of target species in eV - ! Eb2 (array(real)): list of bulk binding energies of target species in eV - ! n2 (array(real)): list of number densities of target species in 1/angstrom^3 + ! ux (real(c_double)): x-direction of incident ion, x-direction of reflected ion + ! uy (real(c_double)): y-direction of incident ion, y-direction of reflected ion + ! uz (real(c_double)): z-direction of incident ion, z-direction of reflected ion + ! E1 (real(c_double)): initial energy of incident ion in eV + ! Z1 (real(c_double)): atomic number of incident ion + ! m1 (real(c_double)): atomic mass of incident ion in eV + ! Ec1 (real(c_double)): cutoff energy of incident ion in eV + ! Es1 (real(c_double)): surface binding energy of incident ion in eV + ! Z2 (real(c_double), dimension(:)): list of atomic numbers of target speciesd + ! m2 (real(c_double), dimension(:)): list of atomic masses of target species in amu + ! Ec2 (real(c_double), dimension(:)): list of cutoff energies of target species in eV + ! Es2 (real(c_double), dimension(:)): list of surface binding energies of target species in eV + ! Eb2 (real(c_double), dimension(:)): list of bulk binding energies of target species in eV + ! n2 (real(c_double), dimension(:)): list of number densities of target species in 1/angstrom^3 use, intrinsic :: iso_c_binding real(c_double), intent(inout) :: ux, uy, uz, E1 @@ -38,6 +38,30 @@ function compound_bca_list_fortran(num_incident_ions, track_recoils, ux, uy, uz, num_species_target, Z2, m2, Ec2, Es2, Eb2, n2, & num_emitted_particles) bind(c) result(output) + + !Runs a homogeneous, flat, compound target BCA with an arbitrary list of ions. + !Args: + ! num_incident_ion (integer(c_int)): number of incident ions + ! track_recoils (logical(c_bool)): whether to generate recoils (disable to turn off sputtering) + ! ux (real(c_double), dimension(:)): x-direction of incident ion, x-direction of reflected ion + ! uy (real(c_double), dimension(:)): y-direction of incident ion, y-direction of reflected ion + ! uz (real(c_double), dimension(:)): z-direction of incident ion, z-direction of reflected ion + ! E1 (real(c_double), dimension(:)): initial energy of incident ion in eV + ! Z1 (real(c_double), dimension(:)): atomic number of incident ion + ! m1 (real(c_double), dimension(:)): atomic mass of incident ion in eV + ! Ec1 (real(c_double), dimension(:)): cutoff energy of incident ion in eV + ! num_species_target(integer(c_int)): number of species in target + ! Es1 (real(c_double), dimension(:)): surface binding energy of incident ion in eV + ! Z2 (real(c_double), dimension(:)): list of atomic numbers of target speciesd + ! m2 (real(c_double), dimension(:)): list of atomic masses of target species in amu + ! Ec2 (real(c_double), dimension(:)): list of cutoff energies of target species in eV + ! Es2 (real(c_double), dimension(:)): list of surface binding energies of target species in eV + ! Eb2 (real(c_double), dimension(:)): list of bulk binding energies of target species in eV + ! n2 (real(c_double), dimension(:)): list of number densities of target species in 1/angstrom^3 + ! num_emitted_particles (integer(c_int), intent(out)): NOTE THAT THIS IS INTENT(OUT) number of emitted particles in output + !Returns: + ! output (type(c_ptr)): a c pointer to a 2D array of size (num_emitted_particles, 6) that consists of Z, m, E, ux, uy, uz + use, intrinsic :: iso_c_binding logical(c_bool), intent(in) :: track_recoils integer(c_int), intent(in) :: num_incident_ions, num_species_target @@ -55,10 +79,10 @@ subroutine transform_to_local_angle(ux, uy, uz, alpha) !Rotates a vector in 2D !Args: - ! ux (real): x-direction - ! uy (real): y-direction - ! uz (real): z-direction - ! alpha (real): local surface angle measured counter-clockwise from x-axis in radians + ! ux (real(c_double)): x-direction + ! uy (real(c_double)): y-direction + ! uz (real(c_double)): z-direction + ! alpha (real(c_double)): local surface angle measured counter-clockwise from x-axis in radians real(8), intent(inout) :: ux, uy, uz real(8), intent(in) :: alpha From 862981c60813acb2214c6f5c0005199dbb916fbd Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:41:21 -0700 Subject: [PATCH 16/45] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fa02929..7222cc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "RustBCA" -version = "1.1.0" +version = "1.1.2" authors = ["Jon Drobny "] edition = "2018" From b434775f0c3606f5a9cb6d50d74be23dfc96f2c0 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Thu, 14 Oct 2021 14:08:35 -0700 Subject: [PATCH 17/45] New feature: particle distributions. Is backwards compatible, thanks to serde's untagged attribute, which will pattern match even if enum tags are missin. --- Cargo.toml | 1 + src/enums.rs | 8 +++++ src/input.rs | 96 ++++++++++++++++++++++++++++++++++++++----------- src/main.rs | 3 -- src/particle.rs | 13 ++++--- 5 files changed, 91 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7222cc7..d63f803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ crate-type = ["cdylib"] [dependencies] rand = "0.8.3" +rand_distr = "0.4.2" toml = "0.5.8" anyhow = "1.0.38" itertools = "0.10.0" diff --git a/src/enums.rs b/src/enums.rs index 07a7cbd..272e923 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -11,6 +11,14 @@ pub enum MaterialType { TRIMESH(material::Material) } +#[derive(Deserialize, PartialEq, Clone, Copy)] +#[serde(untagged)] +pub enum Distributions { + UNIFORM{min: f64, max: f64}, + NORMAL{mean: f64, std: f64}, + POINT(f64), +} + #[derive(Deserialize)] pub enum GeometryType { MESH0D, diff --git a/src/input.rs b/src/input.rs index 43cb185..a07dfc4 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,4 +1,5 @@ use super::*; +use rand_distr::{Normal, Distribution, Uniform}; pub trait InputFile: GeometryInput { fn new(string: &str) -> Self; @@ -332,25 +333,53 @@ where ::InputFileFormat: Deserialize<'static> + 'static { let Ec = particle_parameters.Ec[particle_index]; let Es = particle_parameters.Es[particle_index]; let interaction_index = particle_parameters.interaction_index[particle_index]; + let (x, y, z) = particle_parameters.pos[particle_index]; let (cosx, cosy, cosz) = particle_parameters.dir[particle_index]; - assert!(cosx < 1., - "Input error: particle x-direction cannot be exactly equal to 1 to avoid numerical gimbal lock."); + for sub_particle_index in 0..N_ { //Add new particle to particle vector particle_input.push( particle::ParticleInput{ m: m*mass_unit, Z: Z, - E: E*energy_unit, + E: match E { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*energy_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*energy_unit}, + Distributions::POINT(x) => x*energy_unit, + }, Ec: Ec*energy_unit, Es: Es*energy_unit, - x: x*length_unit, - y: y*length_unit, - z: z*length_unit, - ux: cosx, - uy: cosy, - uz: cosz, + x: match x { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + y: match y { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + z: match z { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + ux: match cosx { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => {assert!(x != 1.0, "ux cannot equal exactly 1.0 to prevent gimbal lock"); x*length_unit} + }, + uy: match cosy { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + uz: match cosz { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, interaction_index: interaction_index, tag: 0, weight: 1.0, @@ -379,8 +408,7 @@ where ::InputFileFormat: Deserialize<'static> + 'static { let interaction_index = particle_parameters.interaction_index[particle_index]; let (x, y, z) = particle_parameters.pos[particle_index]; let (cosx, cosy, cosz) = particle_parameters.dir[particle_index]; - assert!(cosx < 1., - "Input error: particle x-direction cannot be exactly equal to 1 to avoid numerical gimbal lock."); + for sub_particle_index in 0..N_ { //Add new particle to particle vector @@ -388,18 +416,46 @@ where ::InputFileFormat: Deserialize<'static> + 'static { particle::ParticleInput{ m: m*mass_unit, Z: Z, - E: E*energy_unit, + E: match E { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*energy_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*energy_unit}, + Distributions::POINT(x) => x*energy_unit, + }, Ec: Ec*energy_unit, Es: Es*energy_unit, - x: x*length_unit, - y: y*length_unit, - z: z*length_unit, - ux: cosx, - uy: cosy, - uz: cosz, - interaction_index, - weight: 1.0, + x: match x { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + y: match y { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + z: match z { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + ux: match cosx { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => {assert!(x != 1.0, "ux cannot equal exactly 1.0 to prevent gimbal lock"); x*length_unit}, + }, + uy: match cosy { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + uz: match cosz { + Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rand::thread_rng())*length_unit}, + Distributions::UNIFORM{min, max} => {let uniform = Uniform::from(min..max); uniform.sample(&mut rand::thread_rng())*length_unit}, + Distributions::POINT(x) => x*length_unit, + }, + interaction_index: interaction_index, tag: 0, + weight: 1.0, } ); } diff --git a/src/main.rs b/src/main.rs index 5eeb94a..e4152e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,9 +43,6 @@ use std::f64::consts::FRAC_2_SQRT_PI; use std::f64::consts::PI; use std::f64::consts::SQRT_2; -//rng -//use rand::{Rng, thread_rng}; - //Load internal modules pub mod material; pub mod particle; diff --git a/src/particle.rs b/src/particle.rs index f82b917..e26ac9e 100644 --- a/src/particle.rs +++ b/src/particle.rs @@ -2,7 +2,6 @@ use super::*; /// Rustbca's internal representation of the particle_parameters input. - #[cfg(feature = "hdf5_input")] #[derive(Deserialize, Clone)] pub struct ParticleParameters { @@ -13,11 +12,11 @@ pub struct ParticleParameters { pub N: Vec, pub m: Vec, pub Z: Vec, - pub E: Vec, + pub E: Vec, pub Ec: Vec, pub Es: Vec, - pub pos: Vec<(f64, f64, f64)>, - pub dir: Vec<(f64, f64, f64)>, + pub pos: Vec<(Distributions, Distributions, Distributions)>, + pub dir: Vec<(Distributions, Distributions, Distributions)>, pub interaction_index: Vec, } @@ -30,11 +29,11 @@ pub struct ParticleParameters { pub N: Vec, pub m: Vec, pub Z: Vec, - pub E: Vec, + pub E: Vec, pub Ec: Vec, pub Es: Vec, - pub pos: Vec<(f64, f64, f64)>, - pub dir: Vec<(f64, f64, f64)>, + pub pos: Vec<(Distributions, Distributions, Distributions)>, + pub dir: Vec<(Distributions, Distributions, Distributions)>, pub interaction_index: Vec, } From 093a857e970e083ddee06dddf4e6ea98ba2b49e5 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 18 Oct 2021 16:27:04 -0700 Subject: [PATCH 18/45] Added more context to error message for NR rootfinder. --- src/bca.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bca.rs b/src/bca.rs index 82ed92a..9c70511 100644 --- a/src/bca.rs +++ b/src/bca.rs @@ -698,8 +698,8 @@ pub fn newton_rootfinder(Za: f64, Zb: f64, Ma: f64, Mb: f64, E0: f64, impact_par return Ok(x0); } } - return Err(anyhow!("Numerical error: exceeded maximum number of Newton-Raphson iterations, {}. E: {}; x0: {}; Error: {}; Tolerance: {}", - max_iterations, E0, x0, err, tolerance)); + return Err(anyhow!("Numerical error: exceeded maximum number of Newton-Raphson iterations, {}. E: {} eV; x0: {}; Error: {}; Tolerance: {}; Za: {}; Zb: {}; Ma: {} amu; Mb: {} amu; a: {}; p: {} A", + max_iterations, E0/Q, x0, err, tolerance, Za, Zb, Ma/AMU, Mb/AMU, a, impact_parameter/ANGSTROM)); } /// Gauss-Mehler quadrature. From c16c447979811e8e6449a3329abb9d294d31cb78 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 27 Oct 2021 20:18:41 -0500 Subject: [PATCH 19/45] Added context to error when particle energy goes NaN following collision. --- src/bca.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bca.rs b/src/bca.rs index 9c70511..4f911bd 100644 --- a/src/bca.rs +++ b/src/bca.rs @@ -447,6 +447,7 @@ pub fn update_particle_energy(particle_1: &mut particle::Particle, recoil_energy: f64, x0: f64, strong_collision_Z: f64, strong_collision_index: usize, options: &Options) { //If particle energy drops below zero before electronic stopping calcualtion, it produces NaNs + assert!(!recoil_energy.is_nan(), "Numerical error: recoil Energy is NaN. E0 = {} Za = {} Ma = {} x0 = {} Zb = {} delta-x = {}", particle_1.E, particle_1.Z, particle_1.m, x0, strong_collision_Z, distance_traveled); particle_1.E -= recoil_energy; assert!(!particle_1.E.is_nan(), "Numerical error: particle energy is NaN following collision."); if particle_1.E < 0. { From 9d96870745db2c4cb47fc658e1099367e6acb3f7 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Wed, 17 Nov 2021 15:48:24 -0800 Subject: [PATCH 20/45] Fix for Issue #159 --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 50c2ba7..27be4ed 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -35,7 +35,7 @@ jobs: run: | git clone https://github.com/uiri/toml.git cd toml - sudo python3 setup.py install + python3 setup.py install - name: Install HDF5 Libraries run: | sudo apt install libhdf5-dev From 5cc112ee59762ccfbe541cefdb9d991c7d1324f8 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Wed, 17 Nov 2021 15:52:35 -0800 Subject: [PATCH 21/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 27be4ed..d5692b1 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -35,14 +35,14 @@ jobs: run: | git clone https://github.com/uiri/toml.git cd toml - python3 setup.py install + python3 setup.py install --root . - name: Install HDF5 Libraries run: | sudo apt install libhdf5-dev - name: test Python Bindings run: | sudo python3 -m pip install setuptools_rust testresources - sudo python3 setup.py install + python3 setup.py install --root . python3 -c "from libRustBCA.pybca import *; print(simple_bca_py)" - name: Test RustBCA run: | From a658f1e847493ae11f0bcec302f95c4cddf057c0 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Wed, 17 Nov 2021 15:56:26 -0800 Subject: [PATCH 22/45] Update setup.py --- setup.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e2ab17b..c9db496 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,18 @@ setup( name="RustBCA", - rust_extensions=[RustExtension("libRustBCA.pybca", binding=Binding.PyO3, features=["python"])], + version="1.1.2", + rust_extensions=[ + RustExtension( + "libRustBCA.pybca", + binding=Binding.PyO3, + features=["python"], + #args=["+nightly", "--edition 2018", "-Z unstable-options"], + #optional=True, + rust_version="1.56.1" + + ) + ], # rust extensions are not zip safe, just like C-extensions. zip_safe=False, ) From d84a76f5ecb668e67cbcb167484e11ca9cd8c00c Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:18:53 -0800 Subject: [PATCH 23/45] Another attempted fix Removes another sudo invocation --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index d5692b1..f542606 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -41,7 +41,7 @@ jobs: sudo apt install libhdf5-dev - name: test Python Bindings run: | - sudo python3 -m pip install setuptools_rust testresources + python3 -m pip install setuptools_rust testresources python3 setup.py install --root . python3 -c "from libRustBCA.pybca import *; print(simple_bca_py)" - name: Test RustBCA From 2a161be4296f640e67085e71426530b12555f3e5 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:26:10 -0800 Subject: [PATCH 24/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index f542606..d8d802d 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -35,15 +35,15 @@ jobs: run: | git clone https://github.com/uiri/toml.git cd toml - python3 setup.py install --root . + python3 setup.py install - name: Install HDF5 Libraries run: | sudo apt install libhdf5-dev - name: test Python Bindings run: | python3 -m pip install setuptools_rust testresources - python3 setup.py install --root . - python3 -c "from libRustBCA.pybca import *; print(simple_bca_py)" + python3 setup.py install + - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 3217150dbfc3af8dbf0c82971994344b40a9cc76 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:28:57 -0800 Subject: [PATCH 25/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index d8d802d..d26b444 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -35,15 +35,14 @@ jobs: run: | git clone https://github.com/uiri/toml.git cd toml - python3 setup.py install + python3 setup.py install --root . - name: Install HDF5 Libraries run: | sudo apt install libhdf5-dev - name: test Python Bindings run: | python3 -m pip install setuptools_rust testresources - python3 setup.py install - + python3 setup.py install --root . - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From f886f027889ad207fb7de096a0cef16fb20e2a92 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:45:21 -0800 Subject: [PATCH 26/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index d26b444..480e95a 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -43,6 +43,8 @@ jobs: run: | python3 -m pip install setuptools_rust testresources python3 setup.py install --root . + cp -r usr/local/lib/python3.8/dist-packages/libRustBCA . + python3 -c "from libRustBCA.pybca import *;" - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 82ec4431e031203f9f73087baee50f0703fa845c Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 13:59:05 -0800 Subject: [PATCH 27/45] Add tests of fortran functions to workflow --- .github/workflows/rustbca_compile_check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 480e95a..789e620 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -45,6 +45,9 @@ jobs: python3 setup.py install --root . cp -r usr/local/lib/python3.8/dist-packages/libRustBCA . python3 -c "from libRustBCA.pybca import *;" + - name: Test Fortran bindings + run : | + gfortran rustbca.f90 target/release/liblibRustBCA.so - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 3351bf72460bb142ef09fc68fb354ad312db9534 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Thu, 18 Nov 2021 15:42:34 -0800 Subject: [PATCH 28/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 789e620..fa9829e 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -47,7 +47,7 @@ jobs: python3 -c "from libRustBCA.pybca import *;" - name: Test Fortran bindings run : | - gfortran rustbca.f90 target/release/liblibRustBCA.so + gfortran -c rustbca.f90 target/release/liblibRustBCA.so - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From bca3d8902b3293e208dc4d61c8f35ac7931a9573 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Fri, 19 Nov 2021 14:38:32 -0800 Subject: [PATCH 29/45] Update lib.rs --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 55707b3..7ccd575 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -416,7 +416,7 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut pos_origin: Vector::new(x, y, z), pos_old: Vector::new(x, y, z), dir_old: Vector::new(*ux, *uy, *uz), - energy_origin: *E1, + energy_origin: *E1*EV, asymptotic_deflection: 0.0, stopped: false, left: false, @@ -441,7 +441,7 @@ pub extern "C" fn reflect_single_ion_c(num_species_target: &mut c_int, ux: &mut if output[0].pos.x >= 0.0 { *E1 = 0.0 } else { - *E1 = output[0].E; + *E1 = output[0].E/EV; } } From d2db27eb668f9ee21a8e571ac80503dad0a10fbb Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Fri, 19 Nov 2021 15:43:28 -0800 Subject: [PATCH 30/45] Fortran routine tests. --- examples/test_rustbca.f90 | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 examples/test_rustbca.f90 diff --git a/examples/test_rustbca.f90 b/examples/test_rustbca.f90 new file mode 100644 index 0000000..f59d5fe --- /dev/null +++ b/examples/test_rustbca.f90 @@ -0,0 +1,75 @@ + +program test_rustbca + + use rustbca + use, intrinsic :: iso_c_binding + + integer :: N_ions + real(c_double), allocatable, dimension(:) :: ux, uy, uz, E, Z1, m1, Ec1, Es1 + integer(c_int) :: num_species_target, num_emitted_particles + real(c_double), target :: Z2(2), m2(2), Ec2(2), Es2(2), Eb2(2), n2(2) + real(c_double) :: ux1, uy1, uz1, E1 + type(c_ptr) :: bca_output_c + real(c_double), pointer, dimension(:,:) :: bca_output_f + real :: start, stop + logical(c_bool) :: track_recoils + + !Initial ion conditions + N_ions = 100000 + allocate(ux(N_ions), uy(N_ions), uz(N_ions), E(N_ions), Z1(N_ions), m1(N_ions), Ec1(N_ions), Es1(N_ions)) + ux(:) = 0.999 + uy(:) = sqrt(1.0 - 0.999*0.999) + uz(:) = 0.0 + E(:) = 1000.0_8 + + !Hydrogen + Z1(:) = 1.0_8 + m1(:) = 1.008_8 + Ec1(:) = 1.0_8 + Es1(:) = 1.5_8 + + !Titanium Hydride + num_species_target = 2 + Z2(1) = 22.0_8 + m2(1) = 47.867_8 + Ec2(1) = 4.84_8 + Es2(1) = 4.84_8 + Eb2(1) = 3.0_8 + n2(1) = 0.04527_8 + + Z2(2) = 1.0_8 + m2(2) = 1.008_8 + Ec2(2) = 1.5_8 + Es2(2) = 1.5_8 + Eb2(2) = 0.0_8 + n2(2) = 0.09054_8 + + track_recoils = .false. + + call cpu_time(start) + bca_output_c = compound_bca_list_fortran(N_ions, track_recoils, ux, uy, uz, E, & + Z1, m1, Ec1, Es1, & + num_species_target, Z2, m2, Ec2, Es2, Eb2, n2, & + num_emitted_particles) + call c_f_pointer(bca_output_c, bca_output_f, [num_emitted_particles, 6]) + call cpu_time(stop) + + write(*,*) "Elapsed time in seconds per ion per eV: ", (stop - start)/N_ions/1000.0 + + !write(*,*) bca_output_f + + call cpu_time(start) + do i = 0, N_ions + !Test reflect_single_ion routine + ux1 = 0.999 + uy1 = sqrt(1.0 - 0.999*0.999) + uz1 = 0.0 + E1 = 1000.0 + call reflect_single_ion_c(num_species_target, ux1, uy1, uz1, E1, Z1(1), m1(1), Ec1(1), Es1(1), Z2, m2, Ec2, Es2, Eb2, n2) + end do + call cpu_time(stop) + write(*,*) "Elapsed time in ions per eV per s: ", (stop - start)/N_ions/1000.0 + + call exit(1) + +end program test_rustbca \ No newline at end of file From 96462d626c0df7d8d0647d0a0c7e0636f70770ac Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sat, 20 Nov 2021 09:19:38 -0800 Subject: [PATCH 31/45] added C example to examples folder. --- examples/RustBCA.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 examples/RustBCA.c diff --git a/examples/RustBCA.c b/examples/RustBCA.c new file mode 100644 index 0000000..a218531 --- /dev/null +++ b/examples/RustBCA.c @@ -0,0 +1,54 @@ +#include "RustBCA.h" +#include +#include + +int main(int argc, char * argv[]) { + OutputTaggedBCA output; + double velocities[2][3] = {{500000.0, 0.1, 0.0}, {500000.0, 0.1, 0.0}}; + double positions[2][3] = {{0.0, 0.0, 0.0}, {1.0, 1.0, 1.0}}; + int tags[2] = {0, 1}; + double weights[2] = {1.0, 1.0}; + double Z[3] = {74.0, 74.0}; + double m[2] = {184.0, 184.0}; + double n[2] = {0.06306, 0.06306}; + double Ec[2] = {1.0, 1.0}; + double Es[2] = {8.79, 8.79}; + double Eb[2] = {0.0, 0.0}; + + InputTaggedBCA input = { + 2, + positions, + velocities, + 1.0, + 1.0, + 1.0, + 1.0, + 2, + Z, + m, + n, + Ec, + Es, + Eb, + tags, + weights + }; + + //output = simple_bca_c(0., 0., 0., 0.5, 0.5, 0.00, 2000.0, 2.0, 4.0, 1.0, 0.0, 74.0, 184.0, 1.0, 8.79, 0.06306, 0.0); + //output = compound_bca_list_c(input); + output = compound_tagged_bca_list_c(input); + + std::cout << "Particle 1 Z: "; + std::cout << output.particles[0][0]; + std::cout << std::endl; + std::cout << "Particle 1 E [eV]: "; + std::cout << output.particles[0][2]; + std::cout << std::endl; + std::cout << "Particle 2 Z: "; + std::cout << output.particles[1][0]; + std::cout << std::endl; + std::cout << "Particle 2 E [eV]: "; + std::cout << output.particles[1][2]; + std::cout << std::endl; + return 0; +} From ca25e27f7daf08361ed0b0d71b3632bb9983db57 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 09:22:32 -0800 Subject: [PATCH 32/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index fa9829e..dd648f4 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -45,9 +45,10 @@ jobs: python3 setup.py install --root . cp -r usr/local/lib/python3.8/dist-packages/libRustBCA . python3 -c "from libRustBCA.pybca import *;" - - name: Test Fortran bindings + - name: Test Fortran and C bindings run : | - gfortran -c rustbca.f90 target/release/liblibRustBCA.so + gfortran -c examples/rustbca.f90 target/release/liblibRustBCA.so + g++ examples/RustBCA.c RustBCA.h target/release/liblibRustBCA.so - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 5dca803bafa47333641aca94c63bef52c724a62f Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 09:38:32 -0800 Subject: [PATCH 33/45] add g++ compilation of C libraries --- .github/workflows/rustbca_compile_check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index dd648f4..68ac613 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -48,7 +48,8 @@ jobs: - name: Test Fortran and C bindings run : | gfortran -c examples/rustbca.f90 target/release/liblibRustBCA.so - g++ examples/RustBCA.c RustBCA.h target/release/liblibRustBCA.so + cp examples/RustBCA.c . + g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -I examples - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 56333cdda76a136955c291a4ff35e492c57b6d6b Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 09:44:57 -0800 Subject: [PATCH 34/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 68ac613..856fe94 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -47,7 +47,7 @@ jobs: python3 -c "from libRustBCA.pybca import *;" - name: Test Fortran and C bindings run : | - gfortran -c examples/rustbca.f90 target/release/liblibRustBCA.so + gfortran -c rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -I examples - name: Test RustBCA From d55f728e088c42316a0ce5bc163aa52d35c19a64 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 09:51:23 -0800 Subject: [PATCH 35/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 856fe94..e8880b8 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -47,9 +47,10 @@ jobs: python3 -c "from libRustBCA.pybca import *;" - name: Test Fortran and C bindings run : | + cargo build --release gfortran -c rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . - g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -I examples + g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -I examples /usr/include/python3.8 - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 559ba45523efbbe11d518809132aba7dca66d905 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 09:57:03 -0800 Subject: [PATCH 36/45] Made sure Python headers are installed --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index e8880b8..4564fd8 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -27,7 +27,7 @@ jobs: sudo apt-get install rustc - name: Install pip for Python-3 run: | - sudo apt-get install python3-pip + sudo apt-get install python3-pip python3-dev - name: Install Python libraries run: | python3 -m pip install numpy shapely scipy From ed472a68a015a1dde8c433869455bcf1c79d9bc7 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 10:02:37 -0800 Subject: [PATCH 37/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 4564fd8..c886f22 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -50,7 +50,7 @@ jobs: cargo build --release gfortran -c rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . - g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -I examples /usr/include/python3.8 + g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 25c3b1b2d7800036837d9792c5010e43bb835bff Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 10:54:27 -0800 Subject: [PATCH 38/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index c886f22..9a3d2a3 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -48,7 +48,7 @@ jobs: - name: Test Fortran and C bindings run : | cargo build --release - gfortran -c rustbca.f90 target/release/liblibRustBCA.so + gfortran examples/test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 - name: Test RustBCA From 52b23a8e197ed063b768ff6e5d1d954d8fb5624b Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 10:59:26 -0800 Subject: [PATCH 39/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 9a3d2a3..0cf7a95 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -48,7 +48,8 @@ jobs: - name: Test Fortran and C bindings run : | cargo build --release - gfortran examples/test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so + cp examples test_rustbca.f90 . + gfortran test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 - name: Test RustBCA From 8af04f002164c5b3e676eb8b58c28de77bed6b77 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 11:03:40 -0800 Subject: [PATCH 40/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index 0cf7a95..ffab5fd 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -48,7 +48,7 @@ jobs: - name: Test Fortran and C bindings run : | cargo build --release - cp examples test_rustbca.f90 . + cp examples/test_rustbca.f90 . gfortran test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 From f6baee775e8ec0ee2a4780e3b47ea2e010ec49e0 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 11:12:24 -0800 Subject: [PATCH 41/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index ffab5fd..c6a751c 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -49,6 +49,7 @@ jobs: run : | cargo build --release cp examples/test_rustbca.f90 . + gfortran -c rustbca.f90 target/release/liblibRustBCA.so gfortran test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 From ccbad254f52eec18e4fd7935a50f1eb8a3a31c15 Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 11:30:35 -0800 Subject: [PATCH 42/45] Update rustbca_compile_check.yml --- .github/workflows/rustbca_compile_check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index c6a751c..e31aa05 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -51,8 +51,10 @@ jobs: cp examples/test_rustbca.f90 . gfortran -c rustbca.f90 target/release/liblibRustBCA.so gfortran test_rustbca.f90 rustbca.f90 target/release/liblibRustBCA.so + ./a.out cp examples/RustBCA.c . g++ RustBCA.c RustBCA.h target/release/liblibRustBCA.so -Iexamples/ -I/usr/include/python3.8 + ./a.out - name: Test RustBCA run: | sudo cargo test --features cpr_rootfinder_netlib,hdf5_input,distributions,parry3d From 731c77a6880fd8057b981ef15aaf57fc26169fff Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Sat, 20 Nov 2021 11:38:11 -0800 Subject: [PATCH 43/45] Update test_rustbca.f90 --- examples/test_rustbca.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/test_rustbca.f90 b/examples/test_rustbca.f90 index f59d5fe..c0b8cae 100644 --- a/examples/test_rustbca.f90 +++ b/examples/test_rustbca.f90 @@ -70,6 +70,6 @@ program test_rustbca call cpu_time(stop) write(*,*) "Elapsed time in ions per eV per s: ", (stop - start)/N_ions/1000.0 - call exit(1) + !call exit(1) -end program test_rustbca \ No newline at end of file +end program test_rustbca From 119f1e0e984c511f65b02bfe2eb74eb0c53871ea Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 29 Nov 2021 09:54:41 -0800 Subject: [PATCH 44/45] Remove generic import from anyhow - it was overriding Ok() and breaking PyO3 --- src/lib.rs | 6 +++--- src/main.rs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7ccd575..98ebe6e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,8 +13,8 @@ use std::{fmt}; use std::mem::discriminant; //Error handling crate -use anyhow::Result; -use anyhow::*; +use anyhow::{Result, Context, anyhow}; +//use anyhow::*; //Serializing/Deserializing crate use serde::*; @@ -787,7 +787,7 @@ pub extern "C" fn compound_bca_list_c(input: InputCompoundBCA) -> OutputBCA { #[no_mangle] pub extern "C" fn compound_bca_list_fortran(num_incident_ions: &mut c_int, track_recoils: &mut bool, - ux: *mut f64, uy: *mut f64, uz: *mut f64, E1: *mut f64, + ux: *mut f64, uy: *mut f64, uz: *mut f64, E1: *mut f64, Z1: *mut f64, m1: *mut f64, Ec1: *mut f64, Es1: *mut f64, num_species_target: &mut c_int, Z2: *mut f64, m2: *mut f64, Ec2: *mut f64, Es2: *mut f64, Eb2: *mut f64, n2: *mut f64, diff --git a/src/main.rs b/src/main.rs index e4152e8..a56fb99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,8 +16,7 @@ use std::mem::discriminant; use indicatif::{ProgressBar, ProgressStyle}; //Error handling crate -use anyhow::Result; -use anyhow::*; +use anyhow::{Result, Context, anyhow}; //Serializing/Deserializing crate use serde::*; From 8d7678d94b7f2b17ad8c672e60f7316180a9c944 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 29 Nov 2021 14:32:22 -0800 Subject: [PATCH 45/45] Testing pip as python build tool instead of directly invoking setup.py. --- .github/workflows/rustbca_compile_check.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rustbca_compile_check.yml b/.github/workflows/rustbca_compile_check.yml index e31aa05..12713e0 100644 --- a/.github/workflows/rustbca_compile_check.yml +++ b/.github/workflows/rustbca_compile_check.yml @@ -42,8 +42,7 @@ jobs: - name: test Python Bindings run: | python3 -m pip install setuptools_rust testresources - python3 setup.py install --root . - cp -r usr/local/lib/python3.8/dist-packages/libRustBCA . + python3 -m pip install . python3 -c "from libRustBCA.pybca import *;" - name: Test Fortran and C bindings run : |