Acceleraion - Time Dilation Calculator

Overview

This was a pretty random project, at one point I started getting pretty interested in Special relativity thanks to couple random youtube videos. I've always enjoyed more advanced parts of physics, things like Einstines thoery of relativity, Quantumn mechanics, etc. But I found out about an interesting part of special relativity. I've always known about how gravity affects time and space, but turns out so does speed.
So basically I created a simple calculator that will calculate how long it will take to accelerate to a certain speed, assuming the acceleration is constant. This value will be different to what one might expect due to time Dilation. The faster you accelerate, the longer it takes to accelerate.

First Version Code


            using System;

            public class calc
            {
            
            // This is a calculator that will calculate how long it will take to get up
            // to a certain speed, taking time dilation into account.
            
            // Hopefully.
            
            private const double c = 299792458; // Speed of light in meters
            
            public static double accuracy = 1; // Measured in Meters
            public static double speed; // Percentage of c
            public static double acceleration = 1000; // 1000 meters per second
            
            //This is approximately equal to 1 meter as a percentage of the speed of light.
            public static double time;
            
            public static double LorentzFactor;
            
            public static double speedPercentage = speed / c;
            
            //    1 / SQRT( 1 - (u^2)  )  --- Lorentz Factor
            // u being the percentage 
            
            static void Main(){
            
                time = 0;
                speed = 0;
                calculate();
            
            }
            
            
            static void calculate(){
                while( speed < (c - accuracy)){
                    
                speedPercentage = speed / c;
                    
                LorentzFactor = 1 / (Math.Sqrt( 1 - (speedPercentage*speedPercentage))  );
                
                
                // How many Seconds
                speed += accuracy; // m
                time += (accuracy / acceleration ) * LorentzFactor;
                
                // How many meters per second
                //speed += acceleration / (1 * LorentzFactor);
                //time += 1;
                
                }
                
                time = time / 60;
                time = time / 60;
                time = time / 24;
                
                Console.WriteLine("Accuracy: " + accuracy);
                Console.WriteLine("(m/s) Acceleration: " + acceleration);
                Console.WriteLine("");
                Console.WriteLine("Days: " + time);
                Console.WriteLine(" Speed: " + (speed / c));
                Console.WriteLine("Lorentz factor at end: " + LorentzFactor);
                Console.WriteLine("---");
            
            }
            
            }
            
        


Second Version Code - Lorentz Value Caclulator


        using System;

        public class calc
        {
        
        private const double c = 299792458; // Speed of light in meters
        
        public static double speed; // Percentage of c
        
        public static double LorentzFactor;
        
        static void Main(){
            
            double speedInput = Convert.ToInt32(Console.ReadLine());
            speed = speedInput;
            calculate();
        }
        
        static void calculate(){
        
            LorentzFactor = 1 / Math.Sqrt( 1 - (Math.Pow( (speed / c) , 2))  );
            
            Console.WriteLine("Percentage Speed: " + speed / c);
            Console.WriteLine("Lorentz Factor: " + LorentzFactor);
        
        }
        }
    
Forum Post: Physics Forum
Awesome Channel: Mahesh Shenoy
Useful Source: Relativistic Rocket

Related Pages

Relativity Studies
Proper Vs Coordinate Acceleration

What I Learned

Having asked a couple different places I've learned that this isn't quite accurate. One of the main things that I will look into is what is called Coordinate Acceleration, as opposed to proper acceleration. I was also given a link to the 'Relativistic Rocket' Which somewhat does what it is I was looking into. Now although this peice of code doesn't really do anything useful, it was a good experience to get a couple questions answered. I will likely turn it into a peice of code that just find the Lorentz factor from a specific speed. So I don't have to constantly solve the equation manully each time.