Example #1
0
        public static void IterateSurfaceTemp(SolarSystem system, Planet primary, ref Planet planet)
        {
            Double previous_temp;
            Double albedo   = 0;
            Double water    = 0;
            Double clouds   = 0;
            Double ice      = 0;
            Int32  num_iter = 0;

            Double optical_depth  = Opacity(planet.molecule_weight, planet.surface_pressure);
            Double effective_temp = EffTemp(system.r_ecosphere, primary.a, Constants.EARTH_ALBEDO);
            Double greenhs_rise   = GreenRise(optical_depth, effective_temp, planet.surface_pressure);
            Double surf1_temp     = effective_temp + greenhs_rise;

            do
            {
                previous_temp = surf1_temp;
                water         = HydrosphereFraction(planet.volatile_gas_inventory, planet.radius);
                clouds        = CloudFraction(surf1_temp, planet.molecule_weight, planet.radius, water);
                ice           = IceFraction(water, surf1_temp);
                if ((surf1_temp >= planet.boil_point) || (surf1_temp <= Constants.FREEZING_POINT_OF_WATER))
                {
                    water = 0.0;
                }
                albedo = PlanetAlbedo(system, water, clouds, ice, planet.surface_pressure);
                if (num_iter++ > 1000)
                {
                    break;
                }
                optical_depth  = Opacity(planet.molecule_weight, planet.surface_pressure);
                effective_temp = EffTemp(system.r_ecosphere, primary.a, albedo);
                greenhs_rise   = GreenRise(optical_depth, effective_temp, planet.surface_pressure);
                surf1_temp     = effective_temp + greenhs_rise;
            } while (Math.Abs(surf1_temp - previous_temp) > 1.0);

            planet.hydrosphere  = water;
            planet.cloud_cover  = clouds;
            planet.ice_cover    = ice;
            planet.albedo       = albedo;
            planet.surface_temp = surf1_temp;
        }
Example #2
0
        public static Planet DistributePlanetaryMasses(ref SolarSystem system, Double stellar_mass_ratio, Double stellar_luminosity_ratio, Double inner_dust, Double outer_dust)
        {
            SetInitialConditions(system, inner_dust, outer_dust);
            Double planetesimal_inner_bound = InnermostPlanet(stellar_mass_ratio);
            Double planetesimal_outer_bound = OutermostPlanet(stellar_mass_ratio);

            while (system.dust_left)
            {
                Double a    = system.random.Range(planetesimal_inner_bound, planetesimal_outer_bound);
                Double e    = system.random.Eccentricity();
                Double mass = Constants.PROTOPLANET_MASS;
                if (system.verbose)
                {
                    system.Callback("Checking " + a + " AU.\n");
                }
                if (!DustAvailable(system, InnerEffectLimit(system, a, e, mass), OuterEffectLimit(system, a, e, mass)))
                {
                    if (system.verbose)
                    {
                        system.Callback(".. failed.\n");
                    }
                    continue;
                }
                system.Callback(".. Injecting protoplanet.\n");
                system.dust_density = Constants.DUST_DENSITY_COEFF * Math.Sqrt(stellar_mass_ratio) * Math.Exp(-Constants.ALPHA * Math.Pow(a, 1.0 / Constants.N));
                Double crit_mass = CriticalLimit(a, e, stellar_luminosity_ratio);
                AccreteDust(ref system, ref mass, a, e, crit_mass, planetesimal_inner_bound, planetesimal_outer_bound);
                if ((mass != 0.0) && (mass != Constants.PROTOPLANET_MASS))
                {
                    CoalescePlanetesimals(ref system, a, e, mass, crit_mass, stellar_luminosity_ratio, planetesimal_inner_bound, planetesimal_outer_bound);
                }
                else
                {
                    system.Callback(".. failed due to large neighbor.\n");
                }
            }
            return(system.planet_head);
        }
