Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/rustbca_compile_check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: rustBCA Compile check
name: RustBCA Compile check

on:
push:
Expand Down Expand Up @@ -41,11 +41,11 @@ jobs:
- name: Run Examples
run: |
cargo run --release 0D examples/boron_nitride_0D.toml
./target/release/rustBCA 0D examples/titanium_dioxide_0D.toml
./target/release/rustBCA 1D examples/layered_geometry_1D.toml
./target/release/RustBCA 0D examples/titanium_dioxide_0D.toml
./target/release/RustBCA 1D examples/layered_geometry_1D.toml
cat 2000.0eV_0.0001deg_He_TiO2_Al_Sisummary.output
./target/release/rustBCA examples/boron_nitride.toml
./target/release/rustBCA examples/layered_geometry.toml
./target/release/RustBCA examples/boron_nitride.toml
./target/release/RustBCA examples/layered_geometry.toml
cat 2000.0eV_0.0001deg_He_TiO2_Al_Sisummary.output
./target/release/rustBCA SPHERE examples/boron_nitride_sphere.toml
./target/release/RustBCA SPHERE examples/boron_nitride_sphere.toml
cargo run --release --features parry3d TRIMESH examples/tungsten_twist_trimesh.toml
97 changes: 53 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
[package]
name = "rustBCA"
version = "1.1.0"
authors = ["Jon Drobny <drobny2@illinois.edu>"]
edition = "2018"

[[bin]]
name="rustBCA"

[dependencies]
rand = "0.8.3"
toml = "0.5.8"
anyhow = "1.0.38"
itertools = "0.10.0"
rayon = "1.5.0"
geo = {version = "0.17.1", optional = false}
indicatif = {version = "0.15.0", features=["rayon"]}
serde = { version = "1.0.123", features = ["derive"] }
hdf5 = {version = "0.7.1", optional = true}
openblas-src = {version = "0.9", optional = true}
netlib-src = {version = "0.8", optional = true}
intel-mkl-src = {version = "0.6.0", optional = true}
rcpr = { git = "https://github.com/drobnyjt/rcpr", optional = true}
ndarray = {version = "0.14.0", features = ["serde"], optional = true}
parry3d-f64 = {version = "0.2.0", optional = true}

[dev-dependencies]
float-cmp = "0.8.0"

[profile.release]
lto = "fat"
codegen-units = 1
opt-level = 3
debug = false

[features]
hdf5_input = ["hdf5"]
cpr_rootfinder_openblas = ["rcpr", "openblas-src"]
cpr_rootfinder_netlib = ["rcpr", "netlib-src"]
cpr_rootfinder_intel_mkl = ["rcpr", "intel-mkl-src"]
distributions = ["ndarray"]
no_list_output = []
parry3d = ["parry3d-f64"]
accelerated_ions = []
[package]
name = "RustBCA"
version = "1.1.0"
authors = ["Jon Drobny <drobny2@illinois.edu>"]
edition = "2018"

[[bin]]
name="RustBCA"

[lib]
name = "libRustBCA"
path = "src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
rand = "0.8.3"
toml = "0.5.8"
anyhow = "1.0.38"
itertools = "0.10.0"
rayon = "1.5.0"
geo = {version = "0.17.1", optional = false}
indicatif = {version = "0.15.0", features=["rayon"]}
serde = { version = "1.0.123", features = ["derive"] }
hdf5 = {version = "0.7.1", optional = true}
openblas-src = {version = "0.9", optional = true}
netlib-src = {version = "0.8", optional = true}
intel-mkl-src = {version = "0.6.0", optional = true}
rcpr = { git = "https://github.com/drobnyjt/rcpr", optional = true}
ndarray = {version = "0.14.0", features = ["serde"], optional = true}
parry3d-f64 = {version = "0.2.0", optional = true}

[dependencies.pyo3]
version = "0.13.2"
features = ["extension-module"]

[dev-dependencies]
float-cmp = "0.8.0"

[profile.release]
lto = "fat"
codegen-units = 1
opt-level = 3
debug = false

[features]
hdf5_input = ["hdf5"]
cpr_rootfinder_openblas = ["rcpr", "openblas-src"]
cpr_rootfinder_netlib = ["rcpr", "netlib-src"]
cpr_rootfinder_intel_mkl = ["rcpr", "intel-mkl-src"]
distributions = ["ndarray"]
no_list_output = []
parry3d = ["parry3d-f64"]
accelerated_ions = []
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include Cargo.toml
recursive-include src *
87 changes: 87 additions & 0 deletions RustBCA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include <cmath>

static const double PI = M_PI;

static const double FRAC_2_SQRT_PI = M_2_PI;

static const double SQRT_2 = M_SQRT2;

///Fundamental charge in Coulombs.
static const double Q = 1.602176634e-19;

/// One electron-volt in Joules.
static const double EV = Q;

/// One atomic mass unit in kilograms.
static const double AMU = 1.66053906660e-27;

/// One Angstrom in meters.
static const double ANGSTROM = 1e-10;

/// One micron in meters.
static const double MICRON = 1e-6;

/// One nanometer in meters.
static const double NM = 1e-9;

/// One centimeter in meters.
static const double CM = 1e-2;

/// Vacuum permitivity in Farads/meter.
static const double EPS0 = 8.8541878128e-12;

/// Bohr radius in meters.
static const double A0 = 5.29177210903e-11;

/// Electron mass in kilograms.
static const double ME = 9.1093837015e-31;

/// sqrt(pi).
static const double SQRTPI = (2. / FRAC_2_SQRT_PI);

/// sqrt(2 * pi).
static const double SQRT2PI = ((2. * SQRT_2) / FRAC_2_SQRT_PI);

/// Speed of light in meters/second.
static const double C = 299792458.;

/// Bethe-Bloch electronic stopping prefactor, in SI units.
static const double BETHE_BLOCH_PREFACTOR = ((((((4. * PI) * ((Q * Q) / ((4. * PI) * EPS0))) * ((Q * Q) / ((4. * PI) * EPS0))) / ME) / C) / C);

/// Lindhard-Scharff electronic stopping prefactor, in SI units.
static const double LINDHARD_SCHARFF_PREFACTOR = (((1.212 * ANGSTROM) * ANGSTROM) * Q);

/// Lindhard reduced energy prefactor, in SI units.
static const double LINDHARD_REDUCED_ENERGY_PREFACTOR = ((((4. * PI) * EPS0) / Q) / Q);

struct OutputBCA {
uintptr_t len;
double (*particles)[9];
};

extern "C" {

OutputBCA simple_bca_c(double x,
double y,
double z,
double ux,
double uy,
double uz,
double E1,
double Z1,
double m1,
double Ec1,
double Es1,
double Z2,
double m2,
double Ec2,
double Es2,
double n2,
double Eb2);

} // extern "C"
Empty file added cbindgen.toml
Empty file.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "setuptools-rust"]
9 changes: 9 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from setuptools import setup
from setuptools_rust import Binding, RustExtension

setup(
name="RustBCA",
rust_extensions=[RustExtension("libRustBCA.pybca", binding=Binding.PyO3)],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
)
Loading