/// <summary> /// Runs a simulation on the bodies in the simulator for the simulation /// length making time steps and recording the properties of the bodies /// to a log file. /// </summary> public void Simulate() { if (!this.ValidateSimulation()) { return; // Maybe throw an exception or something instead } int maxSteps = (int)(this.SimulationLength / this.TimeStep); using (StreamWriter file = new StreamWriter(@"D:\My documents\Documents\Dropbox\Programming\C#\Gravity Simulator\Outputs\output.txt")) { for (int stepsTaken = 0; stepsTaken < maxSteps; stepsTaken++) { this.Bodies = CelestialBody.Update(this.Bodies, TimeStep); if (stepsTaken % 10 == 0) { this.Bodies = CelestialBody.CentreOfMass(this.Bodies); } if (stepsTaken % this.PrintResolution == 0) { file.WriteLine(Bodies.ToLog()); } } file.WriteLine(Bodies.ToLog()); } }