Пример #1
0
        public void initStar(double _densityMul = 1.0, double rel_mass = 1.0, List <double> percentage = null)
        {
            ChemicalComposition chemicalComposition = new ChemicalComposition(this.stellarCompositionMats, percentage);

            this.starComposition = chemicalComposition;
            elementsDistribution = percentage;
            NumberFormatInfo nfi        = new NumberFormatInfo();
            Random_Extension randomSeed = new Random_Extension();

            nfi.NumberDecimalSeparator = ".";
            Function hydrostaticEquilibrium = ParametriUtente.Science.hydrostaticEquilibrium;
            int      randomGenForBlackHoles;
            //mass in grammi / 18.015 = moles
            //ideal gas law
            double molecularWeight = 0.0;
            double sumofElement    = 0.0;

            double pressione;

            this.meanDensity = 0;


            randomGenForBlackHoles = randomSeed.Next(0, 1);



            foreach (ChemicalElement element in starComposition.get_elements())
            {
                double currentElement = starComposition.get_percentage_per_element(element);

                sumofElement    = sumofElement + currentElement;
                molecularWeight = (molecularWeight + (element.mass)
                                   );
            }
            molecularWeight = molecularWeight / sumofElement;

            this.Volume = ((Math.Pow(this.starRadius, 3) * (4.0 / 3.0)) * Math.PI); //km3

            this.mass = rel_mass * ParametriUtente.Science.m_sun;

            this.luminosity = SimulationEngine.getLuminosityFromMass(this.mass);

            this.meanDensity = (this.mass * 1000 / (Math.Pow(10, 15) * Volume)) * _densityMul;


            pressione = ((ParametriUtente.Science.G
                          * mass
                          * (Converter.gcm3_to_kgm3(this.meanDensity)))
                         / (this.starRadius * 1000));

            this.Core_temperature = ((0.84 * Math.Pow(10, -27)) * pressione)
                                    / ((Converter.gcm3_to_kgm3(this.meanDensity))
                                       * (1.380649 * Math.Pow(10, -23)));

            this.Core_temperature = this.Core_temperature * 1.3;


            this.Surface_temperature = SimulationEngine.getTemperatureFromLumRadiusRatio(this.starRadius, this.luminosity);//this.Core_temperature / (2717.203184);//2543.37;

            if (randomGenForBlackHoles == 0)
            {
                this.starRadius      = this.getSchwarzschildRadius();
                this.Volume          = ((Math.Pow(this.starRadius, 3) * (4.0 / 3.0)) * Math.PI); //km3
                this.meanDensity     = (this.mass * 1000 / (Math.Pow(10, 15) * Volume));
                this.Surface_density = this.meanDensity;
                this.Core_density    = this.meanDensity;
            }


            this.setRelativeValues();

            this.InitStarClassification();

            this.finalizeStar();
        }
