using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using UnitsNet; using static ManyWorldsTheory.Form2; namespace ManyWorldsTheory { class Galaxy { public double GetRandomeNumber(double minimum, double maximum) { Random random = new Random(); return random.NextDouble() * (maximum - minimum); } Atome Periodensys2; public async Task CreateGalaxies(Teilsys2 t2, Boolean gravitation, Boolean Carbonoxide, Boolean coalorsilicium, Boolean hasGalxyStartAtoms) { double numberGalaxies = 0; //The mass of the current universe double mass2 = t2.mass; //if all atoms were used in the creation process to see if there are more reactions to await bool allatomsused = false; double Pressure = 0; double massallatomsinGas = 0; double speedofatoms = 0; double age = t2.getageofUniversev1(); Atombau.Elementarteilchen.Quarks.Fermions.UP Up = new Atombau.Elementarteilchen.Quarks.Fermions.UP(); Atombau.Elementarteilchen.Quarks.Fermions.Down Down = new Atombau.Elementarteilchen.Quarks.Fermions.Down(); Atombau.Elementarteilchen.Quarks.Fermions.Charm Charm = new Atombau.Elementarteilchen.Quarks.Fermions.Charm(); Atombau.Elementarteilchen.Quarks.Fermions.Top Top = new Atombau.Elementarteilchen.Quarks.Fermions.Top(); Atombau.Elementarteilchen.Quarks.Fermions.Strange Strange = new Atombau.Elementarteilchen.Quarks.Fermions.Strange(); Atombau.Elementarteilchen.Quarks.Leptionen.Electron e = new Atombau.Elementarteilchen.Quarks.Leptionen.Electron(); Atombau.Hadrons.Meson.Proton prot = new Atombau.Hadrons.Meson.Proton(); Particles hydogen; Particles Magnesium; Particles Silicium; Particles Sulfur; Particles Calcium; Particles Titatnium; Particles Carbon; Particles Oxygen; Particles Ferrum; Particles Helium; Form2 f2 = new Form2(); //Arrays for storing of the Atoms which are used to create a Galaxy Particles[] hydrogenarr = new Particles[380000]; Particles[] Carbonarr = new Particles[380000]; Particles[] magnesarr = new Particles[380000]; Particles[] Oxygenarr = new Particles[380000]; Particles[] Heliumarr = new Particles[380000]; Particles[] water = new Particles[380000]; Particles[] watermagnes = new Particles[380000]; Particles[] Siliciumarr = new Particles[380000]; Particles[] CarbonOxide = new Particles[380000]; Particles[] TitatniumArr = new Particles[380000]; Particles[] FerrumArr = new Particles[380000]; //a constant used to get the Gas Pressure out of a cloud of particles double Boltzmannconstant = 1.380649 * Math.Pow(10,-23); //2 Variables used for the Creation of an Galaxy which determines if the Galaxy produces Planets or Stars instead double getratio2 = 0.00; double getvalue2 = 0.00; Periodensys2 = new Atome(); //instances of the single atomes which are then used to fill the arrays //index number -1 due to begin an array at 0 and the PSE at 1 hydogen = Periodensys2.getSearch(0); Helium = Periodensys2.getSearch(1); Carbon = Periodensys2.getSearch(5); Oxygen = Periodensys2.getSearch(7); Magnesium = Periodensys2.getSearch(11); Silicium = Periodensys2.getSearch(13); Sulfur = Periodensys2.getSearch(15); Calcium = Periodensys2.getSearch(19); Titatnium = Periodensys2.getSearch(21); Ferrum = Periodensys2.getSearch(25); //Source: https://www.planet-schule.de/mm/die-erde/Barrierefrei/pages/Wie_entstehen_Sterne.html //https://phys.org/news/2019-12-cores-massive-galaxies-billion-years.html //The arrays are being filled based on how much time has passed do { //The Array of the Helium is filled in the first 10 seconds of the creating process for (age = 0; age < 3.1709791983765 * Math.Pow(10, -7); age++) { Heliumarr= new Particles[(int)age]; hydrogenarr[(int)age] = Periodensys2.getSearch(0); setspeedofParticles(hydrogenarr[(int)age]); speedofatoms += hydrogenarr[(int)age].getspeed(); getvalue2 += hydrogenarr[(int)age].getmass(); } //The arrays are being filled and the masses are added to get an Basis of calculation for the temperature and Gas pressure calculations for (age = 0; age >= 380000; age++) { hydrogenarr = new Particles[(int)age]; hydrogenarr[(int)age] = Periodensys2.getSearch(0); setspeedofParticles(hydrogenarr[(int)age]); speedofatoms += hydrogenarr[(int)age].getspeed(); getvalue2 += hydrogenarr[(int)age].getmass(); mass2 += getvalue2; magnesarr = new Particles[(int)age]; magnesarr[(int)age] = Periodensys2.getSearch(11); setspeedofParticles(magnesarr[(int)age]); speedofatoms += magnesarr[(int)age].getspeed(); mass2 += magnesarr[(int)age].getmass(); Carbonarr = new Particles[(int)age]; Carbonarr[(int)age] = Periodensys2.getSearch(5); setspeedofParticles(Carbonarr[(int)age]); speedofatoms += Carbonarr[(int)age].getspeed(); mass2 += Carbonarr[(int)age].getmass(); Oxygenarr = new Particles[(int)age]; Oxygenarr[(int)age] = Periodensys2.getSearch(11); setspeedofParticles(Oxygenarr[(int)age]); speedofatoms += Oxygenarr[(int)age].getspeed(); mass2 += Oxygenarr[(int)age].getmass(); CarbonOxide = new Particles[(int)age]; CarbonOxide[(int)age] = Periodensys2.getSearch(5) + Periodensys2.getSearch(7); setspeedofParticles(CarbonOxide[(int)age]); speedofatoms += CarbonOxide[(int)age].getspeed(); mass2 += CarbonOxide[(int)age].getmass(); Siliciumarr = new Particles[(int)age]; Siliciumarr[(int)age] = Periodensys2.getSearch(13); setspeedofParticles(Siliciumarr[(int)age]); speedofatoms += Siliciumarr[(int)age].getspeed(); mass2 += Siliciumarr[(int)age].getmass(); TitatniumArr = new Particles[(int)age]; TitatniumArr[(int)age] = Periodensys2.getSearch(21); setspeedofParticles(TitatniumArr[(int)age]); speedofatoms += TitatniumArr[(int)age].getspeed(); mass2 += TitatniumArr[(int)age].getmass(); FerrumArr = new Particles[(int)age]; FerrumArr[(int)age] = Periodensys2.getSearch(0); setspeedofParticles(FerrumArr[(int)age]); speedofatoms += FerrumArr[(int)age].getspeed(); mass2 += getvalue2; Heliumarr = new Particles[(int)age]; Heliumarr[(int)age] = Periodensys2.getSearch(1); setspeedofParticles(Heliumarr[(int)age]); speedofatoms += Heliumarr[(int)age].getspeed(); massallatomsinGas = Heliumarr[(int)age].getmass(); mass2 += getvalue2; } //The getration Variable is used to get the ratios of the hydrogen amount in comparison to the whole mass used in creating the galaxy getratio2 = getvalue2 / mass2; } while (t2.age < 1.5 * Math.Pow(10, 9) && getratio2 <= 0.92); //A few if (CarbonOxide.Length != 0 & Carbon != null & Oxygen != null) Carbonoxide = true; if (Siliciumarr.Length != 0) coalorsilicium = true; if (Carbonoxide == true && coalorsilicium == true) gravitation = true; if (gravitation == true) hasGalxyStartAtoms = true; //If the ratio of the Electrons andProtons are right to get an Reaction and the ratio of hydrogen is right then start the creation of the start atomes for creating an Galaxy if (f2.getMassProportionProtontoElectrons(e, prot) && getratio2 == 0.92) { if (t2.age > 1.5 * Math.Pow(10, 9) & t2.getVolumeofUniverse2() != 0) hasGalxyStartAtoms = true; else hasGalxyStartAtoms = false; //If The age has been long enough then start creating the needed Elements or create new ones //Sources: https://www.astrobio.net/cosmic-evolution/metal-ratios-of-planet-formation/ while (t2.age > 1.5 * Math.Pow(10, 9) && getratio2 <= 0.92 && hasGalxyStartAtoms == true) { water = new Particles[hydrogenarr.Length + (Oxygenarr.Length / 2)]; watermagnes = new Particles[magnesarr.Length + water.Length]; for (int anzhyd = hydrogenarr.Length; anzhyd > 0; anzhyd--) { for (int anzoxygen = Oxygenarr.Length; anzoxygen > 0; anzoxygen--) { water[anzhyd] = hydogen + (Oxygen + Oxygen); setspeedofParticles(water[anzhyd]); speedofatoms += water[anzhyd].getspeed(); massallatomsinGas += water[anzhyd].getmass(); anzoxygen--; anzoxygen--; CarbonOxide[anzoxygen] = Carbonarr[anzoxygen] + Oxygenarr[anzoxygen]; setspeedofParticles(CarbonOxide[anzoxygen]); speedofatoms += CarbonOxide[anzoxygen].getspeed(); massallatomsinGas += CarbonOxide[anzoxygen].getmass(); anzoxygen--; } } //create a new gas to get more particles for (int anzmagn = magnesarr.Length; anzmagn >= 0; anzmagn--) { watermagnes[anzmagn] = water[anzmagn] + magnesarr[anzmagn]; setspeedofParticles(watermagnes[anzmagn]); speedofatoms += watermagnes[anzmagn].getspeed(); } if(magnesarr.Length == 0 && hydrogenarr.Length == 0) allatomsused = true; //If all atomes were used, then Start the calculations for getting the right Entropies of the Galaxies and the Microenergy which is used to get the Temperature of an Atom cloud : Source: https://en.wikipedia.org/wiki/Temperature under the Section: Intensive variability if (allatomsused == true) { Particles[] anzahlatoms = new Particles [Carbonarr.Length + CarbonOxide.Length + Siliciumarr.Length + water.Length + watermagnes.Length + Oxygenarr.Length]; int anzatms = Carbonarr.Length + CarbonOxide.Length + Siliciumarr.Length + water.Length + watermagnes.Length + Oxygenarr.Length; for (int i = 0; i< anzatms;i++) { anzahlatoms[i] = Carbonarr[i]; } //The Settings for initializing the Entropy of the current universe to get the Temperature of the gas out of the number of the Atoms used double[] MikroEnergyofT = new double[anzatms]; double ImpulsofT = 0; double EntropyofSystem = 0; for (int i = 0; i < anzatms; i++) { for (int j = 0; j < anzatms-i; j++) { ImpulsofT = Math.Pow(anzahlatoms[anzatms].getImpuls().X,2)+Math.Pow(anzahlatoms[anzatms].getImpuls().Y,2)+ Math.Pow(anzahlatoms[anzatms].getImpuls().Z, 2); } MikroEnergyofT[i] = Entropy.FromJoulesPerKelvin(1 / anzatms * ((1/2)* Math.Pow(anzahlatoms[i].getspeed(),2))).JoulesPerKelvin; } for (int i = 0; i < MikroEnergyofT.Length; i++) { double Energyofatms = 0; for (int j = 0; j < anzatms; j++) { Energyofatms = MikroEnergyofT[j]; EntropyofSystem = - Boltzmannconstant * Energyofatms * Math.Log(MikroEnergyofT[i]); } } double anzahlallatomsinGas = Mass.FromKilograms(Carbonarr.Length + CarbonOxide.Length + Siliciumarr.Length + water.Length + watermagnes.Length + Oxygenarr.Length).Kilograms / Mass.FromKilograms(t2.getmassofUniverse2()).Kilograms; double Molmass = MolarMass.FromKilogramsPerMole(anzahlallatomsinGas * massallatomsinGas).KilogramsPerMole; double mittelofspeedsquared = Speed.FromMetersPerSecond(Math.Pow((speedofatoms/ anzatms), 2)).MetersPerSecond; double Energyofallatoms = 0; for(int i = 0; i < MikroEnergyofT.Length; i++) { Energyofallatoms += MikroEnergyofT[i]; } //Expression to get the Integral from the formula Func f3 = x => (x / EntropyofSystem); //x = Energyofallatoms double TempofDust = Temperature.FromDegreesCelsius(1/Boltzmannconstant *Math.Pow(MathNet.Numerics.Integrate.DoubleExponential(f3,0,t2.getageofUniversev1()),-1)).Kelvins; //The optimal number of creating interstellar dust to create Galaxies //Source: https://phys.org/news/2012-12-stars-early-galaxies.html if (anzahlallatomsinGas <= GetRandomeNumber(100, 300)) { Pressure = (anzahlallatomsinGas * Molmass * mittelofspeedsquared) / 3 * t2.getVolumeofUniverse2(); for (double temp = anzahlallatomsinGas; temp <= 0; temp--) { if (Pressure != 0) numberGalaxies += 1; } } else Pressure = 0; //Starcreation //if (numberGalaxies != 0) //{ //} //await } } } double TempfromCelsiustoKelvin( double CelsiusTmp) { return CelsiusTmp + 273.15; } void setspeedofParticles(Particles t) { if (t2.g == 0) { t.setspeed(0); } else { t.setspeed(t2.g); } } //needed to create the process async but it dind't work yet double temp2 = 0; temp2 = await numberGalaxies; } } }