private void GenerateKmesh() { tb.kmesh = KptList.GenerateMesh(tb.lattice, tb.kgrid, tb.kshift, tb.symmetries, false); Output.WriteLine("Applied {0} symmetries to get {1} irreducible kpoints from {2}.", tb.symmetries.Count, tb.kmesh.Kpts.Count, tb.kmesh.AllKpts.Count); using (StreamWriter writer = new StreamWriter("kpts")) { for (int i = 0; i < tb.kmesh.Kpts.Count; i++) { Vector3 red = tb.lattice.ReducedCoords(tb.kmesh.Kpts[i].Value); writer.WriteLine("{0} {1}", i, red); } } if (tb.UseQPlane == false) { tb.qmesh = KptList.GenerateMesh(tb.lattice, tb.qgrid, tb.qshift, tb.symmetries, false); Output.WriteLine("Found {0} qpoints in the zone.", tb.qmesh.Kpts.Count); } if (tb.setQplane) { tb.qplane = KptList.GeneratePlane(tb.lattice, tb.qplaneDef, tb.symmetries, tb.qgrid, null); Output.WriteLine("Found {0} irreducible qpoints in the plane of {1} qpoints.", tb.qplane.Kpts.Count, tb.qplane.AllKpts.Count); using (StreamWriter writer = new StreamWriter("qpts")) { for (int i = 0; i < tb.qplane.Kpts.Count; i++) { Vector3 red = tb.lattice.ReducedCoords(tb.qplane.Kpts[i].Value); writer.WriteLine("{0} {1}", i, red); } } } }
private void WriteGreenFunctionPlane(TightBindingSuite.TightBinding tb, Matrix[] green, KptList kmesh) { Console.WriteLine("Output as a plane."); Console.WriteLine(); Console.WriteLine("Enter vectors as a series of three numbers, like: 1 1 0"); Console.WriteLine("Only integer values need be used."); Console.WriteLine(); Console.Write("Enter first vector: "); string first = Console.ReadLine(); if (string.IsNullOrEmpty(first)) return; Console.Write("Enter second vector: "); string second = Console.ReadLine(); Vector3 sdir = Vector3.Parse(first); Vector3 tdir = Vector3.Parse(second); Vector3 udir = Vector3.CrossProduct(sdir, tdir); Console.Write("Enter origin point: "); string origin = Console.ReadLine(); Vector3 orig = Vector3.Parse(origin); Vector3 closestKpt = Vector3.Zero; double closestDistance = 999999999; foreach (var kpt in kmesh.AllKpts) { double distance = (kpt.Value - orig).MagnitudeSquared; if (distance < closestDistance) { closestKpt = kpt.Value; closestDistance = distance; } } if (closestDistance > 1e-6) { Console.WriteLine("Using closest k-point to specified origin: {0}.", closestKpt); orig = closestKpt; sdir += closestKpt; tdir += closestKpt; } KptList plane = KptList.GeneratePlane( tb.Lattice, new Vector3[] { orig, sdir, tdir }, tb.Symmetries, kmesh); string tr_filename = string.Format("green.tr.pln"); StreamWriter tr = new StreamWriter(tr_filename); double lastt = double.MinValue; for (int k = 0; k < plane.AllKpts.Count; k++) { Complex trValue = new Complex(); for (int i = 0; i < green[k].Rows; i++) { trValue += green[k][i, i]; } Vector3 kpt = plane.AllKpts[k].Value; List<int> orbitalMap; double s, t; plane.GetPlaneST(plane.AllKpts[k], out s, out t); int kindex = kmesh.IrreducibleIndex(kpt, tb.Lattice, tb.Symmetries, out orbitalMap); if (Math.Abs(t - lastt) > 1e-6) { tr.WriteLine(); lastt = t; } tr.WriteLine("{0}\t{1}\t{2}", s, t, -trValue.ImagPart); } tr.Close(); for (int i = 0; i < green[0].Rows; i++) { for (int j = 0; j < green[0].Columns; j++) { string re_filename = string.Format("green.re.{0}.{1}.pln", i,j); string im_filename = string.Format("green.im.{0}.{1}.pln", i, j); string mag_filename = string.Format("green.mag.{0}.{1}.pln", i, j); StreamWriter rew = new StreamWriter(re_filename); StreamWriter imw = new StreamWriter(im_filename); StreamWriter mag = new StreamWriter(mag_filename); try { lastt = double.MaxValue; for (int k = 0; k < plane.AllKpts.Count; k++) { Vector3 kpt = plane.AllKpts[k].Value; List<int> orbitalMap; double s, t; plane.GetPlaneST(plane.AllKpts[k], out s, out t); int kindex = kmesh.IrreducibleIndex(kpt, tb.Lattice, tb.Symmetries, out orbitalMap); if (Math.Abs(t - lastt) > 1e-6) { rew.WriteLine(); imw.WriteLine(); mag.WriteLine(); lastt = t; } rew.WriteLine("{0}\t{1}\t{2}", s, t, green[kindex][i, j].RealPart); imw.WriteLine("{0}\t{1}\t{2}", s, t, -green[kindex][i, j].ImagPart); mag.WriteLine("{0}\t{1}\t{2}", s, t, green[kindex][i, j].Magnitude); } } finally { rew.Dispose(); imw.Dispose(); mag.Dispose(); } } } }