Exemplo n.º 1
0
            void ReadKPathSection(string section, ref KptList path)
            {
                if (path != null)
                {
                    ThrowEx(section + " found twice.");
                }

                Vector3 lastKpt = Vector3.Zero;

                char[]       array   = new char[] { ' ' };
                const double ptScale = 400;
                int          ptCount = 0;

                path = new KptList();
                while (EOF == false && LineType != LineType.NewSection)
                {
                    double dummy;

                    string[] vals = Line.Split(array, StringSplitOptions.RemoveEmptyEntries);
                    if (vals.Length != 3 && vals.Length != 4)
                    {
                        ThrowEx("Cannot understand path entry.");
                    }

                    string text = Line;
                    string name = string.Empty;

                    if (double.TryParse(vals[0], out dummy) == false)
                    {
                        text = text.Substring(text.IndexOf(' '));
                        name = vals[0];
                    }

                    Vector3 vecval = Vector3.Parse(text);
                    Vector3 kpt    = vecval;
                    double  length = (kpt - lastKpt).Magnitude;

                    if (ptCount == 0)
                    {
                        path.AddPts(kpt, kpt, 1);
                    }
                    else
                    {
                        path.AddPts(lastKpt, kpt, Math.Max((int)(ptScale * length), 1));
                    }
                    path.Kpts[path.Kpts.Count - 1].Name = name;
                    ptCount++;

                    lastKpt = kpt;

                    ReadNextLine();
                }
            }
Exemplo n.º 2
0
        public static KptList DefaultPath(Lattice l)
        {
            const int pts    = 40;
            KptList   retval = new KptList();

            retval.Kpts.Add(new KPoint(Vector3.Zero));
            retval.AddPts(Vector3.Zero, l.G1 * Math.PI, pts);
            retval.AddPts(l.G1 * Math.PI, (l.G1 + l.G2) * Math.PI, pts);
            retval.AddPts((l.G1 + l.G2) * Math.PI, l.G2 * Math.PI, pts);
            retval.AddPts(l.G2 * Math.PI, l.G3 * Math.PI, pts);
            retval.AddPts(l.G3 * Math.PI, Vector3.Zero, pts);

            return(retval);
        }
Exemplo n.º 3
0
        public static KptList DefaultPath(Lattice l)
        {
            const int pts = 40;
            KptList retval = new KptList();

            retval.Kpts.Add(new KPoint(Vector3.Zero));
            retval.AddPts(Vector3.Zero, l.G1 * Math.PI, pts);
            retval.AddPts(l.G1 * Math.PI, (l.G1 + l.G2) * Math.PI, pts);
            retval.AddPts((l.G1 + l.G2) * Math.PI, l.G2 * Math.PI, pts);
            retval.AddPts(l.G2 * Math.PI, l.G3 * Math.PI, pts);
            retval.AddPts(l.G3 * Math.PI, Vector3.Zero, pts);

            return retval;
        }
            void ReadKPathSection(string section, ref KptList path)
            {
                if (path != null)
                    ThrowEx(section + " found twice.");

                Vector3 lastKpt = Vector3.Zero;
                char[] array = new char[] { ' ' };
                const double ptScale = 400;
                int ptCount = 0;

                path = new KptList();
                while (EOF == false && LineType != LineType.NewSection)
                {
                    double dummy;

                    string[] vals = Line.Split(array, StringSplitOptions.RemoveEmptyEntries);
                    if (vals.Length != 3 && vals.Length != 4)
                        ThrowEx("Cannot understand path entry.");

                    string text = Line;
                    string name = string.Empty;

                    if (double.TryParse(vals[0], out dummy) == false)
                    {
                        text = text.Substring(text.IndexOf(' '));
                        name = vals[0];
                    }

                    Vector3 vecval = Vector3.Parse(text);
                    Vector3 kpt = vecval;
                    double length = (kpt - lastKpt).Magnitude;

                    if (ptCount == 0)
                    {
                        path.AddPts(kpt, kpt, 1);
                    }
                    else
                    {
                        path.AddPts(lastKpt, kpt, Math.Max((int)(ptScale * length), 1));
                    }
                    path.Kpts[path.Kpts.Count - 1].Name = name;
                    ptCount++;

                    lastKpt = kpt;

                    ReadNextLine();
                }
            }