/** * Gets the natural mass of this element, defined as average of masses of isotopes, * weighted by abundance. * * @param element the element in question * @return The natural mass value */ public double getNaturalMass(IElement element) { IIsotope[] isotopes = getIsotopes(element.getSymbol()); double summedAbundances = 0; double summedWeightedAbundances = 0; double getNaturalMass = 0; for (int i = 0; i < isotopes.length; i++) { summedAbundances += isotopes[i].getNaturalAbundance(); summedWeightedAbundances += isotopes[i].getNaturalAbundance() * isotopes[i].getExactMass(); getNaturalMass = summedWeightedAbundances / summedAbundances; } return getNaturalMass; }
/** * Gets the natural mass of this element, defined as average of masses of isotopes, * weighted by abundance. * * @param element the element in question * @return The natural mass value */ public double getNaturalMass(IElement element) { IIsotope[] isotopes = getIsotopes(element.getSymbol()); double summedAbundances = 0; double summedWeightedAbundances = 0; double getNaturalMass = 0; for (int i = 0; i < isotopes.length; i++) { summedAbundances += isotopes[i].getNaturalAbundance(); summedWeightedAbundances += isotopes[i].getNaturalAbundance() * isotopes[i].getExactMass(); getNaturalMass = summedWeightedAbundances / summedAbundances; } return getNaturalMass; }
@Test public void testGetIsotopes_Nonelement() throws Exception { IsotopeFactory isofac = Isotopes.getInstance(); IIsotope[] list = isofac.getIsotopes("E"); Assert.assertNotNull(list); Assert.assertEquals(0, list.length); }
public ValidationReport validateIsotopeExistence(IIsotope isotope) { ValidationReport report = new ValidationReport(); ValidationTest isotopeExists = new ValidationTest(isotope, "Isotope with this mass number is not known for this element."); try { IsotopeFactory isotopeFac = Isotopes.getInstance(); IIsotope[] isotopes = isotopeFac.getIsotopes(isotope.getSymbol()); if (isotope.getMassNumber() != null && isotope.getMassNumber() != 0) { boolean foundKnownIsotope = false; for (int i = 0; i < isotopes.length; i++) { if (Objects.equals(isotopes[i].getMassNumber(), isotope.getMassNumber())) { foundKnownIsotope = true; } } if (!foundKnownIsotope) { report.addError(isotopeExists); } else { report.addOK(isotopeExists); } } else { // isotopic is unspecified report.addOK(isotopeExists); } } catch (Exception exception) { // too bad... } return report; }
for (IIsotope isotope : isoFactory.getIsotopes(elementSymbol)) { double mass = isotope.getExactMass(); double abundance = isotope.getNaturalAbundance();
IIsotope[] carbons = ifac.getIsotopes("C"); IIsotope c13 = carbons[5]; // 13 IIsotope h = ifac.getMajorIsotope("H");