Exemplo n.º 1
0
        // Constructor function
        public FireEvent(ActiveSite initiationSite, int day, IgnitionType ignitionType)
        {
            this.initiationSite = initiationSite;
            this.IgnitionDay    = day;
            this.IgnitionType   = ignitionType;
            IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[initiationSite];

            int actualYear = (PlugIn.ModelCore.CurrentTime - 1) + Climate.Future_DailyData.First().Key;

            this.annualWeatherData             = Climate.Future_DailyData[actualYear][ecoregion.Index];
            SiteVars.Disturbed[initiationSite] = true;

            this.CohortsKilled              = 0;
            this.AvailableCohorts           = 0;
            this.TotalSitesSpread           = 0;
            this.TotalSitesBurned           = 0;
            this.InitiationFireWeatherIndex = annualWeatherData.DailyFireWeatherIndex[day];
            this.NumberOfDays = 1;
            //this.MeanIntensity = 0.0;
            this.MeanPET                = 0.0;
            this.MeanWD                 = 0.0;
            this.MeanClay               = 0.0;
            this.MeanFineFuels          = 0.0;
            this.MeanLadderFuels        = 0.0;
            this.MeanWindDirection      = 0.0;
            this.MeanWindSpeed          = 0.0;
            this.MeanEffectiveWindSpeed = 0.0;
            this.MeanSpreadProbability  = 0.0;
            this.MeanDNBR               = 0.0;
            this.MeanSuppression        = 0.0;
            this.MeanFWI                = 0.0;
            this.TotalBiomassMortality  = 0.0;
            this.currentSite            = initiationSite;
            this.maxDay                 = day;
        }
Exemplo n.º 2
0
        protected void SetBodyEngineObject(IVehicle vehicleObj, string vehicleType)
        {
            IgnitionType eIgnitionType = IgnitionType.None;

            Enum.TryParse(vehicleType, out eIgnitionType);
            var bodyObj    = vehicleObj.GetVehicleBody(BodyType.None);
            var engineType = vehicleObj.GetVehicleEngine(bodyObj, eIgnitionType);

            VehicleObject = vehicleObj;
            AutoBody      = bodyObj;
            EngineType    = engineType;
        }
Exemplo n.º 3
0
        //---------------------------------------------------------------------
        // Ignites and Spreads a fire
        private static bool Ignite(IgnitionType ignitionType, ActiveSite site, int day, double fireWeatherIndex)
        {
            if (SiteVars.Disturbed[site])
            {
                return(false);
            }
            FireEvent fireEvent = FireEvent.Initiate(site, modelCore.CurrentTime, day, ignitionType);

            totalBurnedSites[(int)ignitionType] += fireEvent.TotalSitesBurned;
            numberOfFire[(int)ignitionType]++;
            totalBiomassMortality[(int)ignitionType] += (int)fireEvent.TotalBiomassMortality;
            dNBR[(int)ignitionType] += (int)fireEvent.SiteMortality;

            return(true);
        }
Exemplo n.º 4
0
        public IAutoEngine GetVehicleEngine(IAutoBody vehicleBody, IgnitionType ignitionType)
        {
            IAutoEngine engine = new ConcreteAutoEngine()
            {
                AutoEngineType = ignitionType, CylinderCount = 4, HorsePower = 100
            };

            if (vehicleBody != null && vehicleBody.AutoBodyType == BodyType.Truck)
            {
                engine.Description = "Truck Engine created.";
            }
            else
            {
                engine.Description = $"No Engine created as body type is {(vehicleBody == null ? BodyType.None : vehicleBody.AutoBodyType)}.";
            }
            return(engine);
        }
Exemplo n.º 5
0
        //---------------------------------------------------------------------
        public static FireEvent Initiate(ActiveSite initiationSite, int timestep, int day, IgnitionType ignitionType)
        {
            //PlugIn.ModelCore.UI.WriteLine("  Fire Event initiated.  Day = {0}, IgnitionType = {1}.", day, ignitionType);

            if (isDebugEnabled)
            {
                PlugIn.ModelCore.UI.WriteLine("   Fire event started at {0} ...", initiationSite.Location);
            }

            FireEvent fireEvent = new FireEvent(initiationSite, day, ignitionType);

            PlugIn.EventID++;

            ActiveSite[] initialSites = new ActiveSite[2];
            initialSites[0] = (ActiveSite)initiationSite;
            initialSites[1] = (ActiveSite)initiationSite;

            fireSites = new List <ActiveSite[]>();
            fireSites.Add(initialSites);

            // desitination and source are the same for ignition site
            fireEvent.Spread(PlugIn.ModelCore.CurrentTime, day);

            LogEvent(PlugIn.ModelCore.CurrentTime, fireEvent, PlugIn.EventID);

            return(fireEvent);
        }
