Skip to content
Merged

Dev #304

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
db015aa
Update lib.rs
drobnyjt Jun 10, 2025
55fd173
Merge pull request #283 from lcpp-org/delta_patch_rotate_given_surfac…
drobnyjt Jun 10, 2025
2644514
Draft of fixing numerical issues in rotate functions.
Jun 11, 2025
34e31a5
Removed panic in rotate_given_surface_normal_py and replaced linear a…
Jun 12, 2025
83d35d8
Rederived particle rotation and transport routines.
Jul 17, 2025
210cbc0
Update testing suite to fix momentum conservation tests.
drobnyjt Jul 18, 2025
f8312bd
Add cube direction test to testing suite.
drobnyjt Jul 19, 2025
725d48e
Additional comments and updated cube test.
drobnyjt Jul 19, 2025
8e26b98
Updates to test_cube.py
drobnyjt Jul 19, 2025
71a1637
Working singularity-free version.
drobnyjt Jul 20, 2025
729d506
Updated singularity-free version.
drobnyjt Jul 21, 2025
b2d52a0
update to test_cube.py script.
drobnyjt Jul 21, 2025
5143239
Merge branch 'dev' into recoil_generation
drobnyjt Jul 21, 2025
b44ea4b
Remove now-unnecessary gimbal lock assertions, fudges, etc.
drobnyjt Jul 21, 2025
6d2f2a9
Update examples to take advantage of singularity-free algorithms.
drobnyjt Jul 21, 2025
35a699f
Remove now-unnecessary absolute values on collision angles.
drobnyjt Jul 21, 2025
be800b3
Remove unnecessary theta definition.
drobnyjt Jul 21, 2025
2936a3a
Fix comments.
drobnyjt Jul 21, 2025
4711853
Update tests to include morse potential when CPR is activated.
drobnyjt Jul 21, 2025
165d868
Fix to mismatched types.
drobnyjt Jul 21, 2025
3848914
Add dereferncing fix to distributions test of momentum conservation.
drobnyjt Jul 21, 2025
4816723
Add comment elaborating on the consequences of the singularity-free a…
drobnyjt Jul 22, 2025
1b93c01
Amend comment elaborating on the consequences of the singularity-free…
drobnyjt Jul 22, 2025
5b01319
Merge pull request #288 from lcpp-org/recoil_generation
drobnyjt Aug 4, 2025
1c3f4ac
Replace sigmoid with smootherstep in Kr-C-Morse.
Aug 22, 2025
f1ded67
Merge pull request #294 from lcpp-org/krc_morse_speedup
drobnyjt Aug 22, 2025
3fc4693
Add comparison to 2024 V Shulga paper to examples.
Aug 26, 2025
259bf79
Add test_cube.py to tests.
Aug 26, 2025
f18e381
Fix default Eb
Aug 27, 2025
533b561
Merge pull request #298 from lcpp-org/sput_at_spectra_test
drobnyjt Aug 27, 2025
b82d0a0
Add compound_bca_list_1d_py example.
drobnyjt Sep 23, 2025
377c2c5
Fix to multiple interaction potentials; somehow was using 1.0 geometr…
drobnyjt Sep 23, 2025
6c9f46a
Add example using tomllib
drobnyjt Sep 23, 2025
6190928
Add example using tomllib
drobnyjt Sep 23, 2025
51673c0
Adjust comments on tomllib example.
drobnyjt Sep 23, 2025
e01474c
Add tomlkit example to workflow.:
drobnyjt Sep 23, 2025
079c8a2
Merge pull request #301 from lcpp-org/add_example
drobnyjt Sep 23, 2025
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
4 changes: 3 additions & 1 deletion .github/workflows/rustbca_compile_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
sudo apt-get install python3-pip python3-dev
- name: Install Python libraries
run: |
python3 -m pip install numpy shapely scipy matplotlib toml
python3 -m pip install numpy shapely scipy matplotlib toml tomlkit
- name: Install HDF5 Libraries
run: |
sudo apt install libhdf5-dev
Expand All @@ -41,6 +41,8 @@ jobs:
python3 -m pip install .
python3 -c "from libRustBCA import *;"
python3 examples/test_rustbca.py
python3 examples/test_cube.py
python3 examples/make_input_file_and_run.py
- name: Test Fortran and C bindings
run : |
cargo build --release --lib --features parry3d
Expand Down
2 changes: 1 addition & 1 deletion examples/boron_nitride_0D.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ E = [ 1000.0 ]
Ec = [ 1.0 ]
Es = [ 10.0 ]
pos = [ [ 0.0, 0.0, 0.0,] ]
dir = [ [ 0.9999999999984769, 1.7453292519934434e-6, 0.0,] ]
dir = [ [ 1.0, 0.0, 0.0,] ]

