standard_atomic_mass/
standard_atomic_mass.rs

1use ::Nuclide::{Nuclide,ChemElement,Isotope};
2//use ::Nuclide::ChemElement;
3
4/*
5   Nuclide does not have a standard atomic weight for the elements however it can be trivially computed for a sample
6   given a list of the  nuclides known to exist and a vector of the distribution ratios 
7   
8   Note that this has been superseded by Jan-Grimo's addition of NuclideFraction and the Element enums
9*/
10
11fn standard_atomic_mass(isos: &[Nuclide], dist: &[f64]) -> f64{
12  let mut mass = 0f64;
13  for i in 0..isos.len(){
14    mass+=isos[i].am()*dist[i];
15  }
16  mass
17}
18
19
20fn main(){
21let hydro = vec![Nuclide::new("H-1").unwrap(), Nuclide::new("H-2").unwrap(), Nuclide::new("H-3").unwrap()];
22let distr = vec![0.9998,0.000156,1E-18];
23 println!("The standard atomic mass of hydrogen is {:?} ", standard_atomic_mass(&hydro[..], &distr[..]));
24
25let error_values = vec!["B-17","N-23","Ne-17","Ne-31","Mg-21","Mg-34","Mg-37",
26"Al-26","K-31","Cr-43","Mn-46","Co-58","Se-63","Kr-67","Rb-92","Ba-114",
27"Ac-225","Th-226","Th-228","Th-230","Th-232","Pa-230","Pa-231","Pa-236","Pa-238",
28"U-228","U-230","U-232","U-233","U-234","U-235","U-236","U-238","Np-229",
29"Np-236","Np-237","Pu-229","Pu-235","Pu-236","Pu-237","Pu-238","Pu-240"];
30
31for i in error_values{
32   println!("{}", Nuclide::new(i).unwrap().decay_string());
33}
34
35}