Example #3
0
        /// <summary>
        ///  This implements Fogg's eq.17.  The 'inventory' returned is unitless.
        /// </summary>
        public static Double VolInventory(SolarSystem system, Double mass, Double escape_vel, Double rms_vel, Double stellar_mass, Int32 zone, Boolean greenhouse_effect)
        {
            Double proportion_const;
            Double velocity_ratio = escape_vel / rms_vel;

            if (!(velocity_ratio >= Constants.GAS_RETENTION_THRESHOLD))
            {
                return(0.0);
            }
            switch (zone)
            {
            case 1:
                proportion_const = 100000.0;
                break;

            case 2:
                proportion_const = 75000.0;
                break;

            case 3:
                proportion_const = 250.0;
                break;

            default:
                proportion_const = 10.0;
                system.Callback("Error: orbital zone not initialized correctly!\n");
                break;
            }
            Double mass_in_earth_units = mass * Constants.EARTH_MASSES_PER_SOLAR_MASS;
            Double temp1 = (proportion_const * mass_in_earth_units) / stellar_mass;
            Double temp2 = system.random.About(temp1, 0.2);

            if (greenhouse_effect)
            {
                return(temp2);
            }
            return(temp2 / 100.0);
        }
Example #4
0
        public static void UpdateDustLanes(ref SolarSystem system, Double min, Double max, Double mass, Double crit_mass, Double body_inner_bound, Double body_outer_bound)
        {
            system.dust_left = false;
            Boolean gas   = !(mass > crit_mass);
            Dust    node1 = system.dust_head;
            Dust    node2;

            while (node1 != null)
            {
                if ((node1.inner_edge < min) && (node1.outer_edge > max))
                {
                    node2 = new Dust
                    {
                        inner_edge = min,
                        outer_edge = max
                    };
                    if (node1.gas_present)
                    {
                        node2.gas_present = gas;
                    }
                    node2.dust_present = false;
                    Dust node3 = new Dust
                    {
                        inner_edge   = max,
                        outer_edge   = node1.outer_edge,
                        gas_present  = node1.gas_present,
                        dust_present = node1.dust_present,
                        next_band    = node1.next_band
                    };
                    node1.next_band  = node2;
                    node2.next_band  = node3;
                    node1.outer_edge = min;
                    node1            = node3.next_band;
                }
                else if ((node1.inner_edge < max) && (node1.outer_edge > max))
                {
                    node2 = new Dust
                    {
                        next_band    = node1.next_band,
                        dust_present = node1.dust_present,
                        gas_present  = node1.gas_present,
                        outer_edge   = node1.outer_edge,
                        inner_edge   = max
                    };
                    node1.next_band  = node2;
                    node1.outer_edge = max;
                    if (node1.gas_present)
                    {
                        node1.gas_present = gas;
                    }
                    node1.dust_present = false;
                    node1 = node2.next_band;
                }
                else if ((node1.inner_edge < min) && (node1.outer_edge > min))
                {
                    node2 = new Dust
                    {
                        next_band    = node1.next_band,
                        dust_present = false
                    };
                    if (node1.gas_present)
                    {
                        node2.gas_present = gas;
                    }
                    node2.outer_edge = node1.outer_edge;
                    node2.inner_edge = min;
                    node1.next_band  = node2;
                    node1.outer_edge = min;
                    node1            = node2.next_band;
                }
                else if ((node1.inner_edge >= min) && (node1.outer_edge <= max))
                {
                    if (node1.gas_present)
                    {
                        node1.gas_present = gas;
                    }
                    node1.dust_present = false;
                    node1 = node1.next_band;
                }
                else if ((node1.outer_edge < min) || (node1.inner_edge > max))
                {
                    node1 = node1.next_band;
                }
            }
            node1 = system.dust_head;
            while (node1 != null)
            {
                if (node1.dust_present && (node1.outer_edge >= body_inner_bound) && (node1.inner_edge <= body_outer_bound))
                {
                    system.dust_left = true;
                }
                node2 = node1.next_band;
                if (node1.dust_present == node2?.dust_present && (node1.gas_present == node2.gas_present))
                {
                    node1.outer_edge = node2.outer_edge;
                    node1.next_band  = node2.next_band;
                    node2            = null;
                }
                node1 = node1.next_band;
            }
        }
Example #5
0
 public static Double OuterEffectLimit(SolarSystem system, Double a, Double e, Double mass)
 {
     return(a * (1.0 + e) * (1.0 + system.reduced_mass) / (1.0 - system.cloud_eccentricity));
 }
Example #6
0
 public static Double InnerEffectLimit(SolarSystem system, Double a, Double e, Double mass)
 {
     return(a * (1.0 - e) * (1.0 - mass) / (1.0 + system.cloud_eccentricity));
 }