[geometry_input]
length_unit = "ANGSTROM"
Expand Down
2 changes: 1 addition & 1 deletion examples/boron_nitride_sphere.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ E = [ 500.0 ]
Ec = [ 1.0 ]
Es = [ 10.0 ]
pos = [ [ -100.0, 0.0, 0.0,] ]
dir = [ [ 0.9999999999984769, 1.7453292519934434e-6, 0.0,] ]
dir = [ [ 1.0, 0.0, 0.0,] ]
interaction_index = [ 0 ]
particle_input_filename=""

Expand Down
2 changes: 1 addition & 1 deletion examples/boron_nitride_wire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ E = [ 5000.0 ]
Ec = [ 1.0 ]
Es = [ 10.0 ]
pos = [ [ 0.0, 0.0, 0.0,] ]
dir = [ [ 0.9999999999984769, 1.7453292519934434e-6, 0.0,] ]
dir = [ [ 1.0, 0.0, 0.0,] ]

[geometry_input]
length_unit = "ANGSTROM"
Expand Down
2 changes: 1 addition & 1 deletion examples/boron_nitride_wire_homogeneous.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ E = [ 5000.0 ]
Ec = [ 1.0 ]
Es = [ 10.0 ]
pos = [ [ 0.0, 0.0, 0.0,] ]
dir = [ [ 0.9999999999984769, 1.7453292519934434e-6, 0.0,] ]
dir = [ [ 1.0, 0.0, 0.0,] ]

[geometry_input]
length_unit = "ANGSTROM"
Expand Down
116 changes: 116 additions & 0 deletions examples/compound_bca_list_1d_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
from libRustBCA import *
import numpy as np
import matplotlib.pyplot as plt
import sys, os
sys.path.append(os.path.dirname(__file__)+'/../scripts')
sys.path.append('scripts')
from materials import *
from formulas import *


'''
This script is intended to serve as an example of using the Python
interface for a multi-layer, multi-species simulation.

In this simulation, 50 He and 50 H ions are incident on a target
of two layers, one titanium boride and one aluminum:

_____________
| |
| TiB2 | dx = 100 A
_____________
| |
| Al | dx = 1 um
| |

'''
number_ions = 10000
angle = 45.0 # angles in BCA codes are typically measured from the surface normal.
energy = 1000.0 # eV

ux = [np.cos(angle*np.pi/180.0)]*number_ions
uy = [np.sin(angle*np.pi/180.0)]*number_ions
uz = [0.0]*number_ions

energies = [energy]*number_ions
ion1 = hydrogen
ion2 = helium

