public Simulation(State_Variables state) { Coordinate_Range = new double[state.Dimension]; Speed_Range = new double[state.Dimension]; Out = new Output_Variables(state); // Fixing the pointer handles handle_Positions = new GCHandle[state.Num_Points]; handle_Velocities = new GCHandle[state.Num_Points]; unsafe { // Un-managed Code! Q = new Quantization(state.Num_Points, state.Num_ScaleBins); } Tile = new Tile_Variables(Q.Num_TileHubs, Q.Tile_Dimension); unsafe { // Un-managed Code! for (uint i_p = 0; i_p < Tile.Num_TileHubs; i_p++) { for (uint i_d = 0; i_d < Tile.Tile_Dimension; i_d++) { Tile.Tile_Positions[i_p][i_d] = Q.Tile_Positions[i_p][i_d]; } } } }
// Reading from File public State_Variables Sate_XML(string file_name) { FileStream fileStream = new FileStream(file_name, FileMode.Open); State_Variables state = (State_Variables)State_XmlSerializer.Deserialize(fileStream); return(state); }
// Writing to File public void Write_XML(string file_name, State_Variables state) { TextWriter textWriter = new StreamWriter(file_name); State_XmlSerializer.Serialize(textWriter, state); textWriter.Close(); }
public Output_Variables(State_Variables state) { Scale_Ladder_Original = new double[state.Num_Points]; Scale_Ladder_Dual = new double[state.Num_Points]; Dendogram_Original = new bool[state.Num_Points][]; Dendogram_Dual = new bool[state.Num_Points][]; KineticEnergy_Vector = new double[state.Num_Points]; PotentialEnergy_Vector = new double[state.Num_Points]; ClassicalEnergy_Exchange = new double[state.Num_Points]; ClassicalEnergy_Vector = new double[state.Num_Points]; ClassicalLaplacian_Energy = new double[state.Num_Points]; ClassicalLaplacian_EigenStates = new double[state.Num_Points][]; ClassicalHamiltonian_Energy = new double[state.Num_Points]; ClassicalHamiltonian_wVacuum_Energy = new double[state.Num_Points]; ClassicalHamiltonian_EigenStates = new double[state.Num_Points][]; ClassicalHamiltonian_wVacuum_EigenStates = new double[state.Num_Points][]; ClassicalParticle_Entropy = new double[state.Num_Points]; for (int i = 0; i < state.Num_Points; i++) { Dendogram_Original[i] = new bool[state.Num_Points]; Dendogram_Dual[i] = new bool[state.Num_Points]; ClassicalLaplacian_EigenStates[i] = new double[state.Num_Points]; ClassicalHamiltonian_EigenStates[i] = new double[state.Num_Points]; ClassicalHamiltonian_wVacuum_EigenStates[i] = new double[state.Num_Points]; } Laplacian_Energy = new double[state.Num_ScaleBins][]; Commutator_Energy = new double[state.Num_ScaleBins][]; Mass_Vector = new double[state.Num_ScaleBins][]; Energy_Vector = new double[state.Num_ScaleBins][]; Laplacian_Orthonormal_Transformation = new double[state.Num_ScaleBins][][]; Energy_Orthonormal_Transformation = new double[state.Num_ScaleBins][][]; Commutator_Orthonormal_Transformation_Real = new double[state.Num_ScaleBins][][]; Commutator_Orthonormal_Transformation_Imag = new double[state.Num_ScaleBins][][]; Laplacian_Energy_Derivative = new double[state.Num_ScaleBins - 1][]; Laplacian_Energy_Derivative_smoothed = new double[state.Num_ScaleBins - 1][]; for (int i = 0; i < state.Num_ScaleBins; i++) { Laplacian_Energy[i] = new double[state.Num_Points]; Commutator_Energy[i] = new double[state.Num_Points]; Mass_Vector[i] = new double[state.Num_Points]; Energy_Vector[i] = new double[state.Num_Points]; Laplacian_Orthonormal_Transformation[i] = new double[state.Num_Points][]; Energy_Orthonormal_Transformation[i] = new double[state.Num_Points][]; Commutator_Orthonormal_Transformation_Real[i] = new double[state.Num_Points][]; Commutator_Orthonormal_Transformation_Imag[i] = new double[state.Num_Points][]; for (int j = 0; j < state.Num_Points; j++) { Laplacian_Orthonormal_Transformation[i][j] = new double[state.Num_Points]; Energy_Orthonormal_Transformation[i][j] = new double[state.Num_Points]; Commutator_Orthonormal_Transformation_Real[i][j] = new double[state.Num_Points]; Commutator_Orthonormal_Transformation_Imag[i][j] = new double[state.Num_Points]; } if (i < (state.Num_ScaleBins - 1)) { Laplacian_Energy_Derivative[i] = new double[state.Num_Points]; Laplacian_Energy_Derivative_smoothed[i] = new double[state.Num_Points]; } } }
private void Initialize_EnergyScalePlot_Base_wBoundary(PlotModel energyscale_plot, OxyPlot.Series.ScatterSeries[] energyscale_data, OxyPlot.Series.LineSeries boundary_max, OxyPlot.Series.LineSeries boundary_min, State_Variables state, bool color_flag, bool scaleBoundary_flag) { Initialize_EnergyScalePlot_Base(energyscale_plot, energyscale_data, state, color_flag); boundary_max.Color = OxyColors.Red; boundary_min.Color = OxyColors.Red; boundary_max.StrokeThickness = 1; boundary_min.StrokeThickness = 1; if (scaleBoundary_flag) { energyscale_plot.Series.Add(boundary_max); energyscale_plot.Series.Add(boundary_min); } }
private void Initialize_EnergyScaleHeatMap(PlotModel energyscale_heatmap_plot, OxyPlot.Series.HeatMapSeries energyscale_heatmap, State_Variables state) { //scaletime_plot.PlotAreaBorderThickness = new OxyThickness(0.0); energyscale_heatmap_plot.PlotMargins = new OxyThickness(0.0); energyscale_heatmap_plot.TitleFontWeight = 5; OxyPlot.Axes.LinearColorAxis xy = new OxyPlot.Axes.LinearColorAxis(); xy.Palette = OxyPalettes.Jet(500); //xy.HighColor = OxyColors.Gray; //xy.LowColor = OxyColors.Black; //xy.Position = OxyPlot.Axes.AxisPosition.Right; energyscale_heatmap_plot.Axes.Add(xy); energyscale_heatmap.Interpolate = true; energyscale_heatmap.RenderMethod = OxyPlot.Series.HeatMapRenderMethod.Bitmap; energyscale_heatmap_plot.Series.Add(energyscale_heatmap); energyscale_heatmap.X0 = 0.0; energyscale_heatmap.X1 = state.Num_ScaleBins; }
private void Initialize_LaplacianEnergyDerivativeScalePlot(PlotModel energyscale_plot, OxyPlot.Series.ScatterSeries[] energyscale_data, State_Variables state) { Initialize_EnergyScalePlot_Base(energyscale_plot, energyscale_data, state, true); energyscale_plot.Title = "Energy Derivative vs Scale"; energyscale_plot.Axes[1].Maximum = 0.01; energyscale_plot.Axes[1].Minimum = 0; energyscale_plot.MouseDown += LaplacianEnergyScalePlot_MouseDown; energyscale_plot.MouseMove += LaplacianEnergyScalePlot_MouseMove; }
private void Initialize_CommutatorEnergyScalePlot(PlotModel energyscale_plot, OxyPlot.Series.ScatterSeries[] energyscale_data, OxyPlot.Series.LineSeries boundary_max, OxyPlot.Series.LineSeries boundary_min, State_Variables state, bool color_flag, bool scaleBoundary_flag) { Initialize_EnergyScalePlot_Base_wBoundary(energyscale_plot, energyscale_data, boundary_max, boundary_min, state, color_flag, scaleBoundary_flag); energyscale_plot.Title = "Commutator Energy vs Scale"; energyscale_plot.Axes[1].Maximum = State.Num_Points; energyscale_plot.Axes[1].Minimum = -State.Num_Points; energyscale_plot.MouseDown += CommutatorEnergyScalePlot_MouseDown; energyscale_plot.MouseMove += CommutatorEnergyScalePlot_MouseMove; }
private void Initialize_EnergyScalePlot_Base(PlotModel energyscale_plot, OxyPlot.Series.ScatterSeries[] energyscale_data, State_Variables state, bool color_flag) { //scaletime_plot.PlotAreaBorderThickness = new OxyThickness(0.0); energyscale_plot.PlotMargins = new OxyThickness(8.0); energyscale_plot.TitleFontWeight = 5; OxyPlot.Axes.LinearAxis x = new OxyPlot.Axes.LinearAxis(); x.Maximum = State.Num_ScaleBins; x.Minimum = 0.0; x.PositionAtZeroCrossing = true; x.Position = OxyPlot.Axes.AxisPosition.Bottom; x.AxislineThickness = 0.5; x.AxislineColor = OxyColors.Black; x.TickStyle = OxyPlot.Axes.TickStyle.Crossing; x.AxisTickToLabelDistance = 0.0; x.FontSize = 8.0; energyscale_plot.Axes.Add(x); OxyPlot.Axes.LinearAxis y = new OxyPlot.Axes.LinearAxis(); y.PositionAtZeroCrossing = true; y.MajorGridlineStyle = LineStyle.Solid; y.MinorGridlineStyle = LineStyle.Dot; y.AxislineThickness = 0.5; y.AxislineColor = OxyColors.Black; y.TickStyle = OxyPlot.Axes.TickStyle.Crossing; y.AxisTickToLabelDistance = 0.0; y.FontSize = 8.0; energyscale_plot.Axes.Add(y); for (int i = 0; i < state.Num_Points; i++) { energyscale_data[i] = new OxyPlot.Series.ScatterSeries(); energyscale_data[i].MarkerType = MarkerType.Circle; energyscale_data[i].MarkerSize = 2; if (!color_flag) { energyscale_data[i].MarkerFill = OxyColors.Black; } energyscale_plot.Series.Add(energyscale_data[i]); } //energyscale_plot.MouseLeave += EnergyScalePlot_MouseLeave; }
public Output_Variables Evolve(State_Variables state, bool eigenvectors_flag, bool perturb_flag, bool smooth_flag) { for (uint i_p = 0; i_p < state.Num_Points; i_p++) { handle_Positions[i_p] = GCHandle.Alloc(state.Positions[i_p], GCHandleType.Pinned); handle_Velocities[i_p] = GCHandle.Alloc(state.Velocities[i_p], GCHandleType.Pinned); } // unsafe { double *[] _positions = new double *[state.Num_Points]; double *[] _velocities = new double *[state.Num_Points]; for (uint i_p = 0; i_p < state.Num_Points; i_p++) { _positions[i_p] = (double *)handle_Positions[i_p].AddrOfPinnedObject().ToPointer(); _velocities[i_p] = (double *)handle_Velocities[i_p].AddrOfPinnedObject().ToPointer(); } fixed(double **p = &_positions[0], v = &_velocities[0]) { fixed(double *m = &state.Mass_Ratios[0]) { // Un-managed Code! Q.Run(p, v, m, state.Num_Points, state.Dimension, dt, state.Num_ScaleBins, eigenvectors_flag, perturb_flag, smooth_flag); } } for (uint i_s = 0; i_s < state.Num_ScaleBins; i_s++) { for (uint i_p = 0; i_p < state.Num_Points; i_p++) { Out.Laplacian_Energy[i_s][i_p] = Q.Laplacian_Energy[i_s][i_p]; Out.Commutator_Energy[i_s][i_p] = Q.Commutator_Energy[i_s][i_p]; Out.Mass_Vector[i_s][i_p] = Q.Mass_Vector[i_s][i_p]; Out.Energy_Vector[i_s][i_p] = Q.Energy_Vector[i_s][i_p]; if (eigenvectors_flag) { if ((i_s < (state.Num_ScaleBins - 1)) && (smooth_flag)) { Out.Laplacian_Energy_Derivative[i_s][i_p] = Q.Laplacian_Energy_Derivative[i_s][i_p]; Out.Laplacian_Energy_Derivative_smoothed[i_s][i_p] = Q.Laplacian_Energy_Derivative_smoothed[i_s][i_p]; } for (uint j_p = 0; j_p < state.Num_Points; j_p++) { Out.Laplacian_Orthonormal_Transformation[i_s][i_p][j_p] = Q.Laplacian_Orthonormal_Transformation[i_s][i_p][j_p]; Out.Energy_Orthonormal_Transformation[i_s][i_p][j_p] = Q.Energy_Orthonormal_Transformation[i_s][i_p][j_p]; Out.Commutator_Orthonormal_Transformation_Real[i_s][i_p][j_p] = Q.Commutator_Orthonormal_Transformation_Real[i_s][i_p][j_p]; Out.Commutator_Orthonormal_Transformation_Imag[i_s][i_p][j_p] = Q.Commutator_Orthonormal_Transformation_Imag[i_s][i_p][j_p]; } } } } for (uint i_p = 0; i_p < state.Num_Points; i_p++) { Out.Scale_Ladder_Original[i_p] = Q.Scale_Ladder_Original[i_p]; Out.Scale_Ladder_Dual[i_p] = Q.Scale_Ladder_Dual[i_p]; Out.ClassicalEnergy_Exchange[i_p] = Q.ClassicalEnergy_Exchange[i_p]; Out.KineticEnergy_Vector[i_p] = Q.KineticEnergy_Vector[i_p] / 2; Out.PotentialEnergy_Vector[i_p] = Q.PotentialEnergy_Vector[i_p] / 2; //Out.ClassicalEnergy_Vector[i_p] = Out.KineticEnergy_Vector[i_p] + Out.PotentialEnergy_Vector[i_p]; //Out.ClassicalEnergy_Vector[i_p] = Out.KineticEnergy_Vector[i_p]; Out.ClassicalEnergy_Vector[i_p] = Q.ClassicalLocalEnergy_Vector[i_p]; Out.ClassicalLaplacian_Energy[i_p] = Q.ClassicalLaplacian_Energy[i_p]; Out.ClassicalHamiltonian_Energy[i_p] = Q.ClassicalHamiltonian_Energy[i_p]; Out.ClassicalHamiltonian_wVacuum_Energy[i_p] = Q.ClassicalHamiltonian_wVacuum_Energy[i_p]; Out.ClassicalParticle_Entropy[i_p] = Q.ClassicalParticle_Entropy[i_p]; for (uint j_p = 0; j_p < state.Num_Points; j_p++) { Out.Dendogram_Original[i_p][j_p] = Q.Dendogram_Original[i_p][j_p]; Out.Dendogram_Dual[i_p][j_p] = Q.Dendogram_Dual[i_p][j_p]; Out.ClassicalHamiltonian_EigenStates[i_p][j_p] = Q.ClassicalHamiltonian_EigenStates[i_p][j_p]; Out.ClassicalHamiltonian_wVacuum_EigenStates[i_p][j_p] = Q.ClassicalHamiltonian_wVacuum_EigenStates[i_p][j_p]; Out.ClassicalLaplacian_EigenStates[i_p][j_p] = Q.ClassicalLaplacian_EigenStates[i_p][j_p]; } } for (uint i_p = 0; i_p < Tile.Num_TileHubs; i_p++) { Tile.Tile_ScalarField[i_p] = Q.Tile_ScalarField[i_p]; for (uint i_d = 0; i_d < Tile.Tile_Dimension; i_d++) { Tile.Tile_VectorField[i_p][i_d] = Q.Tile_VectorField[i_p][i_d]; } } } // Releasing the pointer handles for (uint i_p = 0; i_p < state.Num_Points; i_p++) { handle_Positions[i_p].Free(); handle_Velocities[i_p].Free(); } // Out.Min_Scale = Q.Min_Scale; Out.Max_Scale = Q.Max_Scale; Out.Min_NonVacScale = Q.Min_NonVacScale; Out.Max_NonVacScale = Q.Max_NonVacScale; Out.ClassicalEnergy = Q.ClassicalEnergy / state.Num_Points; Out.ClassicalKineticEnergy = Q.ClassicalKineticEnergy / state.Num_Points; Out.ClassicalPotentialEnergy = Q.ClassicalPotentialEnergy / state.Num_Points; return(Out); }