Example #7
0
        public static void CoalescePlanetesimals(ref SolarSystem system, Double a, Double e, Double mass, Double crit_mass, Double stellar_luminosity_ratio, Double body_inner_bound, Double body_outer_bound)
        {
            Boolean coalesced = false;
            Planet  node1     = system.planet_head;
            Planet  node2     = null;
            Planet  node3     = null;

            while (node1 != null)
            {
                node2 = node1;
                Double temp = node1.a - a;
                Double dist1;
                Double dist2;
                if (temp > 0.0)
                {
                    dist1 = a * (1.0 + e) * (1.0 + system.reduced_mass) - a;
                    /* x aphelion   */
                    system.reduced_mass = Math.Pow(node1.mass / (1.0 + node1.mass), 1.0 / 4.0);
                    dist2 = node1.a
                            - node1.a * (1.0 - node1.e) * (1.0 - system.reduced_mass);
                }
                else
                {
                    dist1 = a - a * (1.0 - e) * (1.0 - system.reduced_mass);
                    /* x perihelion */
                    system.reduced_mass = Math.Pow(node1.mass / (1.0 + node1.mass), 1.0 / 4.0);
                    dist2 = node1.a * (1.0 + node1.e) * (1.0 + system.reduced_mass)
                            - node1.a;
                }
                if ((Math.Abs(temp) <= Math.Abs(dist1)) || (Math.Abs(temp) <= Math.Abs(dist2)))
                {
                    system.Callback("Collision between two planetesimals!\n");
                    Double a3 = (node1.mass + mass) / (node1.mass / node1.a + mass / a);
                    temp = node1.mass * Math.Sqrt(node1.a) * Math.Sqrt(1.0 - Math.Pow(node1.e, 2.0));
                    temp = temp + mass * Math.Sqrt(a) * Math.Sqrt(Math.Sqrt(1.0 - Math.Pow(e, 2.0)));
                    temp = temp / ((node1.mass + mass) * Math.Sqrt(a3));
                    temp = 1.0 - Math.Pow(temp, 2.0);
                    if ((temp < 0.0) || (temp >= 1.0))
                    {
                        temp = 0.0;
                    }
                    e    = Math.Sqrt(temp);
                    temp = node1.mass + mass;
                    AccreteDust(ref system, ref temp, a3, e, stellar_luminosity_ratio, body_inner_bound, body_outer_bound);
                    node1.a    = a3;
                    node1.e    = e;
                    node1.mass = temp;
                    node1      = null;
                    coalesced  = true;
                }
                else
                {
                    node1 = node1.next_planet;
                }
            }
            if (coalesced)
            {
                return;
            }
            node3 = new Planet
            {
                a         = a,
                e         = e,
                gas_giant = mass >= crit_mass,
                mass      = mass
            };
            system.bodies.Add(node3);
            if (system.planet_head == null)
            {
                system.planet_head = node3;
                node3.next_planet  = null;
            }
            else
            {
                node1 = system.planet_head;
                if (a < node1.a)
                {
                    node3.next_planet  = node1;
                    system.planet_head = node3;
                }
                else if (system.planet_head.next_planet == null)
                {
                    system.planet_head.next_planet = node3;
                    node3.next_planet = null;
                }
                else
                {
                    while ((node1 != null) && (node1.a < a))
                    {
                        node2 = node1;
                        node1 = node1.next_planet;
                    }
                    node3.next_planet = node1;
                    node2.next_planet = node3;
                }
            }
        }
Example #8
0
 public static Double StellarDustLimit(SolarSystem system, Double stellar_mass_ratio)
 {
     return(200.0 * Math.Pow(stellar_mass_ratio, 1.0 / 3.0));
 }
