public void initPlanet(double _densityMul = 1.0, double rel_mass = 1.0, List <double> percentage = null) { //elementsDistribution = percentage; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalSeparator = "."; Function hydrostaticEquilibrium = ParametriUtente.Science.hydrostaticEquilibrium; //mass in grammi / 18.015 = moles double pressione; this.Volume = ((Math.Pow(this.planetRadius, 3) * (4.0 / 3.0)) * Math.PI); //km3 this.mass = rel_mass * ParametriUtente.Science.m_t; this.meanDensity = (this.mass * 1000 / (Math.Pow(10, 15) * Volume)) * _densityMul; pressione = ((ParametriUtente.Science.G * mass * (this.meanDensity * 1000)) / (this.planetRadius * this.planetRadius)); this.Core_temperature = ((0.84 * Math.Pow(10, -27)) * pressione) / (this.meanDensity * (1.380649 * Math.Pow(10, -23))); this.Surface_temperature = this.Core_temperature / 2543.37; double areaOfAbstoRadiationArea_ratio = 4; // 4 for fast rotation 2 for slow/tidal lock surfaceGravity = (ParametriUtente.Science.G * this.mass) / Math.Pow(this.planetRadius * 1000, 2); //https://en.wikipedia.org/wiki/Effective_temperature this.setRelativeValues(); this.initAtmoSphere(); this.planetRegions = ClimateEngine.createLatitudinalRegions(4, this.Surface_temperature); if (this.hasAtmosphere) { for (int i = 0; i < 2; i++) { this.applyChemicalBonds(); } Atmosphere = new Atmosphere(this.body_composition.getCompositionFromElements(body_composition.get_gas_elements())); Atmosphere.get_set_Pressure(ParametriUtente.Science.atm_t * (this.surfaceGravity / ParametriUtente.Science.g_t)); double atmMass = (4 * Math.PI * Math.Pow(this.planetRadius * 1000, 2) * Converter.atm_to_PA(Atmosphere.get_set_Pressure())) / this.surfaceGravity; Atmosphere.get_set_Masspercentage(this.planetMass / atmMass); //TODO: Create ClimateModel programmatically this.climateModel = new ClimateModel_TerrestrialPlanet(this.Surface_temperature, 0, this.planetRegions); this.climateModel.distributeHeat(); this.averageTemperature = this.climateModel.getRealTemperature(); this.waterBoilingPoint = ChemicalEngine.getElementBoilingPoint(null, Converter.K_to_C(this.averageTemperature), Converter.atm_to_mmHg(this.Atmosphere.get_set_Pressure())); this.waterBoilingPoint = Converter.C_to_K(this.waterBoilingPoint); this.waterMeltingPoint = ChemicalEngine.getWaterMeltingPoint_AtP(this.Atmosphere.get_set_Pressure()); } this.InitPlanetClassification(); }
public void applyChemicalBonds() { Random random = new Random(); List <ChemicalElement> chemicalElements = this.body_composition.get_elements(); List <ChemicalElement> chosenOnes = new List <ChemicalElement>(); List <int> chosenIndexes = new List <int>(); int elementToCompositeRatio = 1000000; double compositeMass = this.planetMass / elementToCompositeRatio; List <ChemicalElement> generatedElements = new List <ChemicalElement>(); int numberOfElements = chemicalElements.Count(); ChemicalComposition composites = ChemicalEngine.generateComposites(1, this.body_composition); this.body_composition.mergeCompositions(composites); }