예제 #1
0
        public void CalculateElementRatio()
        {
            for (int i = 0; i < Elements.Count; i++)
            {
                Elements[i].WeightRatio    = 0;
                Elements[i].MolarAbundance = 0;
                Elements[i].StandardName   = this.Name;
                if (!Molecules.Any(m => m.Elements.Any(e => e.Z == Elements[i].Z)))
                {
                    Elements.RemoveAt(i--);
                }
            }

            if (WeightMode)
            {
                double totalMol = 0;
                for (int i = 0; i < Molecules.Count; i++)
                {
                    totalMol += Molecules[i].WeightRatio / Molecules[i].MolarWeight;
                }
                if (totalMol > 0)
                {
                    for (int i = 0; i < Molecules.Count; i++)
                    {
                        Molecules[i].MolarAbundance = Molecules[i].WeightRatio / Molecules[i].MolarWeight / totalMol;
                    }
                }
            }
            else
            {
                double totalWeight = 0;
                for (int i = 0; i < Molecules.Count; i++)
                {
                    totalWeight += Molecules[i].MolarWeight * Molecules[i].MolarAbundance;
                }
                if (totalWeight > 0)
                {
                    for (int i = 0; i < Molecules.Count; i++)
                    {
                        Molecules[i].WeightRatio = Molecules[i].MolarWeight * Molecules[i].MolarAbundance / totalWeight;
                    }
                }
            }

            foreach (Molecule m in Molecules)
            {
                foreach (Element e in m.Elements)
                {
                    int j = Elements.FindIndex(e1 => e1.Z == e.Z);
                    if (j >= 0)//見つかったら
                    {
                        Elements[j].WeightRatio    += m.WeightRatio * e.MolarAbundance * e.MolarWeight / m.MolarWeight;
                        Elements[j].MolarAbundance += m.MolarAbundance * e.MolarAbundance;
                    }
                    else
                    {
                        Element element = Deep.Copy <Element>(e);
                        element.StandardName = this.Name;
                        Elements.Add(element);
                        Elements[^ 1].WeightRatio    = m.WeightRatio * e.MolarAbundance * e.MolarWeight / m.MolarWeight;
예제 #2
0
        public static Profile SavitzkyGolay(Profile profile, int pointNum, int order)
        {
            if (pointNum < 2)
            {
                return(Deep.Copy <Profile>(profile));
            }
            if (pointNum < order + 1)
            {
                order = pointNum - 1;
            }
            if (order <= 0)
            {
                return(Deep.Copy <Profile>(profile));
            }
            if (profile.Pt.Count < 3)
            {
                return(Deep.Copy <Profile>(profile));
            }

            if (Math.Abs((profile.Pt[profile.Pt.Count - 1].X - profile.Pt[profile.Pt.Count - 2].X) / (profile.Pt[1].X - profile.Pt[0].X) - 1) < 0.000000001)
            {
                return(new Profile(SavitzkyGolaySimple(profile.Pt.ToArray(), pointNum, order)));
            }
            else
            {
                return(new Profile(SavitzkyGolayAccuracy(profile.Pt.ToArray(), pointNum, order)));
            }
        }
예제 #3
0
        public static Profile SavitzkyGolay(Profile profile, int pointNum, int order)
        {
            if (pointNum < 2)
            {
                return(Deep.Copy <Profile>(profile));
            }
            if (pointNum < order + 1)
            {
                order = pointNum - 1;
            }
            if (order <= 0)
            {
                return(Deep.Copy <Profile>(profile));
            }
            if (profile.Pt.Count < 3)
            {
                return(Deep.Copy <Profile>(profile));
            }

            if (Math.Abs((profile.Pt[^ 1].X - profile.Pt[^ 2].X) / (profile.Pt[1].X - profile.Pt[0].X) - 1) < 0.000000001)
예제 #4
0
 public Element Clone()
 {
     return(Deep.Copy <Element>(this));
 }
예제 #5
0
 public Compound Clone()
 {
     return(Deep.Copy <Compound>(this));
 }
예제 #6
0
 public Molecule Clone()
 {
     return(Deep.Copy <Molecule>(this));
 }