Beispiel #1
0
        private void lb_Sweeps_SelectedIndexChanged(object sender, EventArgs e)
        {
            string fName = tb_Sweeps.Text + "\\";

            if (lb_Sweeps.SelectedIndex > -1)
            {
                fName += lb_Sweeps.SelectedItem.ToString();
                ovf2     ovf   = new ovf2(fName);
                string   itxt  = tb_CompInfo.Text;
                string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                this.componentNum = Convert.ToInt16(sitxt[0]);
                PlotRow(ovf, chart2, ovf.header.ynodes / 2);
                Bitmap bmp = Viz.MakeImage(ovf, componentNum);
                //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                pictureBox1.Image    = bmp;
                if (mt != null)
                {
                    string filename  = lb_Sweeps.SelectedItem.ToString();
                    string fn        = filename.Substring(1, filename.Length - 5);
                    int    fileN     = Convert.ToInt32(fn);
                    string fileNname = tb_colname.Text.Split(',')[0];
                    string fieldname = tb_colname.Text.Split(',')[1];
                    int    index     = mt.data[fileNname].IndexOf(fileN);
                    double field     = mt.data[fieldname][index];
                    double amp       = chart1.Series[0].Points.Where(point => point.XValue == field).ToList()[0].YValues[0];

                    this.VA.X  = field;
                    Field.Text = field.ToString() + "(G)";
                    Amp.Text   = amp.ToString();
                }
            }
        }
Beispiel #2
0
        //xy or z = 1,2 or 3
        public static double[] GetMinMax(ovf2 ovfFile, int XYorZ_12or3)
        {
            double max = double.NegativeInfinity;
            double min = double.PositiveInfinity;
            int    Nx  = ovfFile.header.xnodes;
            int    Ny  = ovfFile.header.ynodes;

            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    double val = Component(ovfFile.CellValue(i, j, 0), XYorZ_12or3);
                    if (val > max)
                    {
                        max = val;
                    }
                    if (val < min)
                    {
                        min = val;
                    }
                }
            }

            return(new double[] { min, max });
        }
Beispiel #3
0
        private ovf2 average(string baseDir, int n, int AvgNum)
        {
            string      fname = baseDir + "\\" + n.ToString() + "-f1-";
            List <ovf2> ovfs  = new List <ovf2>();

            for (int i = 0; i < AvgNum; i++)
            {
                ovf2 ovf = new ovf2(fname + i.ToString() + ".ovf");
                //return ovf;
                ovfs.Add(ovf);
            }

            double dblAvgNum = Convert.ToDouble(AvgNum);

            for (int i = 0; i < ovfs[0].data.Count; i++)
            {
                Vector avg = new Vector(0, 0, 0);
                for (int j = 0; j < AvgNum; j++)
                {
                    avg += ovfs[j].data[i];
                }
                ovfs[0].data[i] = new Vector(avg.x / dblAvgNum, avg.y / dblAvgNum, avg.z / dblAvgNum);
            }
            return(ovfs[0]);
        }
Beispiel #4
0
        private void btn_ExportSel_Click(object sender, EventArgs e)
        {
            string dir = tb_Sweeps.Text;
            //ovf2 m0 = new ovf2(dir + "\\m000000.ovf", false);
            string fname    = lb_Sweeps.SelectedItem.ToString();
            string FileName = dir + '\\' + fname.Substring(0, fname.Length - 4) + ".txt";

            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName);
            ovf2 m = new ovf2(dir + '\\' + fname);

            if (tb_minit.Text != "")
            {
                ovf2 m0 = new ovf2(tb_minit.Text);
                ExportCurrFile(sw, m0, m, cb_inseries.Checked, 0);
            }
            //find ground state automatically if the selected states are generated using 8-avg methods
            else if (cb_autoground.Checked)
            {
                string f0name = fname.Split('-')[0] + "-m0.ovf";
                ovf2   m0     = new ovf2(dir + '\\' + f0name);;
                ExportCurrFile(sw, m0, m, cb_inseries.Checked, 0);
            }
            else
            {
                ExportCurrFile(sw, m, null, cb_inseries.Checked, 0);
            }
            sw.Close();
        }