Example #9
0
        /// <summary>
        /// The surface temperature passed in is in units of Kelvin.
        /// The cloud adjustment is the fraction of cloud cover obscuring each
        /// of the three major components of albedo that lie below the clouds.
        /// </summary>
        public static Double PlanetAlbedo(SolarSystem system, Double water_fraction, Double cloud_fraction, Double ice_fraction, Double surface_pressure)
        {
            Double rock_contribution, ice_contribution;

            Double rock_fraction = 1.0 - water_fraction - ice_fraction;
            Double components    = 0.0;

            if (water_fraction > 0.0)
            {
                components = components + 1.0;
            }
            if (ice_fraction > 0.0)
            {
                components = components + 1.0;
            }
            if (rock_fraction > 0.0)
            {
                components = components + 1.0;
            }
            Double cloud_adjustment = cloud_fraction / components;

            if (rock_fraction >= cloud_adjustment)
            {
                rock_fraction = rock_fraction - cloud_adjustment;
            }
            else
            {
                rock_fraction = 0.0;
            }
            if (water_fraction > cloud_adjustment)
            {
                water_fraction = water_fraction - cloud_adjustment;
            }
            else
            {
                water_fraction = 0.0;
            }
            if (ice_fraction > cloud_adjustment)
            {
                ice_fraction = ice_fraction - cloud_adjustment;
            }
            else
            {
                ice_fraction = 0.0;
            }
            Double cloud_contribution = cloud_fraction * system.random.About(Constants.CLOUD_ALBEDO, 0.2);

            if (surface_pressure == 0.0)
            {
                rock_contribution = rock_fraction * system.random.About(Constants.AIRLESS_ROCKY_ALBEDO, 0.3);
            }
            else
            {
                rock_contribution = rock_fraction * system.random.About(Constants.ROCKY_ALBEDO, 0.1);
            }
            Double water_contribution = water_fraction * system.random.About(Constants.WATER_ALBEDO, 0.2);

            if (surface_pressure == 0.0)
            {
                ice_contribution = ice_fraction * system.random.About(Constants.AIRLESS_ICE_ALBEDO, 0.4);
            }
            else
            {
                ice_contribution = ice_fraction * system.random.About(Constants.ICE_ALBEDO, 0.1);
            }
            return(cloud_contribution + rock_contribution + water_contribution + ice_contribution);
        }
Example #10
0
        /// <summary>
        /// The orbital radius is expected in units of Astronomical Units (AU).
        /// Inclination is returned in units of degrees.
        /// </summary>
        public static Int32 Inclination(SolarSystem system, Double orbital_radius)
        {
            Int32 temp = (Int32)(Math.Pow(orbital_radius, 0.2) * system.random.About(Constants.EARTH_AXIAL_TILT, 0.4));

            return(temp % 360);
        }
