Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Sun Gear

Content

Warnings

  1. No version in dependency reference to oolite.oxp.Wildeblood.distant_suns:null
  2. No version in dependency reference to oolite.oxp.Rustem.DistantStar:null
  3. Conflict Expansions mismatch between OXP Manifest and Expansion Manager at character position 0068 (DIGIT ZERO vs LATIN SMALL LETTER N)

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description This OXP simulates more realistic sun population based on real astronomical data. Vast solar systems with main planets in habitable zones and with simulated solar wind. Requires Habitable Main Planets OXP. This OXP simulates more realistic sun population based on real astronomical data. Vast solar systems with main planets in habitable zones and with simulated solar wind. Requires Habitable Main Planets OXP.
Identifier oolite.oxp.stranger.SunGear oolite.oxp.stranger.SunGear
Title Sun Gear Sun Gear
Category Ambience Ambience
Author stranger stranger
Version 4.5.2 4.5.2
Tags sun, star, system sun, star, system
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.stranger.HabitableMainPlanets:1.4.0
  • oolite.oxp.stranger.HabitableMainPlanets:1.4.0
  • Optional Expansions
    Conflict Expansions
  • oolite.oxp.Wildeblood.distant_suns:0
  • oolite.oxp.Rustem.DistantStar:0
  • oolite.oxp.Wildeblood.distant_suns:
  • oolite.oxp.Rustem.DistantStar:
  • Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=19973 n/a
    Download URL https://wiki.alioth.net/img_auth.php/2/28/SunGear.oxz n/a
    License CC-BY-NC-SA 3.0 CC-BY-NC-SA 3.0
    File Size n/a
    Upload date 1670023752

    Documentation

    Also read http://wiki.alioth.net/index.php/Sun%20Gear

    Sun Gear READ ME.txt

    ----------------------------
    Sun Gear OXP
    ----------------------------
    
    Author: Stranger
    This OXP is inspired by Distant Suns OXP (author of original work Wildblood).
    This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.
    You are free to use and distribute this OXP on non-commercial basis. 
    Rebundling of this OXP within another distribution is permitted as long as it is unchanged.
    Any mods/derivatives of this OXP must be distributed under another names.
    The license information (either as this file or merged into a larger one) must be included in the OXP.
    
    Features:
    
    Distribution of sun colors rebalanced in accordance with real astronomical data. Despite red dwarves being most common class in Galaxy stellar population most part of known exoplanets belongs to yellow Sun-like G-stars and orange K-stars (https://en.wikipedia.org/wiki/List_of_exoplanetary_host_stars). It may reflect observation bias of course but planets of yellow Sun-like stars seems to be more hospitable for colonization.
    More detailed system of spectral classes - 28 spectral subclasses from M3.5V to F6V (Wildblood's spectra covers only 6 base classes) and 56 unique spectral signatures (two steps for subclass).
    Spectral classes B and A completely removed from Ooniverse. Hottest bound of main sequence is limited to F6 spectral subclass. Bluish-white hot stars are too short-lived to maintain advanced ecosystems in real worlds and bit ugly in Ooniverse :-(
    Spectral class M restricted to M3 stars to adopt more realistic star models. Red dwarves in real world has too low luminosities to model habitable zones in Oolite.
    Sun radius is a function of spectral class. Sun radius and luminosity function vs spectral class based on real astronomical data.
    Large suns and solar systems implemented - sun radii are in range 360000�1120000 km (smoothed distribution), main planet orbit radii are approx. 20�40 times of default value.
    Spectral class of sun and main planet radius are correlated values - large main planets in white and yellow hot star systems, small main planets in systems of red and orange dwarves.
    Distance from sun to main planet is a function of sun luminosity.
    Habitable zones simulated. Main planets are located near Standard Insolation Level with random distance bias � 5%. Large main planets in systems of white and yellow stars has more warm climate as compared with small main planets in systems of orange and red dwarves not due to more hot sun per se but due to more dense atmospheres providing more evident greenhouse effect.
    Corona flare is controlled dynamically via script. Most of time sun of system is in quiet state (corona_flare random value in range 0.1�0.2), but sometimes solar flares occurs and corona_flare rises randomly up to 0.5 (yes, I know, in reality it is NOT linear correlation between solar corona size and solar flares!). As a rule flare frequency increases from yellow to red stars. Peculiar suns with "solar activity" in system description has more frequent flares with higher magnitudes (corona_flare rises up to 1.0 in case of "deadly solar activity").
    Wildblood's spectroscope script was rewritten to adopt RGB color model. Sun radius is used to determine sun spectral class instead named color.
    Solar wind model is implemented. Solar wind flux is a function of solar radius and corona flare, distance to sun and ship speed.
    Solar wind allows to refuel ship without sunskimming (in some cases refuelling is possible en route from witchpoint to main planet).
    Magnetospheres of celestial bodies are simulated. Solar wind density is drop to zero level near planets and moons. Upper boundary of magnetosphere is equal to upper boundary of gravity well (green/yellow horizon).
    
    AstroLibrary
    
    AstroLibrary is a library, providing astronomic (oostronomic may be?) functions to calculate sun spectrum, main planet temperature (used in Planetary Systems OXP to set planet texture), main planet orbital period &  planet and moon parameters (used in Planetary Systems OXP to display on special info screen), solar wind density (used in Hard Way OXP to collect fuel) etc.
    
    
    Advanced System Data MFD
    
    Advanced System Data MFD provides custom system info on two pages.
    
    Sun Data info page displays:
    
    Sun catalog number (galaxy sector and system ID)
    Sun spectral class
    Sun radius
    Sun mass
    Sun luminosity
    Solar activity
    Main planet period in days
    Sun distance
    Solar wind flux
    
    Planetary System Data info page provides list of additional planets in solar system. It displays only planet orbit radii in OU and planet class:
    
    Dwarf terra � planet like Pluto or Ceres
    Miniterra � planet like Mercury
    Subterra � planet like Mars
    Terra � planet like Earth or Venus
    Superterra � planet like� hmm, we have no such example in our Solar System. Gliese 667 Cc maybe?
    Ice giant � planet like Uranus or Neptune
    Gas giant � planet like Jupiter or Saturn
    
    System Data Sheet
    
    Advanced system info also available in docked state using F4 screen. Select System Data Sheet option to view info:
    
    Sun spectral class
    Sun radius
    Sun mass
    Sun luminosity
    Main planet period in days
    List of system planets
    
    System Data Sheet is available even if your ship has no ASC, but this service is provided only on GalCop main stations.
    
    Dependencies
    
    Sun Gear OXP requires Habitable Main Planets OXP installed because sun population is generated using recalibrated main planet radii, not vanilla ones.
    
    Compatibility notes
    
    Vast solar systems can cause problems in intra-system missions such as search and rescue operations or in-system taxi service. So you need additional OXPs to overcome these difficulties. Some OXPs uses absolute coordinates to populate systems with custom objects, so you may find such objects placed too close to large suns for example.
    Refueling by sun-skimming is really challenging task in case of large suns (you have no enough time to leave more wide overheat zone). This is not the case if you are using fuel collection from solar wind, but this option is realized for player ship only, so pre-scripted AI sun-skimming activity will be suicidal behavior pattern.
    
    Disclaimer:
    
    Sun Gear is NOT simulation of real solar systems. It uses some relative values from real astronomy, scaled to fit into Oolite game world.
    Don't try to use this software for real interstellar navigation!
    
    Credits:
    
    Wildblood - Distant Suns OXP/OXZ: initial concept of custom sun population & spectroscope script.
    Tch - Tch_Russian_Systems OXP: idea of using RGB model for sun color.
    Rustem - Distant Stars OXP/OXZ: idea of dynamic coronae.
    Damocles Edge, phkb and another_commander - for detecting OXP incompatibility with DH ANC OXP, formulation of issue with HSB colors and invaluable help to solve this issue.
    Dybal, Milo and Cholmondely - valuable feedback for improving this OXP.
    
    ---------------------
    Installation and use:
    ---------------------
    
    To use, simply place the Sun Gear OXP into your "AddOns" folder or download OXZ from OXZ manager.
    To call �Sun Data� MFD page lock Advanced Space Compass onto sun and list MFD modes.
    To call �Planetary System Data� MFD page "Stellar Data" lock Advanced Space Compass onto any planet or moon and list MFD modes.
    Advanced System Data MFD is not purchasable upgrade. It is expanded functionality of ASC, so upgrade your basic astrocompass to ASC is the only necessary condition to have access to Advanced System Data.
    To use solar wind feature for fuel collection you need Hard Way OXP to be installed.
    
    This package minimum requirement is Oolite 1.82. Integer-valued distance format in early versions of Oolite before 1.80 and graphical glitch with distant objects in Oolite 1.80 prevents using of this package in pre-1.82 Oolite versions.
    
    -----------
    Change Log:
    -----------
    
    03.12.2022 - Version 4.5.2	System Data Sheet on F4 screen now declared as Informational instead Ambience 
    01.12.2022 - Version 4.5.1	Code improved to activate System Data Sheet on F4 screen after start-up.
    01.12.2022 - Version 4.5.0	Added System Data Sheet on F4 screen.
    07.07.2020 - Version 4.4.0	Fixed error in log file generated by SolarSystemData script in case of misjump.
    03.07.2020 - Version 4.3.2	Fixed missed parenthesis in manifest.plist preventing download OZX via OXZ manager.
    03.07.2020 - Version 4.3.1	Uploaded repeatedly to override problem with downloading version 4.3.0.
    02.07.2020 - Version 4.3.0	Redefined sun database based on redefined Habitable Main planets radii.
    				Spectral class range now includes suns from F6V to M3.5V.
    				AstroLibrary improved again to display added spectral classes.
    				Improved script to display info on Planetary System Data MFD page based on redefined planet classification.
    23.04.2019 - Version 4.2.0	Tweaked runaway greenhouse trigger in PlanetEngine.
    17.04.2019 - Version 4.1.0	Improved function for simple calculation of main planet temperature.
    				(still has some discrepancy with result of more complex calculation of planet temperature in PlanetEngine)
    06.02.2019 - Version 4.0.0	Sun colors redefined in RGB model.
    				Distant Suns and Distant Stares declared as conflicting OXPs in manifest.plist.
    04.02.2019 - Version 3.9.0	Fixed error in variable name, preventing display of sun spectral class on F7 System Info page.
    02.02.2019 - Version 3.8.0	PlanetEngine improved again - less one empirical quotient, less one IF-THEN-ELSE construction, almost the same result.
    02.02.2019 - Version 3.7.0	Improved AstroLibrary functions for calculation of planet atmospheres in PlanetEngine.
    31.01.2019 - Version 3.6.1	Converted onto OXZ
    04.12.2018 - Version 3.6	More detailed spectral class info displayed (such as G2V or G2.5V instead just G2V)
    				Some tweaks in names of variables.
    14.09.2018 - Version 3.5	Tweaked sun parameters to synchronize with updated Habitable Main Planets.
    				manifest.plist added.
    25.08.2018 - Version 3.4	Fixed critical error in calculation of main planet temperature in remote systems.
    18.08.2018 - Version 3.3	Tweaked sun parameters for agricultural planets with TL < 4.
    17.08.2018 - Version 3.2	Suns of F8V, F9V and M2V spectral class added.
    				AstroLibrary improved to display added spectral classes.
    				Function main planet size vs sun size recalibrated.
    				All main planets centered to Standard Insolation Level with random distance bias � 5%.
    				Greenhouse effect is added to calculation of main planet temperature.
    12.08.2018 - Version 3.1	Main planet temperature data removed from Sun Data MFD page.
    12.06.2018 - Version 3.0	Calculation of additional planet parameters added to AstroLibrary.
    				Info pages �Sun Data� and �Planetary System Data� displayed on MFD.
    				Info screen is removed as obsolete and unrecommended method. 
    19.05.2018 - Version 2.9	Minor tweak in planet classification displayed on planet info page.
    13.05.2018 - Version 2.8	AstroLibrary code refactored to satisfy JavaScript strict mode.
    28.04.2017 - Version 2.7	AstroLibrary functions improved.
    				Sun temperature and mass are calculated functions of sun radius, not fixed predefined values.
    27.04.2017 - Version 2.6	Sun parameters upgraded to fit more resent astronomical data.
    				Less yellow G-stars, more orange K-stars in star population.
    				Sun radii distribution smoothed, every sun on chart has unique radius and luminosity.
    				Smoothed function of main planet orbit radius vs sun luminosity with pseudo-random shift provides more accurate matching to habitable zone.
    				All 99 Famous Planets (extended set) orbital parameters verified and tuned to match planet texture vs calculated temperature.
    				All 8 planetinfo.plist merged onto one planetinfo.plist. Package reassembled onto more simple structure.
    				Distance from main planet to sun is redefined in absolute value sun_distance.
    				Distance in planet radii (sun_distance_modifier) is abandoned as obsolete method.
    				AstroLibrary functions rewritten to adopt new smoothed sun radii feature.
    22.10.2016 - Version 2.5	Dynamic solar coronae implemented.
    				Solar wind density recalibrated to new model.
    				Sun Coronae dictionaries deleted.
    				Fixed error in calculation of sun luminosity, reduced to standard Sun candle (used to display Sun Data).
    				corona_flare is displayed in Sun Data as human-friendly Sun Activity index in range from 1.00 to 10.00.
    20.07.2016 - Version 2.4	Public release of Sun Gear with updated code.
    09.07.2016 - Version 2.3	Planetary System Data page code rewritten to adopt expanded planet set from Planetary Systems OXP
    				(some info for internal testing added).
    25.12.2015 - Version 2.2	Hull temperature info removed from F7 screen.
    18.11.2015 - Version 2.1	Sun scale boosted up to 10x.
    				M1V star spectral class added.
    				Calculation of main planet temperature and ship hull temperature added to AstroLibrary functions.
    				AstroLibrary functions generates solar radius, mass and luminosity values with some pseudorandom component.
    				Sun info screen divided onto 2 pages - Stellar Data (sun info) and Planetary System Data (planet info).
    11.06.2015 - Version 2.0	New sun scale implemented. Sun radii and main planet distances scaled up to 4x.
    				Fine tuning of arctic Famous Planets systems - more cold suns for Qutiri, Beusrior, Edorte etc (8 systems readjsted)
    27.11.2014 - Version 1.9	Sun database is completely rewritten again :-)
    				Local sun_distance_modifier values are restored to fix radii of habit zones.
    21.10.2014 - Version 1.8	16 Famous Planets sun radii readjusted to fix conflict with descriptions and texture appearance.
    				Solar wind flow check condition switched to Green status.	
    22.09.2014 - Version 1.7	Sun database is completely rewritten again. Correlation sun radius vs planet radius refined.
    				sun_distance_modifier is fixed to 60 main planet radii for all systems. 
    15.09.2014 - Version 1.6	Sun database is completely rewritten to adopt new correlation sun radius vs planet radius.
    				Sun coronae also recalculated and rewritten.
    28.06.2014 - Version 1.5	Main planet period calculation refined.
    				A bit randomness to main planet period added.
    				Main planet period info added to Stellar Data screen.
    27.06.2014 - Version 1.4	AstroLibrary improved with database of main planet orbital periods.
    24.06.2014 - Version 1.3	Spectral class F stars completely removed from database.
    				Distribution of other suns readjusted.
    				Parameter sun_distance_modifier is readjusted.
    				Sun color curve readjusted to Oolite 1.80.
    19.05.2014 - Version 1.2	AstroLibrary improved to scan planets, created by Planetary Systems OXP.
    14.05.2014 - Version 1.1	Code rewritten to use AstroLibrary global functions.
    12.03.2014 - Version 1.0	Fixed bug in solar_wind.js (incorrect test for interstellar space replaced).
    20.01.2014 - Version 0.9	Fixed bug in solar_wind.js (overflow of fuel collect counter in close proximity of sun).
    07.12.2013 - Version 0.8	Some code refining (not reflected in game functionality).
    30.11.2013 - Version 0.7	Corona parameters are completely rewritten.
    				Unified version index is implemented (old Sun Coronae Chart 1 version 0.3.oxp, for example, replaced to simple Sun Coronae Chart 1.oxp).
    19.11.2013 - Version 0.6	Magnetospheres of celestial bodies are simulated.
    				Garbage piece of code removed from sun_info.js (unused variables in startUp function).
    				Calculation of solar wind critical density is refined.
    16.11.2013 - Version 0.5	Minor bug in sun_info.js fixed (corona_flare value output fixed to 2 digits).
    				Old Wildblood licence text removed. 
    15.11.2013 - Version 0.4	Nested sun spectra scripts replaced to single script for all 8 charts.
    				Solar wind model and new scheme of refuelling implemented. Sun info screen is added.
    18.07.2013 - Version 0.3	Wildblood Sun Debugger is removed.
    				Brief info for Russian gamers is included.
    02.03.2013 - Version 0.2	All 8 Sun Spectra planetinfo.plist are completely rewritten to adopt improved sun model.
    				Spectral class M is restricted to M0 stars, M1�M5 stars removed from database.
    				Some improvement in color model.
    				All 8 Sun Coronae planetinfo.plists are edited - a bit tweak of Wildblood's coronae.
    23.02.2013 - Version 0.1	Initial release.

    Equipment

    Name Visible Cost [deci-credits] Tech-Level
    Advanced System Data MFD no 1 101+

    Ships

    This expansion declares no ships. This may be related to warnings.

    Models

    This expansion declares no models. This may be related to warnings.

    Scripts

    Path
    Scripts/astro_library.js
    "use strict";
    this.name           = "AstroLibrary";
    this.author         = "Stranger";
    this.copyright      = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description    = "Library of oostronomical functions";
    this.version        = "4.3";
    
    // SunEngine functions
    
    this.$astroLib_sunSpectrum = function(sunRadius)    // sun spectrum class as function of sun radius
        {
        if (system.isInterstellarSpace) return;
        var spectrum;
        var spectrumSelector;
        if (sunRadius <= 600000)
            {
            spectrumSelector = Math.floor(sunRadius / 30000);
            }
        else
            {
            if(sunRadius > 1000000)
                {
                spectrumSelector = Math.floor((sunRadius + 500000) / 15000);
                }
            else
                {
                spectrumSelector = Math.floor(sunRadius / 10000);
                }
            }
        switch (spectrumSelector)
            {
            // M class red dwarf
            case 12: spectrum = "M3.5V"; break;
            case 13: spectrum = "M3V"; break;
            case 14: spectrum = "M2.5V"; break;
            case 15: spectrum = "M2V"; break;
            case 16: spectrum = "M1.5V"; break;
            case 17: spectrum = "M1V"; break;
            case 18: spectrum = "M0.5V"; break;
            case 19: spectrum = "M0V"; break;
            // K class orange dwarf
            case 60: spectrum = "K9.5V"; break;
            case 61: spectrum = "K9V"; break;
            case 62: spectrum = "K8.5V"; break;
            case 63: spectrum = "K8V"; break;
            case 64: spectrum = "K7.5V"; break;
            case 65: spectrum = "K7V"; break;
            case 66: spectrum = "K6.5V"; break;
            case 67: spectrum = "K6V"; break;
            case 68: spectrum = "K5.5V"; break;
            case 69: spectrum = "K5V"; break;
            case 70: spectrum = "K4.5V"; break;
            case 71: spectrum = "K4V"; break;
            case 72: spectrum = "K3.5V"; break;
            case 73: spectrum = "K3V"; break;
            case 74: spectrum = "K2.5V"; break;
            case 75: spectrum = "K2V"; break;
            case 76: spectrum = "K1.5V"; break;
            case 77: spectrum = "K1V"; break;
            case 78: spectrum = "K0.5V"; break;
            case 79: spectrum = "K0V"; break;
            // G class yellow dwarf
            case 80: spectrum = "G9.5V"; break;
            case 81: spectrum = "G9V"; break;
            case 82: spectrum = "G8.5V"; break;
            case 83: spectrum = "G8V"; break;
            case 84: spectrum = "G7.5V"; break;
            case 85: spectrum = "G7V"; break;
            case 86: spectrum = "G6.5V"; break;
            case 87: spectrum = "G6V"; break;        
            case 88: spectrum = "G5.5V"; break;
            case 89: spectrum = "G5V"; break;
            case 90: spectrum = "G4.5V"; break;
            case 91: spectrum = "G4V"; break;
            case 92: spectrum = "G3.5V"; break;
            case 93: spectrum = "G3V"; break;
            case 94: spectrum = "G2.5V"; break;
            case 95: spectrum = "G2V"; break;
            case 96: spectrum = "G1.5V"; break;
            case 97: spectrum = "G1V"; break;
            case 98: spectrum = "G0.5V"; break;
            case 99: spectrum = "G0V"; break;
            // F class white hot star
            case 100: spectrum = "F9.5V"; break;
            case 101: spectrum = "F9V"; break;
            case 102: spectrum = "F8.5V"; break;
            case 103: spectrum = "F8V"; break;
            case 104: spectrum = "F7.5V"; break;
            case 105: spectrum = "F7V"; break;
            case 106: spectrum = "F6.5V"; break;
            case 107: spectrum = "F6V"; break;
            default: spectrum = null;
            };    
        return spectrum;
        }
    
    this.$astroLib_sunTemperature = function(sunRadius)    // sun temperature as function of sun radius
        {
        if (system.isInterstellarSpace) return;
        var solarTemperature;
        if (sunRadius <= 600000)
            {
            solarTemperature = 4000 - (600000 - sunRadius) / 300;
            }
        else
            {
            if (sunRadius > 1000000)
                {
                solarTemperature = 6000 + (sunRadius - 1000000) / 300;
                }
            else
                {
                solarTemperature = 6000 - (1000000 - sunRadius) / 200;
                }
            }  
        var solarTemperatureTweaked = solarTemperature - 25 + 50 * system.scrambledPseudoRandomNumber(119);
        return solarTemperatureTweaked;
        }
    
    this.$astroLib_sunLuminosity = function(sunTemperature, sunRadius)    // sun luminosity as function of sun radius
        {
        if (system.isInterstellarSpace) return;   
        var sunLuminosity = Math.pow((sunTemperature / 6000),4) * Math.pow((sunRadius / 1000000),2); // Stefan-Boltzmann law
        return sunLuminosity;
        }
    
    this.$astroLib_sunMass = function(sunRadius)    // sun mass as function of sun radius
        {
        if (system.isInterstellarSpace) return;
        var solarMass;
        if (sunRadius <= 300000)
            {
        solarMass = 0.175;
            }
        else
            {
            solarMass = 1.0 - (960000 - sunRadius) / 1000000 * 1.25;
            }    
        var sunMassTweaked = solarMass * (0.975 + 0.05 * system.scrambledPseudoRandomNumber(120));
        return sunMassTweaked;
        }
    
    this.$astroLib_solPeriod = function(sunMass)    // main planet period as function of sun mass
        {
        if (system.isInterstellarSpace) return;   
        var standardOU = 63750 * 675;   // Sol-Terra system twin AU
        var standardYear = 365.25;   // standard year for Sol-Terra system twin
        var mainOrbitVector = new Vector3D(system.sun.position.subtract(system.mainPlanet.position));
        var ouScale = mainOrbitVector.magnitude();  // OU in custom system
        var mainPeriod = standardYear * Math.pow((ouScale / standardOU),1.5) / Math.pow(sunMass,0.5); // 3rd Kepler low
        return mainPeriod;
        }
    
    this.$astroLib_orbitRadius = function()         // planet orbits in OU
        {
        if (system.isInterstellarSpace) return;
        var mainOrbitVector = new Vector3D(system.sun.position.subtract(system.mainPlanet.position));
        var ouScale = mainOrbitVector.magnitude();
        var planetsOrbitsOU = new Array();
        var planetOrbitVector;
        for (let i=0; i<system.planets.length; i++)
            {
            planetOrbitVector = new Vector3D(system.sun.position.subtract(system.planets[i].position));
            planetsOrbitsOU[i] = planetOrbitVector.magnitude() / ouScale;
            }
        return planetsOrbitsOU;    
        }
    
    this.$astroLib_mainPlanetTemperature = function(sunLuminosity,sunDistance,mainPlanetRadius)  // main planet temperature - simplified function of radius
        {
        if (system.isInterstellarSpace) return;    
        var mainInsolation = sunLuminosity * Math.pow((50000000 / sunDistance),2);
        var equilibriumTemperature = 255 * Math.pow(mainInsolation,0.25);
        var mainTemperature;
        mainTemperature = equilibriumTemperature + (mainPlanetRadius - 4800) * 3 / 400 + 20;    
        return mainTemperature;
        }
    
    this.$astroLib_SolarWind = function(sunDistance)    // solar wind. Used to collect fuel
    	{
        if (system.isInterstellarSpace) return;
        var solarWindDensity = (system.sun.radius * system.sun.radius) / (sunDistance * sunDistance) * system.info.corona_flare;
        if (player.alertCondition != 1)
            {
            solarWindDensity = 0;
            }
        var solarWindFlux;
        if(player.ship.speed > player.ship.maxSpeed)
            {
            solarWindFlux = solarWindDensity * player.ship.maxSpeed;
            }
        else
            {
            solarWindFlux = solarWindDensity * player.ship.speed;      //rate of fuel collection, LY/min          
            }
        return solarWindFlux;
    	}
    
    // PlanetEngine functions
    
    this.$astroLib_insolation = function(sunLuminosity, sunDistance)    // insolation level
        {
        if (system.isInterstellarSpace) return;   
        var insolation = sunLuminosity * Math.pow((50000000 / sunDistance),2);
        return insolation;    
        }
    
    this.$astroLib_equilibriumTemperature = function(insolation)    // equilibrium temperature without greenhouse effect. Albedo same as Earth
        {
        if (system.isInterstellarSpace) return;   
        var equilibriumTemperature = 255 * Math.pow(insolation,0.25);
        return equilibriumTemperature;
        }
    
    this.$astroLib_planetDensity = function(planetRadius, equilibriumTemperature)   // planet density as function of planet radius and equilibrium temperature
        {
        if (system.isInterstellarSpace) return; 
        var planetDensity = 0.925 + Math.sqrt(planetRadius / 302.5) * Math.sqrt(equilibriumTemperature / 255);
        return planetDensity;
        }
    
    this.$astroLib_escapeVelocity = function(planetRadius, planetDensity)   // escape velocity as function of planet radius and density
        {
        if (system.isInterstellarSpace) return;
        var escapeVelocity = 11180 * planetRadius / 6400 * Math.sqrt(planetDensity / 5.5);
        return escapeVelocity;
        }
    
    this.$astroLib_surfaceGravity = function(planetRadius, escapeVelocity)  // planet surface gravity as function of planet radius and escape velocity
        {
        if (system.isInterstellarSpace) return;
        var surfaceGravity = escapeVelocity * escapeVelocity / (planetRadius * 1000) / (9.81 * 2);
        return surfaceGravity;
        }
    
    this.$astroLib_atmosphereMass = function(planetRadius, escapeVelocity, equilibriumTemperature) // mass of atmosphere per unit of surface square as function of planet radius, escape velocity and equilibrium temperature
        {
        if (system.isInterstellarSpace) return;
        var termosphereTemperature = equilibriumTemperature * 4;
        var termosphereVelocity = 320 * Math.sqrt(termosphereTemperature / 273.15);
        var dissipation_ratio = termosphereVelocity / escapeVelocity;
        var dissipation_adjust = dissipation_ratio * 25;
        var volatile_pool = planetRadius / 1600 * Math.pow(255 / equilibriumTemperature,2);
        var atmosphereMass;
        var insolation = Math.pow(equilibriumTemperature / 255,4);
        var volatile_adjust = (planetRadius - 6250) / 100;
        if (insolation > 1.75 && planetRadius > 6250 && planetRadius < 7500)    // runaway greenhouse trigger
            {
            atmosphereMass = volatile_pool * Math.exp(-dissipation_adjust) * (1 + volatile_adjust * volatile_adjust);
            }
        else
            {
            atmosphereMass = volatile_pool * Math.exp(-dissipation_adjust);
            }
        return atmosphereMass;
        }
    
    this.$astroLib_atmospherePressure = function(atmosphereMass, surfaceGravity)    // atmosphere pressure as function of atmosphere mass and surface gravity
        {
        if (system.isInterstellarSpace) return;
        var atmospherePressure = atmosphereMass * surfaceGravity;
        return atmospherePressure;
        }
    
    this.$astroLib_atmosphereTemperature = function(equilibriumTemperature, atmosphereMass) // planet surface temperature as function of equilibrium temperature and atmosphere mass (greenhouse effect)
        {
        if (system.isInterstellarSpace) return;
        var atmosphereTemperature = equilibriumTemperature + 0.125 * equilibriumTemperature * Math.sqrt(atmosphereMass);
        return atmosphereTemperature;
        }
    
    Scripts/solar_activity.js
    "use strict";
    this.name				= "SolarActivity";
    this.author				= "Stranger";
    this.copyright			= "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
    this.description		= "Dynamic solar flares";
    this.version			= "2.5";
    
    this.shipWillLaunchFromStation = this.shipWillExitWitchspace = function()
        {
        if (system.isInterstellarSpace) return;
        var info = system.info;
        // regular case
        var flareBasic = 0.10 + Math.random() * 0.10; 
        var flareRate = 0.10 * 1000000 / system.sun.radius;     // red dwarves has more frequent flares than yellow stars
        var flareFlux = 0.30;
        // peculiar solar activity mentioned in system description
        if (system.info.description.indexOf("occasional solar activity") > -1)
            {
            flareRate = 0.30;
            flareFlux = 0.40;
            }
        if (system.info.description.indexOf("unpredictable solar activity") > -1)
            {
            flareRate = 0.35;
            flareFlux = 0.50;
            }
        if (system.info.description.indexOf("frequent solar activity") > -1)
            {
            flareRate = 0.40;
            flareFlux = 0.60;
            }
        if (system.info.description.indexOf("dreadful solar activity") > -1)
            {
            flareRate = 0.45;
            flareFlux = 0.70;
            }
        if (system.info.description.indexOf("deadly solar activity") > -1)
            {
            flareRate = 0.50;
            flareFlux = 0.80;
            }
        var flareTrigger = Math.random();
        // active sun
        if (flareTrigger < flareRate)
            {
            info.corona_flare = flareBasic + Math.random() * flareFlux;
            }
        // quiet sun
        else
            {
            info.corona_flare = flareBasic;
            }
        }
    
    Scripts/solar_system_data.js
    "use strict";
    this.name    = "SolarSystemData";
    this.author = "Stranger";
    this.copyright = "This work is hereby placed in the public domain.";
    this.description = "Displays system sun and planet data on MFD and F4 info page.";
    this.version = "4.5.2";
    
    this.startUpComplete = function()
        {
        this.self = player.ship;
        this.$setupDelay = new Timer(this, this.$setupSystemInfo, 1);    //delay to set planet orbits!
        }
    
    this.shipWillLaunchFromStation = this.shipWillExitWitchspace = function()
        {
        if (system.isInterstellarSpace) return;
        if(this.self.equipmentStatus("EQ_ADVANCED_COMPASS") == "EQUIPMENT_OK")
            {
            this.self.awardEquipment("EQ_ADVANCED_SYSTEM_DATA_MFD");
            this.$scriptDelay = new Timer(this, this.$setupSystemInfo, 1);
            this.$startUpdateMFDTimer();
            }
        else
            {
            this.self.removeEquipment("EQ_ADVANCED_SYSTEM_DATA_MFD");
            }
        }
    
    this.$startUpdateMFDTimer = function()
    	{
    	if(this.$updateMFDTimer)
    		{ this.$updateMFDTimer.start(); }
    	else
    		{ this.$updateMFDTimer = new Timer(this, this.$updateMFD,0,1); }
    	}
    
    this.shipWillDockWithStation = this.shipDied = this.$stop$updateMFDTimer = function()
    	{   
    	if(this.$updateMFDTimer && this.$updateMFDTimer.isRunning) { this.$updateMFDTimer.stop(); } 
    	}
    
    this.$updateMFD = function()
        {
        if(this.self.equipmentStatus("EQ_ADVANCED_COMPASS") != "EQUIPMENT_OK") return;
        if(this.self.compassMode === "COMPASS_MODE_SUN")
            {
            this.$starPage();
            }
        else
            {
            this.$planetPage();
            }
        }
    
    this.$starPage = function()
    	{
        var w = worldScripts.AstroLibrary;
    	var info = system.info;
    	var catNum = " " + galaxyNumber + " " + system.ID;
        if (system.info.sun_radius)
    		{
            var sunRadius = system.sun.radius;
    		}
        var sunDistance = player.ship.position.distanceTo(system.sun).toFixed(0);
        var sunRelDistance = (sunDistance/system.sun.radius);
        var solarWind = w.$astroLib_SolarWind(sunDistance);
        var solarActivity = 10 * info.corona_flare;
    
        var output = "Catalog number: " + catNum + "\n"
    	                + "Spectral class: " + this.$spectrumText + "\n"
    	                + "Radius: " + this.$solRadius.toFixed(2) + "\n"
    	                + "Mass: " + this.$sunMass.toFixed(2) + "\n"
                        + "Luminosity: " + this.$solLuminosity.toFixed(2) + "\n"
    	                + "Solar activity: " + solarActivity.toFixed(2) + "\n"                    
                        + "Main planet period: " + this.$localYear.toFixed(2) + " days" + "\n"
    	                + "Sun distance: " + sunRelDistance.toFixed(2) + " R" + "\n"
    	                + "Solar wind flux: " + solarWind.toFixed(2) + " LY/min" + "\n\n";
        
        this.self.setMultiFunctionText("EQ_ADVANCED_SYSTEM_DATA_MFD", output, false);
    	}
    
    this.$planetPage = function()
        {
        var output = this.$planetOrbitInfo;
        this.self.setMultiFunctionText("EQ_ADVANCED_SYSTEM_DATA_MFD", output, false);
        }
    
    this.$setupSystemInfo = function()
        {
        var w = worldScripts.AstroLibrary;
        // sun info
    	var info = system.info;
    	var catNum = " " + galaxyNumber + " " + system.ID;
        if (system.info.sun_radius)
    		{
            var sunRadius = system.sun.radius;
    		}
        var spectrumText = w.$astroLib_sunSpectrum(sunRadius);
        var solRadius = system.sun.radius/950000 * (0.99 + 0.02 * system.scrambledPseudoRandomNumber(119));
        var sunMass = w.$astroLib_sunMass(sunRadius);
        var sunTemperature = w.$astroLib_sunTemperature(sunRadius);
        var sunLuminosity = w.$astroLib_sunLuminosity(sunTemperature,sunRadius);
        var solLuminosity = 1.31 * sunLuminosity; // use for display only, not in real calculations!
        var localYear = w.$astroLib_solPeriod(sunMass);
        this.$spectrumText = spectrumText;
        this.$solRadius = solRadius;
        this.$sunMass = sunMass;
        this.$solLuminosity = solLuminosity;
        this.$localYear = localYear;
        // planet info
        var infoFlag = 1;
        var planetMaxNumber = 8;
        var planetOrbitInfoRow = new Array();
        planetOrbitInfoRow[0] = "1.00 OU * Main Planet\n";
        for (let i=1; i<planetMaxNumber; i++)
            {
            planetOrbitInfoRow[i] = "";
            } 
        var planetOrbitRadius;
        var planetRadius;
        var planetDataTag;
        var planetOrbitScan = w.$astroLib_orbitRadius();
        var planetOrbitInfo = "PLANETS" + "\n";
        for (let i=0; i<system.planets.length; i++)
            {
            planetOrbitRadius = planetOrbitScan[i];
            planetRadius = system.planets[i].radius;
    
            if(system.planets[i].radius < 25000)     
                {
                planetDataTag = 0;
                }
            if(system.planets[i].radius >= 27500 && system.planets[i].radius < 30000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 1;
                } 
            if(system.planets[i].radius >= 50000 && system.planets[i].radius < 75000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 2;
                }
            if(system.planets[i].radius >= 30000 && system.planets[i].radius < 50000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 3;
                }
            if(system.planets[i].radius >= 75000 && system.planets[i].radius < 100000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 4;
                }
            if(system.planets[i].radius >= 150000 && system.planets[i].radius < 175000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 5;
                } 
            if(system.planets[i].radius >= 125000 && system.planets[i].radius < 150000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 6;
                } 
            if(system.planets[i].radius >= 100000 && system.planets[i].radius < 125000 && system.planets[i] != system.mainPlanet)
                {
                planetDataTag = 7;
                } 
            if(system.planets[i].radius >= 25000 && system.planets[i].radius < 27500 && system.planets[i] != system.mainPlanet)       
                {
                planetDataTag = 8;
                }
            
            switch (planetDataTag)
                {
                case 0: infoFlag = 0; break;
                case 1: planetOrbitInfoRow[1] = planetOrbitRadius.toFixed(2) + " OU * Miniterra\n"; break;
                case 2: planetOrbitInfoRow[2] = planetOrbitRadius.toFixed(2) + " OU * Terra\n"; break;
                case 3: planetOrbitInfoRow[3] = planetOrbitRadius.toFixed(2) + " OU * Subterra\n"; break;
                case 4: planetOrbitInfoRow[4] = planetOrbitRadius.toFixed(2) + " OU * Superterra\n"; break;
                case 5: planetOrbitInfoRow[5] = planetOrbitRadius.toFixed(2) + " OU * Gas Giant\n"; break;
                case 6: planetOrbitInfoRow[6] = planetOrbitRadius.toFixed(2) + " OU * Gas Giant\n"; break;
                case 7: planetOrbitInfoRow[7] = planetOrbitRadius.toFixed(2) + " OU * Ice Giant\n"; break;
                case 8: planetOrbitInfoRow[8] = planetOrbitRadius.toFixed(2) + " OU * Dwarf Terra\n"; break;
                }
            }
    
        for (let i=0; i<planetOrbitInfoRow.length; i++)
            {
            planetOrbitInfo += planetOrbitInfoRow[i];
            }
            this.$planetOrbitInfo = planetOrbitInfo;
        
        if(this.self.docked) this.$initInterface(this.self.dockedStation);
        }
    
    this.shipWillDockWithStation = this.shipWillEnterWitchspace = function()
    	{
        this.shipDied();
        }
    
    this.shipDied = function()
    	{
    	if(this.$scriptDelay) 
    		{
    		this.$scriptDelay.stop();
    		delete this.$scriptDelay;
    		}
        }
    
    this.shipDockedWithStation = function(station)
        {
        this.$setupSystemInfo();    
        if (this.self.dockedStation.isMainStation == true)
            {
            this.$initInterface(station);    
            }
        }
    
    this.$initInterface = function(station)
        {
    	station.setInterface(this.name,{
    		title:"System Data Sheet",
    		category:"Informational",
    		summary:"Provide advanced system data",
    		callback:this.$setupSystemInfoPage.bind(this)
            });
        }
    
    this.$setupSystemInfoPage = function()
        {
        var systemAdvancedInfo = "SUN" + "\n"
    	                + "Spectral class: " + this.$spectrumText + "\n"
    	                + "Radius: " + this.$solRadius.toFixed(2) + "\n"
    	                + "Mass: " + this.$sunMass.toFixed(2) + "\n"
                        + "Luminosity: " + this.$solLuminosity.toFixed(2) + "\n"                   
                        + "Main planet period: " + this.$localYear.toFixed(2) + " days" + "\n"
                        + "\n"
                        + this.$planetOrbitInfo;
    
        mission.runScreen({
            title: "System Data Sheet",
    //        background: {name: "specialCargoLoad.png", height: 480 },
            message: systemAdvancedInfo,}
            );     
        }
    Scripts/spectral_class.js
    "use strict";
    this.name    = "SunSpectralAnalyzer";
    this.author = "Stranger";
    this.copyright = "This work is hereby placed in the public domain.";
    this.description = "Conversion sun color to spectral index";
    this.version = "3.9";
    
    //This script inspired and partly based on Wildblood's Spectroscope script
    
    this.guiScreenChanged = function()
    	{
    	if (guiScreen === "GUI_SCREEN_SYSTEM_DATA")
    		{
    		var info = System.infoForSystem(galaxyNumber, player.ship.targetSystem);
    		if (info.sun_gone_nova) return;
    		var w = worldScripts.AstroLibrary;
    		var name = info.name;
    		var sunName = info.sun_name;
            var sunRadius = info.sun_radius; 
    		var spectrumText = w.$astroLib_sunSpectrum(sunRadius);
    		if (spectrumText && sunName) mission.addMessageText("The planet " + name + " orbits the " + spectrumText + " " + sunName + ".");
    		else if (spectrumText) mission.addMessageText("The planet " + name + " orbits a " + spectrumText + " " + "star.");
    		else if (sunName) mission.addMessageText("The planet " + name + " orbits the star " + sunName + ".");
    		}
    	}