Esempio n. 1
0
        private string GetMatrixHead(ArrayList selectedGases)
        {
            string head = "";

            for (int n = 1; n < selectedGases.Count; n++)
            {
                for (int j = 0; j < selectedGases.Count; j++)
                {
                    GasNode node = (GasNode)selectedGases[j];
                    if (node.index == n)
                    {
                        head = head + node.name + "\t";
                    }
                }
            }
            return(head);
        }
Esempio n. 2
0
        //保存测量数据文件
        public string SaveParameter(double[,] V, double[,] E, string machId, string instId, ArrayList selectedGases, Dictionary <string, List <string> > map)
        {
            string path = System.Windows.Forms.Application.StartupPath + "\\ParameterGen\\";

            if (!string.IsNullOrEmpty(machId) && !string.IsNullOrEmpty(instId))
            {
                path = path + machId + "@" + instId + "\\";
            }

            path = path + DateTime.Now.ToString("s").Replace(':', ':').Replace('/', '-') + "\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string head = GetMatrixHead(selectedGases);

            string[] tail = new string[4];

            tail[0] = "a1 * x1 + a2 * x2 + a3 * x1 * x1 + a4 * x1 * x2 + a5 * x2 * x2";
            tail[1] = "a1 * x1 + a2 * x2 + a3 * x3 + a4 * x1 * x1 + a5 * x1 * x2 + a6 * x1 * x3 + a7 * x2 * x2 + a8 * x2 * x3 + a9 * x3 * x3";

            //FileControl.SaveMatrix(Cs, path + "吸收截面" + ".txt", 1, "e", head, null);

            //保存每种气体,0表示N2,不用保存
            for (int n = 1; n < selectedGases.Count; n++)
            {
                for (int j = 0; j < selectedGases.Count; j++)
                {
                    GasNode node = (GasNode)selectedGases[j];
                    if (node.index == n)
                    {
                        string        thingName = node.name;
                        List <string> lists     = map[thingName];
                        int           start     = V.GetLength(0);
                        int           end       = 0;
                        int           py        = 0;
                        for (int k = 0; k < V.GetLength(0); k++)
                        {
                            if (V[k, n - 1] != 0)
                            {
                                start = k;
                                break;
                            }
                        }
                        if (start < V.GetLength(0))
                        {
                            for (int k = V.GetLength(0) - 6; k >= 0; k--)
                            {
                                if (V[k, n - 1] != 0)
                                {
                                    end = k;
                                    break;
                                }
                            }
                            py = end - start + 1;
                        }
                        int count = py + 1;
                        lists.Add(count.ToString());
                        lists.Add("5");

                        int length = V.GetLength(0) + 13;
                        double[,] gasV = new double[length, 1];
                        string fist = lists[0];
                        for (int i = 1; i < lists.Count; i++)
                        {
                            gasV[i - 1, 0] = Convert.ToDouble(lists[i]);
                        }
                        int listCount = lists.Count;
                        for (int k = 0; k < V.GetLength(0); k++)
                        {
                            gasV[listCount + k - 1, 0] = V[k, n - 1];
                        }
                        FileControl.SaveMatrix(gasV, path + node.name + "_" + machId + "_" + instId + ".txt", 1, "g", fist, null);
                    }
                }
            }
            FileControl.SaveMatrix(E, path + "拟合误差.txt", 1, "F", head, null);
            return(path);
        }