Пример #2
0
        public void createStarSystem()
        {
            int supportedPlanets;

            double habitableZone_min;
            double habitableZone_max;
            double jupMass_EarthRadii = 11.209;
            double multiplierFactor = 1;
            double radiiMultiplierFactor = 1;
            double asteroidBeltDistanceMax = 0.0, asteroidBeltDistanceMin = 0.0;

            int[]            supportedAsteroids = new int[] { 100, 2000 };
            Random_Extension randomSeed         = new Random_Extension();

            this.createStarCenter();


            //This is measured in AU
            habitableZone_min = Math.Sqrt(this.stars.getRelLuminosity() / 1.1);
            habitableZone_max = Math.Sqrt((this.stars.getRelLuminosity() / 0.53));
            //everything beyond habitableZone_max has (should have) less than 0° surface temp and be either rocky(frozen) or gas giant
            //everything beyond habitableZone_min has (should have) more than 40° surfacete temp and can be only a rocky barren planet.

            randomSeed = new Random_Extension();

            asteroidBeltDistanceMax = randomSeed.NextDouble(habitableZone_min * 0.3, habitableZone_max * 10) + ((habitableZone_max - habitableZone_min) / 2);
            asteroidBeltDistanceMin = asteroidBeltDistanceMax - (habitableZone_max - habitableZone_min);
            Double radii;

            int c = 0;


            Double distance = 0;

            multiplierFactor = 5;
            c = 0;


            while (c < maxSupportedPlanets)
            {
                radii = randomSeed.NextDouble()
                        * ((jupMass_EarthRadii * radiiMultiplierFactor) - 0.5) + 0.5;

                c++;


                if (radii > 10)
                {
                    radiiMultiplierFactor = 0.7;
                }

                if (c >= (int)(this.maxSupportedPlanets / 2))
                {
                    multiplierFactor = 2;
                }

                distance = (randomSeed.NextDouble() * ((multiplierFactor * habitableZone_max) - 0.1) + (0.1));



                ChemicalComposition chemicalComposition;

                if (distance > habitableZone_max)
                {
                    //more chances of a cold gas giant lesser chance of a cold icy planet
                    int planetType = randomSeed.Next(1, 5);
                    if (planetType < 2)
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.rockyPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.rockyPlanetSeed.Count));
                        //icy
                    }
                    else
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.gasPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.gasPlanetSeed.Count));

                        //gas giant
                    }
                }
                else if (distance < habitableZone_min)
                {
                    //more chances of hot small-to-medium rocky-metallic planet
                    int planetType = randomSeed.Next(1, 5);
                    if (planetType < 2)
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.rockyPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.rockyPlanetSeed.Count));
                        if (radii > 5)
                        {
                            radii = radii / (randomSeed.Next(2, 5));
                        }
                        //rocky with atmosphere
                    }
                    else
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.rockyPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.rockyPlanetSeed.Count));
                        //rocky without atmosphere
                    }
                }
                else
                {
                    //slight more chances of a planet with liquid H2O
                    int planetType = randomSeed.Next(1, 5);
                    if (planetType < 2)
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.rockyPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.rockyPlanetSeed.Count));
                        //generic rocky planet
                    }
                    else
                    {
                        chemicalComposition = new ChemicalComposition(DataEngine.ironPlanetSeed
                                                                      , SimulationEngine.generateNPercentages(DataEngine.ironPlanetSeed.Count));
                        //h20
                    }
                }

                Planet createdPlanet;

                if (radii < 9)
                {
                    createdPlanet = SimulationEngine.createPlanet(chemicalComposition, radii, distance);
                }
                else
                {
                    createdPlanet = SimulationEngine.createGasGiant(chemicalComposition, radii, distance);
                }

                this.planets.Add(createdPlanet);
                c++;
            }

            int numberOfAsteroid = randomSeed.Next(supportedAsteroids[0], supportedAsteroids[1]);

            for (int i = 0; i < numberOfAsteroid; i++)
            {
                ChemicalComposition chemicalComposition = null;
                chemicalComposition = new ChemicalComposition(DataEngine.carbonAsteroidSeed,
                                                              SimulationEngine.generateNPercentages(DataEngine.carbonAsteroidSeed.Count, 50));

                int seedGen = randomSeed.Next(1, 20);

                if (seedGen < 19 && seedGen > 15)
                {
                    chemicalComposition = new ChemicalComposition(DataEngine.siliconAsteroidSeed,
                                                                  SimulationEngine.generateNPercentages(DataEngine.carbonAsteroidSeed.Count, 50));
                }
                else
                {
                    chemicalComposition = new ChemicalComposition(DataEngine.carbonAsteroidSeed,
                                                                  SimulationEngine.generateNPercentages(DataEngine.carbonAsteroidSeed.Count, 50));
                }


                int    radius_Km   = randomSeed.Next(1, 500);
                double relMassSeed = 0.0004;
                relMassSeed = relMassSeed / (500 % radius_Km);
                Asteroid asteroid = new Asteroid(chemicalComposition, radius_Km, randomSeed.NextDouble(asteroidBeltDistanceMin, asteroidBeltDistanceMax));
                asteroid.initAsteroid(1, relMassSeed);
                this.asteroidBelt.Add(asteroid);
            }

            Console.WriteLine("AU min: " + habitableZone_min + " \n \tAU max: " + habitableZone_max);
        }