Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ materials.py is intended to provide example input values only; all input values
>>> angle = 0.0 # deg
>>> energy = 1000.0 # eV
>>> num_samples = 10000
>>> sputtering_yield(argon, tungsten, energy, angle, num_samples) == 1.0291
>>> sputtering_yield(argon, tungsten, energy, angle, num_samples) == 1.0447
True
>>> R_N, R_E = reflection_coefficient(argon, tungsten, energy, angle, num_samples)
>>> R_N == 0.3297
Expand Down
16 changes: 8 additions & 8 deletions examples/test_different_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,17 @@ def run_test(
sim_times = []

Y_test = np.array([
0.02593, 0.02104, 0.02467, 0.02731, 0.02593, 0.0218, 0.02211, 0.02288,
0.03577, 0.02593, 0.02587, 0.0296, 0.0255, 0.02593, 0.02587, 0.02593,
0.02905, 0.02593, 0.02593, 0.02593, 0.02593, 0.02593, 0.02593, 0.02593,
0.02593
0.02812, 0.02328, 0.02656, 0.02973, 0.02812, 0.02568, 0.02524, 0.02679,
0.03886, 0.02812, 0.02817, 0.03208, 0.02825, 0.02812, 0.02815, 0.02812,
0.03194, 0.02812, 0.02812, 0.02812, 0.02812, 0.02812, 0.02812, 0.02812,
0.02812
])

R_N_test = np.array([
0.17442, 0.17032, 0.16802, 0.18216, 0.17442, 0.17437, 0.17449, 0.17777,
0.28801, 0.17442, 0.17452, 0.22074, 0.17506, 0.17442, 0.17445, 0.17442,
0.17722, 0.17442, 0.17442, 0.17442, 0.17442, 0.17442, 0.17442, 0.17442,
0.17442
0.17688, 0.17252, 0.16998, 0.18417, 0.17688, 0.17672, 0.17642, 0.1799,
0.29106, 0.17688, 0.17688, 0.2229, 0.17705, 0.17688, 0.17695, 0.17688,
0.1798, 0.17688, 0.17688, 0.17688, 0.17688, 0.17688, 0.17688, 0.17688,
0.17688
])

Y = np.zeros_like(Y_test)
Expand Down
12 changes: 6 additions & 6 deletions examples/test_rustbca.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main():
Y = sputtering_yield(ion, target, energy, angle, num_samples)

print(f'Sputtering yield for {ion["symbol"]} on {target["symbol"]} at {energy} eV is {Y} at/ion. Yamamura predicts { np.round(yamamura(ion, target, energy),3)} at/ion.')
np.testing.assert_approx_equal(Y, 0.044)
np.testing.assert_approx_equal(Y, 0.045)

R_N, R_E = reflection_coefficient(ion, target, energy, angle, num_samples)
print(f'Particle reflection coefficient for {ion["symbol"]} on {target["symbol"]} at {energy} eV is {R_N}. Thomas predicts {np.round(thomas_reflection(ion, target, energy), 3)}.')
Expand All @@ -132,15 +132,15 @@ def main():
Y = sputtering_yield(ion, target, energy, angle, num_samples)
R_N, R_E = reflection_coefficient(ion, target, energy, angle, num_samples)

np.testing.assert_approx_equal(Y, 3.3481)
np.testing.assert_approx_equal(Y, 3.3154)
np.testing.assert_approx_equal(R_N, 0.0878)
np.testing.assert_approx_equal(R_E, 0.013734709021659743)

ion = copper # testing with Es > 0
Y = sputtering_yield(ion, target, energy, angle, num_samples)
R_N, R_E = reflection_coefficient(ion, target, energy, angle, num_samples)

np.testing.assert_approx_equal(Y, 4.9431)
np.testing.assert_approx_equal(Y, 4.9043)
np.testing.assert_approx_equal(R_N, 0.0066)
np.testing.assert_approx_equal(R_E, 0.000298720196409247)

Expand Down Expand Up @@ -273,7 +273,7 @@ def main():
plt.plot([50.0, 50.0], [0.0, np.max(heights)*1.1])
plt.gca().set_ylim([0.0, np.max(heights)*1.1])

np.testing.assert_approx_equal(np.mean(x), 10.424570485829282)
np.testing.assert_approx_equal(np.mean(x), 9.844300403767717)

number_ions = 10000

Expand Down Expand Up @@ -343,8 +343,8 @@ def main():
print(f'RustBCA R: {len(reflected[:, 0])/number_ions} Thomas R: {thomas}')
print(f'Time per ion: {delta_time/number_ions} s/{ion["symbol"]}')

np.testing.assert_approx_equal(len(sputtered[:, 0])/number_ions, 0.027)
np.testing.assert_approx_equal(len(reflected[:, 0])/number_ions, 0.5155)
np.testing.assert_approx_equal(len(sputtered[:, 0])/number_ions, 0.0269)
np.testing.assert_approx_equal(len(reflected[:, 0])/number_ions, 0.5152)

plt.figure()
plt.plot(incident_index)
Expand Down
2 changes: 1 addition & 1 deletion src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Geometry for Mesh1D {
}
}
panic!("Geometry error: method inside() is returning true for points outside all layers. Check geometry.")
} else if x < self.top {
} else if x <= self.top {
&self.layers[0].densities
} else {
&self.layers[self.layers.len() - 1].densities
Expand Down
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ pub fn process_input_file<T: Geometry>(input: <T as Geometry>::InputFileFormat)
"Input error: particle input arrays of unequal length.");

if particle_parameters.interaction_index.len() <= 1 {
particle_parameters.interaction_index = vec![0; particle_parameters.Z.len()];
particle_parameters.interaction_index = vec![particle_parameters.interaction_index[0]; particle_parameters.Z.len()];
}

//Check that interaction indices are all within interaction matrices
Expand Down
2 changes: 1 addition & 1 deletion src/interactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn scaling_function(r: f64, a: f64, interaction_potential: InteractionPotent
1./(1. + (r/a).powi(2))
},
InteractionPotential::LENNARD_JONES_12_6{sigma, ..} => {
1./(1. + (r/sigma).powi(11))
1./(1. + (r/sigma).powi(12))
},
InteractionPotential::LENNARD_JONES_65_6{sigma, ..} => {
1./(1. + (r/sigma).powi(6))
Expand Down
2 changes: 2 additions & 0 deletions src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ pub fn surface_binding_energy<T: Geometry>(particle_1: &mut particle::Particle,
particle_1.dir.y = -2.*(costheta)*dy/mag + cosy;
particle_1.dir.z = -2.*(costheta)*dz/mag + cosz;
particle_1.backreflected = true;

}
particle_1.dir_old = particle_1.dir;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/particle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ impl Particle {
self.pos_old.z = self.pos.z;

//In order to keep average denisty constant, must add back previous asymptotic deflection
let distance_traveled = mfp + self.asymptotic_deflection - asymptotic_deflection;
let distance_traveled = if mfp + self.asymptotic_deflection - asymptotic_deflection > 0. {
mfp + self.asymptotic_deflection - asymptotic_deflection
} else {
0.
};

//dir has been updated, so use previous direction to advance in space
self.pos.x += self.dir_old.x*distance_traveled;
Expand Down
Loading