//--------------------------------------------------------------------- /// <summary> /// Grows the cohorts during spin-up /// Makes the set of biomass cohorts at a site based on the age cohorts /// at the site, using a specified method for computing a cohort's /// initial biomass. /// </summary> /// <param name="ageCohorts"> /// A sorted list of age cohorts, from oldest to youngest. /// </param> /// <param name="site"> /// Site where cohorts are located. /// </param> /// <param name="initialBiomassMethod"> /// The method for computing the initial biomass for a new cohort. /// </param> public static ISiteCohorts MakeBiomassCohorts(List <Landis.Library.AgeOnlyCohorts.ICohort> ageCohorts, ActiveSite site, ComputeMethod initialBiomassMethod) { IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[site]; //if (Climate.Spinup_AllData.Count >= ageCohorts[0].Age) //try //{ //PlugIn.ModelCore.UI.WriteLine("Making Biomass Cohorts using spin-up climate data"); SiteVars.Cohorts[site] = new Library.LeafBiomassCohorts.SiteCohorts(); if (ageCohorts.Count == 0) { return(SiteVars.Cohorts[site]); } int indexNextAgeCohort = 0; // The index in the list of sorted age cohorts of the next // cohort to be considered // Loop through time from -N to 0 where N is the oldest cohort. // So we're going from the time when the oldest cohort was "born" // to the present time (= 0). Because the age of any age cohort // is a multiple of the succession timestep, we go from -N to 0 // by that timestep. NOTE: the case where timestep = 1 requires // special treatment because if we start at time = -N with a // cohort with age = 1, then at time = 0, its age will N+1 not N. // Therefore, when timestep = 1, the ending time is -1. //int endTime = (successionTimestep == 1) ? -1 : -1; //PlugIn.ModelCore.UI.WriteLine(" Ageing initial cohorts. Oldest cohorts={0} yrs, succession timestep={1}, endTime={2}.", ageCohorts[0].Age, successionTimestep, endTime); for (int time = -(ageCohorts[0].Age); time <= -1; time += successionTimestep) { //PlugIn.ModelCore.UI.WriteLine(" Ageing initial cohorts. Oldest cohorts={0} yrs, succession timestep={1}.", ageCohorts[0].Age, successionTimestep); EcoregionData.SetSingleAnnualClimate(ecoregion, time + ageCohorts[0].Age, Climate.Phase.SpinUp_Climate); //the spinup climate array is sorted from oldest to newest years // Add those cohorts that were born at the current year while (indexNextAgeCohort < ageCohorts.Count && ageCohorts[indexNextAgeCohort].Age == -time) { ISpecies species = ageCohorts[indexNextAgeCohort].Species; float[] initialBiomass = initialBiomassMethod(species, SiteVars.Cohorts[site], site); SiteVars.Cohorts[site].AddNewCohort(ageCohorts[indexNextAgeCohort].Species, 1, initialBiomass[0], initialBiomass[1]); indexNextAgeCohort++; } Main.Run(site, successionTimestep, true); } return(SiteVars.Cohorts[site]); }
//--------------------------------------------------------------------- public override void Initialize() { PlugIn.ModelCore.UI.WriteLine("Initializing {0} ...", ExtensionName); Timestep = parameters.Timestep; SuccessionTimeStep = Timestep; sufficientLight = parameters.LightClassProbabilities; ProbEstablishAdjust = parameters.ProbEstablishAdjustment; MetadataHandler.InitializeMetadata(Timestep, modelCore, SoilCarbonMapNames, SoilNitrogenMapNames, ANPPMapNames, ANEEMapNames, TotalCMapNames); CohortBiomass.SpinupMortalityFraction = parameters.SpinupMortalityFraction; //Initialize climate. Climate.Initialize(parameters.ClimateConfigFile, false, modelCore); FutureClimateBaseYear = Climate.Future_MonthlyData.Keys.Min(); EcoregionData.Initialize(parameters); SpeciesData.Initialize(parameters); EcoregionData.ChangeParameters(parameters); OtherData.Initialize(parameters); FunctionalType.Initialize(parameters); // Cohorts must be created before the base class is initialized // because the base class' reproduction module uses the core's // SuccessionCohorts property in its Initialization method. Library.LeafBiomassCohorts.Cohorts.Initialize(Timestep, new CohortBiomass()); // Initialize Reproduction routines: Reproduction.SufficientResources = SufficientLight; Reproduction.Establish = Establish; Reproduction.AddNewCohort = AddNewCohort; Reproduction.MaturePresent = MaturePresent; base.Initialize(modelCore, parameters.SeedAlgorithm); InitialBiomass.Initialize(Timestep); Landis.Library.BiomassCohorts.Cohort.DeathEvent += CohortDied; Landis.Library.LeafBiomassCohorts.Cohort.PartialDeathEvent += CohortPartialMortality; AgeOnlyDisturbances.Module.Initialize(parameters.AgeOnlyDisturbanceParms); Dynamic.Module.Initialize(parameters.DynamicUpdates); FireEffects.Initialize(parameters); InitializeSites(parameters.InitialCommunities, parameters.InitialCommunitiesMap, modelCore); //the spinup is heppend within this fucntion if (parameters.CalibrateMode) { Outputs.CreateCalibrateLogFile(); } Outputs.WritePrimaryLogFile(0); Outputs.WriteShortPrimaryLogFile(0); }