Пример #1
0
        public void Write_Temperature_Field(Node[,] Nodes, string AppendedFileName)
        {
            try
            {
                // 1 Copper
                // 2 BiTe
                // 3 Ceramic
                // 4 Air

                TextWriter dataWrite = new StreamWriter(WT_directory + AppendedFileName + ".csv");

                List<string> Lines = new List<string>();

                dataWrite.WriteLine("XPOS" + "," + "YPOS" + "," + "TEMP");

                for (int i = 0; i < Nodes.GetLength(0); i++)
                {
                    for (int j = 0; j < Nodes.GetLength(1); j++)
                    {
                        //if (i > 1 && j > 1 && i < (Nodes.GetLength(0) - 1) && j < (Nodes.GetLength(1) - 1))
                        //{
                        dataWrite.WriteLine(Nodes[i, j].x_Position + "," + Nodes[i, j].y_Position + "," + Nodes[i, j].T);
                        //}
                    }
                }

                dataWrite.Close();
            }
            catch
            {
                Console.WriteLine("Error saving file, or writing was canceled ");
            }
        }
Пример #2
0
        public void WriteMesh(Node[,] Nodes)
        {
            try
            {
                // 1 Copper
                // 2 BiTe
                // 3 Ceramic
                // 4 Air

                TextWriter dataWrite = new StreamWriter(W_directory);

                List<string> Lines = new List<string>();

                dataWrite.WriteLine("ID" + "," + "XPOS" + "," + "YPOS" + "," + "Material" + "," + "Flag");

                for (int i = 0; i < Nodes.GetLength(0); i++)
                {
                    for (int j = 0; j < Nodes.GetLength(1); j++)
                    {
                        int Mat_ID;

                        switch (Nodes[i, j].Material)
                        {
                            case "Copper":
                                Mat_ID = 1;
                                break;
                            case "BiTe":
                                Mat_ID = 2;
                                break;
                            case "Ceramic":
                                Mat_ID = 3;
                                break;
                            case "Air":
                                Mat_ID = 4;
                                break;
                            default:
                                Mat_ID = 0;
                                Console.WriteLine("Error with Mesh!  Mat_ID is 0");
                                break;
                        }

                        int spFlag;

                        if (Nodes[i, j].sp != 0 | Nodes[i, j].sc != 0)
                        {
                            spFlag = 1;
                        }
                        else
                        {
                            spFlag = 0;
                        }

                        dataWrite.WriteLine(Nodes[i, j].ID + "," + Nodes[i, j].x_Position + "," + Nodes[i, j].y_Position + "," + Mat_ID + "," + spFlag);
                    }
                }

                dataWrite.Close();
            }
            catch
            {
                Console.WriteLine("Error saving file, or writing was canceled ");
            }
        }
Пример #3
0
        public void Write_Mid_Field(Node[,] Nodes, string AppendedFileName)
        {
            try
            {

                TextWriter dataWrite = new StreamWriter(Write_Mid_T + AppendedFileName + ".csv");

                List<string> Lines = new List<string>();

                dataWrite.WriteLine("XPOS" + "," + "YPOS" + "," + "TEMP");

                int idx = 0;

                foreach (Node node in Nodes)
                {
                    if (node.x_Position >= 0.01660 && node.x_Position <= 0.01670)
                    {
                        idx = node.i;
                        Debug.WriteLine("Node found:  " + idx + " at x position:  " + node.x_Position);
                    }
                }

                if (idx == 0)
                {
                    Console.WriteLine("ERROR Finding midline temperature.... re-run simulation by adjusting idx tolerance");
                }

                for (int i = 0; i < Nodes.GetLength(0); i++)
                {
                    for (int j = 0; j < Nodes.GetLength(1); j++)
                    {
                        // This pulls the middle indexed node out--however, this catches the air pocket
                        // as opposed to a BiTe element of interest.
                        //int idx = (int)Math.Round(Nodes.GetLength(0) / 2.0);

                        if (i == idx)
                        {
                            dataWrite.WriteLine(Nodes[i, j].x_Position + "," + Nodes[i, j].y_Position + "," + Nodes[i, j].T);
                        }

                    }
                }

                dataWrite.Close();
            }
            catch
            {
                Console.WriteLine("Error saving file, or writing was canceled ");
            }
        }