Skip to content

Commit af11818

Browse files
authored
Merge pull request #189 from lcpp-org/dev
Merge dev into main
2 parents 76bfbd6 + 5c8b9c3 commit af11818

File tree

19 files changed

+561
-87
lines changed

19 files changed

+561
-87
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Benchmark request
3+
about: Suggest a benchmark for validation
4+
title: "[benchmark]"
5+
labels: benchmark
6+
assignees: ''
7+
8+
---
9+
10+
**Description**
11+
A clear and concise description of the requested benchmark.
12+
13+
**Source**
14+
Source of data for benchmark; a paper, code, or database with sputtering yields, reflection coefficients, etc.

examples/test_rustbca.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,49 @@ def main():
8181
print(f'RustBCA R: {len(reflected[:, 0])/number_ions} Thomas R: {thomas}')
8282
print(f'Time per ion: {delta_time/number_ions*1e3} us/{ion["symbol"]}')
8383

84+
#Next up is the layered target version. I'll add a 50 Angstrom layer of W-H to the top of the target.
85+
86+
#1 keV is above the He on W sputtering threshold of ~150 eV
87+
energies_eV = 1000.0*np.ones(number_ions)
88+
89+
#Working with angles of exactly 0 is problematic due to gimbal lock
90+
angle = 0.0001
91+
92+
#In RustBCA's 0D geometry, +x -> into the surface
93+
ux = np.cos(angle*np.pi/180.)*np.ones(number_ions)
94+
uy = np.sin(angle*np.pi/180.)*np.ones(number_ions)
95+
uz = np.zeros(number_ions)
96+
97+
print(f'Running RustBCA for {number_ions} {ion["symbol"]} ions on {target["symbol"]} with hydrogenated layer at {energies_eV[0]/1000.} keV...')
98+
print(f'This may take several minutes.')
99+
#Not the different argument order; when a breaking change is due, this will
100+
#be back-ported to the other bindings as well for consistency.
101+
output, incident, stopped = compound_bca_list_1D_py(
102+
ux, uy, uz, energies_eV, [ion['Z']]*number_ions,
103+
[ion['m']]*number_ions, [ion['Ec']]*number_ions, [ion['Es']]*number_ions, [target['Z'], 1.0], [target['m'], 1.008],
104+
[target['Ec'], 1.0], [target['Es'], 1.5], [target['Eb'], 0.0], [[target['n']/10**30, target['n']/10**30], [target['n']/10**30, 0.0]], [50.0, 1e6]
105+
)
106+
107+
output = np.array(output)
108+
109+
Z = output[:, 0]
110+
m = output[:, 1]
111+
E = output[:, 2]
112+
x = output[:, 3]
113+
y = output[:, 4]
114+
z = output[:, 5]
115+
ux = output[:, 6]
116+
uy = output[:, 7]
117+
uz = output[:, 8]
118+
119+
plt.figure(3)
120+
plt.title(f'Implanted {ion["symbol"]} Depth Distribution with 50A {target["symbol"]}-H layer')
121+
plt.xlabel('x [A]')
122+
plt.ylabel('f(x) [A.U.]')
123+
heights, _, _ = plt.hist(x[np.logical_and(incident, stopped)], bins=100, density=True, histtype='step')
124+
plt.plot([50.0, 50.0], [0.0, np.max(heights)*1.1])
125+
plt.gca().set_ylim([0.0, np.max(heights)*1.1])
126+
84127
plt.show()
85128

86129
if __name__ == '__main__':

src/RustBCA.egg-info/PKG-INFO

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Metadata-Version: 2.1
2+
Name: RustBCA
3+
Version: 1.2.0
4+
License-File: LICENSE