Example #11
0
        /// <summary>
        /// Entry method
        /// </summary>
        public static void Main(String[] args)
        {
            // Get the commandline Options
            Options options = new Options();

            Parser.Default.ParseArguments(args, options);

            // Generate a new Solar System
            SolarSystem system = new SolarSystem(options.Verbose, false, Console.Write);

            if (options.Seed != Int32.MinValue)
            {
                SolarSystem.Generate(ref system, options.Seed, options.Count);
            }
            else
            {
                SolarSystem.Generate(ref system, options.Count);
            }

            // Save it to file
            StreamWriter file = new StreamWriter(Directory.GetCurrentDirectory() + "/" + options.File, false);

            file.Write("                         SYSTEM  CHARACTERISTICS\n");
            file.Write("Mass of central star:          {0:F3} solar masses\n", system.stellar_mass_ratio);
            file.Write("Luminosity of central star:    {0:F3} (relative to the sun)\n", system.stellar_luminosity_ratio);
            file.Write("Total main sequence lifetime:  {0:F0} million years\n", (system.main_seq_life / 1.0E6));
            file.Write("Current age of stellar system: {0:F0} million years\n", (system.age / 1.0E6));
            file.Write("Radius of habitable ecosphere: {0:F3} AU\n\n", system.r_ecosphere);

            Planet node1   = system.planet_head;
            Int32  counter = 1;

            while (node1 != null)
            {
                file.Write("Planet #{0}:\n", counter);
                if (node1.gas_giant)
                {
                    file.Write("Gas giant...\n");
                }
                if (node1.resonant_period)
                {
                    file.Write("In resonant period with primary.\n");
                }

                file.Write("   Distance from primary star (in A.U.): {0:F3}\n", node1.a);
                file.Write("   Eccentricity of orbit:                {0:F3}\n", node1.e);
                file.Write("   Mass (in Earth masses):               {0:F3}\n", node1.mass * Constants.EARTH_MASSES_PER_SOLAR_MASS);
                file.Write("   Equatorial radius (in Km):            {0:F1}\n", node1.radius);
                file.Write("   Density (in g/cc):                    {0:F3}\n", node1.density);
                file.Write("   Escape Velocity (in km/sec):          {0:F2}\n", node1.escape_velocity / Constants.CM_PER_KM);
                file.Write("   Smallest molecular weight retained:   {0:F2}", node1.molecule_weight);

                if (node1.molecule_weight < Constants.MOLECULAR_HYDROGEN)
                {
                    file.Write("   (H2)\n");
                }
                else if (node1.molecule_weight < Constants.HELIUM)
                {
                    file.Write("   (He)\n");
                }
                else if (node1.molecule_weight < Constants.METHANE)
                {
                    file.Write("   (CH4)\n");
                }
                else if (node1.molecule_weight < Constants.AMMONIA)
                {
                    file.Write("   (NH3)\n");
                }
                else if (node1.molecule_weight < Constants.WATER_VAPOR)
                {
                    file.Write("   (H2O)\n");
                }
                else if (node1.molecule_weight < Constants.NEON)
                {
                    file.Write("   (Ne)\n");
                }
                else if (node1.molecule_weight < Constants.MOLECULAR_NITROGEN)
                {
                    file.Write("   (N2)\n");
                }
                else if (node1.molecule_weight < Constants.CARBON_MONOXIDE)
                {
                    file.Write("   (CO)\n");
                }
                else if (node1.molecule_weight < Constants.NITRIC_OXIDE)
                {
                    file.Write("   (NO)\n");
                }
                else if (node1.molecule_weight < Constants.MOLECULAR_OXYGEN)
                {
                    file.Write("   (O2)\n");
                }
                else if (node1.molecule_weight < Constants.HYDROGEN_SULPHIDE)
                {
                    file.Write("   (H2S)\n");
                }
                else if (node1.molecule_weight < Constants.ARGON)
                {
                    file.Write("   (Ar)\n");
                }
                else if (node1.molecule_weight < Constants.CARBON_DIOXIDE)
                {
                    file.Write("   (CO2)\n");
                }
                else if (node1.molecule_weight < Constants.NITROUS_OXIDE)
                {
                    file.Write("   (N2O)\n");
                }
                else if (node1.molecule_weight < Constants.NITROGEN_DIOXIDE)
                {
                    file.Write("   (NO2)\n");
                }
                else if (node1.molecule_weight < Constants.OZONE)
                {
                    file.Write("   (O3)\n");
                }
                else if (node1.molecule_weight < Constants.SULPHUR_DIOXIDE)
                {
                    file.Write("   (SO2)\n");
                }
                else if (node1.molecule_weight < Constants.SULPHUR_TRIOXIDE)
                {
                    file.Write("   (SO3)\n");
                }
                else if (node1.molecule_weight < Constants.KRYPTON)
                {
                    file.Write("   (Kr)\n");
                }
                else if (node1.molecule_weight < Constants.XENON)
                {
                    file.Write("   (Xe)\n");
                }
                else
                {
                    file.Write("\n");
                }

                file.Write("   Surface acceleration (in cm/sec2):    {0:F2}\n", node1.surface_accel);
                if (!(node1.gas_giant))
                {
                    file.Write("   Surface Gravity (in Earth gees):      {0:F2}\n", node1.surface_grav);
                    if (node1.boil_point > 0.1)
                    {
                        file.Write("   Boiling point of water (celcius):     {0:F1}\n", (node1.boil_point - Constants.KELVIN_CELCIUS_DIFFERENCE));
                    }
                    if (node1.surface_pressure > 0.00001)
                    {
                        file.Write("   Surface Pressure (in atmospheres):    {0:F3}", (node1.surface_pressure / 1000.0));
                        file.Write(node1.greenhouse_effect ? "     RUNAWAY GREENHOUSE EFFECT\n" : "\n");
                    }
                    file.Write("   Surface temperature (Celcius):        {0:F2}\n", (node1.surface_temp - Constants.KELVIN_CELCIUS_DIFFERENCE));
                    if (node1.hydrosphere > 0.01)
                    {
                        file.Write("   Hydrosphere percentage:               {0:F2}\n", (node1.hydrosphere * 100));
                    }
                    if (node1.cloud_cover > 0.01)
                    {
                        file.Write("   Cloud cover percentage:               {0:F2}\n", (node1.cloud_cover * 100));
                    }
                    if (node1.ice_cover > 0.01)
                    {
                        file.Write("   Ice cover percentage:                 {0:F2}\n", (node1.ice_cover * 100));
                    }
                }
                file.Write("   Axial tilt (in degrees):              {0}\n", node1.axial_tilt);
                file.Write("   Planetary albedo:                     {0:F3}\n", node1.albedo);
                file.Write("   Length of year (in years):            {0:F2}\n", (node1.orbital_period / 365.25));
                file.Write("   Length of day (in hours):             {0:F2}\n\n", node1.day);
                counter++;
                node1 = node1.next_planet;
            }
            file.Close();
            Console.WriteLine();
            Console.WriteLine("Done! System definition written to \"{0}\"", options.File);
        }