Beispiel #5
0
        public static Bitmap MakeImage(ovf2 ovfFile, int XYorZ_12or3)
        {
            int        Nx    = ovfFile.header.xnodes;
            int        Ny    = ovfFile.header.ynodes;
            Bitmap     bmp   = new Bitmap(Nx, Ny);
            Graphics   g     = Graphics.FromImage(bmp);
            SolidBrush brush = new SolidBrush(Color.Black);

            double[] minmax = Viz.GetMinMax(ovfFile, XYorZ_12or3);
            for (int i = 0; i < Nx; i++)
            {
                for (int j = 0; j < Ny; j++)
                {
                    Vector vij = ovfFile.CellValue(i, j, 0);
                    //if (vij.z < 1)
                    //Console.WriteLine(vij.z.ToString());
                    brush.Color = ColorMap.BlackWhite(minmax[0], minmax[1], Component(vij, XYorZ_12or3));
                    //Console.WriteLine("{0}, {1}", i, Nx - 1 - j);
                    Rectangle pxl = new Rectangle(i, Ny - 1 - j, 1, 1);
                    g.FillRectangle(brush, pxl);
                }
            }

            return(bmp);
        }
Beispiel #6
0
        public double CalculateFz(ovf2 mRef, ovf2 m)
        {
            int    Ny  = mRef.header.ynodes;
            double fz  = 0;
            double vol = mRef.header.xstepsize * mRef.header.ystepsize * mRef.header.zstepsize;
            double mom = vol * MaterialMs;

            for (int i = 0; i < Ny; i++)
            {
                Vector[] row0 = mRef.GetRow(i, 0);
                Vector[] rowf = m.GetRow(i, 0);
                Vector[] dm   = vecSub(rowf, row0);
                for (int j = 0; j < dm.Count(); j++)
                {
                    Vector mf = new Vector(dm[j].x * mom, dm[j].y * mom, dm[j].z * mom);
                    //Vector mf = new Vector(0, 0, dm[j].z * mom);
                    Vector r = m.GetPos(j, i, 0);
                    //double fzi = dipole.Fz(mf, r);
                    double fzi = dipole.Fz_ip(mf, r);
                    //if (fzi > 0)
                    //   Console.WriteLine(fzi.ToString());
                    fz += fzi;
                }
            }

            return(fz);
        }
Beispiel #7
0
        private void chart1_MouseDown(object sender, MouseEventArgs e)
        {
            double xval = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X);

            Field.Text = Convert.ToString(xval);
            currXVal   = xval;
            Console.WriteLine(xval);
            //return;
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                string fileNname = tb_colname.Text.Split(',')[0];
                string fieldname = tb_colname.Text.Split(',')[1];
                double N         = mt.find(fileNname, fieldname, xval);
                if (ActiveSim != null)
                {
                    if (comboBox1.Text == "8Avg_FieldScan")
                    {
                        string baseName = ActiveSim.dir + "\\" + Convert.ToInt32(N).ToString() + "-";
                        //ovf2 m0 = new ovf2(baseName + Ni.ToString() + ".ovf");
                        //ovf2 mf = new ovf2(baseName + Nf.ToString() + ".ovf");
                        ovf2     m0 = new ovf2(baseName + "m0.ovf");
                        ovf2     mf;
                        string   itxt  = tb_CompInfo.Text;
                        string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                        this.componentNum = Convert.ToInt16(sitxt[0]);
                        int tfAvg = Convert.ToInt16(sitxt[1]);
                        if (tfAvg == 1)
                        {
                            mf = new ovf2(baseName + "mf.ovf");
                        }
                        else
                        {
                            mf = new ovf2(baseName + "f1-0.ovf");
                        }

                        PlotRow(mf, m0, chart2, mf.header.ynodes / 2);
                        Bitmap bmp = GetImageDiff(mf, m0);
                        pictureBox1.Image = bmp;
                    }
                    else if (comboBox1.Text == "FFT")
                    {
                        string   filename = ActiveSim.dir + "\\f" + Convert.ToInt32(N).ToString() + ".ovf";
                        ovf2     m        = new ovf2(filename);
                        string   itxt     = tb_CompInfo.Text;
                        string[] sitxt    = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                        this.componentNum = Convert.ToInt16(sitxt[0]);
                        PlotRow(m, chart2, m.header.ynodes / 2);
                        Bitmap bmp = Viz.MakeImage(m, componentNum);
                        //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                        pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
                        pictureBox1.Image    = bmp;
                    }
                }
                Console.WriteLine("N={0}, H={1}", N, (xval).ToString());
            }
        }