# Ion properties are per-ion; so we have a list of number_ions/2 of each:
Z1 = [ion1["Z"]]*(number_ions//2) + [ion2["Z"]]*(number_ions//2)
m1 = [ion1["m"]]*(number_ions//2) + [ion2["m"]]*(number_ions//2)
Ec1 = [ion1["Ec"]]*(number_ions//2) + [ion2["Ec"]]*(number_ions//2)
Es1 = [ion1["Es"]]*(number_ions//2) + [ion2["Es"]]*(number_ions//2)

# Material properties are per species; so we have a list of 3 species:
Z2 = [titanium["Z"], boron["Z"], aluminum["Z"]]
m2 = [titanium["m"], boron["m"], aluminum["m"]]
Ec2 = [titanium["Ec"], boron["Ec"], aluminum["Ec"]]
Es2 = [titanium["Es"], boron["Es"], aluminum["Es"]]
Eb2 = [titanium["Eb"], boron["Eb"], aluminum["Eb"]]

# Densities (n2) are specified as a list of layers,
# each of which has a list of the densities per-species:

#top layer, titanium diboride:
# n_i calculated from ni = rho_TiB2 / (m_Ti + 2 * m_B)
ni = 3.8e28 # 1/m3

nTi1 = ni/10**30 # 1/A^3
nB1 = 2 * ni/10**30 # 1/A^3
nAl1 = 0.0

# bottom layer, pure aluminum:
nTi2 = 0.0
nB2 = 0.0
nAl2 = aluminum["n"]/10**30 # 1/A^3

n2 = [
[nTi1, nB1, nAl1], # top layer
[nTi2, nB2, nAl2] # bottom layer
]

dx = [
100.0, # Angstrom, top layer
1.0*1e-6/1e-10 # Angstrom; bottom layer
]

# compound_bca_list_py provides three return values
output, incident, stopped = compound_bca_list_1D_py(
ux,
uy,
uz,
energies,
Z1,
m1,
Ec1,
Es1,
Z2,
m2,
Ec2,
Es2,
Eb2,
n2,
dx
)

# output columns = [Z, m (amu), E (eV), x, y, z, (angstrom), ux, uy, uz]
output = np.array(output)
Z = output[:, 0]
E = output[:, 0]

# implanted ions can be selected using the stopped value
x_He = output[np.logical_and(Z == helium["Z"], stopped), 3]
x_H = output[np.logical_and(Z == hydrogen["Z"], stopped), 3]

num_bins = 50
bins = np.linspace(0.0, 400.0, num_bins)
plt.hist(x_He, bins=bins, histtype='step', label='He')
plt.hist(x_H, bins=bins, histtype='step', label='H')
plt.plot([dx[0], dx[0]], [0.0, number_ions], linestyle='--', color='gray')
plt.ylim([0.0, 375])
plt.xlabel('x [A]')
plt.ylabel('f(x) [counts]')
plt.title('H/He implantation in TiB2 on Al')
plt.legend()
plt.show()
2 changes: 1 addition & 1 deletion examples/layered_geometry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Ec = [ 1.0,]
Es = [ 0.0,]
interaction_index = [0]
pos = [ [ -1.7453292519934434e-8, 0.0, 0.0,],]
dir = [ [ 0.999, 0.001, 0.0,],]
dir = [ [ 1.0, 0.0, 0.0,],]

[geometry_input]
length_unit = "MICRON"
Expand Down
2 changes: 1 addition & 1 deletion examples/layered_geometry_1D.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Ec = [ 1.0,]
Es = [ 0.0,]
interaction_index = [0]
pos = [ [ -1.7453292519934434e-8, 0.0, 0.0,],]
dir = [ [ 0.999, 0.001, 0.0,],]
dir = [ [ 1.0, 0.0, 0.0,],]

[geometry_input]
length_unit = "MICRON"
Expand Down
2 changes: 1 addition & 1 deletion examples/lithium_vapor_shield.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Ec = [ 1.0,]
Es = [ 0.0,]
interaction_index = [0]
pos = [ [ -1.7453292519934434e-8, 0.0, 0.0,],]
dir = [ [ 0.999, 0.001, 0.0,],]
dir = [ [ 1.0, 0.0, 0.0,],]

[geometry_input]
length_unit = "MICRON"
Expand Down
Loading