private void step_button_Click(object sender, EventArgs e) { dimension = 1; conduction_band.Series["conduction_band_data"].Points.Clear(); conduction_band.Series["valence_band_data"].Points.Clear(); conduction_band.Series["x_data"].Points.Clear(); density.Series["car_dens_data"].Points.Clear(); density.Series["dop_dens_data"].Points.Clear(); density.Series["gphi_data"].Points.Clear(); int nz; int i = int.Parse(count_no_label.Text); if (!int.TryParse(nz1Dval.Text, out nz)) { MessageBox.Show("Format of Nz for dopent potential is invalid"); return; } // initialise dopent experiment if the count is zero if (i == 0) { exp1d = new OneD_ThomasFermiPoisson.Experiment(); car_dens = new SpinResolved_Data(nz); dop_dens = new SpinResolved_Data(nz); Dictionary <string, object> inputs_tmp = Create_Dictionary(); foreach (KeyValuePair <string, object> option in inputs_tmp) { inputs.Add(option.Key.Replace("_1d", ""), option.Value); } inputs["surface_charge"] = 0.0; inputs["max_iterations"] = 0.0; exp1d.Initialise(inputs); } converged = exp1d.Run(); ILayer[] layers = exp1d.Layers; double dz = exp1d.Dz_Pot; double zmin = exp1d.Zmin_Pot; car_dens = exp1d.Carrier_Density; dop_dens = exp1d.Dopent_Density; Band_Data x = Physics_Base.q_e * exp1d.X; Band_Data gphi = exp1d.GPhi; chem_pot = (Input_Band_Structure.Get_BandStructure_Grid(layers, dz, nz, zmin) - exp1d.Chemical_Potential); // + x); val_pot = (-1.0 * Input_Band_Structure.Get_BandStructure_Grid(layers, dz, nz, zmin) - exp1d.Chemical_Potential); // + x); for (int j = 0; j < chem_pot.Length; j++) { double pos = zmin + dz * j; conduction_band.Series["conduction_band_data"].Points.AddXY(pos, chem_pot[j]); conduction_band.Series["valence_band_data"].Points.AddXY(pos, val_pot[j]); conduction_band.Series["x_data"].Points.AddXY(pos, x[j]); density.Series["car_dens_data"].Points.AddXY(pos, car_dens.Spin_Summed_Data[j]); density.Series["dop_dens_data"].Points.AddXY(pos, dop_dens.Spin_Summed_Data[j]); density.Series["gphi_data"].Points.AddXY(pos, gphi[j]); } Set_Plot_Axes(dens_xmin_val.Text, dens_xmax_val.Text, density.ChartAreas["ChartArea1"].AxisX); Set_Plot_Axes(dens_ymin_val.Text, dens_ymax_val.Text, density.ChartAreas["ChartArea1"].AxisY); Set_Plot_Axes(pot_xmin_val.Text, pot_xmax_val.Text, conduction_band.ChartAreas["ChartArea1"].AxisX); Set_Plot_Axes(pot_ymin_val.Text, pot_ymax_val.Text, conduction_band.ChartAreas["ChartArea1"].AxisY); conduction_band.Refresh(); density.Refresh(); this.count_no_label.Text = (i + 1).ToString(); this.temperature_val_label.Text = exp1d.Current_Temperature.ToString() + " K"; this.carrier_dopent_density_Text.Text = (from val in car_dens.Spin_Summed_Data.vec where val < 0.0 select - 1.0e14 * val * dz / Physics_Base.q_e).ToArray().Sum().ToString("e3"); }
void run() { ToConsole("Initialising hardware."); exp.Initialise(parameters); ToConsole("Acquiring data..."); int numberOfScans = 0; while (es.Equals(ExperimentState.IsRunning) || es.Equals(ExperimentState.IsPaused)) { //Tell UI to clear in preparation for new data. Clients.All.clearPlot(); currentDataSet = new DataSet(); int i = 0, iterationsSinceLastDataUpdate = 0; while (i < parameters.ScanParams.NumberOfPoints) { //This is to break out mid-scan if (es.Equals(ExperimentState.IsRunning)) { //Need to call this whether acquiring or not... (otherwise DDS command doesn't get sent) currentDataSet.Add(exp.SetupAndAcquire(parameters.ScanParams.ScanParameterValues[i])); i++; iterationsSinceLastDataUpdate++; //Only send to plot if acquisition happened. if (parameters.ScanParams.AcquireDataDuringScan) { //Cheezy solution for real time plotting. Update roughly every 0.5 seconds. If I update too often, it crashes on UI side. if (iterationsSinceLastDataUpdate * parameters.ScanParams.Sleep > 500) { //Push data down to the client like this. Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); iterationsSinceLastDataUpdate = 0; } } } else if (es.Equals(ExperimentState.IsPaused)) { //Only send to plot if acquisition happened. if (parameters.ScanParams.AcquireDataDuringScan) { //Plots any residual data points during pause, if there is anything to plot if (iterationsSinceLastDataUpdate != 0) { Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); iterationsSinceLastDataUpdate = 0; } } Thread.Sleep(1000); } else { break; //Somebody pressed the stop button during a scan. } } if (parameters.ScanParams.AcquireDataDuringScan) { dataArchive.Add(currentDataSet); numberOfScans++; //Push data down to the client like this. Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); } if (parameters.ScanParams.StopOnEOS) { es = ExperimentState.IsFinishing; } } ToConsole("Acquisition/Move complete."); ToConsole("Disposing hardware classes..."); exp.Dispose(); ToConsole("Disposed."); ToConsole("Setting ExperimentState to stopped and closing thread..."); es = ExperimentState.IsStopped; }
private void step_button_Click(object sender, EventArgs e) { dimension = 1; conduction_band.Series["conduction_band_data"].Points.Clear(); conduction_band.Series["valence_band_data"].Points.Clear(); conduction_band.Series["x_data"].Points.Clear(); density.Series["car_dens_data"].Points.Clear(); density.Series["dop_dens_data"].Points.Clear(); density.Series["gphi_data"].Points.Clear(); int nz; int i = int.Parse(count_no_label.Text); if (!int.TryParse(nz1Dval.Text, out nz)) { MessageBox.Show("Format of Nz for dopent potential is invalid"); return; } // initialise dopent experiment if the count is zero if (i == 0) { exp1d = new OneD_ThomasFermiPoisson.Experiment(); car_dens = new SpinResolved_Data(nz); dop_dens = new SpinResolved_Data(nz); Dictionary<string, object> inputs_tmp = Create_Dictionary(); foreach (KeyValuePair<string, object> option in inputs_tmp) inputs.Add(option.Key.Replace("_1d", ""), option.Value); inputs["surface_charge"] = 0.0; inputs["max_iterations"] = 0.0; exp1d.Initialise(inputs); } converged = exp1d.Run(); ILayer[] layers = exp1d.Layers; double dz = exp1d.Dz_Pot; double zmin = exp1d.Zmin_Pot; car_dens = exp1d.Carrier_Density; dop_dens = exp1d.Dopent_Density; Band_Data x = Physics_Base.q_e * exp1d.X; Band_Data gphi = exp1d.GPhi; chem_pot = (Input_Band_Structure.Get_BandStructure_Grid(layers, dz, nz, zmin) - exp1d.Chemical_Potential);// + x); val_pot = (-1.0 * Input_Band_Structure.Get_BandStructure_Grid(layers, dz, nz, zmin) - exp1d.Chemical_Potential);// + x); for (int j = 0; j < chem_pot.Length; j++) { double pos = zmin + dz * j; conduction_band.Series["conduction_band_data"].Points.AddXY(pos, chem_pot[j]); conduction_band.Series["valence_band_data"].Points.AddXY(pos, val_pot[j]); conduction_band.Series["x_data"].Points.AddXY(pos, x[j]); density.Series["car_dens_data"].Points.AddXY(pos, car_dens.Spin_Summed_Data[j]); density.Series["dop_dens_data"].Points.AddXY(pos, dop_dens.Spin_Summed_Data[j]); density.Series["gphi_data"].Points.AddXY(pos, gphi[j]); } Set_Plot_Axes(dens_xmin_val.Text, dens_xmax_val.Text, density.ChartAreas["ChartArea1"].AxisX); Set_Plot_Axes(dens_ymin_val.Text, dens_ymax_val.Text, density.ChartAreas["ChartArea1"].AxisY); Set_Plot_Axes(pot_xmin_val.Text, pot_xmax_val.Text, conduction_band.ChartAreas["ChartArea1"].AxisX); Set_Plot_Axes(pot_ymin_val.Text, pot_ymax_val.Text, conduction_band.ChartAreas["ChartArea1"].AxisY); conduction_band.Refresh(); density.Refresh(); this.count_no_label.Text = (i + 1).ToString(); this.temperature_val_label.Text = exp1d.Current_Temperature.ToString() + " K"; this.carrier_dopent_density_Text.Text = (from val in car_dens.Spin_Summed_Data.vec where val < 0.0 select -1.0e14 * val * dz / Physics_Base.q_e).ToArray().Sum().ToString("e3"); }