src/RustBCA.egg-info/SOURCES.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Cargo.toml
2+
LICENSE
3+
MANIFEST.in
4+
README.md
5+
pyproject.toml
6+
setup.py
7+
src/bca.rs
8+
src/consts.rs
9+
src/enums.rs
10+
src/geometry.rs
11+
src/gui.rs
12+
src/input.rs
13+
src/interactions.rs
14+
src/lib.rs
15+
src/main.rs
16+
src/material.rs
17+
src/output.rs
18+
src/parry.rs
19+
src/particle.rs
20+
src/physics.rs
21+
src/sphere.rs
22+
src/structs.rs
23+
src/tests.rs
24+
src/RustBCA.egg-info/PKG-INFO
25+
src/RustBCA.egg-info/SOURCES.txt
26+
src/RustBCA.egg-info/dependency_links.txt
27+
src/RustBCA.egg-info/not-zip-safe
28+
src/RustBCA.egg-info/top_level.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/RustBCA.egg-info/not-zip-safe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/RustBCA.egg-info/top_level.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/bca.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ pub fn single_ion_bca<T: Geometry>(particle: particle::Particle, material: &mate
7575

7676
//Remove particle from top of vector as particle_1
7777
let mut particle_1 = particles.pop().unwrap();
78-
79-
//println!("Particle start Z: {} E: {} ({}, {}, {})", particle_1.Z, particle_1.E/Q, particle_1.pos.x/ANGSTROM, particle_1.pos.y/ANGSTROM, particle_1.pos.z/ANGSTROM);
80-
8178
//BCA loop
8279
while !particle_1.stopped & !particle_1.left {
8380

@@ -114,8 +111,6 @@ pub fn single_ion_bca<T: Geometry>(particle: particle::Particle, material: &mate
114111
particle_1.pos.x, particle_2.pos.x, &binary_collision_geometry))
115112
.unwrap();
116113

117-
//println!("{}", binary_collision_result);
118-
119114
//Only use 0th order collision for local electronic stopping
120115
if k == 0 {
121116
normalized_distance_of_closest_approach = binary_collision_result.normalized_distance_of_closest_approach;
@@ -127,17 +122,14 @@ pub fn single_ion_bca<T: Geometry>(particle: particle::Particle, material: &mate
127122
particle_2.E = binary_collision_result.recoil_energy - material.average_bulk_binding_energy(particle_2.pos.x, particle_2.pos.y, particle_2.pos.z);
128123
particle_2.energy_origin = particle_2.E;
129124

130-
//Accumulate asymptotic deflections for primary particle
125+
//Accumulate energy losses and asymptotic deflections for primary particle
131126
total_energy_loss += binary_collision_result.recoil_energy;
132-
133-
//total_deflection_angle += psi;
134127
total_asymptotic_deflection += binary_collision_result.asymptotic_deflection;
135128

136-
//Rotate particle 1, 2 by lab frame scattering angles
137-
particle::rotate_particle(&mut particle_1, binary_collision_result.psi,
129+
particle_1.rotate(binary_collision_result.psi,
138130
binary_collision_geometry.phi_azimuthal);
139131

140-
particle::rotate_particle(&mut particle_2, -binary_collision_result.psi_recoil,
132+
particle_2.rotate(-binary_collision_result.psi_recoil,
141133
binary_collision_geometry.phi_azimuthal);
142134

143135
particle_2.dir_old.x = particle_2.dir.x;
@@ -184,28 +176,24 @@ pub fn single_ion_bca<T: Geometry>(particle: particle::Particle, material: &mate
184176

185177
//Advance particle in space and track total distance traveled
186178
#[cfg(not(feature = "accelerated_ions"))]
187-
let distance_traveled = particle::particle_advance(&mut particle_1,
179+
let distance_traveled = particle_1.advance(
188180
binary_collision_geometries[0].mfp, total_asymptotic_deflection);
189181

190182
#[cfg(feature = "accelerated_ions")]
191-
let distance_traveled = particle::particle_advance(&mut particle_1,
183+
let distance_traveled = particle_1.advance(
192184
binary_collision_geometries[0].mfp + distance_to_target - material.geometry.get_energy_barrier_thickness(), total_asymptotic_deflection);
193185

194186
//Subtract total energy from all simultaneous collisions and electronic stopping
195187
bca::update_particle_energy(&mut particle_1, &material, distance_traveled,
196188
total_energy_loss, normalized_distance_of_closest_approach, strong_collision_Z,
197189
strong_collision_index, &options);
198-
//println!("Particle finished collision loop Z: {} E: {} ({}, {}, {})", particle_1.Z, particle_1.E/Q, particle_1.pos.x/ANGSTROM, particle_1.pos.y/ANGSTROM, particle_1.pos.z/ANGSTROM);
199-
200-
//println!("{} {} {}", energy_0/EV, energy_1/EV, (energy_1 - energy_0)/EV);
201190

202191
//Check boundary conditions on leaving and stopping
203192
material::boundary_condition_planar(&mut particle_1, &material);
204193

205194
//Set particle index to topmost particle
206195
particle_index = particles.len();
207196
}
208-
//println!("Particle stopped or left Z: {} E: {} ({}, {}, {})", particle_1.Z, particle_1.E/Q, particle_1.pos.x/ANGSTROM, particle_1.pos.y/ANGSTROM, particle_1.pos.z/ANGSTROM);
209197
particle_output.push(particle_1);
210198
}
211199
particle_output

src/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub const MICRON: f64 = 1E-6;
1515
pub const NM: f64 = 1E-9;
1616
/// One centimeter in meters.
1717
pub const CM: f64 = 1E-2;
18+
/// One milimter in meters.
19+
pub const MM: f64 = 1E-3;
1820
/// Vacuum permitivity in Farads/meter.
1921
pub const EPS0: f64 = 8.8541878128E-12;
2022
/// Bohr radius in meters.

src/geometry.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl Geometry for Mesh0D {
5252
let length_unit: f64 = match input.length_unit.as_str() {
5353
"MICRON" => MICRON,
5454
"CM" => CM,
55+
"MM" => MM,
5556
"ANGSTROM" => ANGSTROM,
5657
"NM" => NM,
5758
"M" => 1.,
@@ -97,7 +98,6 @@ impl Geometry for Mesh0D {
9798
}
9899

99100
fn inside_simulation_boundary(&self, x: f64, y: f64, z: f64) -> bool {
100-
//println!("x: {} energy_barrier_thickness: {}", x/ANGSTROM, self.energy_barrier_thickness/ANGSTROM);
101101
x > -10.*self.energy_barrier_thickness
102102
}
103103

@@ -143,6 +143,7 @@ impl Geometry for Mesh1D {
143143
let length_unit: f64 = match geometry_input.length_unit.as_str() {
144144
"MICRON" => MICRON,
145145
"CM" => CM,
146+
"MM" => MM,
146147
"ANGSTROM" => ANGSTROM,
147148
"NM" => NM,
148149
"M" => 1.,
@@ -324,6 +325,7 @@ impl Geometry for Mesh2D {
324325
let length_unit: f64 = match geometry_input.length_unit.as_str() {
325326
"MICRON" => MICRON,
326327
"CM" => CM,
328+
"MM" => MM,
327329
"ANGSTROM" => ANGSTROM,
328330
"NM" => NM,
329331
"M" => 1.,

src/input.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ where <T as Geometry>::InputFileFormat: Deserialize<'static> + 'static {
381381
let length_unit: f64 = match particle_parameters.length_unit.as_str() {
382382
"MICRON" => MICRON,
383383
"CM" => CM,
384+
"MM" => MM,
384385
"ANGSTROM" => ANGSTROM,
385386
"NM" => NM,
386387
"M" => 1.,

src/interactions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub fn crossing_point_doca(interaction_potential: InteractionPotential) -> f64 {
88
InteractionPotential::MORSE{D, alpha, r0} => (alpha*r0 - (2.0_f64).ln())/alpha,
99
InteractionPotential::WW => 50.*ANGSTROM,
1010
_ => 10.*ANGSTROM,
11-
//_ => panic!("Input error: potential never crosses zero for r > 0. Consider using the Newton rootfinder.")
1211
}
1312

1413
}

0 commit comments

Comments
 (0)