public void TestIsotope_IElement() { var element = ChemicalElement.C; IIsotope i = new Isotope(element); Assert.AreEqual("C", i.Symbol); }
/// <summary> /// Comparison method to sort the isotopes by natural abundance /// Sorts largest to smallest /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private int CompareNaturalAbundance(Isotope x, Isotope y) { if (x == null) { if (y == null) { return(0); } return(-1); } if (y == null) { return(1); } var returnValue = y.NaturalAbundance.CompareTo(x.NaturalAbundance); if (returnValue != 0) { return(returnValue); } return(y.Mass.CompareTo(x.Mass)); }
public double CalculateMassSums() { double mass_sum = 0; for (Isotope iso = Isotope.pu238; iso <= Isotope.am241; iso++) { currentMassSum[(int)iso].v = 0; } foreach (CompositeIsotopic ci in isotopicComponents) { if (ci.pu_mass == 0.0f) { continue; } for (Isotope iso = Isotope.pu238; iso <= Isotope.am241; iso++) { currentMassSum[(int)iso].v += ci.CurrentMass[(int)iso].v; } } for (Isotope iso = Isotope.pu238; iso <= Isotope.pu242; iso++) { mass_sum += currentMassSum[(int)iso].v; } return(mass_sum); }
//draws the isotope label at ten-o-clock private LabelMetrics DrawIsotopeLabel(DrawingContext drawingContext, AtomTextMetrics mainAtomMetrics, AtomTextMetrics hMetrics) { Debug.Assert(Isotope != null); string isoLabel = Isotope.ToString(); var isotopeText = new IsotopeLabelText(isoLabel, PixelsPerDip()); Vector isotopeOffsetVector = BasicGeometry.ScreenNorth * GlyphText.SymbolSize; Matrix rotator = new Matrix(); double angle = -60; //avoid overlap of label and hydrogens if (hMetrics != null && ParentAtom.GetDefaultHOrientation() == CompassPoints.West) { angle = -35; } rotator.Rotate(angle); isotopeOffsetVector = isotopeOffsetVector * rotator; Point isoCenter = mainAtomMetrics.Geocenter + isotopeOffsetVector; isotopeText.MeasureAtCenter(isoCenter); isotopeText.Fill = Fill; isotopeText.DrawAtBottomLeft(isotopeText.TextMetrics.BoundingBox.BottomLeft, drawingContext); return(isotopeText.TextMetrics); }
/// <summary> /// Parse isotopic envelope string for feature. /// </summary> /// <param name="env">Isotopic envelope string.</param> /// <returns>Array of isotopes.</returns> private static Isotope[] ReadIsotopicEnvelope(string env) { var isotopePeaks = env.Split(';'); if (isotopePeaks.Length == 0) { return(null); } var isotopes = new Isotope[isotopePeaks.Length]; for (int i = 0; i < isotopePeaks.Length; i++) { var parts = isotopePeaks[i].Split(','); if (parts.Length < 2) { continue; } int index; double relativeIntensity; if (!int.TryParse(parts[0], out index) || !double.TryParse(parts[1], out relativeIntensity)) { continue; } isotopes[i] = new Isotope(index, relativeIntensity); } return(isotopes); }
/// <summary> /// Compares the isotopicNumber for sorting purposes. Sorts smallest to largest /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private int CompareNumber(Isotope x, Isotope y) { if (x == null) { if (y == null) { return(0); } else { return(-1); } } else { if (y == null) { return(1); } else { return(x.IsotopeNumber.CompareTo(y.IsotopeNumber)); } } }
/// <summary> /// Comparison method to sort the isotopes by natural abundance /// Sorts largest to smallest /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private int CompareNaturalAbundance(Isotope x, Isotope y) { if (x == null) { if (y == null) { return(0); } else { return(-1); } } else { if (y == null) { return(1); } else { var retval = y.NaturalAbundance.CompareTo(x.NaturalAbundance); if (retval != 0) { return(retval); } else { return(y.Mass.CompareTo(x.Mass)); } } } }
public void TestIsotope_String_int() { IIsotope i = new Isotope("C", 12); Assert.AreEqual(12, i.MassNumber.Value); Assert.AreEqual("C", i.Symbol); }
public void TestIsotope_Transmute() { int z1 = 1, a1 = 4; var iso1 = new Isotope(z1, a1, null, Decay.NEmit, 0.001, 's'); int z1p = iso1.Transmute(Decay.NEmit, out int a1p); Assert.AreEqual(a1 - 1, a1p); Assert.AreEqual(z1, z1p); int z2 = 118, a2 = 300; var iso2 = new Isotope(z: z2, a: a2, abundance: null, decayMode: Decay.Alpha, halflife: 0.02, timeUnit: 's'); int z2p = iso2.Transmute(Decay.Alpha, out int a2p); Assert.AreEqual(a2 - 4, a2p); Assert.AreEqual(z2 - 2, z2p); int z3 = 3, a3 = 8; var iso3 = new Isotope(z3, a3, null, Decay.BetaMinus, 0.03, 's'); int z3p = iso3.Transmute(Decay.BetaMinus, out int a3p); Assert.AreEqual(a3, a3p); Assert.AreEqual(z3 + 1, z3p); int z4 = 4, a4 = 11; var iso4 = new Isotope(z4, a4, null, Decay.BetaPlus, 0.04, 's'); int z4p = iso4.Transmute(Decay.BetaPlus, out int a4p); Assert.AreEqual(a4, a4p); Assert.AreEqual(z4 - 1, z4p); int z5 = 6, a5 = 15; var iso5 = new Isotope(z5, a5, null, Decay.Beta2, 0.05, 's'); int z5p = iso5.Transmute(Decay.Beta2, out int a5p); Assert.AreEqual(a5, a5p); Assert.AreEqual(z5 + 2, z5p); int z6 = 6, a6 = 15; var iso6 = new Isotope(z6, a6, null, Decay.ECap1, 0.06, 's'); int z6p = iso6.Transmute(Decay.ECap1, out int a6p); Assert.AreEqual(a6, a6p); Assert.AreEqual(z6 - 1, z6p); int z7 = 7, a7 = 17; var iso7 = new Isotope(z7, a7, null, Decay.ECap2, 0.07, 's'); int z7p = iso7.Transmute(Decay.ECap2, out int a7p); Assert.AreEqual(a7, a7p); Assert.AreEqual(z7 - 2, z7p); int z8 = 8, a8 = 18; var iso8 = new Isotope(z8, a8, null, Decay.Gamma, 0.08, 's'); int z8p = iso8.Transmute(Decay.Gamma, out int a8p); Assert.AreEqual(a8, a8p); Assert.AreEqual(z8, z8p); }
public void TestIsotope_int_String_double_double() { IIsotope i = new Isotope("C", 12.001, 80.0); Assert.AreEqual("C", i.Symbol); Assert.AreEqual(6, i.AtomicNumber); Assert.AreEqual(12.001, i.ExactMass.Value, 0.001); Assert.AreEqual(80.0, i.Abundance.Value, 0.001); }
public bool check_grid(int n, Isotope.Drawing.Size s, int dcols, int drows) { int r, c; GridLayout.GetSquarestGrid(n, s, out c, out r); Assert.AreEqual(drows, r); Assert.AreEqual(dcols, c); return true; }
public void AddLargeIsotopeToFormula() { ChemicalFormula formulaA = new ChemicalFormula("C2H3NO"); ChemicalFormula formulaB = new ChemicalFormula("C2H3NOFe"); Isotope fe = PeriodicTable.GetElement("Fe").PrincipalIsotope; formulaA.Add(fe, 1); Assert.AreEqual(formulaA, formulaB); }
public void AddZeroIsotopeToFormula() { ChemicalFormula formulaA = new ChemicalFormula("C2H3NO"); ChemicalFormula formulaB = new ChemicalFormula("C2H3NO"); Isotope h1 = PeriodicTable.GetElement("H")[1]; formulaA.Add(h1, 0); Assert.AreEqual(formulaA, formulaB); }
public void AddNegativeIsotopeToFormula() { ChemicalFormula formulaA = new ChemicalFormula("C2HH{1}2NO"); ChemicalFormula formulaB = new ChemicalFormula("C2HNO"); Isotope h1 = PeriodicTable.GetElement("H")[1]; formulaA.Add(h1, -2); Assert.AreEqual(formulaA, formulaB); }
public static void AddIsotopeToFormula() { ChemicalFormula formulaA = ChemicalFormula.ParseFormula("C2H3NO"); ChemicalFormula formulaB = ChemicalFormula.ParseFormula("C2H3H{1}NO"); Isotope h1 = PeriodicTable.GetElement("H")[1]; formulaA.Add(h1, 1); Assert.AreEqual(formulaA, formulaB); }
/// <summary> /// Removes an isotope. /// </summary> /// <param name="isotope">The isotope to remove.</param> /// <returns>true if exists; otherwise, false.</returns> public bool RemoveIsotope(Isotope isotope) { if (!isotopes.Remove(isotope)) { return(false); } if (isotopes.Remove(isotope)) { isotopes.Remove(isotope); } return(true); }
public void AddIsotopeWithExistingMassNumber() { var elementC = new Element("C", 6, 12.0106); elementC.AddIsotope(12, 12, 0.9893); elementC.AddIsotope(13, 13.00335483507, 0.0107); Isotope isotope = elementC[13]; Assert.AreEqual("C{13}", isotope.ToString()); Assert.AreEqual(6, isotope.Protons); Assert.AreEqual(7, isotope.Neutrons); }
public int SpecificIsotopeCount(Isotope isotope) { // Residues count int count = residues.Sum(aar => aar.ThisChemicalFormula.CountSpecificIsotopes(isotope)); // Modifications count (if the mod is a IHasChemicalFormula) if (_modifications != null) { count += _modifications.Where(mod => mod is IHasChemicalFormula).Cast <IHasChemicalFormula>().Sum(mod => mod.ThisChemicalFormula.CountSpecificIsotopes(isotope)); } return(count); }
public void TestCompare_NaturalAbundance() { Isotope iso = new Isotope("C") { Abundance = 12.000000 }; Isotope iso2 = new Isotope("C") { Abundance = 12.0 }; Assert.IsTrue(iso.Compare(iso2)); }
public void TestCompare_ExactMass() { Isotope iso = new Isotope("C") { ExactMass = 12.000000 }; Isotope iso2 = new Isotope("C") { ExactMass = 12.0 }; Assert.IsTrue(iso.Compare(iso2)); }
public void TestCompare_MassNumber() { Isotope iso = new Isotope("C") { MassNumber = 12 }; Isotope iso2 = new Isotope("C") { MassNumber = (int)12.0 }; Assert.IsTrue(iso.Compare(iso2)); }
public Isotopics CreateIsotopicsFromSums(DateTime ref_date, bool INCCParity, double mass_sum) { Isotopics isor = new Isotopics(); isor.pu_date = new DateTime(ref_date.Ticks); isor.am_date = new DateTime(ref_date.Ticks); isor.source_code = source_code; isor.id = string.Copy(id); for (Isotope iso = Isotope.pu238; iso <= Isotope.am241; iso++) { isor.SetVal(iso, 100.0 * currentMassSum[(int)iso].v / mass_sum); } return(isor); }
private IElement GetFixedIsotopeElement(IElement element, int?fixedIsotopeNumber) { if (fixedIsotopeNumber == null) { return(element); } IIsotope oldIsotope = element.Isotopes .Single(x => x.NeutronCount == fixedIsotopeNumber - element.AtomicNumber); IIsotope newIsotope = new Isotope(element.AtomicNumber, oldIsotope.NeutronCount, 1.0); return(new Element(element.AtomicNumber, element.Symbol, new ReadOnlyCollection <IIsotope>(new[] { newIsotope }))); }
protected void InitializeIsotopes() { var elements = GetAllElements(Constants.FILETYP.DECAY); foreach (var element in elements) { var isotope = new Isotope(element.Z, element.A); foreach (var data in NuclearData) { var fn = GetIsotopeFile(element.Z, element.A, data.ReactionType); isotope = data.Read(isotope, element.Z, element.A, fn); } Isotopes.Add(isotope); } }
public void TestIsotope_Ctor() { var iso1 = new Isotope(2, 5, 0.0); Assert.AreEqual(2, iso1.Z); Assert.AreEqual(5, iso1.A); Assert.AreEqual(Decay.None, iso1.DecayMode); Assert.AreEqual(0, iso1.StabilityIndex); Assert.IsTrue(iso1.IsStable); var iso2 = new Isotope(z: 118, a: 300, abundance: null, decayMode: Decay.Alpha, halflife: 0.01, timeUnit: 's'); Assert.AreEqual(300, iso2.A); Assert.AreEqual(Decay.Alpha, iso2.DecayMode); Assert.AreEqual(5, iso2.StabilityIndex); }
public static void FillIsotopes() { DataTable dt = iRadiate.Common.IO.TextFileReader.ReadCSVFile("Isotopes.csv", true); foreach (DataRow r in dt.Rows) { Isotope iso = new Isotope(); iso.Element = lib.GetItems(typeof(Element), new List <RetrievalCriteria>()).Where(x => (x as Element).Symbol == r["AtomicSymbol"].ToString()).First() as Element; iso.Weight = Convert.ToInt32(r["Weight"].ToString()); iso.Metastable = Convert.ToBoolean(r["Metastable"].ToString()); iso.HalfLife = Convert.ToDouble(r["HalfLife"].ToString()); lib.SaveItem(iso); DumpDataStoreItem(iso); } }
private Geometry DrawIsotopeLabel(Atom parentAtom, Geometry symbolGeometry) { Point startingPoint = parentAtom.Position; Point nextPos; if (parentAtom.IsotopeNumber == null) { return(symbolGeometry); } else { Geometry atomGeo = null; string isoLabel = Isotope.ToString(); if (!(symbolGeometry is EllipseGeometry)) //that is, weve got an explcit, non carbon element { var atomText = BuildSymbolLabel(parentAtom.SymbolText, ref startingPoint, out nextPos); atomGeo = atomText.BuildGeometry(startingPoint); } else //its a vertex carbon { atomGeo = symbolGeometry; } //have a stab at placing the isotope label. //placementvector gives the CENTRE of the charge text! //first generate a vector pointing straight up Vector placementVector = new Vector(0.0, -Math.Max(atomGeo.Bounds.Width, atomGeo.Bounds.Height)); Matrix rotator = new Matrix(); //isotope labels always go in at 10-o-clock from the atom. rotator.Rotate(-60); placementVector *= rotator; //Point firstPlacementPoint = new Point(atomGeo.Bounds.Right, atomGeo.Bounds.Top - chargeText.Height/2); FormattedText isoText = GetSubscriptText(isoLabel); Point firstPlacementPoint = parentAtom.Position + placementVector - new Vector(isoText.Width / 2, isoText.Height / 2); System.Windows.Media.Geometry isoGeo = isoText.BuildGeometry(firstPlacementPoint); return(new CombinedGeometry(symbolGeometry, isoGeo)); } }
public static void FillRadiopharmaceuticals() { DataTable dt = iRadiate.Common.IO.TextFileReader.ReadCSVFile("Radiopharmacueticals.csv", true); foreach (DataRow r in dt.Rows) { Console.WriteLine(r["AtomicSymbol"].ToString() + " " + r["AtomicWeight"].ToString()); Chemical rp = new Chemical(); List <RetrievalCriteria> rcList = new List <RetrievalCriteria>(); RetrievalCriteria rc1 = new RetrievalCriteria("Abbreviation", CriteraType.ExactTextMatch, r["AtomicSymbol"].ToString() + "-" + r["AtomicWeight"].ToString()); rcList.Add(rc1); Isotope iso = lib.GetItems(typeof(Isotope), rcList).First() as Isotope; rp.Isotope = iso; rp.LigandAbbreviation = r["Ligand"].ToString(); lib.SaveItem(rp); } }
public void PeptideCountElements() { Peptide pep = new Peptide("G"); pep.AddModification(new OldSchoolModification(1)); Assert.AreEqual(5, pep.ElementCountWithIsotopes("H")); pep.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H{1}"))); Assert.AreEqual(5, pep.ElementCountWithIsotopes("H")); // NOTHING HAS BEEN ADDED! pep.AddModification(new OldSchoolChemicalFormulaModification(ChemicalFormula.ParseFormula("H{1}"), ModificationSites.G)); Assert.AreEqual(6, pep.ElementCountWithIsotopes("H")); Isotope isotope = PeriodicTable.GetElement("H").PrincipalIsotope; Assert.AreEqual(1, pep.SpecificIsotopeCount(isotope)); }
private void initialize(Isotope isotope) { AtomicMassLabel.Text = isotope.AtomicMass + " aem"; IsotopeName.Text = isotope.Name; var time = " s"; var halfLife = isotope.HalfLife; if (isotope.HalfLife < 1.0) { time = " ms"; halfLife = isotope.HalfLife * 1000.0; } if (isotope.HalfLife >= 60) { time = " mins"; halfLife = isotope.HalfLife / 60.0; } if (isotope.HalfLife >= 3600) { time = " hs"; halfLife = isotope.HalfLife / 3600.0; } if (isotope.HalfLife >= 86400) { time = " days"; halfLife = isotope.HalfLife / 86400.0; } if (isotope.HalfLife >= 31536000) { time = " yrs"; halfLife = isotope.HalfLife / 31536000; } HalfLifeLabel.Text = halfLife + time; decaysPanel.Controls.Clear(); if (Isotope.Decays.Count == 0) { label5.Text = ""; HalfLifeLabel.Text = "stable"; } foreach (var decay in Isotope.Decays) { var decayView = new DecayInfoView(decay.Value); decaysPanel.Controls.Add(decayView); decayView.Dock = DockStyle.Top; } var csView = new CrossSectionInfoView(Isotope.CrossSections.Select(x => x.Value).ToList()); crossSectionPanel.Controls.Clear(); crossSectionPanel.Controls.Add(csView); csView.Dock = DockStyle.Top; }
private void Submit_Click(object sender, EventArgs e) { if (txtB_Nuclear.Text == null || txtB_Nuclear.Text == "") { MessageBox.Show("Не правльный формат названия изотопа, должно быть U-235", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var iso = Endf.GetIsotope(txtB_Nuclear.Text); var str = Isotope.ShowIsotope(iso); txtB_Info.Text = str; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Parse text field to as non-negative double, /// assign value to current isotopics instance, /// format the active text field for user display. /// </summary> /// <param name="sender">dialog text field event handler</param> /// <param name="i">isotopic entry index</param> private void IsoSigmaNNCheck(TextBox sender, Isotope i) { m_iso.modified |= Format.ToNN(sender.Text, ref m_iso[i].sigma); sender.Text = m_iso[i].sigma.ToString("F6"); }
/// <summary> /// Parse text field to as percent (double), /// assign value to current isotopics instance, /// format the active text field for user display. /// </summary> /// <param name="sender">dialog text field event handler</param> /// <param name="i">isotopic entry index</param> private void IsoPctCheck(TextBox sender, Isotope i) { m_iso.modified |= Format.ToPct(sender.Text, ref m_iso[i].v); sender.Text = m_iso[i].v.ToString("F6"); }
private static void drawnode(Isotope.Layout.BoxHierarchy.Node<object> node, Isotope.Drawing.Rectangle rect, object data) { }