//--------------------------------------------------------------------- public static int GenerateWindDirection(IWindDirectionParameters windDir) { double randNum = Util.Random.GenerateUniform(); int primeWindDirection = 0; double bottom = 0.0; double top = 0.0; for (int i = 0; i <= 7; i++) { top += windDir.WindDirections[i]; if(randNum >= bottom && randNum <= top) { primeWindDirection = i * 45; //45 degrees per slice break; } bottom += windDir.WindDirections[i]; } //Next, randomize around cardinal direction: int wiggle = (int) ((Util.Random.GenerateUniform() * 45.0) - 22.5); //return primeWindDirection + wiggle; return primeWindDirection; }
//--------------------------------------------------------------------- public static Event Initiate(ActiveSite site, int timestep, SizeType fireSizeType, bool bui, ISeasonParameters[] seasons, IWindDirectionParameters[] windDirs) { //Adjust ignition probability (measured on an annual basis) for the //user determined fire time step. int fuelIndex = SiteVars.CFSFuelType[site]; //-----Edited by BRM----- //double initProb = fuelTypeParms[fuelIndex].InitiationProbability * timestep; double initProb = fuelTypeParms[fuelIndex].InitiationProbability; //--------- //The initial site must exceed the probability of initiation and //have a severity > 0 and exceed the ignition threshold: if (Util.Random.GenerateUniform() <= initProb) { Event FireEvent = new Event(site, seasons, windDirs); if(!FireEvent.Spread(site, fireSizeType, bui)) return null; else return FireEvent; } return null; }
//--------------------------------------------------------------------- public Parameters(int timestep, SizeType fireSizeType, bool buildUpIndex, ISeasonParameters[] seasonParameters, IWindDirectionParameters[] windDirectionParameters, IFuelTypeParameters[] fuelTypeParameters, IDamageTable[] damages, string mapNameTemplate, string logFileName, string summaryLogFileName) { this.timestep = timestep; this.fireSizeType = fireSizeType; this.buildUpIndex = buildUpIndex; this.seasonParameters = seasonParameters; this.windDirectionParameters = windDirectionParameters; this.fuelTypeParameters = fuelTypeParameters; this.damages = damages; this.mapNamesTemplate = mapNameTemplate; this.logFileName = logFileName; this.summaryLogFileName = summaryLogFileName; }
//--------------------------------------------------------------------- private Event(ActiveSite initiationSite, ISeasonParameters[] seasons, IWindDirectionParameters[] windDirs) { this.initiationSite = initiationSite; this.sitesInEvent = new int[Ecoregions.Dataset.Count]; foreach(IEcoregion ecoregion in Ecoregions.Dataset) this.sitesInEvent[ecoregion.Index] = 0; this.cohortsKilled = 0; this.eventSeverity = 0; this.totalSitesDamaged = 0; this.lengthB = 0.0; this.lengthA = 0.0; this.lengthD = 0.0; this.fireSeason = Weather.GenerateSeason(seasons); this.windSpeed = Weather.GenerateWindSpeed(this.fireSeason); this.fineFuelMoistureCode = Weather.GenerateFineFuelMoistureCode(this.fireSeason); this.buildUpIndex = Weather.GenerateBuildUpIndex(this.fireSeason); IWindDirectionParameters windDir = windDirs[(int) this.fireSeason.NameOfSeason]; this.windDirection = Weather.GenerateWindDirection(windDir); }