예제 #1
0
        private static (long sunEarth, long earthMoon, long marsPhobos, long marsDeimos, long earthMars, long RK4Time) RunRK4(int rK4steps, double rK4TimeStep)
        {
            system.Reset("system.json", rK4TimeStep);
            stopwatch.Reset();
            stopwatch.Start();
            Thread[] threads = system.StartThreadsPerCoreRK(rK4steps);
            foreach (Thread thread in threads)
            {
                thread.Join();
            }
            stopwatch.Stop();
            long[] sun        = system.SelectObject("Sun").Position;
            long[] earth      = system.SelectObject("Earth").Position;
            long[] moon       = system.SelectObject("Moon").Position;
            long[] mars       = system.SelectObject("Mars").Position;
            long[] phobos     = system.SelectObject("Phobos").Position;
            long[] deimos     = system.SelectObject("Deimos").Position;
            long   sunEarth   = CalculateDistance(sun, earth);
            long   earthMoon  = CalculateDistance(earth, moon);
            long   marsPhobos = CalculateDistance(mars, phobos);
            long   marsDeimos = CalculateDistance(mars, deimos);
            long   earthMars  = CalculateDistance(earth, mars);
            long   RK4Time    = stopwatch.ElapsedMilliseconds;

            return(sunEarth, earthMoon, marsPhobos, marsDeimos, earthMars, RK4Time);
        }
예제 #2
0
 /// <summary>
 /// Redraws UI in cycles with simulation running at maximum possible speed.
 /// </summary>
 /// <remarks>
 /// <code>system.StartThreadsPerCoreWithLocker(token)</code> is hardcoded, as this method is optimalized for UI use.
 /// Could use non-locked version, but will generate position artifacts with smaller view ranges.
 /// </remarks>
 /// <param name="token">Cancellation token to stop simulation</param>
 private void AnimateThreaded(CancellationToken token)
 {
     timer = new DispatcherTimer
     {
         Interval = new TimeSpan(0, 0, 0, 0, 30)
     };
     timer.Tick += Timer_Tick;
     lockers     = system.StartThreadsPerCoreRK(token);
     //lockers = system.StartThreadsPerCoreRK(token);
     timer.Start();
 }
예제 #3
0
 public long RunThreadedRK()
 {
     stopwatch.Reset();
     stopwatch.Start();
     Thread[] threads = system.StartThreadsPerCoreRK(count);
     foreach (Thread thread in threads)
     {
         thread.Join();
     }
     stopwatch.Stop();
     return(stopwatch.ElapsedMilliseconds);
 }