Esempio n. 1
0
        public void Take4()
        {
            var list     = FList.New(1, 2, 3, 4, 5);
            var actual   = FList.Take(0, list);
            var expected = FList.Empty <int>();

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void Take6()
        {
            var list     = FList.New(1, 2, 3, 4, 5);
            var actual   = FList.Take(2, list);
            var expected = FList.New(1, 2);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void Map1()
        {
            var list     = FList.New(1, 2, 3);
            var actual   = FList.Map(i => i * i, list);
            var expected = FList.New(1, 4, 9);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void ToStringContainsAllItems()
        {
            var items              = Enumerable.Range(1, 10).ToArray();
            var list               = FList.New(items);
            var list_string        = list.ToString();
            var string_list_values = Regex.Matches(list_string, @"\d+").Select(m => int.Parse(m.Value)).ToArray();

            Assert.That.Collection(string_list_values).IsEqualTo(items);
        }
Esempio n. 5
0
        public void EdgeCase()
        {
            var Outputs1 = Collisions.CollisionFuntions.TotalRestmass(FList.New <double>(1000000, 100000, 10000, 1000000));

            Assert.AreEqual(2110000, Outputs1);
            var Outputs2 = Collisions.CollisionFuntions.TotalRestmass(FList.New <double>(1E-50, 1E-50));

            Assert.AreEqual(2E-50, Outputs2);
        }
        public void EdgeCase()
        {
            var Outputs1 = Collisions.CollisionFuntions.TotalVelocity(FList.New <double>(3E8, 123434));

            Assert.AreEqual(300123434, Outputs1);
            var Outputs2 = Collisions.CollisionFuntions.TotalVelocity(FList.New <double>(1E-50, 1E-50));

            Assert.AreEqual(2E-50, Outputs2);
        }
Esempio n. 7
0
        public void FList_New_CreateNewFListWithSingleElement()
        {
            const int head = 42;
            var       list = FList.New(head);

            Assert.That.Value(list)
            .Where(l => l.IsEmpty).CheckEquals(false)
            .Where(l => l.Head).CheckEquals(head)
            .Where(l => l.Tail).Check(tail => tail.IsReferenceEquals(FList <int> .Empty));
        }
        public void HappyCase()
        {
            var a = Collisions.CollisionFuntions.PartialFeynmanDiagram(FList.New("A", "B", "c"));

            Assert.AreEqual("A + B + c", a);
            var b = Collisions.CollisionFuntions.PartialFeynmanDiagram(FList.New(new Particles.Proton(0).FeynmanSymbol,
                                                                                 new Particles.Electron(0).FeynmanSymbol, new Particles.Positron(0).FeynmanSymbol));

            Assert.AreEqual("P + e- + e+", b);
        }
Esempio n. 9
0
        public void EnumerationListNodes()
        {
            var items      = Enumerable.Range(1, 100).ToArray();
            var list       = FList.New(items);
            var item_index = 0;

            foreach (var item in (IEnumerable)list)
            {
                Assert.That.Value(item).IsEqual(items[item_index++]);
            }
        }
Esempio n. 10
0
        public void FList_NewParams_CreateNewFListWithItems()
        {
            int[] items = { 1, 2, 3 };
            var   list  = FList.New(items);

            Assert.That.Value(list)
            .Where(l => l.IsEmpty).CheckEquals(false)
            .Where(l => l.Head).CheckEquals(items[0])
            .Where(l => l.Tail).Check(tail1 => tail1
                                      .Where(l => l.IsEmpty).CheckEquals(false)
                                      .Where(l => l.Head).CheckEquals(items[1])
                                      .Where(l => l.Tail).Check(tail2 => tail2
                                                                .Where(l => l.IsEmpty).CheckEquals(false)
                                                                .Where(l => l.Head).CheckEquals(items[2])
                                                                .Where(l => l.Tail).Check(tail3 => tail3
                                                                                          .Where(l => l.IsEmpty).CheckEquals(true))))
            ;
        }
Esempio n. 11
0
        public void FList_NewEnum_CreateNewFListWithItems()
        {
            var items       = Enumerable.Range(1, 3);
            var items_array = items.ToArray();
            var list        = FList.New(items);

            Assert.That.Value(list)
            .Where(l => l.IsEmpty).CheckEquals(false)
            .Where(l => l.Head).CheckEquals(items_array[0])
            .Where(l => l.Tail).Check(tail1 => tail1
                                      .Where(l => l.IsEmpty).CheckEquals(false)
                                      .Where(l => l.Head).CheckEquals(items_array[1])
                                      .Where(l => l.Tail).Check(tail2 => tail2
                                                                .Where(l => l.IsEmpty).CheckEquals(false)
                                                                .Where(l => l.Head).CheckEquals(items_array[2])
                                                                .Where(l => l.Tail).Check(tail3 => tail3
                                                                                          .Where(l => l.IsEmpty).CheckEquals(true))))
            ;
        }
        public void EdgeCase()
        {
            var a = Collisions.CollisionFuntions.PartialFeynmanDiagram(FList.New(new Particles.Proton(0).FeynmanSymbol));

            Assert.AreEqual("P", a);
        }
Esempio n. 13
0
        public void TwoListsAndArrow()
        {
            var a = Collisions.CollisionFuntions.FeynmanDiagram(FList.New("a", "b", "c"), FList.New("d", "e", "f"));

            Assert.AreEqual("a + b + c ---> d + e + f", a);
        }
Esempio n. 14
0
        public void ThreeSymbolsAndPlus()
        {
            var a = Collisions.CollisionFuntions.PartialFeynmanDiagram(FList.New("a", "b", "c"));

            Assert.AreEqual("a + b + c", a);
        }
Esempio n. 15
0
        public void SingleSymbol()
        {
            var a = Collisions.CollisionFuntions.PartialFeynmanDiagram(FList.New("a"));

            Assert.AreEqual("a", a);
        }
Esempio n. 16
0
        public void Strings1()
        {
            var list = FList.New("Tom", "Dick", "Harry");

            Assert.AreEqual("Tom", FList.Head(list));
        }
Esempio n. 17
0
        public void HappyCase()
        {
            var Outputs = Collisions.CollisionFuntions.TotalRestmass(FList.New <double>(13, 43, 665, 345, 7657));

            Assert.AreEqual(8723, Outputs);
        }
Esempio n. 18
0
        //Dirty
        static void Main(string[] args)
        {
            bool ContinueLoop = true;

            while (ContinueLoop)
            {
                Console.WriteLine("What collsision would you like to simulate?");

                Console.WriteLine("1: Annihilation");
                Console.WriteLine("2: Electron capture");
                Console.WriteLine("3: Pair Production");
                Console.WriteLine("4: Velocity Selector");
                Console.WriteLine("5: Atom Intercations");
                Console.WriteLine("6: Electrostatic Repulsion");
                Console.WriteLine("7: Cyclatron");
                Console.WriteLine("10: Exit");
                int userinput = 0;
                try
                {
                    userinput = Convert.ToInt32(Console.ReadLine());
                    if (userinput > 7 || userinput < 1)
                    {
                        if (userinput != 10)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Number not offered as an option, please enter a number shown");
                            Console.WriteLine("");
                        }
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("");
                    Console.WriteLine("Invalid input, please try again");
                    Console.WriteLine("");
                }


                FRandom FirstSeed = FRandom.SeedFromClock(DateTime.Now);
                switch (userinput)
                {
                case 1:
                    Console.WriteLine("What particle will you annihilate?");
                    Console.WriteLine("1: Proton and Anti-proton");
                    Console.WriteLine("2: Electron and positron");
                    var answer = 0;
                    try
                    {
                        answer = Convert.ToInt32(Console.ReadLine());
                        if (userinput != 1 && userinput != 2)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Number not offered as an option, please enter a number shown");
                            Console.WriteLine("");
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Invalid input, please try again");
                        Console.WriteLine("");
                        break;
                    }
                    bool   BothParticlesEntered = false;
                    double VelocityP1           = -1;
                    double VelocityP2           = -1;
                    Console.WriteLine("Please enter the modules of the velocitys of the two particles");

                    var Entered1 = false;
                    while (Entered1 == false)
                    {
                        Console.WriteLine("Particle 1:");

                        try
                        {
                            VelocityP1 = Convert.ToDouble(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Invalid input");
                            Console.WriteLine("");
                            Entered1 = false;
                        }
                        if (VelocityP1 == -1)
                        {
                        }
                        else
                        {
                            Entered1 = true;
                        }
                    }


                    var Entered2 = false;
                    while (Entered2 == false)
                    {
                        Console.WriteLine("Particle2:");
                        try
                        {
                            VelocityP2 = Convert.ToDouble(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("");
                            Console.WriteLine("Invalid input");
                            Console.WriteLine("");
                            Entered2 = false;
                        }
                        if (VelocityP2 == -1)
                        {
                        }
                        else
                        {
                            Entered2 = true;
                        }
                    }

                    Tuple <Photon, Photon> AnihilationOutput = null;
                    Console.Clear();
                    switch (answer)
                    {
                    case 1:

                        if (VelocityP1 > 300000000 || VelocityP2 > 300000000)
                        {
                            Console.WriteLine("That is faster than the speed of light, which is not allowed");
                        }
                        else if (VelocityP1 < 0 || VelocityP2 < 0)
                        {
                            Console.WriteLine("That is less than zero, modules means the positive version of the same number");
                        }
                        else
                        {
                            AnihilationOutput = Collisions.CollisionFuntions.Annialation(new Proton(VelocityP1), new Antiproton(VelocityP2), FirstSeed);
                            Console.WriteLine("The particle is a " + AnihilationOutput.Item1);
                            Console.WriteLine("It's velocity is " + AnihilationOutput.Item1.Velocity);
                            Console.WriteLine("It's energy is " + Collisions.CollisionFuntions.WavelengthToEnergy(AnihilationOutput.Item1));
                            Console.WriteLine("And its ejection direction is " + AnihilationOutput.Item1.Position);
                            Console.WriteLine("");

                            Console.WriteLine("The particle is a " + AnihilationOutput.Item2);
                            Console.WriteLine("It's velocity is " + AnihilationOutput.Item2.Velocity);
                            Console.WriteLine("It's energy is " + Collisions.CollisionFuntions.WavelengthToEnergy(AnihilationOutput.Item2));
                            Console.WriteLine("And its ejection direction is " + AnihilationOutput.Item2.Position);
                            Console.WriteLine("");

                            Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(new Proton(0).FeynmanSymbol, new Proton(0).FeynmanSymbol), FList.New(new Photon().FeynmanSymbol, new Photon().FeynmanSymbol)));
                        }

                        Console.WriteLine("");
                        break;

                    case 2:
                        if (VelocityP1 > 300000000 || VelocityP2 > 300000000)
                        {
                            Console.WriteLine("That is faster than the speed of light, which is not allowed");
                        }
                        else if (VelocityP1 < 0 || VelocityP2 < 0)
                        {
                            Console.WriteLine("That is less than zero, modules means the positive version of the same number");
                        }
                        else
                        {
                            AnihilationOutput = Collisions.CollisionFuntions.Annialation(new Electron(VelocityP1), new Positron(VelocityP2), FirstSeed);
                            Console.WriteLine("The particle is a " + AnihilationOutput.Item1);
                            Console.WriteLine("It's velocity is " + AnihilationOutput.Item1.Velocity);
                            Console.WriteLine("It's energy is " + Collisions.CollisionFuntions.WavelengthToEnergy(AnihilationOutput.Item1));
                            Console.WriteLine("");

                            Console.WriteLine("The particle is a " + AnihilationOutput.Item2);
                            Console.WriteLine("It's velocity is " + AnihilationOutput.Item2.Velocity);
                            Console.WriteLine("It's energy is " + Collisions.CollisionFuntions.WavelengthToEnergy(AnihilationOutput.Item2));
                            Console.WriteLine("");
                            Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(new Electron(0).FeynmanSymbol, new Electron(0).FeynmanSymbol), FList.New(new Photon().FeynmanSymbol, new Photon().FeynmanSymbol)));
                        }


                        break;

                    default:
                        break;
                    }

                    break;

                case 2:
                    int UserInputMassNumber = 0;
                    var MassNumberInput     = false;
                    while (MassNumberInput == false)
                    {
                        Console.WriteLine("Please entre the mass number of the atom");
                        UserInputMassNumber = Convert.ToInt32(Console.ReadLine());
                        if (UserInputMassNumber < 1 || UserInputMassNumber > 295)
                        {
                            Console.WriteLine("Not a valid mass number");
                        }
                        else
                        {
                            MassNumberInput = true;
                        }
                    }
                    int UserInputAtomicNumber = 0;
                    var AtomicNumberInput     = false;
                    while (AtomicNumberInput == false)
                    {
                        Console.WriteLine("Please entre the atomic number of the atom ");
                        UserInputAtomicNumber = Convert.ToInt32(Console.ReadLine());
                        if (UserInputAtomicNumber < 0 || UserInputAtomicNumber > 118)
                        {
                            Console.WriteLine("Not a valid atomic number");
                        }
                        else
                        {
                            AtomicNumberInput = true;
                        }
                    }

                    Console.Clear();
                    var ElectronCapture = Collisions.CollisionFuntions.ElectronCaputre(Collisions.CollisionFuntions.AtomCreator(UserInputAtomicNumber, UserInputMassNumber), FirstSeed);
                    Console.WriteLine("The new atom created is " + ElectronCapture.Item1.Name + ", and it has an atomic number of " + ElectronCapture.Item1.AtomicNumber + " And a mass number of " + ElectronCapture.Item1.MassNumber);
                    Console.WriteLine("The other particle produced was a " + ElectronCapture.Item2);
                    Console.WriteLine("");
                    break;

                case 3:
                    double UserWavelength  = 0;
                    var    WavelengthInput = false;
                    while (WavelengthInput == false)
                    {
                        Console.WriteLine("Please enter the Wavelength of the photon");
                        UserWavelength = Convert.ToDouble(Console.ReadLine());
                        if (UserWavelength < 0)
                        {
                            Console.WriteLine("Less than zero");
                        }
                        else
                        {
                            WavelengthInput = true;
                        }
                    }
                    double UserFrequency  = 0;
                    var    FrequencyInput = false;
                    while (FrequencyInput == false)
                    {
                        Console.WriteLine("Please enter the Frequency of the photon");
                        UserFrequency = Convert.ToDouble(Console.ReadLine());
                        if (UserFrequency < 0)
                        {
                            Console.WriteLine("Less than zero");
                        }
                        else
                        {
                            FrequencyInput = true;
                        }
                    }
                    Console.Clear();
                    Console.WriteLine("");
                    Console.WriteLine(Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item1);
                    Console.WriteLine(Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item1.Velocity + " m/s");
                    Console.WriteLine("And its ejection direction is " + Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item1.Position);
                    Console.WriteLine("");
                    Console.WriteLine(Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item2);
                    Console.WriteLine(Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item2.Velocity + " m/s");
                    Console.WriteLine("And its ejection direction is " + Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item2.Position);
                    Console.WriteLine("");
                    //Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(new Photon().FeynmanSymbol, new Photon().FeynmanSymbol), FList.New(Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item1.FeynmanSymbol, Collisions.CollisionFuntions.PairProductionPhoton(new Photon(UserWavelength, UserFrequency), FirstSeed).Item2.FeynmanSymbol)));
                    break;

                case 4:
                    Console.WriteLine("What particle is bieng selected?  ");
                    Console.WriteLine("1: Protons");
                    Console.WriteLine("2: Electrons");
                    var answer4 = Console.ReadLine();
                    Console.WriteLine("How many particles are passing through the Velocity Selector? (Up to 1000)  ");
                    var NumberOfparticles = Console.ReadLine();
                    Console.WriteLine("Set the strength of the Electric Field E  ");
                    var E = Console.ReadLine();
                    Console.WriteLine("Set the strength of the Magnetic Field B  ");
                    var B = Console.ReadLine();
                    if (Convert.ToInt32(answer4) == 1)
                    {
                        var a = Collisions.CollisionFuntions.VelocitySelector(new Proton(0), Convert.ToInt32(NumberOfparticles), Convert.ToInt32(E), Convert.ToInt32(B), FirstSeed);
                        if (FList.Length(a) == 0)
                        {
                            Console.WriteLine("No particles were generated with this velocity");
                        }
                        else
                        {
                            Console.WriteLine("The number of particles output is " + FList.Length(a));
                        }
                    }
                    else
                    {
                        var a = Collisions.CollisionFuntions.VelocitySelector(new Electron(0), Convert.ToInt32(NumberOfparticles), Convert.ToInt32(E), Convert.ToInt32(B), FirstSeed);
                        if (FList.Length(a) == 0)
                        {
                            Console.WriteLine("No particles were generated with this velocity");
                        }
                        else
                        {
                            Console.WriteLine("The number of particles output is " + FList.Length(a));
                        }
                    }



                    break;

                case 5:
                    Console.WriteLine("This segment lets you create an atom and the pass it through interactions to see how it is effected");
                    Console.WriteLine("First to create the atom, please input the following, in order");

                    int AtomicNumber        = 0;
                    var IsAtomicNumberInput = false;
                    while (IsAtomicNumberInput == false)
                    {
                        Console.WriteLine("Please entre the atomic number of the atom");
                        AtomicNumber = Convert.ToInt32(Console.ReadLine());
                        if (AtomicNumber < 0 || AtomicNumber > 118)
                        {
                            Console.WriteLine("Not a valid atomic number");
                        }
                        else
                        {
                            IsAtomicNumberInput = true;
                        }
                    }
                    int MassNumber        = 0;
                    var IsMassNumberInput = false;
                    while (IsMassNumberInput == false)
                    {
                        Console.WriteLine("Please entre the mass number of the atom ");
                        MassNumber = Convert.ToInt32(Console.ReadLine());
                        if (MassNumber < 1 || MassNumber > 295)
                        {
                            Console.WriteLine("Not a valid mass number");
                        }
                        else
                        {
                            IsMassNumberInput = true;
                        }
                    }
                    var Atom = Collisions.CollisionFuntions.AtomCreator(AtomicNumber, MassNumber);
                    Console.Clear();
                    while (true)
                    {
                        bool AllowedAnswer = false;
                        bool ShouldBreak   = false;
                        while (AllowedAnswer == false)
                        {
                            Console.WriteLine("For Beta-Plus Decay press 1");
                            Console.WriteLine("For Beta-Minus Decay press 2");
                            Console.WriteLine("For Electron capture press 3");
                            Console.WriteLine("For Alpha Decay press 4");


                            Console.WriteLine("To exit to main menu press 10");
                            var answer5 = Convert.ToInt32(Console.ReadLine());


                            if (answer5 < 1 || answer5 > 4)
                            {
                                if (answer5 != 10)
                                {
                                    Console.WriteLine("Not a valid number, please choice from the menu");
                                }
                                else
                                {
                                    ShouldBreak = true;
                                    break;
                                }
                            }
                            else
                            {
                                AllowedAnswer = true;
                                if (answer5 == 1)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaPlusDecayAtom(Atom).Name);
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaPlusDecayAtom(Atom).AtomicNumber);
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaPlusDecayAtom(Atom).MassNumber);
                                    Atom = Collisions.CollisionFuntions.BetaPlusDecayAtom(Atom);
                                    Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(Atom.Name), FList.New(Collisions.CollisionFuntions.BetaPlusDecayAtom(Atom).Name, new Particles.Positron(0).FeynmanSymbol)));
                                    Console.WriteLine("");
                                }
                                else if (answer5 == 2)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaMinusDeacyAtom(Atom).Name);
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaMinusDeacyAtom(Atom).AtomicNumber);
                                    Console.WriteLine(Collisions.CollisionFuntions.BetaMinusDeacyAtom(Atom).MassNumber);
                                    Atom = Collisions.CollisionFuntions.BetaMinusDeacyAtom(Atom);
                                    Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(Atom.Name), FList.New(Collisions.CollisionFuntions.BetaMinusDeacyAtom(Atom).Name, new Particles.Electron(0).FeynmanSymbol)));
                                    Console.WriteLine("");
                                }
                                else if (answer5 == 3)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine(Collisions.CollisionFuntions.ElectronCaputre(Atom, FirstSeed).Item1.Name);
                                    Console.WriteLine(Collisions.CollisionFuntions.ElectronCaputre(Atom, FirstSeed).Item1.AtomicNumber);
                                    Console.WriteLine(Collisions.CollisionFuntions.ElectronCaputre(Atom, FirstSeed).Item1.MassNumber);
                                    Atom = Collisions.CollisionFuntions.ElectronCaputre(Atom, FirstSeed).Item1;
                                    Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(Atom.Name), FList.New(Collisions.CollisionFuntions.ElectronCaputre(Atom, FirstSeed).Item1.Name, new Particles.ElectronNeutrino(0).FeynmanSymbol)));
                                    Console.WriteLine("");
                                }
                                else if (answer5 == 4)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine(Collisions.CollisionFuntions.AlphaDecay(Atom).Name);
                                    Console.WriteLine(Collisions.CollisionFuntions.AlphaDecay(Atom).AtomicNumber);
                                    Console.WriteLine(Collisions.CollisionFuntions.AlphaDecay(Atom).MassNumber);
                                    Atom = Collisions.CollisionFuntions.AlphaDecay(Atom);
                                    Console.WriteLine(Collisions.CollisionFuntions.FeynmanDiagram(FList.New(Atom.Name), FList.New(Collisions.CollisionFuntions.AlphaDecay(Atom).Name, Collisions.CollisionFuntions.AtomCreator(2, 4).Name + " Nucleus")));
                                    Console.WriteLine("");
                                }
                            }
                            if (ShouldBreak == true)
                            {
                                break;
                            }
                        }
                        break;
                    }
                    break;

                case 6:

                    Console.WriteLine("Which two Particles are bieng simulated?");
                    Console.WriteLine("1: Two Protons");
                    Console.WriteLine("2: Two Electrons");
                    var answer6 = Convert.ToInt32(Console.ReadLine());
                    if (answer6 == 1)
                    {
                        var VP1Entered = false;
                        int VP1        = 0;
                        while (VP1Entered == false)
                        {
                            Console.WriteLine("Please enter the velocity for the first particles");
                            VP1 = Convert.ToInt32(Console.ReadLine());
                            if (VP1 < 0 || VP1 > 2.9E8)
                            {
                                Console.WriteLine("Invalid velocity, please enter again");
                            }
                            else
                            {
                                VP1Entered = true;
                            }
                        }
                        Console.WriteLine("Now enter the x, y and z coordinates for the first particle");
                        var X1             = Convert.ToInt32(Console.ReadLine());
                        var Y1             = Convert.ToInt32(Console.ReadLine());
                        var Z1             = Convert.ToInt32(Console.ReadLine());
                        var StartPosition1 = new Vector3D(X1, Y1, Z1);


                        var VP2Entered = false;
                        int VP2        = 0;
                        while (VP2Entered == false)
                        {
                            Console.WriteLine("Please enter the velocity for the second particles");
                            VP2 = Convert.ToInt32(Console.ReadLine());
                            if (VP2 < 0 || VP2 > 2.9E8)
                            {
                                Console.WriteLine("Invalid velocity, please enter again");
                            }
                            else
                            {
                                VP2Entered = true;
                            }
                        }
                        Console.WriteLine("Now enter the x, y and z coordinates for the second particle");
                        var X2             = Convert.ToInt32(Console.ReadLine());
                        var Y2             = Convert.ToInt32(Console.ReadLine());
                        var Z2             = Convert.ToInt32(Console.ReadLine());
                        var StartPosition2 = new Vector3D(X2, Y2, Z2);
                        Console.Clear();
                        Console.WriteLine("The first particle is ejected at (" + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.X + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.Y + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.Z + ")");
                        Console.WriteLine("With a velocity of " + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Velocity);
                        Console.WriteLine("");
                        Console.WriteLine("The second particle is ejected at (" + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.X + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.Y + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.Z + ")");
                        Console.WriteLine("With a velocity of " + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Proton(VP1), new Proton(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Velocity);
                        Console.WriteLine("");
                    }
                    else
                    {
                        var VP1Entered = false;
                        int VP1        = 0;
                        while (VP1Entered == false)
                        {
                            Console.WriteLine("Please enter the velocity for the first particles");
                            VP1 = Convert.ToInt32(Console.ReadLine());
                            if (VP1 < 0 || VP1 > 2.9E8)
                            {
                                Console.WriteLine("Invalid velocity, please enter again");
                            }
                            else
                            {
                                VP1Entered = true;
                            }
                        }
                        Console.WriteLine("Now enter the x, y and z coordinates for the first particle");
                        var X1             = Convert.ToInt32(Console.ReadLine());
                        var Y1             = Convert.ToInt32(Console.ReadLine());
                        var Z1             = Convert.ToInt32(Console.ReadLine());
                        var StartPosition1 = new Vector3D(X1, Y1, Z1);


                        var VP2Entered = false;
                        int VP2        = 0;
                        while (VP2Entered == false)
                        {
                            Console.WriteLine("Please enter the velocity for the second particles");
                            VP2 = Convert.ToInt32(Console.ReadLine());
                            if (VP2 < 0 || VP2 > 2.9E8)
                            {
                                Console.WriteLine("Invalid velocity, please enter again");
                            }
                            else
                            {
                                VP2Entered = true;
                            }
                        }
                        Console.WriteLine("Now enter the x, y and z coordinates for the second particle");
                        var X2             = Convert.ToInt32(Console.ReadLine());
                        var Y2             = Convert.ToInt32(Console.ReadLine());
                        var Z2             = Convert.ToInt32(Console.ReadLine());
                        var StartPosition2 = new Vector3D(X2, Y2, Z2);
                        Console.Clear();
                        Console.WriteLine("The first particle is ejected at (" + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.X + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.Y + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Position.Z + ")");
                        Console.WriteLine("With a velocity of " + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item1.Velocity);
                        Console.WriteLine("");
                        Console.WriteLine("The second particle is ejected at (" + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.X + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.Y + "," + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Position.Z + ")");
                        Console.WriteLine("With a velocity of " + Collisions.CollisionFuntions.ElectrostaticRepulsion(new Electron(VP1), new Electron(VP2), FirstSeed, StartPosition1, StartPosition2).Item2.Velocity);
                        Console.WriteLine("");
                    }

                    break;

                case 7:
                    var ParticleSelected = false;
                    var answer7          = 0;
                    while (ParticleSelected == false)
                    {
                        Console.WriteLine("Please choose what particles are bieng accelerated");
                        Console.WriteLine("1: Protons");
                        Console.WriteLine("2: Electrons");
                        Console.WriteLine("3: Positrons");
                        Console.WriteLine("4: AntiProtons");
                        answer7 = Convert.ToInt32(Console.ReadLine());
                        if (answer7 < 1 || answer7 > 4)
                        {
                            Console.WriteLine("Invalid answer, please choce a number from the table");
                        }
                        else
                        {
                            ParticleSelected = true;
                        }
                    }


                    var    EFSEntred             = false;
                    double ElectricFielsStrength = 0;
                    while (EFSEntred == false)
                    {
                        Console.WriteLine("Enter the electric field strength of the cyclatron");
                        ElectricFielsStrength = Convert.ToDouble(Console.ReadLine());
                        if (ElectricFielsStrength < 0)
                        {
                            Console.WriteLine("Invalid answer, the strength cannot be nagative");
                        }
                        else
                        {
                            EFSEntred = true;
                        }
                    }
                    Console.Clear();

                    var    MFSEntered            = false;
                    double MagneticFieldStrength = 0;
                    while (MFSEntered == false)
                    {
                        Console.WriteLine("Enter the magnetic field strength of the cyclatron");
                        MagneticFieldStrength = Convert.ToDouble(Console.ReadLine());
                        if (MagneticFieldStrength < 0)
                        {
                            Console.WriteLine("Invalid answer, the strength cannot be negative");
                        }
                        else
                        {
                            MFSEntered = true;
                        }
                    }
                    Console.Clear();

                    var    TargetVelocitEnteredy = false;
                    double TargetV = 0;
                    while (TargetVelocitEnteredy == false)
                    {
                        Console.WriteLine("What is the target velocity?");
                        TargetV = Convert.ToDouble(Console.ReadLine());
                        if (TargetV < 0 || answer7 > 2.0E8)
                        {
                            Console.WriteLine("Invalid answer, enter again");
                        }
                        else
                        {
                            TargetVelocitEnteredy = true;
                        }
                    }
                    Console.Clear();
                    if (answer7 == 1)
                    {
                        Console.WriteLine("The true speed ejected is " + Collisions.CollisionFuntions.Cyclatron(new Proton(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Velocity + " m/s");
                        Console.WriteLine("The distance it travled from the centre is " + Collisions.CollisionFuntions.Cyclatron(new Proton(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Position.Y + " m");
                    }
                    else if (answer7 == 2)
                    {
                        Console.WriteLine("The true speed ejected is " + Collisions.CollisionFuntions.Cyclatron(new Electron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Velocity + " m/s");
                        Console.WriteLine("The distance it travled from the centre is " + Collisions.CollisionFuntions.Cyclatron(new Electron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Position.Y + "m");
                    }
                    else if (answer7 == 3)
                    {
                        Console.WriteLine("The true speed ejected is " + Collisions.CollisionFuntions.Cyclatron(new Positron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Velocity + " m/s");
                        Console.WriteLine("The distance it travled from the centre is " + Collisions.CollisionFuntions.Cyclatron(new Positron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Position.Y + "m");
                    }
                    else if (answer7 == 4)
                    {
                        Console.WriteLine("The true speed ejected is " + Collisions.CollisionFuntions.Cyclatron(new Electron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Velocity + " m/s");
                        Console.WriteLine("The distance it travled from the centre is " + Collisions.CollisionFuntions.Cyclatron(new Electron(1), ElectricFielsStrength, MagneticFieldStrength, TargetV).Position.Y + "m");
                    }
                    else
                    {
                        Console.WriteLine("Not a valid option, please choose again");
                    }



                    break;

                case 10:
                    ContinueLoop = false;
                    break;
                }
            }
        }
Esempio n. 19
0
 //Pure
 public static Photon CreateAnnialationPhoton(Particle Particle, Particle AntiParticle)
 {
     // This is all one line, it has been split onto multiple lines for readability
     return(new Photon(EnergyToWavelength(MassToEnergy(TotalRestmass(FList.Map(GetRestMass, FList.New <Particles.Particle>(Particle, AntiParticle)))) + VelocityToEnergy(TotalVelocity(FList.Map(GetVelocity, FList.New <Particles.Particle>(Particle, AntiParticle))), TotalRestmass(FList.Map(GetRestMass, FList.New <Particles.Particle>(Particle, AntiParticle)))) / 2), EnergyToFrequency(MassToEnergy(TotalRestmass(FList.Map(GetRestMass, FList.New <Particles.Particle>(Particle, AntiParticle)))) + VelocityToEnergy(TotalVelocity(FList.Map(GetVelocity, FList.New <Particles.Particle>(Particle, AntiParticle))), TotalRestmass(FList.Map(GetRestMass, FList.New <Particles.Particle>(Particle, AntiParticle)))) / 2)));
 }
Esempio n. 20
0
 public static FList <Particles.Particle> GenerateListOfParticlesWithRandomVelocity <T>(T particle, int numberOfInputParticles, FRandom Rand) where T : Particle
 {
     return(numberOfInputParticles != 1 ? FList.New(GenerateParticleWithRandomVelocity(particle, Rand), GenerateListOfParticlesWithRandomVelocity(GenerateParticleWithRandomVelocity(particle, FRandom.Next(Rand, 0, 100)), numberOfInputParticles - 1, FRandom.Next(Rand, 0, 100))) : FList.New(GenerateParticleWithRandomVelocity(particle, Rand)));
 }
Esempio n. 21
0
        public void NewWithString3()
        {
            var list = FList.New("Hello");

            Assert.AreEqual(1, FList.Length(list));
        }
Esempio n. 22
0
        public void NewWithNull()
        {
            var list = FList.New <int>(null);

            Assert.IsTrue(FList.IsEmpty(list));
        }
        public void HappyCase()
        {
            var Outputs = Collisions.CollisionFuntions.TotalVelocity(FList.New <double>(234, 4322, new Particles.Proton(48893).Velocity));

            Assert.AreEqual(53449, Outputs);
        }