planets * starSystem::distributePlanetaryMasses(double inner_dust, double outer_dust) { double a, e, mass, crit_mass, planetesimal_inner_bound, planetesimal_outer_bound; dust_bands* dust_head=new dust_bands(inner_dust,outer_dust); planets *planet_head=0; planets *&temp=planet_head; isDustLeft=TRUE; cloudEccentricity=0.2; planetesimal_inner_bound = innermost_planet(starMass); planetesimal_outer_bound = outermost_planet(starMass); while (isDustLeft) { a = random_number(planetesimal_inner_bound,planetesimal_outer_bound); e = random_eccentricity( ); mass = PROTOPLANET_MASS; #ifdef VERBOSE printf("Checking %10f AU: ",a); #endif if (dust_head->dustAvailable(inner_effect_limit(a, e, mass),outer_effect_limit(a, e, mass))) { #ifdef VERBOSE printf(".. Injecting protoplanet.\n"); #endif assert(a>0.0); dustDensity = DUST_DENSITY_COEFF * sqrt(starMass) * exp(-ALPHA * pow(a,(1.0 / N))); crit_mass = critical_limit(a,e,starLuminosity); accreteDust(dust_head,mass,a,e,crit_mass,planetesimal_inner_bound,planetesimal_outer_bound); if ((mass != 0.0) && (mass != PROTOPLANET_MASS)) coalescePlanetesimals(planet_head,dust_head,a,e,mass,crit_mass, planetesimal_inner_bound,planetesimal_outer_bound); #ifdef VERBOSE else printf(".. failed due to large neighbor.\n"); #endif } #ifdef VERBOSE else printf(".. failed.\n"); #endif } return temp; }
void starSystem::make(int diam, int atm, int hyd) { planetList=distributePlanetaryMasses(0.0,stellarMaxDust(starMass)); planets *planet_head=planetList; while (planet_head) { planet_head->buildPlanet(starMass,starLuminosity,rEcosphere,rGreenhouse,age); // attempt to build moons! planet_head->addMoons(starMass, starLuminosity, rEcosphere, rGreenhouse, age); // distributeMoonMasses(*planet_head,planet_head->radius*2.0/1E6,stellarMaxDust(planet_head->mass)); planet_head = planet_head->nextPlanet; } if(diam>-1) { planets* mainworld=new planets; mainworld->buildMainworld(diam,atm,hyd,random_eccentricity(),starMass,starLuminosity,rEcosphere,age); insertMainworld(mainworld); } }
planet_pointer dist_planetary_masses(long double stell_mass_ratio, long double stell_luminosity_ratio, long double inner_dust, long double outer_dust, long double outer_planet_limit, long double dust_density_coeff, planet_pointer seed_system, int do_moons) { long double a; long double e; long double mass; long double dust_mass; long double gas_mass; long double crit_mass; long double planet_inner_bound; long double planet_outer_bound; planet_pointer seeds = seed_system; set_initial_conditions(inner_dust,outer_dust); planet_inner_bound = nearest_planet(stell_mass_ratio); if (outer_planet_limit == 0) planet_outer_bound = farthest_planet(stell_mass_ratio); else planet_outer_bound = outer_planet_limit; while (dust_left) { if (seeds != NULL) { a = seeds->a; e = seeds->e; seeds = seeds->next_planet; } else { a = random_number(planet_inner_bound,planet_outer_bound); e = random_eccentricity( ); } mass = PROTOPLANET_MASS; dust_mass = 0; gas_mass = 0; if (flag_verbose & 0x0200) fprintf (stderr, "Checking %Lg AU.\n",a); if (dust_available(inner_effect_limit(a, e, mass), outer_effect_limit(a, e, mass))) { if (flag_verbose & 0x0100) fprintf (stderr, "Injecting protoplanet at %Lg AU.\n", a); dust_density = dust_density_coeff * sqrt(stell_mass_ratio) * exp(-ALPHA * pow(a,(1.0 / N))); crit_mass = critical_limit(a,e,stell_luminosity_ratio); accrete_dust(&mass, &dust_mass, &gas_mass, a,e,crit_mass, planet_inner_bound, planet_outer_bound); dust_mass += PROTOPLANET_MASS; if (mass > PROTOPLANET_MASS) coalesce_planetesimals(a,e,mass,crit_mass, dust_mass, gas_mass, stell_luminosity_ratio, planet_inner_bound,planet_outer_bound, do_moons); else if (flag_verbose & 0x0100) fprintf (stderr, ".. failed due to large neighbor.\n"); } else if (flag_verbose & 0x0200) fprintf (stderr, ".. failed.\n"); } return(planet_head); }