Ejemplo n.º 1
0
        public static SpaceGroup IdentifyGroup(SymmetryList syms)
        {
            for (int i = 230; i >= 1; i--)
            {
                SpaceGroup test  = mGroups[i];
                bool       found = true;

                foreach (var sym in test.PrimitiveSymmetries)
                {
                    if (syms.Contains(sym) == false)
                    {
                        found = false;
                    }
                }

                if (found)
                {
                    test.GenerateSymmetries();
                    return(test);
                }
            }

            // return lowest symmetry group.
            mGroups[1].GenerateSymmetries();
            return(mGroups[1]);
        }
Ejemplo n.º 2
0
        static void Initialize()
        {
            if (init)
            {
                return;
            }
            init = true;

            InitializeRegex();
            string groups = Properties.Resources.spgroup;

            using (StringReader r = new StringReader(groups))
            {
                for (; ;)
                {
                    string groupName = r.ReadLine().Trim();
                    int    number;

                    if (groupName.EndsWith("&"))
                    {
                        break;
                    }

                    if (int.TryParse(groupName.Substring(1, groupName.Length - 2), out number) == false)
                    {
                        throw new Exception();
                    }


                    SpaceGroup sp = new SpaceGroup();
                    sp.Number = number;

                    for (; ;)
                    {
                        if (r.Peek() == '/')
                        {
                            break;
                        }

                        string text      = r.ReadLine();
                        int    lastColon = text.IndexOf(":", 8);

                        var sym = ParseSymmetry(text);
                        sym.Name = text.Substring(lastColon + 1).Trim();

                        if (sym.Value.IsIdentity)
                        {
                            continue;
                        }

                        if (mPrimitiveSymmetries.Contains(sym) == false)
                        {
                            mPrimitiveSymmetries.Add(sym);
                        }

                        sp.PrimitiveSymmetries.Add(sym);
                    }

                    mGroups.Add(number, sp);
                }
            }

            using (StringReader r = new StringReader(Properties.Resources.spnames))
            {
                for (; ;)
                {
                    string text = r.ReadLine();

                    if (text == "&")
                    {
                        break;
                    }

                    string[] vals = text.Split('-');

                    int    number = int.Parse(vals[0]);
                    string name   = vals[1].Trim();

                    mGroups[number].Name = name;
                }
            }
        }