From eb98e99f63ad21ea3906ba466ccc4a602bc20a9a Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 10:00:42 -0700 Subject: [PATCH 1/6] Added checks on Ed/Eb >0 --- src/input.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/input.rs b/src/input.rs index 55950734..ca323a82 100644 --- a/src/input.rs +++ b/src/input.rs @@ -426,6 +426,14 @@ where ::InputFileFormat: Deserialize<'static> + 'static { material.Ed = vec![material.Ed[0]; material.m.len()]; } + for Ed_ in &material.Ed { + assert!(*Ed_ > 0.0, "Input Error: Ed cannot be less than zero.") + } + + for Eb_ in &material.Eb { + assert!(*Eb_ > 0.0, "Input Error: Eb cannot be less than zero.") + } + //Check that incompatible options are not on simultaneously if options.high_energy_free_flight_paths { assert!(options.electronic_stopping_mode == ElectronicStoppingMode::INTERPOLATED, From 0a614b957f1e86bea1e0f3e893059156ad083873 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 10:46:11 -0700 Subject: [PATCH 2/6] Add seed to make_input_file_and_run.py --- examples/make_input_file_and_run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/make_input_file_and_run.py b/examples/make_input_file_and_run.py index 9a63f8bf..366ec737 100644 --- a/examples/make_input_file_and_run.py +++ b/examples/make_input_file_and_run.py @@ -144,6 +144,7 @@ } ] ], + 'seed': 0 # if <0, will generate a seed from thread-local PRNG; if >0, will be used as seed to PRNG } # material parameters are per-species From 125f5436451c80485f8feaba3eab66e8ffadb023 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 13:19:33 -0700 Subject: [PATCH 3/6] Revert ck --- src/input.rs | 10 +++++----- src/material.rs | 2 +- src/tests.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/input.rs b/src/input.rs index ca323a82..34d41315 100644 --- a/src/input.rs +++ b/src/input.rs @@ -665,27 +665,27 @@ where ::InputFileFormat: Deserialize<'static> + 'static { y: match y { Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rng)*length_unit}, Distributions::UNIFORM{min, max} => {let uniform = Uniform::new(min, max).unwrap(); uniform.sample(&mut rng)*length_unit}, - Distributions::POINT(x) => x*length_unit, + Distributions::POINT(y) => y*length_unit, }, z: match z { Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rng)*length_unit}, Distributions::UNIFORM{min, max} => {let uniform = Uniform::new(min, max).unwrap(); uniform.sample(&mut rng)*length_unit}, - Distributions::POINT(x) => x*length_unit, + Distributions::POINT(z) => z*length_unit, }, ux: match cosx { Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rng)*length_unit}, Distributions::UNIFORM{min, max} => {let uniform = Uniform::new(min, max).unwrap(); uniform.sample(&mut rng)*length_unit}, - Distributions::POINT(x) => x*length_unit + Distributions::POINT(ux) => ux }, uy: match cosy { Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rng)*length_unit}, Distributions::UNIFORM{min, max} => {let uniform = Uniform::new(min, max).unwrap(); uniform.sample(&mut rng)*length_unit}, - Distributions::POINT(x) => x*length_unit, + Distributions::POINT(uy) => uy, }, uz: match cosz { Distributions::NORMAL{mean, std} => {let normal = Normal::new(mean, std).unwrap(); normal.sample(&mut rng)*length_unit}, Distributions::UNIFORM{min, max} => {let uniform = Uniform::new(min, max).unwrap(); uniform.sample(&mut rng)*length_unit}, - Distributions::POINT(x) => x*length_unit, + Distributions::POINT(uz) => uz, }, interaction_index, tag: 0, diff --git a/src/material.rs b/src/material.rs index b547ba73..9fcff592 100644 --- a/src/material.rs +++ b/src/material.rs @@ -298,7 +298,7 @@ impl Material { let stopping_power = match electronic_stopping_mode { //Biersack-Varelas Interpolation - ElectronicStoppingMode::INTERPOLATED => 1./(1./S_high + 1./S_low)*ck, + ElectronicStoppingMode::INTERPOLATED => 1./(1./S_high + 1./(S_low*ck)) //Oen-Robinson ElectronicStoppingMode::LOW_ENERGY_LOCAL => S_low*ck, //Lindhard-Scharff diff --git a/src/tests.rs b/src/tests.rs index 237044ec..d920490e 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -975,15 +975,15 @@ fn test_momentum_conservation() { println!(); //These values are in [angstrom amu / second], so very large. - assert!(approx_eq!(f64, initial_momentum.x/ANGSTROM/AMU, final_momentum.x/ANGSTROM/AMU, epsilon = 1000.)); - assert!(approx_eq!(f64, initial_momentum.y/ANGSTROM/AMU, final_momentum.y/ANGSTROM/AMU, epsilon = 1000.)); - assert!(approx_eq!(f64, initial_momentum.z/ANGSTROM/AMU, final_momentum.z/ANGSTROM/AMU, epsilon = 1000.)); + assert!(approx_eq!(f64, initial_momentum.x/ANGSTROM/AMU, final_momentum.x/ANGSTROM/AMU, epsilon = 10.)); + assert!(approx_eq!(f64, initial_momentum.y/ANGSTROM/AMU, final_momentum.y/ANGSTROM/AMU, epsilon = 10.)); + assert!(approx_eq!(f64, initial_momentum.z/ANGSTROM/AMU, final_momentum.z/ANGSTROM/AMU, epsilon = 10.)); assert!(!particle_1.E.is_nan()); assert!(!particle_2.E.is_nan()); assert!(!initial_momentum.x.is_nan()); - assert!(!initial_momentum.x.is_nan()); - assert!(!initial_momentum.x.is_nan()); + assert!(!initial_momentum.y.is_nan()); + assert!(!initial_momentum.z.is_nan()); } } } From d5121b5bac415acdfe12d1f0dacd3187884ab2a5 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 13:28:20 -0700 Subject: [PATCH 4/6] Fix missing comma in match arm. --- src/material.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material.rs b/src/material.rs index 9fcff592..e429ebe9 100644 --- a/src/material.rs +++ b/src/material.rs @@ -298,7 +298,7 @@ impl Material { let stopping_power = match electronic_stopping_mode { //Biersack-Varelas Interpolation - ElectronicStoppingMode::INTERPOLATED => 1./(1./S_high + 1./(S_low*ck)) + ElectronicStoppingMode::INTERPOLATED => 1./(1./S_high + 1./(S_low*ck)), //Oen-Robinson ElectronicStoppingMode::LOW_ENERGY_LOCAL => S_low*ck, //Lindhard-Scharff From a227bd4c9f9f083925e3dcde13b69c9522dcd0f3 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 13:37:03 -0700 Subject: [PATCH 5/6] Changes to assertions on Ed - not sure why it is failing. --- src/input.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input.rs b/src/input.rs index 34d41315..3411ad18 100644 --- a/src/input.rs +++ b/src/input.rs @@ -427,11 +427,11 @@ where ::InputFileFormat: Deserialize<'static> + 'static { } for Ed_ in &material.Ed { - assert!(*Ed_ > 0.0, "Input Error: Ed cannot be less than zero.") + assert!(*Ed_ > 0.0, "Input Error: Ed = {}; Ed cannot be less than zero.", Ed_); } for Eb_ in &material.Eb { - assert!(*Eb_ > 0.0, "Input Error: Eb cannot be less than zero.") + assert!(*Eb_ > 0.0, "Input Error: Eb = {}; Eb cannot be less than zero.", Eb_); } //Check that incompatible options are not on simultaneously From d67c407286deeb8aeab621ef5b1a4a0edcdf6878 Mon Sep 17 00:00:00 2001 From: Jon Drobny Date: Wed, 29 Jul 2026 13:41:20 -0700 Subject: [PATCH 6/6] Check needed to be >=, not >. --- src/input.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input.rs b/src/input.rs index 3411ad18..02665b17 100644 --- a/src/input.rs +++ b/src/input.rs @@ -427,11 +427,11 @@ where ::InputFileFormat: Deserialize<'static> + 'static { } for Ed_ in &material.Ed { - assert!(*Ed_ > 0.0, "Input Error: Ed = {}; Ed cannot be less than zero.", Ed_); + assert!(*Ed_ >= 0.0, "Input Error: Ed = {}; Ed cannot be less than zero.", Ed_); } for Eb_ in &material.Eb { - assert!(*Eb_ > 0.0, "Input Error: Eb = {}; Eb cannot be less than zero.", Eb_); + assert!(*Eb_ >= 0.0, "Input Error: Eb = {}; Eb cannot be less than zero.", Eb_); } //Check that incompatible options are not on simultaneously