コード例 #1
0
ファイル: Form1.cs プロジェクト: DrizzWu/MuMaxViewer
        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);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: DrizzWu/MuMaxViewer
        private void StartSim(string idir)
        {
            chart1.Series[0].ChartType = SeriesChartType.Line;

            System.Diagnostics.Stopwatch stw = new System.Diagnostics.Stopwatch();
            stw.Start();

            string mom_str = tb_DipMom.Text;
            string pos_str = tb_DipPos.Text;

            string[]   mom        = mom_str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            string[]   pos        = pos_str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            Vector     M          = new Vector(mom[0], mom[1], mom[2]);
            Vector     P          = new Vector(pos[0], pos[1], pos[2]);
            Dipole     dip1       = new Dipole(P, M);
            double     interfaceX = Convert.ToDouble(tb_IP.Text) * 1e-6;
            double     MS1        = Convert.ToInt32(tb_Ms.Text) / (4 * Math.PI) * 1.0e3;
            double     MS2        = Convert.ToInt32(tb_Ms2.Text) / (4 * Math.PI) * 1.0e3;
            List <int> PltChoice  = new List <int>()
            {
                0, 1
            };

            if (cb_Fz.Checked == false)
            {
                if (cb_Fx.Checked)
                {
                    PltChoice[1] = 2;
                }
                else if (cb_Fy.Checked)
                {
                    PltChoice[1] = 3;
                }
                else if (cb_Mz.Checked)
                {
                    PltChoice[0] = 1;
                    PltChoice[1] = 1;
                }
                else if (cb_Mx.Checked)
                {
                    PltChoice[0] = 1;
                    PltChoice[1] = 2;
                }
                else if (cb_My.Checked)
                {
                    PltChoice[0] = 1;
                    PltChoice[1] = 3;
                }
            }
            if (Simulation_Method == "8Avg_FieldScan")
            {
                AverageMagnetizations(idir, 8);
                pictureBox1.SizeMode       = PictureBoxSizeMode.StretchImage;
                chart1.Series[0].ChartType = SeriesChartType.Line;
                currImgNum = 524;

                string loc = idir;
                chart1.Series[0].ChartType = SeriesChartType.Line;

                //FMRFM fmr = new FMRFM(dip1, new ovf2(loc + @"\1-m0.ovf"), 135282);
                FMRFM         fmr = new FMRFM(dip1);
                SimController sim = new SimController(loc, fmr);
                //sim = new SimController(loc, fmr);

                sim.DoSweep(ops.newF, PltChoice, (vb1) => { if (vb1.x > interfaceX)
                                                            {
                                                                return(MS2);
                                                            }
                                                            else
                                                            {
                                                                return(MS1);
                                                            } }, tb_section.Text);
                sim.PlotSweep(chart1, 0, "f2-2");

                sim.SaveSweep(loc + "\\fieldSweep.txt");
                ActiveSim = sim;
                mt        = sim.table;

                return;
            }
            else if (Simulation_Method == "FFT")
            {
                pictureBox1.SizeMode       = PictureBoxSizeMode.StretchImage;
                chart1.Series[0].ChartType = SeriesChartType.Line;
                currImgNum = 524;

                string loc = tb_Sweeps.Text;
                chart1.Series[0].ChartType = SeriesChartType.Line;

                FMRFM         fmr = new FMRFM(dip1);
                SimController sim = new SimController(loc, fmr);
                sim = new SimController(loc, fmr);
                sim.DoSweep(ops.noRefF, PltChoice, (vb1) => { if (vb1.x > interfaceX)
                                                              {
                                                                  return(MS2);
                                                              }
                                                              else
                                                              {
                                                                  return(MS1);
                                                              } }, tb_section.Text);
                sim.PlotSweep(chart1, 0, "f2-2");

                sim.SaveSweep(loc + "\\fieldSweep.txt");
                ActiveSim = sim;
                mt        = sim.table;

                ChartArea CA = chart1.ChartAreas[0];
                VA                 = new VerticalLineAnnotation();
                VA.AxisX           = CA.AxisX;
                VA.AllowMoving     = true;
                VA.IsInfinitive    = true;
                VA.ClipToChartArea = CA.Name;
                VA.Name            = "myLine";
                VA.LineColor       = Color.Red;
                VA.LineWidth       = 2;   // use your numbers!
                chart1.Annotations.Add(VA);

                return;
            }
        }