Esempio n. 1
0
        // ファイルからテキストを読み出し。
        //          1         2         3         4         5         6         7         8         9         0         1         1         2 
        //01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
        //-------------------------------------------------------------------------------------------------------------------------------
        //          Observed  |  Rel. |    Aki    | Acc. |         Ei           Ek         | Lower level | Upper level |  gi   gk  |Type|
        //         Wavelength |  Int. |    s^-1   |      |        (eV)         (eV)        |-------------|-------------|           |    |
        //          Air (nm)  |  (?)  |           |      |                                 | J           | J           |           |    |
        //-------------------------------------------------------------------------------------------------------------------------------
        //                    |       |           |      |                                 |             |             |           |    |
        //          477.175   |   200 | 7.97e+05  | C    |    7.487795    -    10.085369   | 2           | 2           |   5 - 5   |    |


        private void ReadAtomData(string fn)
        {
            using (StreamReader r = new StreamReader(fn))   //@"OI.txt"
            using (StreamWriter w = new StreamWriter(fn+".txt"))   //@"OI.txt"
            {
                double d;
                string line="", s, s1;

                // 先頭1行基本データ取得
                // E0[eV] g0  原子番号  中性・イオン 呼び名
                line = r.ReadLine();
                string[] stArrayData = line.Split(' ');

                int atomic_num = int.Parse(stArrayData[2]);
                int state = int.Parse(stArrayData[3]);

                atomdata[atomic_num].atomic_number = atomic_num;
                atomdata[atomic_num].state = state;
                atomdata[atomic_num].e0 = double.Parse(stArrayData[0]);
                atomdata[atomic_num].g0 = int.Parse(stArrayData[1]);
                atomdata[atomic_num].name = stArrayData[4];

                // 先頭6行スキップ
                for (int i = 0; i < 6; i++)
                {
                    line = r.ReadLine();
                    //richTextBox1.AppendText(line);
                }
                while ((line = r.ReadLine()) != null) // 1行ずつ読み出し。
                {
                    Level_Data levdata = new Level_Data();
                    Line_Data lid = new Line_Data();
                    string[] linesp = line.Split('|');
                    // wavelenth
                    if (double.TryParse(linesp[0], out d))
                    {
                        levdata.Wavelength = d;
                        lid.Wavelength = d;
                        lid.photon_number = 0;
                    }
                    else
                    {
                        continue;
                    }
                    // Aki
                    if (double.TryParse(linesp[2], out d))
                    {
                        levdata.Aki = d;
                    }
                    // Ei
                    string[] linesp2 = linesp[4].Split('-');
                    if (double.TryParse(linesp2[0], out d))
                    {
                        levdata.Ei = d;
                    }
                    // Ek
                    s = linesp2[1];
                    s1 = s.Replace("[", " ").Replace("]", " ");
                    if (double.TryParse(s1, out d))
                    {
                        levdata.Ek = d;
                    }
                    // gi
                    linesp2 = linesp[7].Split('-');
                    if (double.TryParse(linesp2[0], out d))
                    {
                        levdata.gi = d;
                    }
                    // gk
                    if (double.TryParse(linesp2[1], out d))
                    {
                        levdata.gk = d;
                    }

                    if (state == 0)
                    {
                        atomdata[atomic_num].add(levdata);
                        atomdata[atomic_num].add(lid);
                        w.WriteLine(atomdata[atomic_num].leveldata.Last().Print());
                    }
                    else if (state == 1)
                    {
                        atomdata[atomic_num].ionization_energy = double.Parse(stArrayData[0]);
                        atomdata[atomic_num].add_2(levdata);
                        atomdata[atomic_num].add_2(lid);
                        w.WriteLine(atomdata[atomic_num].leveldata_2.Last().Print());
                    }
                }
                foreach (Level_Data ld in atomdata[atomic_num].leveldata)
                {
                    //w.WriteLine(ld.Print());   //richTextBox1.AppendText(line);
                }
                richTextBox1.AppendText(atomic_num.ToString() + ": " + atomdata[atomic_num].leveldata[0].Print() + "\n");
            }
        }
Esempio n. 2
0
 public void add(Line_Data d)
 {
     linedata.Add(d);
 }
Esempio n. 3
0
 public void add_2(Line_Data d)
 {
     linedata_2.Add(d);
 }