Beispiel #8
0
        public void DoSweep(double H0, double dH)
        {
            double h;

            for (int i = 0; i < files.Count; i++)
            {
                h = H0 + i * dH;
                ovf2   mi  = new ovf2(files[i].FullName, false);
                double fzi = fmrfm.CalculateFz(mi) - (0.00206897 * (h - H0));
                H.Add(h);
                Fz.Add(fzi);
            }
        }
Beispiel #9
0
        private Bitmap GetImageDiff(ovf2 fileA, ovf2 fileB)
        {
            for (int i = 0; i < fileA.data.Count; i++)
            {
                Vector v1 = fileA.data[i];
                Vector v2 = fileB.data[i];
                Vector v  = v1 - v2;
                fileA.data[i] = v;
            }

            Bitmap bmp = Viz.MakeImage(fileA, componentNum);

            return(bmp);
        }
Beispiel #10
0
        private void btn_Export_Click(object sender, EventArgs e)
        {
            SaveFileDialog svd = new SaveFileDialog();

            if (svd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Console.WriteLine(svd.FileName);
                string FileName           = svd.FileName.Substring(0, svd.FileName.Length - 4) + ".txt";
                System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName);
                if (ActiveSim != null)
                {
                    //find the index N of currently selected point in the table
                    string fileNname = tb_colname.Text.Split(',')[0];
                    string fieldname = tb_colname.Text.Split(',')[1];
                    double N         = mt.find(fileNname, fieldname, currXVal);
                    string baseName  = ActiveSim.dir + "\\" + Convert.ToInt32(N).ToString() + "-";
                    ovf2   m0        = new ovf2(baseName + "m0.ovf");
                    //ovf2 mf = new ovf2(baseName + "f1-" + k.ToString() + ".ovf");
                    //ovf2 mf = new ovf2(baseName + "f1-0.ovf", cb_py.Checked);
                    ovf2     mf    = new ovf2(baseName + "mf.ovf");
                    string   itxt  = tb_CompInfo.Text;
                    string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                    this.componentNum = Convert.ToInt16(sitxt[0]);
                    int tfAvg = Convert.ToInt16(sitxt[1]);
                    if (tfAvg == 1)
                    {
                        mf = new ovf2(baseName + "mf.ovf");
                        ExportCurrFile(sw, m0, mf, false, 0);
                    }
                    else if (tfAvg == 2)
                    {
                        for (int k = 0; k < 8; k++)
                        {
                            string FName = svd.FileName.Substring(0, svd.FileName.Length - 4) + "-" + "-snapshot" + k.ToString() + ".txt";
                            System.IO.StreamWriter sww = new System.IO.StreamWriter(FName);
                            mf = new ovf2(baseName + "f1-" + k.ToString() + ".ovf");
                            ExportCurrFile(sww, m0, mf, false, 0);
                        }
                    }
                    else
                    {
                        mf = new ovf2(baseName + "f1-0.ovf");
                        ExportCurrFile(sw, m0, mf, false, 0);
                    }
                }
                sw.Close();
            }
        }
Beispiel #11
0
        public static double ogF(int N, SimController sim, List <int> pltChoice)
        {
            //m000001.ovf
            N--;
            double f     = 0;
            string file1 = sim.dir + fName(2 * N);
            string file2 = sim.dir + fName(2 * N + 1);
            //string file3 = sim.dir + fName(3 * N + 2);

            ovf2   m0  = new ovf2(file1, false);
            ovf2   mi  = new ovf2(file2, false);
            double fzi = sim.fmrfm.CalculateFz(m0, mi);

            return(fzi);
        }
