Esempio n. 1
0
        /// <summary>
        /// Shifts position of the potential in for 10µm in x direction in the beginning. Afterwards the
        /// time-evolution of the wave function is calculated, using the Bit Reversal algorithm.
        /// </summary>
        private void shiftPotButton_Click(object sender, EventArgs e)
        {
            gpe.changeCenterOfV(Math.Pow(10, -5) * 1);  // Shift of the potential
            plotV.Points.Clear();                       // Deleting the data points of the previous potential

            //Creates the data points for the new potential
            for (int k = 0; k < gpe.psi.Length; k++)
            {
                plotV.Points.Add(new DataPoint(gpe.X[k], gpe.V[k]));
            }

            potModel.Series.Clear();                    // deletes previous data series
            potModel.Series.Add(plotV);                 // adds new data series
            this.plot1.Model = potModel;                // shows new plot of the potential

            double[,] dataMap = new double[gpe.psi.Length, tsteps / 100];
            int writeOut = 0;

            for (int i = 0; i < tsteps; i++)
            {
                //Calculation of Ψ(t) using the split-step-fourier-method using the bit-reverse algorithm for the FFT
                gpe.splitStepFourier("BR");


                // Writing every 100th calculated value into the plot array
                if (i == writeOut)
                {
                    for (int k = 0; k < gpe.psi.Length; k++)
                    {
                        dataMap[k, i / 100] = Math.Pow(gpe.psi[k].Norm(), 2);
                    }
                    writeOut += 100;
                }
            }

            //ColorMap
            maxColor          = OxyPlot.ArrayExtensions.Max2D(dataMap);
            ColorBarSeries.Y1 = maxColor;

            heatPsi.Data = dataMap;         // Writes calculated data series into plot array
            timeModel.Series.Clear();       // clears plot model from previous data series
            timeModel.Series.Add(heatPsi);  // adds new data series

            this.plot1.Model = timeModel;   // shows new data series in plot
        }