Exemplo n.º 6
0
        //---------------------------------------------------------------------

        //  Determines the number of Ignitions per day
        //  Returns: 0 <= numIgnitons <= 3
        private static int NumberOfIgnitions(IgnitionType ignitionType, double fireWeatherIndex)
        {
            double b0 = 0.0;
            double b1 = 0.0;

            if (ignitionType == IgnitionType.Lightning)
            {
                b0 = Parameters.LightningIgnitionB0;
                b1 = Parameters.LightningIgnitionB1;
            }
            if (ignitionType == IgnitionType.Accidental)
            {
                b0 = Parameters.AccidentalFireIgnitionB0;
                b1 = Parameters.AccidentalFireIgnitionB1;
            }

            int numIgnitions = 0;

            if (IgnitionDist == IgnitionDistribution.Poisson)
            {
                //Draw from a poisson distribution  with lambda equal to the log link (b0 +b0 *fireweather )
                double possibleIgnitions = ModelCore.PoissonDistribution.Lambda = Math.Pow(Math.E, (b0 + (b1 * fireWeatherIndex)));
                // Because the Core Poisson Distribution Lambda returns the population mean we transform it to the whole number + the probability of the remainder to get
                // a integer as the response.
                // Whole Number
                int floorPossibleIginitions = (int)Math.Floor(possibleIgnitions);
                numIgnitions += floorPossibleIginitions;
                // Remainder
                numIgnitions += (modelCore.GenerateUniform() <= (possibleIgnitions - (double)floorPossibleIginitions) ? 1 : 0);
                //modelCore.UI.WriteLine("   Processing landscape for Fire events.  Possible={0}, Rounded={1}", possibleIgnitions, numIgnitions);
            }
            else
            {
                // Zero Inflated: Requires two additional variables
                double binomb0 = 0.0;
                double binomb1 = 0.0;

                if (ignitionType == IgnitionType.Lightning)
                {
                    binomb0 = Parameters.LightningIgnitionBinomialB0;
                    binomb1 = Parameters.LightningIgnitionBinomialB1;
                }
                if (ignitionType == IgnitionType.Accidental)
                {
                    binomb0 = Parameters.AccidentalFireIgnitionBinomialB0;
                    binomb1 = Parameters.AccidentalFireIgnitionBinomialB1;
                }
                /// The Binomial portion of the draw:
                /// Probability of a zero is caculated then a random draw is checked agianst this
                /// If greater than the probability of zero the Poisson section is used.
                double BinomDraw = modelCore.NextDouble();
                /// alpha= reverse logit link of the regression values and FWI
                double alpha     = Math.Pow(Math.E, (binomb0 + (binomb1 * fireWeatherIndex)));
                double zerosprob = alpha / (alpha + 1);
                if (BinomDraw >= zerosprob)
                {
                    /// If yes the mean of possion draw with reverse log link of regression variables.
                    double possibleIgnitions = ModelCore.PoissonDistribution.Lambda = Math.Pow(Math.E, (b0 + (b1 * fireWeatherIndex)));
                    ///Because the the Core Poisson Distribution Lambda returns the population mean we transform it to the whole number + the probability of the remainder to get
                    /// a integer as the response.
                    ///
                    /// Whole Number
                    int floorPossibleIginitions = (int)Math.Floor(possibleIgnitions);
                    numIgnitions += floorPossibleIginitions;
                    /// Remainder
                    numIgnitions += (modelCore.GenerateUniform() <= (possibleIgnitions - (double)floorPossibleIginitions) ? 1 : 0);
                }
                else
                {
                    numIgnitions = 0;
                }
            }
            return(numIgnitions);
        }