Beispiel #12
0
        private void btn_ExportAll_Click(object sender, EventArgs e)
        {
            int    i          = 0;
            int    packagenum = 0;
            string dir        = tb_Sweeps.Text;

            //ovf2 m0 = new ovf2(dir + "\\m000000.ovf", false);

            foreach (string fname in lb_Sweeps.Items)
            {
                string FileName = "";
                if (!cb_inseries.Checked)
                {
                    FileName = dir + '\\' + fname.Substring(0, fname.Length - 4) + ".txt";
                }
                else
                {
                    FileName = dir + "\\package" + Convert.ToString(packagenum) + ".txt";
                }
                System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, cb_inseries.Checked);
                ovf2 m = new ovf2(dir + '\\' + fname);

                if (tb_minit.Text != "")
                {
                    ovf2 m0 = new ovf2(tb_minit.Text);
                    ExportCurrFile(sw, m, m0, cb_inseries.Checked, i);
                }
                //find ground state automatically if the selected states are generated using 8-avg methods
                else if (cb_autoground.Checked)
                {
                    string f0name = fname.Split('-')[0] + "-m0.ovf";
                    ovf2   m0     = new ovf2(dir + '\\' + f0name);;
                    ExportCurrFile(sw, m, m0, cb_inseries.Checked, i);
                }
                else
                {
                    ExportCurrFile(sw, m, null, cb_inseries.Checked, i);
                }

                i++;
                if (i == Convert.ToInt32(tb_packn.Text))
                {
                    i = 0;
                    packagenum++;
                }
                sw.Close();
            }
        }
Beispiel #13
0
        public static double noRefF(int N, SimController sim, List <int> plotChoice, MagnetizationByPosition MsByPos, string calccondition)
        {
            //N--;
            string fmt = "000000.##";
            //string file = sim.dir + 'f' + N.ToString(fmt) + ".ovf";
            string file = sim.dir + 'f' + N.ToString() + ".ovf";

            //string file3 = sim.dir + fName(3 * N + 2);
            Console.WriteLine("Dip pos:" + sim.fmrfm.dipole.r0.ToString());
            ovf2 m = new ovf2(file, true);

            //double fzi = sim.fmrfm.CalculateFz(m0, mi);
            double fzi = sim.fmrfm.CalculateFzConditional(null, m, ops.CalcCondition_range, MsByPos, plotChoice, calccondition);

            return(fzi);
        }
Beispiel #14
0
        public void DoSweep(double H0, double dH, bool propEven)
        {
            double h;
            int    num = (files.Count - 1) / 2;

            for (int i = 0; i < num; i++)
            {
                int bg   = 2 * i + 1;
                int real = 2 * i + 2;
                h = H0 + i * dH;
                ovf2   m0  = new ovf2(files[bg].FullName, false);
                ovf2   mi  = new ovf2(files[real].FullName, false);
                double fzi = fmrfm.CalculateFz(m0, mi);
                H.Add(h);
                Fz.Add(fzi);
            }
        }
Beispiel #15
0
        public static double dualFSmooth(int N, SimController sim, List <int> pltChoice)
        {
            //m000001.ovf
            N--;
            double        f     = 0;
            string        file1 = sim.dir + "mx" + (3 * N).ToString() + ".ovf";
            string        file2 = sim.dir + "mx" + (3 * N + 1).ToString() + ".ovf";
            string        file3 = sim.dir + "mx" + (3 * N + 2).ToString() + ".ovf";
            List <string> file  = new List <string> {
                file1, file2, file3
            };
            ovf2   m0  = new ovf2(file[pltChoice[0]], false);
            ovf2   mi  = new ovf2(file[pltChoice[1]], false);
            double fzi = sim.fmrfm.CalculateFz(m0, mi);

            return(fzi);
        }
Beispiel #16
0
        public static double dualF(int N, SimController sim, List <int> pltChoice)
        {
            //m000001.ovf
            N--;
            double        f     = 0;
            string        file1 = sim.dir + fName(3 * N);
            string        file2 = sim.dir + fName(3 * N + 1);
            string        file3 = sim.dir + fName(3 * N + 2);
            List <string> file  = new List <string> {
                file1, file2, file3
            };
            ovf2   m0  = new ovf2(file[pltChoice[0]]);
            ovf2   mi  = new ovf2(file[pltChoice[1]]);
            double fzi = sim.fmrfm.CalculateFz(m0, mi);

            return(fzi);
        }
