Exemple #1
0
        // return belt radiation hitting the vessel, in rad/s
        public static double BeltRadiation(Vessel v)
        {
            if (v.mainBody.flightGlobalsIndex == 0)
            {
                return(0.0);
            }
            body_info info          = instance.bodies[v.mainBody.flightGlobalsIndex];
            double    belt_altitude = info.belt_altitude;
            double    dynamo        = info.dynamo;
            double    belt_k        = belt_altitude > double.Epsilon ? 1.0 - Math.Min(Math.Abs(v.altitude - belt_altitude) / (belt_altitude * Settings.BeltFalloff), 1.0) : 0.0;

            return(Settings.BeltRadiation * dynamo * belt_k);
        }
Exemple #2
0
        // 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);
            }
        }