Exemplo n.º 1
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);

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

            return(fzi);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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;
            }
        }