Esempio n. 2
0
        /// <summary>
        /// Starts the calculation of the time development of the wavefunction under given parameters.
        /// As starting wave function it is either used the ground state wave function, if calculated before
        /// or a default one, or another one, if the double BEC checkbox is selected.
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            getParams(); //read-out of the parameters
            // Initialization of the GPE solver, transferring the read-out parameters
            gpe = new GPESolver(mass, anzahl, sclength, wx, wr);

            double[] normedPsi = new double[gpe.psi.Length];   //Creation of the array for |Ψ|²

            //Plot of the trap potential, that is shown during the calculation of the time-evolution calculation

            plotV.Points.Clear(); // Deletes previous data points from the data series

            //Creation of the new data series for the plot of the potential
            for (int k = 0; k < gpe.psi.Length; k++)
            {
                plotV.Points.Add(new DataPoint(gpe.X[k], gpe.V[k]));
            }

            potModel.Series.Clear();     // Deletes previous data series from the plotmodel
            potModel.Series.Add(plotV);  // Adds new data series to the plotmodel
            this.plot1.Model = potModel; // Shows the potential plot

            // Preparation of the time-dependent plot

            // Creation of the data grid for the time-dependent plot of |Ψ|²
            heatPsi.X0 = gpe.X[0];              // set xmin
            heatPsi.X1 = gpe.X[gpe.xSteps - 1]; // set xmax
            heatPsi.Y0 = 0;
            heatPsi.Y1 = gpe.deltaT * tsteps;   //set the height of the plot

            heatPsi.Interpolate = true;         //switch on color gradient

            //Creation of two color scales, using the 'Jet-palette'
            LinearColorAxis cAxis = new LinearColorAxis();

            cAxis.Palette = OxyPalettes.Jet(100);
            LinearColorAxis cAxisC = new LinearColorAxis();

            cAxisC.Palette = OxyPalettes.Jet(100);



            ColorBarModelE.Series.Clear();
            this.ColorBar.Model = ColorBarModelE; //Prevents bug with colorbar if time evolution is selected before starting calculation. Reason unknown.



            timeModel.Axes.Add(cAxis);                                     // Adding the color axis
            ColorBarModel.Axes.Add(cAxisC);
            double[,] dataMap  = new double[gpe.psi.Length, tsteps / 100]; //Initializing data array for time-dependent plot
            double[,] ColorMap = new double[10, 10000];                    //Initializing data array for color bar



            Stopwatch Stopwatch1 = new Stopwatch(); // Initialisation of the stopwatch

            Stopwatch1.Start();                     // Start of the stopwatch

            //deciding which method to use for the time-development-calculation,
            //if there is no method chosen, Bit-Reverse is used
            string method;


            if (FFTCheckBox.Checked)
            {
                method = "CT";
            }
            else if (DFTCheckBox.Checked)
            {
                method = "DFT";
            }
            else if (bitReverse.Checked)
            {
                method = "BR";
            }
            else
            {
                method = "BR";
            }

            // The starting wave function is created, either using the default one (see GPESolver) or the ground state
            // is calculated, or the double BEC function is used with the offset chosen in the GUI
            ComplexNumber[] psiStart = (ComplexNumber[])gpe.psi.Clone();

            if (getgroundstate.Checked)
            {
                gpe.getGroundState();
            }
            else if (DBECCheckBox.Checked)
            {
                offsetDBEC = Convert.ToInt32(OffsetDBECTextBox.Text);
                gpe.getDPsi(offsetDBEC);
            }


            int writeOut = 0;

            for (int i = 0; i < tsteps; i++)
            {
                // Calculation of Ψ(t) using the split-step-fourier method using the chosen algorithm for the FFT
                gpe.splitStepFourier(method);


                // Writing every 100th calculated value into the plot array
                if (i == writeOut)
                {
                    for (int k = 0; k < gpe.psi.Length; k++)
                    {
                        dataMap[k, i / 100] = Math.Pow(gpe.psi[k].Norm(), 2);
                    }
                    writeOut += 100;
                }
            }

            Stopwatch1.Stop();                                                                                                                              // Stops the time after calculation
            LaufzeitTextBox.Text = Convert.ToString(Stopwatch1.ElapsedMilliseconds);                                                                        // Shows runtime in textbox
            listBox1.Items.Insert(0, method + "-FFT:" + " " + Convert.ToString(Stopwatch1.ElapsedMilliseconds) + "ms" + "  Timesteps" + tsteps.ToString()); // Adds runtime, used method and number of time steps to listbox

            maxColor = OxyPlot.ArrayExtensions.Max2D(dataMap);                                                                                              //@David ich weiß leider nicht so richtig was das macht
            for (int k = 0; k < 10000; k++)
            {
                for (int l = 0; l < 10; l++)
                {
                    ColorMap[l, k] = maxColor * k / 10000;
                }
            }
            // Creation of the data grid for the display of the colorbar
            ColorBarSeries.X0          = 0;    //set xmin
            ColorBarSeries.X1          = 10;   //set xmax
            ColorBarSeries.Y0          = 0;    //set height of the colorbar
            ColorBarSeries.Y1          = maxColor;
            ColorBarSeries.Interpolate = true; //switch on color gradient

            //Preparing Oxyplot
            heatPsi.Data        = dataMap;  // Write calculated data into plotarray
            ColorBarSeries.Data = ColorMap; // Write calculated data into plotarray
            timeModel.Series.Clear();
            timeModel.Series.Add(heatPsi);  // Add plotarray to plotmodel

            // Add the recent data series to the color bar model
            ColorBarModel.Series.Clear();
            ColorBarModel.Series.Add(ColorBarSeries);

            //Calculating |Ψ|² and |Ψstart|² and writing it into the plot arrays
            for (int k = 0; k < gpe.psi.Length; k++)
            {
                normedPsi[k] = Math.Pow(gpe.psi[k].Norm(), 2);
                plotPsi.Points.Add(new DataPoint(gpe.X[k], normedPsi[k]));
                normedPsi[k] = Math.Pow(psiStart[k].Norm(), 2);
                plotPsiStart.Points.Add(new DataPoint(gpe.X[k], normedPsi[k]));
            }

            // Deleting the old series and add the new ones
            myModel.Series.Clear();
            myModel.Series.Add(plotPsiStart);
            myModel.Series.Add(plotPsi); //


            this.plot1.Model      = timeModel;     // Show the time-dependent plot
            this.ColorBar.Model   = ColorBarModel; // Show the created color bar
            this.ColorBar.Visible = true;          // Make the color bar visible

            this.shiftPotButton.Enabled = true;    // The shift potential button is usable now

            //Energy = ETC.Hamilton(gpe.psi, gpe.V, gpe.deltaX, PhysConst.hbar, mass, gpe.g1D);
            //EnergieTextBox.Text = Convert.ToString(Energy); //Energie in TextBox
        }