Example #1
0
        private static Symmetry ParseSymmetry(string text)
        {
            Match           rotText = rotation.Match(text);
            MatchCollection values  = rotationValues.Matches(rotText.ToString());

            Matrix matrix = new Matrix(3, 3);

            for (int i = 0; i < 3; i++)
            {
                Vector3 opVec = GetOperationVector(values[i].ToString());

                matrix.SetRow(i, opVec);
            }

            Match           transText   = translation.Match(text);
            MatchCollection transValues = translationValues.Matches(transText.ToString());

            Vector3 trans = new Vector3();

            for (int i = 0; i < 3; i++)
            {
                trans[i] = EvaluateFraction(transValues[i].ToString());
            }


            Symmetry sym = new Symmetry(matrix, trans);

            return(sym);
        }
Example #2
0
        public Symmetry Clone()
        {
            Symmetry x = new Symmetry(Value.Clone());
            x.OrbitalTransform.AddRange(OrbitalTransform);

            return x;
        }
Example #3
0
        public Symmetry Clone()
        {
            Symmetry x = new Symmetry(Value.Clone());

            x.OrbitalTransform.AddRange(OrbitalTransform);

            return(x);
        }
Example #4
0
        private bool DuplicateSymmetry(Symmetry newSym)
        {
            foreach (Symmetry sym in Symmetries)
            {
                if ((sym.Value - newSym.Value).IsZero)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        private void GenerateSymmetries(Symmetry sym)
        {
            foreach (var s in PrimitiveSymmetries)
            {
                Symmetry newSym = Symmetry.Compose(sym, s);

                if (DuplicateSymmetry(newSym))
                {
                    continue;
                }

                Symmetries.Add(newSym);
                GenerateSymmetries(newSym);
            }
        }
Example #6
0
        Matrix CalcX0(TightBinding tb, double freq, Vector3 q)
        {
            int    orbitalCount = tb.Orbitals.Count;
            int    size         = orbitalCount * orbitalCount;
            Matrix x            = new Matrix(size, size);

            Complex denom_factor = new Complex(0, 1e-4);

            //StreamWriter w = new StreamWriter(string.Format("qcont.{0}", q.ToString("0.000")));
            //bool writeThis = false;

            for (int l1 = 0; l1 < orbitalCount; l1++)
            {
                for (int l4 = 0; l4 < orbitalCount; l4++)
                {
                    for (int l3 = l1; l3 < orbitalCount; l3++)
                    {
                        for (int l2 = l4; l2 < orbitalCount; l2++)
                        {
                            int  i             = GetIndex(tb, l1, l2);
                            int  j             = GetIndex(tb, l3, l4);
                            bool foundSymmetry = false;

                            //if (l1 == 0 && l2 == 0 && l3 == 0 && l4 == 0)
                            //    writeThis = true;
                            //else
                            //writeThis = false;

                            //if (writeThis)
                            //    w.WriteLine("{0}{1}{2}{3}", l1, l2, l3, l4);

                            for (int s = 0; s < tb.Symmetries.Count; s++)
                            {
                                Symmetry sym = tb.Symmetries[s];

                                if (sym.OrbitalTransform == null || sym.OrbitalTransform.Count == 0)
                                {
                                    continue;
                                }

                                int newL1 = sym.OrbitalTransform[l1];
                                int newL2 = sym.OrbitalTransform[l2];
                                int newL3 = sym.OrbitalTransform[l3];
                                int newL4 = sym.OrbitalTransform[l4];

                                int newI = GetIndex(tb, newL1, newL2);
                                int newJ = GetIndex(tb, newL3, newL4);

                                if (newI == i && newJ == j)
                                {
                                    continue;
                                }

                                foundSymmetry = true;

                                if (newL1 > l1)
                                {
                                    foundSymmetry = false;
                                }
                                if (newL2 > l2)
                                {
                                    foundSymmetry = false;
                                }
                                if (newL3 > l3)
                                {
                                    foundSymmetry = false;
                                }
                                if (newL4 > l4)
                                {
                                    foundSymmetry = false;
                                }

                                if (foundSymmetry)
                                {
                                    x[i, j] = x[newI, newJ];
                                    x[j, i] = x[i, j].Conjugate();

                                    break;
                                }
                            }

                            if (foundSymmetry)
                            {
                                continue;
                            }

                            Complex total = 0;

                            for (int allkindex = 0; allkindex < tb.KMesh.AllKpts.Count; allkindex++)
                            {
                                Complex val = 0;
                                Vector3 k   = tb.KMesh.AllKpts[allkindex];
                                Vector3 kq  = k + q;

                                //List<int> kOrbitalMap;
                                //List<int> kqOrbitalMap;

                                //int kindex = tb.KMesh.IrreducibleIndex(k, tb.Lattice, tb.Symmetries, out kOrbitalMap);
                                //int kqindex = tb.KMesh.IrreducibleIndex(kq, tb.Lattice, tb.Symmetries, out kqOrbitalMap);
                                int kindex  = tb.KMesh.AllKindex(k, tb.Lattice);
                                int kqindex = tb.KMesh.AllKindex(kq, tb.Lattice);

                                System.Diagnostics.Debug.Assert(kindex == allkindex);

                                //int newL1 = TransformOrbital(kqOrbitalMap, l1);
                                //int newL2 = TransformOrbital(kOrbitalMap, l2);
                                //int newL3 = TransformOrbital(kqOrbitalMap, l3);
                                //int newL4 = TransformOrbital(kOrbitalMap, l4);

                                for (int n1 = 0; n1 < orbitalCount; n1++)
                                {
                                    Wavefunction wfk = Bands(tb, kindex, n1);
                                    double       e1  = wfk.Energy;
                                    double       f1  = wfk.FermiFunction;

                                    for (int n2 = 0; n2 < orbitalCount; n2++)
                                    {
                                        Wavefunction wfq = Bands(tb, kqindex, n2);
                                        double       e2  = wfq.Energy;
                                        double       f2  = wfq.FermiFunction;

                                        Complex coeff =
                                            wfq.Coeffs[l1] * wfq.Coeffs[l4].Conjugate() *
                                            wfk.Coeffs[l3] * wfk.Coeffs[l2].Conjugate();

                                        if (coeff == 0)
                                        {
                                            continue;
                                        }
                                        if (f1 < 1e-15 && f2 < 1e-15)
                                        {
                                            continue;
                                        }

                                        Complex denom_p = (e2 - e1 + freq + denom_factor);
                                        //Complex denom_n = (e2 - e1 - freq - denom_factor);
                                        //Complex lindhard = (f1 - f2) * (1.0 / denom_p + 1.0 / denom_n);
                                        Complex lindhard = (f1 - f2) * (1.0 / denom_p);
                                        Complex contrib  = coeff * lindhard;

                                        if (Math.Abs(f1 - f2) < 1e-11 && freq == 0.0)
                                        {
                                            contrib = coeff * f1 * (1 - f1) * Beta;
                                        }

                                        //w.Write("{0}  {1}   {2}   {3}           ", kindex, kqindex, n1, n2);
                                        //w.WriteLine("{0}   {1}   {2}   {3}   {4}", coeff, e1, e2, f1, f2);

                                        if (double.IsNaN(contrib.RealPart) || double.IsNaN(contrib.ImagPart))
                                        {
                                            throw new Exception("Found NaN when evaluating X0");
                                        }

                                        val += contrib;
                                    }
                                }

                                //w.WriteLine("{0}  {1}   total           {2} + {3}i", kindex, kqindex,
                                //    Math.Round(val.RealPart, 4), Math.Round(val.ImagPart, 4));

                                //Output.WriteLine(tb.KMesh.AllKpts[kindex].Weight.ToString());
                                val   *= tb.KMesh.AllKpts[kindex].Weight;
                                total += val;

                                //if (writeThis)
                                //    w.WriteLine("{0}        {1}              {2}", allkindex, total, val);
                            }

                            x[i, j] = total;
                            x[j, i] = total.Conjugate();

                            //if (writeThis)
                            //{
                            //    w.WriteLine("total for {0}{1}{2}{3}: {4}", l1, l2, l3, l4, total);
                            //    w.WriteLine("---------------------");
                            //}
                        }
                    }
                }
            }

            //w.Close();

            return(x);
        }
Example #7
0
        private void GenerateSymmetries(Symmetry sym)
        {
            foreach (var s in PrimitiveSymmetries)
            {
                Symmetry newSym = Symmetry.Compose(sym, s);

                if (DuplicateSymmetry(newSym))
                    continue;

                Symmetries.Add(newSym);
                GenerateSymmetries(newSym);
            }
        }
Example #8
0
        private bool DuplicateSymmetry(Symmetry newSym)
        {
            foreach (Symmetry sym in Symmetries)
            {
                if ((sym.Value - newSym.Value).IsZero)
                    return true;
            }

            return false;
        }
Example #9
0
        private static Symmetry ParseSymmetry(string text)
        {
            Match rotText = rotation.Match(text);
            MatchCollection values = rotationValues.Matches(rotText.ToString());

            Matrix matrix = new Matrix(3, 3);
            for (int i = 0; i < 3; i++)
            {
                Vector3 opVec = GetOperationVector(values[i].ToString());

                matrix.SetRow(i, opVec);
            }

            Match transText = translation.Match(text);
            MatchCollection transValues = translationValues.Matches(transText.ToString());

            Vector3 trans = new Vector3();
            for (int i = 0; i < 3; i++)
            {
                trans[i] = EvaluateFraction(transValues[i].ToString());
            }

            Symmetry sym = new Symmetry(matrix, trans);
            return sym;
        }