Beispiel #17
0
        public static double newF(int N, SimController sim, List <int> plotChoice, MagnetizationByPosition MsByPos, string calccondition)
        {
            //N--;
            double f     = 0;
            string file1 = sim.dir + N.ToString() + "-m0.ovf";
            string file2 = sim.dir + N.ToString() + "-mf.ovf";

            //string file3 = sim.dir + fName(3 * N + 2);
            Console.WriteLine("Dip pos:" + sim.fmrfm.dipole.r0.ToString());
            ovf2 m0 = new ovf2(file1, false);
            ovf2 mi = new ovf2(file2, false);

            //double fzi = sim.fmrfm.CalculateFz(m0, mi);
            //double fzi = sim.fmrfm.CalculateFzConditional(m0, mi, (v) => { return true; }, MsByPos,plotChoice);
            double fzi = sim.fmrfm.CalculateFzConditional(m0, mi, ops.CalcCondition_range, MsByPos, plotChoice, calccondition);

            return(fzi);
        }
Beispiel #18
0
        private void lb_Files_SelectedIndexChanged(object sender, EventArgs e)
        {
            string fName = tb_Dir.Text + "\\";

            if (lb_Files.SelectedIndex > -1)
            {
                fName += lb_Files.SelectedItem.ToString();
                ovf2     ovf   = new ovf2(fName);
                string   itxt  = tb_CompInfo.Text;
                string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                this.componentNum = Convert.ToInt16(sitxt[0]);
                PlotRow(ovf, chart2, ovf.header.ynodes / 2);
                Bitmap bmp = Viz.MakeImage(ovf, componentNum);
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Image    = bmp;
            }
        }
Beispiel #19
0
        private void AverageMagnetizations(string dirPath, int NumOfAvgs)
        {
            //string fName = "-f1-";
            MuMaxTable mt1       = new MuMaxTable(dirPath + "\\table.txt");
            string     fileNname = tb_colname.Text.Split(',')[0];
            int        fnum      = mt1.data[fileNname].Count;

            for (int i = 0; i < fnum; i++)
            {
                if (!System.IO.File.Exists(dirPath + "\\" + i.ToString() + "-mf.ovf"))
                {
                    ovf2 newAvg = average(dirPath, i, NumOfAvgs);
                    newAvg.SaveAs(dirPath + "\\" + i.ToString() + "-mf.ovf");
                    Console.WriteLine("Done with {0}", i);
                }
                else
                {
                    Console.WriteLine("Skipping {0}", i);
                }
            }
        }
Beispiel #20
0
 private void PlotRow(ovf2 m, Chart chart, int RowNumber)
 {
     chart.Series[0].ChartType = SeriesChartType.Line;
     Vector[] vecM = m.GetRow(RowNumber, 0);
     chart.Series[0].Points.Clear();
     for (int i = 0; i < vecM.Count(); i++)
     {
         double dV = 0;
         if (componentNum == 1)
         {
             dV = (vecM[i].x);
         }
         else if (componentNum == 2)
         {
             dV = (vecM[i].y);
         }
         else if (componentNum == 3)
         {
             dV = (vecM[i].z);
         }
         chart.Series[0].Points.AddXY(i, dV);
     }
 }
Beispiel #21
0
        public double CalculateFz(ovf2 m)
        {
            double fz = CalculateFz(this.m0, m);

            return(fz);
        }
