public Graphene(Graphene graphene, int i, double dx, double dy, double dz) { this.N = graphene.N; this.atoms = graphene.atoms; this.atoms[i].x += dx; this.atoms[i].y += dy; this.atoms[i].z += dz; }
static void Main(string[] args) { List <Atom> list = new List <Atom>(); using (StreamReader sr = new StreamReader("input.txt")) { string numbers; while ((numbers = sr.ReadLine()) != null) { string[] arr = numbers.Split('\t'); double x = Double.Parse(arr[0]); double y = Double.Parse(arr[1]); double z = Double.Parse(arr[2]); char type = Char.Parse(arr[3]); Console.WriteLine(x + "\t" + y + "\t" + z + "\t" + type); list.Add(new Atom(x, y, z, type)); } } Graphene graphene = new Graphene(list); int N = list.Count; /*Заполнение матрицы соседей*/ int[,] mat = new int[N, 3]; double[] r = new double[N]; for (int i = 0; i < N; i++) { int count = 0; for (int j = 0; j < N; j++) { if (Math.Abs(graphene.R(i, j) - d) < f) { mat[i, count] = j + 1; count++; } } } Console.WriteLine(); for (int i = 0; i < N; i++) { Console.Write(i + 1 + "\t"); for (int j = 0; j < 3; j++) { Console.Write(mat[i, j] + "\t"); } Console.WriteLine(); } /*Запись файла*/ using (StreamWriter sw = new StreamWriter("output.txt")) { for (int i = 0; i < N; i++) { for (int j = 0; j < 3; j++) { sw.Write(mat[i, j] + " "); } } } /*Подсчет потенциала*/ double E = 0; E += graphene.Energy1(); Console.WriteLine("E = " + E); E += graphene.Energy2(mat); Console.WriteLine("E = " + E); /* * Graphene graphene1 = new Graphene(graphene, 0, dx, 0, 0); * double E1 = 0; * E1 += graphene1.Energy1(); * Console.WriteLine("E1 = " + E1); * E1 += graphene1.Energy2(mat); * Console.WriteLine("E1 = " + E1); * double f1 = (E - E1) / dx; * Console.WriteLine("f1 = " + f1);*/ double[] f1 = new double[] { -2, -1, 0, 1, 3, 4 }; double[] E1 = new double[] { 3, 1, 1, 0, -1, -3 }; Console.WriteLine("k = " + OLS(f1, E1)); Console.ReadLine(); }