Exemple #1
0
        private void StartField()
        {
            chart1.Invoke(new MethodInvoker(delegate() { chart1.Series[0].Points.Clear(); }));
            chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.Clear(); }));
            //       chart1.Series[0].Points.Clear(); chart2.Series[0].Points.Clear();

            CloseMe = false;
            DateTime T1;
            int Ns = Convert.ToInt32(tbNs.Text); int Nt = Convert.ToInt32(tbNt.Text);

            SU3 Field = new SU3(Ns,Nt, Convert.ToDouble(tbBeta.Text),Convert.ToDouble(tbflux.Text), checkBox1.Checked);
            for (int i = 0; i < 100000; i++)
            {
                T1 = DateTime.Now;

                //for (int or = 0; or < 5; or++) Field.Sweep(false); //SU(2) ONLY!!!
                this.Text = Field.Sweep(false).ToString();

                chart1.Invoke(new MethodInvoker(delegate() { chart1.Series[0].Points.AddY(Field.MeasureS()); }));
                chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.AddY(Field.MeasurePL()); }));

                lblTime1.Invoke(new MethodInvoker(delegate() { lblTime1.Text = Math.Round((DateTime.Now - T1).TotalMilliseconds).ToString() ; }));
                if (CloseMe) break;

               // if (cbDraw.Checked) DrawPicture(Field);

                Application.DoEvents();
            }
            CloseMe = false;
        }
Exemple #2
0
        private void GetData()
        {
            var l = new List<int>(new int[]{1,2,3});
            //l.Where(

            DateTime T, Tfull; double Chi = 0;
            double BetaStart = Convert.ToDouble(tbBS.Text);
            double BetaEnd = Convert.ToDouble(tbBE.Text);
            double BetaStep = Convert.ToDouble(tbBSt.Text);

            int Tsteps = Convert.ToInt16(tbTsteps.Text);
            int Msteps = Convert.ToInt16(tbMsteps.Text);
            for (double b = BetaStart; b <= BetaEnd; b = b + BetaStep)
            {
                SU3 Field = new SU3(Convert.ToInt32(tbNs.Text), Convert.ToInt32(tbNt.Text), b,Convert.ToDouble(tbflux.Text), checkBox1.Checked);
                double PL = 0, PL2 = 0, PLt; Chi = 0;
                int n = 0;
                Tfull = DateTime.Now;
                InvokeMe(() => Text = "1");
                InvokeMe(() => lblProcess.Text = "Thermalizing");
                for (int i = 0; i < Tsteps; i++)
                {
                    //T = DateTime.Now;
                    Field.Sweep(false);
                    InvokeMe(() => lblProcess.Text = "Thermalizing " + i.ToString());
                   // lblTime1.Invoke(new MethodInvoker(delegate() { lblTime1.Text = (DateTime.Now - T).TotalMilliseconds.ToString(); }));
                }

                //chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.AddXY(b, 0); }));
                for (int i = 0; i < Msteps; i++)
                {

                    Field.Sweep(false);
                    //  for (int or = 0; or < 5; or++) Field.Sweep(false);
                    if (rbS.Checked) PLt = Field.MeasureS(); else PLt = Field.MeasurePL();
                    PL += PLt; n++;
                   PL2 += PLt * PLt;

                    Chi = PL2 / n - (PL / n) * (PL / n);
                   // chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.Last().YValues = new double[1] { Chi }; }));
                    InvokeMe(() => chart1.Series[0].Points.Add(Chi));
                    InvokeMe(() => chart2.Series[0].Points.Add(PLt));
                    InvokeMe(() => lblProcess.Text = "Measuring " + i.ToString());

                }

               // Chi = PL2 / n - (PL / n) * (PL / n);
               // chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.Last().YValues = new double[1] { Chi }; }));

              //  chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.AddXY(b, PL/n); }));
                double t = (DateTime.Now - Tfull).TotalMilliseconds * (BetaEnd - b) / BetaStep;
                InvokeMe(() => lblRemain.Text = (DateTime.Now.AddMilliseconds(t)).ToString());
                InvokeMe(() => chart2.Update());

            }
        }