Beispiel #22
0
        public double CalculateFzConditional(ovf2 mRef, ovf2 m, CalcCondition ccond, MagnetizationByPosition MsAtPos, List <int> plotChoice, string cond)
        {
            //int Ny = mRef.header.ynodes;
            int    Ny = m.header.ynodes;
            double fz = 0;
            //double vol = mRef.header.xstepsize * mRef.header.ystepsize * mRef.header.zstepsize;
            double vol = m.header.xstepsize * m.header.ystepsize * m.header.zstepsize;

            for (int i = 0; i < Ny; i++)
            {
                Vector[] dm = m.GetRow(i, 0);
                if (mRef != null)
                {
                    Vector[] row0 = mRef.GetRow(i, 0);
                    dm = vecSub(dm, row0);
                }

                for (int j = 0; j < dm.Count(); j++)
                {
                    //Vector mf = new Vector(dm[j].x * mom, dm[j].y * mom, dm[j].z * mom);
                    Vector r = m.GetPos(j, i, 0);
                    //Vector mf = new Vector(0, 0, dm[j].z * MsAtPos(r) * vol);
                    Vector mf  = new Vector(dm[j].x * MsAtPos(r) * vol, dm[j].y * MsAtPos(r) * vol, dm[j].z * MsAtPos(r) * vol);
                    double fzi = 0;
                    if (plotChoice[0] == 0)
                    {
                        if (plotChoice[1] == 1)
                        {
                            fzi = dipole.Fz(mf, r);
                        }
                        else if (plotChoice[1] == 2)
                        {
                            fzi = dipole.Fz_ip(mf, r);
                        }
                        else if (plotChoice[1] == 3)
                        {
                            fzi = dipole.Fz_ipy(mf, r);
                        }
                    }
                    if (plotChoice[0] == 1)
                    {
                        if (plotChoice[1] == 1)
                        {
                            fzi = dm[j].z;
                        }
                        else if (plotChoice[1] == 2)
                        {
                            fzi = dm[j].x;
                        }
                        else if (plotChoice[1] == 3)
                        {
                            fzi = dm[j].y;
                        }
                    }
                    //double fzi = dipole.Fz(mf, r);
                    //double fzi = dipole.Fz_ip(mf, r);
                    if (ccond(r, cond))
                    {
                        fz += fzi;
                    }
                }
            }

            return(fz);
        }
Beispiel #23
0
 public FMRFM(Dipole cantileverDipole, ovf2 m0, double MaterialMs)
 {
     this.dipole     = cantileverDipole;
     this.m0         = m0;
     this.MaterialMs = MaterialMs;
 }
Beispiel #24
0
        private void ExportCurrFile(System.IO.StreamWriter sw, ovf2 m0, ovf2 mf, bool inseries, int index)
        {
            double factor = 1.0;
            int    Nx     = m0.header.xnodes;
            int    Ny     = m0.header.ynodes;

            int startK = 0;
            int endK   = (m0.GetRow(0, 0)).Count();

            double vcomp = 0;

            if (inseries)
            {
                if (index > 0 && index < Convert.ToInt32(tb_packn.Text))
                {
                    sw.Write("##\n");
                }
            }
            for (int i = 0; i < Ny; i++)
            {
                Vector[] vrow0 = m0.GetRow(i, 0);
                Vector[] vrowf;
                if (mf != null)
                {
                    vrowf = mf.GetRow(i, 0);
                }
                else
                {
                    vrowf = new Vector[vrow0.Count()];
                }
                Vector[] vsub     = new Vector[vrow0.Count()];
                int      colStart = vrow0.Count() / 2;
                for (int k = startK; k < endK; k++)
                {
                    if (mf != null)
                    {
                        vsub[k] = vrow0[k] - vrowf[k];
                    }
                    else
                    {
                        vsub[k] = vrow0[k];
                    }
                    //which component to plot (x, y or z)
                    string   itxt  = tb_CompInfo.Text;
                    string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    //ovf2 mf = new ovf2(baseName + "f1-0.ovf");
                    this.componentNum = Convert.ToInt16(sitxt[0]);
                    if (this.componentNum == 1)
                    {
                        vcomp = vsub[k].x;
                    }
                    else if (this.componentNum == 2)
                    {
                        vcomp = vsub[k].y;
                    }
                    else if (this.componentNum == 3)
                    {
                        vcomp = vsub[k].z;
                    }

                    sw.Write((factor * vcomp).ToString());
                    if (k < endK - 1)
                    {
                        sw.Write(" ");
                    }
                    else
                    {
                        sw.Write("\n");
                    }
                }
            }
            sw.Close();
        }