// ctor Radiation() { // enable global access instance = this; // keep it alive DontDestroyOnLoad(this); // compute magnetosphere of bodies CelestialBody home = FlightGlobals.GetHomeBody(); double home_surfspeed = Sim.SurfaceSpeed(home); double home_surfgrav = Sim.SurfaceGravity(home); foreach (CelestialBody body in FlightGlobals.Bodies) { // skip the sun if (body.flightGlobalsIndex == 0) { continue; } // get body parameters and normalize them against home body double surfspeed = Sim.SurfaceSpeed(body); double surfgrav = Sim.SurfaceGravity(body); double norm_radius = body.Radius / home.Radius; double norm_surfspeed = surfspeed / home_surfspeed; double norm_surfgrav = surfgrav / home_surfgrav; // store magnetosphere info body_info info = new body_info(); // deduce magnetic strength from body parameters info.dynamo = norm_radius * norm_surfspeed * norm_surfgrav / (Math.Min(norm_radius, Math.Min(norm_surfspeed, norm_surfgrav))); // deduce magnetopause from body parameters // - if magnetic strength is below a threshold, there is no magnetosphere // - magnetopause has to be higher than double the atmosphere (if any) // - magnetopause has to be higher than 1/2 radii info.magn_altitude = info.dynamo > 0.0666 ? Math.Max(surfspeed * 33.33 * norm_surfgrav * 1000.0, Math.Max(body.atmosphereDepth * 2.0, body.Radius * 0.5)) : 0.0; // deduce radiation belt // - if magnetic strength is below a threshold, there is no belt // - if magnetopause is lower than 2 radii, there is no belt info.belt_altitude = info.dynamo > 0.1888 && info.magn_altitude > body.Radius * 2.0 ? body.Radius : 0.0; // add magnetosphere info to the cache bodies.Add(body.flightGlobalsIndex, info); } }