From f2b7dc77fdf1ae20fcd55bbe95d3a5b0cdd6cc9e Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Sat, 20 Mar 2021 00:23:52 -0500 Subject: [PATCH 1/3] Added ability to run lists of energy-angle coords for simple_bca. --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a851fea..1bd1397 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,7 @@ pub use crate::parry::{ParryBall, ParryBallInput, InputParryBall, ParryTriMesh, #[pymodule] pub fn pybca(py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(simple_bca_py, m)?)?; + m.add_function(wrap_pyfunction!(simple_bca_list_py, m)?)?; Ok(()) } @@ -97,6 +98,27 @@ pub fn simple_bca_py(x: f64, y: f64, z: f64, ux: f64, uy: f64, uz: f64, E1: f64, simple_bca(x, y, z, ux, uy, uz, E1, Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, n2, Eb2) } +#[pyfunction] +pub fn simple_bca_list_py(energies: Vec, usx: Vec, usy: Vec, usz: Vec, Z1: f64, m1: f64, Ec1: f64, Es1: f64, Z2: f64, m2: f64, Ec2: f64, Es2: f64, n2: f64, Eb2: f64) -> Vec<[f64; 9]> { + + assert_eq!(energies.len(), usx.len()); + assert_eq!(energies.len(), usy.len()); + assert_eq!(energies.len(), usz.len()); + + let x = -2.*(n2*10E30).powf(-1./3.)/SQRTPI*2.; + let y = 0.0; + let z = 0.0; + + let mut total_output = vec![]; + for (((E1, ux), uy), uz) in energies.iter().zip(usx).zip(usy).zip(usz) { + let output = simple_bca(x, y, z, ux, uy, uz, *E1, Z1, m1, Ec1, Es1, Z2, m2, Ec2, Es2, n2, Eb2); + for particle in output { + total_output.push(particle); + } + } + total_output +} + pub fn simple_bca(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) -> Vec<[f64; 9]> { #[cfg(feature = "distributions")] From 8d1d93f34393f540604d7a214653caca488af82c Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Mon, 22 Mar 2021 09:42:49 -0500 Subject: [PATCH 2/3] Updates to bindings. --- RustBCA.c | 14 ++++++++++++++ src/lib.rs | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 RustBCA.c diff --git a/RustBCA.c b/RustBCA.c new file mode 100644 index 0000000..dee3b1e --- /dev/null +++ b/RustBCA.c @@ -0,0 +1,14 @@ +#include "RustBCA.h" +#include +#include + +int main() { + OutputBCA output; + + 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); + + std::cout << output.len; + std::cout << output.particles[1][0]; + + return 0.; +} diff --git a/src/lib.rs b/src/lib.rs index 1bd1397..6a54c37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,7 +79,6 @@ pub struct OutputBCA { len: usize, pub particles: *mut [f64; 9], } - #[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 bd7dca14718d848c8cfa5deb7e33e7032bce2f0d Mon Sep 17 00:00:00 2001 From: Jon Drobny <37962344+drobnyjt@users.noreply.github.com> Date: Mon, 22 Mar 2021 09:43:22 -0500 Subject: [PATCH 3/3] Delete RustBCA.c --- RustBCA.c | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 RustBCA.c diff --git a/RustBCA.c b/RustBCA.c deleted file mode 100644 index dee3b1e..0000000 --- a/RustBCA.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "RustBCA.h" -#include -#include - -int main() { - OutputBCA output; - - 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); - - std::cout << output.len; - std::cout << output.particles[1][0]; - - return 0.; -}