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; }
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()); } }