Exemple #3
0
        private void GetSample()
        {
            double Beta = Convert.ToDouble(tbBeta.Text);
            int Ns = Convert.ToInt32(tbNs.Text);
            int Nt = Convert.ToInt32(tbNt.Text);

            int Tsteps = Convert.ToInt32(tbTsteps.Text);
            int Msteps = Convert.ToInt32(tbMsteps.Text);

              //  double[] Sample = new double[N];

            SU3 Field = new SU3(Ns, Nt, Beta, Convert.ToDouble(tbflux.Text),checkBox1.Checked);
            double sum = 0, sum2 = 0, t = 0;
            int n = 0;
            int Mark = Convert.ToInt32(tbMark.Text);

            InvokeMe(() => lblProcess.Text = "Thermalizing");
            for (int i = 0; i < Tsteps; i++) { Field.Sweep(false); lblProcess.Invoke(new MethodInvoker(delegate() { lblProcess.Text = "Thermalizing " + i.ToString(); })); }
            while (true)
            {
                Field.Sweep(false); Field.Sweep(false); //Field.Sweep(false); Field.Sweep(false);
                t = Field.MeasureS();
               // Sample[n] = t;
                n++;
                sum += t; sum2 += t * t;
                InvokeMe(() => lblProcess.Text = "Measuring " + n.ToString());
                //
                if (n % Mark == 0)
                {
                    InvokeMe(() => chart2.Series[0].Points.AddY(sum / n));
                    InvokeMe(() => lblValue.Text = (sum / n).ToString());

                }
            }

            sum = sum / n;

            //finding error
            /*double sigma2=0, Sn=0, Ssample=0;
            for (int i=0;i<N;i++)
            {
                Sn = 1 / (N - 1.0) * (N*sum - Sample[i]);
                Ssample += Sn;
                sigma2 += (Sn - sum) * (Sn - sum);
                chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.AddY(Sample[i]); }));
            }
            Ssample = Ssample / N;
            sigma2 = Math.Sqrt((N-1.0)/N*sigma2);
            Ssample = sum - (N - 1f) * (Ssample - sum);
            */

            //   int k = 10;
            //   int d = N / k; sum2 = 0;
            //   for (int i = 0; i < d; i++)
            //   {
            //       sum = 0;
            //       for (int j = 0; j < k; j++) sum += Sample[i * k + j];
            //       sum /= k;
            //       chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[1].Points.AddY(sum); }));
            //       sum2 = (sum2 * i + sum) / ((i + 1));
            //       chart2.Invoke(new MethodInvoker(delegate() { chart2.Series[0].Points.AddY(sum2); }));

            //   }

            // lblSampleValue.Invoke(new MethodInvoker(delegate() { lblSampleValue.Text = Ssample.ToString(); }));
            //    lblSampleError.Invoke(new MethodInvoker(delegate() { lblSampleError.Text = sigma2.ToString(); }));

            //average and dispersion
            sum2 = Math.Sqrt(sum2 / n - sum * sum);

            InvokeMe(() => lblValue.Text = sum.ToString());
            InvokeMe(() => lblError.Text = sum2.ToString());
        }
Exemple #4
0
        private void button14_Click(object sender, EventArgs e)
        {
            double beta = 6;
            SU3 Field = new SU3(int.Parse(tbNs.Text), int.Parse(tbNt.Text), beta, 0, true);//4х2 field beta=6 flux=0
            DateTime t = DateTime.Now;
            for (int i = 0; i < 4; i++)
            {
                Field.Sweep(false);
                MessageBox.Show(Field.MeasureS().ToString());

                Text = (DateTime.Now - t).TotalMilliseconds.ToString(); Application.DoEvents();
            }
        }