Пример #1
0
        public BoundaryCondition(Node[,] Node_Array, double dt)
        {
            this.Node_Array = Node_Array;

            h_Top = 15.0;
            h_Bottom = 0.0;
            h_Left = 15.0;
            h_Right = 15.0;

            T_Top = 0.0;
            T_Bottom = 240; // 240
            T_Right = 0.0;
            T_Left = 0.0;

            Tinf_Top = 288.0;
            Tinf_Bottom = 0.0;
            Tinf_Right = 288.0;
            Tinf_Left = 288.0; //288

            q_Top = 0.0;
            q_Bottom = 0.0;
            q_Left = 0.0;
            q_Right = 0.0;

            is_TBC_Top = 1;
            is_TBC_Bottom = 0;
            is_TBC_Right = 1;
            is_TBC_Left = 1;

            Console.WriteLine("Setting Boundary Conditions...");
            Apply_Boundary_Conditions(dt);
        }
Пример #2
0
        private void Generate_Nodes()
        {
            //List<Node> Node_List = new List<Node>();

            Node_Array = new Node[Coordinate_Array.GetLength(0) - 1, Coordinate_Array.GetLength(1) - 1];

            int ID = 0;

            for (int i = 0; i < Coordinate_Array.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < Coordinate_Array.GetLength(1) - 1; j++)
                {
                    Coordinate upper_Left = Coordinate_Array[i, j + 1];
                    Coordinate upper_Right = Coordinate_Array[i + 1, j + 1];
                    Coordinate lower_Left = Coordinate_Array[i, j];
                    Coordinate lower_Right = Coordinate_Array[i + 1, j];

                    double DY = upper_Right.Y - lower_Right.Y;
                    double DX = upper_Right.X - upper_Left.X;
                    double X = lower_Left.X + (0.5) * (DX);
                    double Y = lower_Left.Y + (0.5) * (DY);

                    foreach (Layer layer in Layer_List)
                    {
                        if ((X > layer.Layer_x0) && (X < layer.Layer_xf) && (Y < layer.Layer_y0) && (Y > layer.Layer_yf))
                        {
                            material = layer.Layer_Material;
                        }
                    }

                    Node_Array[i, j] = new Node(X, Y, DY, DX, ID, i, j);
                    Node_Array[i, j].Material = material;

                    ID++;
                }
            }

            foreach (Node node in Node_Array)
            {
                foreach (Material mat in MaterialList)
                {
                    if (node.Material == mat.Material_Name)
                    {
                        node.Node_Material = mat;
                    }
                }
            }

            Console.WriteLine("Nodes Created:  " + ID);
        }
Пример #3
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 ");
            }
        }
Пример #4
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 ");
            }
        }
Пример #5
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 ");
            }
        }