Example #12
0
        /// <summary>
        /// Generates the solar system
        /// </summary>
        private static void GenerateInternal(ref SolarSystem system, Int32 Count)
        {
            // Describe the star
            system.stellar_mass_ratio       = system.random.Range(0.6, 1.3);
            system.stellar_radius_ratio     = Math.Floor(system.random.About(Math.Pow(system.stellar_mass_ratio, 1.0 / 3.0), 0.05) * 1000.0) / 1000.0;
            system.stellar_luminosity_ratio = Enviro.Luminosity(system.stellar_mass_ratio);
            system.stellar_temp             = Math.Floor(5650 * Math.Sqrt(Math.Sqrt(system.stellar_luminosity_ratio) / system.stellar_radius_ratio));
            system.main_seq_life            = 1.0E10 * (system.stellar_mass_ratio / system.stellar_luminosity_ratio);
            if (system.main_seq_life > 6.0E9)
            {
                system.age = system.random.Range(1.0E9, 6.0E9);
            }
            else if (system.main_seq_life > 1.0E9)
            {
                system.age = system.random.Range(1.0E9, system.main_seq_life);
            }
            else
            {
                system.age = system.random.Range(system.main_seq_life / 10, system.main_seq_life);
            }
            system.age          = system.random.Range(1.0E9, (system.main_seq_life >= 6.0E9) ? 6.0E9 : system.main_seq_life);
            system.r_ecosphere  = Math.Sqrt(system.stellar_luminosity_ratio);
            system.r_greenhouse = system.r_ecosphere * Constants.GREENHOUSE_EFFECT_CONST;
            system.type         = StellarType.GetStellarTypeTemp(system.stellar_temp);

            // Create the first Planet
            Planet planet = Accretation.DistributePlanetaryMasses(ref system, system.stellar_mass_ratio, system.stellar_luminosity_ratio, 0.0, Accretation.StellarDustLimit(system, system.stellar_mass_ratio));
            Int32  i      = 0;

            while (planet != null && i < Count)
            {
                planet.orbit_zone = Enviro.OrbitalZone(system, planet.a);
                if (planet.gas_giant)
                {
                    planet.density = Enviro.EmpiricalDensity(system, planet.mass, planet.a, planet.gas_giant);
                    planet.radius  = Enviro.VolumeRadius(planet.mass, planet.density);
                }
                else
                {
                    planet.radius  = Enviro.KothariRadius(planet.mass, planet.a, planet.gas_giant, planet.orbit_zone);
                    planet.density = Enviro.VolumeRadius(planet.mass, planet.radius);
                }
                planet.orbital_period  = Enviro.Period(planet.a, planet.mass, system.stellar_mass_ratio);
                planet.day             = Enviro.DayLength(ref system, planet.mass, planet.radius, planet.orbital_period, planet.e, planet.gas_giant);
                planet.resonant_period = system.spin_resonance;
                planet.axial_tilt      = Enviro.Inclination(system, planet.a);
                planet.escape_velocity = Enviro.EscapeVel(planet.mass, planet.radius);
                planet.surface_accel   = Enviro.Acceleration(planet.mass, planet.radius);
                planet.rms_velocity    = Enviro.RmsVel(Constants.MOLECULAR_NITROGEN, planet.a);
                planet.molecule_weight = Enviro.MoleculeLimit(planet.a, planet.mass, planet.radius);
                if ((planet.gas_giant))
                {
                    planet.greenhouse_effect = false;
                    planet.hydrosphere       = Constants.INCREDIBLY_LARGE_NUMBER;
                    planet.albedo            = system.random.About(Constants.GAS_GIANT_ALBEDO, 0.1);
                }
                planet.surface_grav           = Enviro.Gravity(planet.surface_accel);
                planet.greenhouse_effect      = Enviro.Greenhouse(planet.orbit_zone, planet.a, system.r_greenhouse);
                planet.volatile_gas_inventory = Enviro.VolInventory(system, planet.mass, planet.escape_velocity, planet.rms_velocity, system.stellar_mass_ratio, planet.orbit_zone, planet.greenhouse_effect);
                planet.surface_pressure       = Enviro.pressure(planet.volatile_gas_inventory, planet.radius, planet.surface_grav);
                planet.boil_point             = (planet.surface_pressure == 0.0) ? 0.0 : Enviro.BoilingPoint(planet.surface_pressure);
                Enviro.IterateSurfaceTemp(system, ref planet);

                // Moons
                if (system.moons)
                {
                    planet.first_moon = Accretation.DistributeMoonMasses(ref system, planet.mass, planet.radius);

                    Planet moon = planet.first_moon;
                    while (moon != null)
                    {
                        moon.radius  = Enviro.KothariRadius(moon.mass, 0, false, planet.orbit_zone);
                        moon.density = Enviro.VolumeDensity(moon.mass, moon.radius);
                        moon.density = system.random.Range(1.5, moon.density * 1.1);
                        if (moon.density < 1.5)
                        {
                            moon.density = 1.5;
                        }
                        moon.radius                 = Enviro.VolumeRadius(moon.mass, moon.density);
                        moon.orbital_period         = Enviro.Period(moon.a, moon.mass, planet.mass);
                        moon.day                    = Enviro.DayLength(ref system, moon.mass, moon.radius, moon.orbital_period, moon.e, false);
                        moon.resonant_period        = system.spin_resonance;
                        moon.axial_tilt             = Enviro.Inclination(system, moon.a);
                        moon.escape_velocity        = Enviro.EscapeVel(moon.mass, moon.radius);
                        moon.surface_accel          = Enviro.Acceleration(moon.mass, moon.radius);
                        moon.rms_velocity           = Enviro.RmsVel(Constants.MOLECULAR_NITROGEN, planet.a);
                        moon.molecule_weight        = Enviro.MoleculeLimit(moon.a, moon.mass, moon.radius);
                        moon.surface_grav           = Enviro.Gravity(moon.surface_accel);
                        moon.greenhouse_effect      = Enviro.Greenhouse(planet.orbit_zone, planet.a, system.r_greenhouse);
                        moon.volatile_gas_inventory = Enviro.VolInventory(system, moon.mass, moon.escape_velocity, moon.rms_velocity, system.stellar_mass_ratio, planet.orbit_zone, moon.greenhouse_effect);
                        moon.surface_pressure       = Enviro.pressure(moon.volatile_gas_inventory, moon.radius, moon.surface_grav);
                        if (moon.surface_pressure == 0.0)
                        {
                            moon.boil_point = 0.0;
                        }
                        else
                        {
                            moon.boil_point = Enviro.BoilingPoint(moon.surface_pressure);
                        }
                        Enviro.IterateSurfaceTemp(system, planet, ref moon);
                        planet.bodies_orbiting.Add(moon);
                        moon = moon.next_planet;
                    }
                    planet.BodiesOrbiting = planet.bodies_orbiting.ToArray();
                }

                if (i + 1 < Count)
                {
                    planet = planet.next_planet;
                    i++;
                }
                else
                {
                    planet.next_planet = null;
                    system.bodies.RemoveWhere(p => p.a > planet.a);
                }
            }
            system.Bodies = system.bodies.ToArray();
        }
Example #13
0
 /// <summary>
 /// Generates the solar system
 /// </summary>
 public static void Generate(ref SolarSystem system, Int32 Seed, Int32 Count = Int32.MaxValue)
 {
     system.random = new Random(Seed);
     GenerateInternal(ref system, Count);
 }
Example #14
0
 /// <summary>
 /// Generates the solar system
 /// </summary>
 public static void Generate(ref SolarSystem system, Int32 Count)
 {
     system.random = new Random();
     GenerateInternal(ref system, Count);
 }
Example #15
0
 /// <summary>
 /// Generates the solar system
 /// </summary>
 public static void Generate(ref SolarSystem system)
 {
     system.random = new Random();
     GenerateInternal(ref system, Int32.MaxValue);
 }