Exemple #1
0
        public void ClearCut()
        {
            disturbance.Damage = disturbance.ClearCut;
            SiteCohorts siteCohorts = initialSiteCohorts.Clone();

            ((Landis.AgeCohort.ISiteCohorts)siteCohorts).DamageBy(disturbance);

            CheckCohorts(siteCohorts[abiebals]);
            CheckCohorts(siteCohorts[betualle]);

            CheckDeadCohorts(abiebals, 30, 40, 50, 150, 170);
            CheckDeadCohorts(betualle, 100, 120, 280, 300);

            Assert.AreEqual(initialSiteCohorts.TotalBiomass - deadCohortsBiomass,
                            siteCohorts.TotalBiomass);
        }
        public void Clone()
        {
            SiteCohorts  cohorts        = new SiteCohorts();
            const ushort initialBiomass = 55;

            cohorts.AddNewCohort(abiebals, initialBiomass);

            mockCalculator.CountCalled = 0;
            mockCalculator.Change      = 1;

            for (int time = successionTimestep; time <= 70; time += successionTimestep)
            {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
                if (time % 20 == 0)
                {
                    cohorts.AddNewCohort(abiebals, initialBiomass);
                }
                if (time % 30 == 0)
                {
                    cohorts.AddNewCohort(betualle, initialBiomass);
                }
            }

            //  Expected cohort changes:
            //
            //  Time  Cohorts
            //  ----  -------
            //    0   abiebals 1(55)
            //   10   abiebals 10(65)
            //   20   abiebals 20(75) 1(55)
            //   30   abiebals 30(85) 10(65)
            //        betualle 1(55)
            //   40   abiebals 40(95) 20(75) 1(55)
            //        betualle 10(65)
            //   50   abiebals 50(105) 30(85) 10(65)
            //        betualle 20(75)
            //   60   abiebals 60(115) 40(95) 20(75) 1(55)
            //        betualle 30(85) 1(55)
            //   70   abiebals 70(125) 50(105) 30(85) 10(65)
            //        betualle 40(95) 10(65)
            expectedCohorts.Clear();
            expectedCohorts[abiebals] = new ushort[] {
                //  age  biomass
                70, 125,
                50, 105,
                30, 85,
                10, 65
            };
            expectedCohorts[betualle] = new ushort[] {
                //  age  biomass
                40, 95,
                10, 65
            };
            Util.CheckCohorts(expectedCohorts, cohorts);

            SiteCohorts clone = cohorts.Clone();

            Util.CheckCohorts(expectedCohorts, clone);

            //  Modify the original set of cohorts by growing them for 2 more
            //  succession timesteps.  Check that clone doesn't change.
            for (int time = 80; time <= 90; time += successionTimestep)
            {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
            }
            Util.CheckCohorts(expectedCohorts, clone);

            expectedCohorts.Clear();
            expectedCohorts[abiebals] = new ushort[] {
                //  age  biomass
                90, 145,
                70, 125,
                50, 105,
                30, 85
            };
            expectedCohorts[betualle] = new ushort[] {
                //  age  biomass
                60, 115,
                30, 85
            };
            Util.CheckCohorts(expectedCohorts, cohorts);
        }
        public void Clone()
        {
            SiteCohorts cohorts = new SiteCohorts();
            const ushort initialBiomass = 55;
            cohorts.AddNewCohort(abiebals, initialBiomass);

            mockCalculator.CountCalled = 0;
            mockCalculator.Change = 1;

            for (int time = successionTimestep; time <= 70; time += successionTimestep) {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
                if (time % 20 == 0)
                    cohorts.AddNewCohort(abiebals, initialBiomass);
                if (time % 30 == 0)
                    cohorts.AddNewCohort(betualle, initialBiomass);
            }

            //  Expected cohort changes:
            //
            //  Time  Cohorts
            //  ----  -------
            //    0   abiebals 1(55)
            //   10   abiebals 10(65)
            //   20   abiebals 20(75) 1(55)
            //   30   abiebals 30(85) 10(65)
            //        betualle 1(55)
            //   40   abiebals 40(95) 20(75) 1(55)
            //        betualle 10(65)
            //   50   abiebals 50(105) 30(85) 10(65)
            //        betualle 20(75)
            //   60   abiebals 60(115) 40(95) 20(75) 1(55)
            //        betualle 30(85) 1(55)
            //   70   abiebals 70(125) 50(105) 30(85) 10(65)
            //        betualle 40(95) 10(65)
            expectedCohorts.Clear();
		    expectedCohorts[abiebals] = new ushort[] {
		        //  age  biomass
		            70,    125,
		            50,    105,
		            30,     85,
		            10,     65
		    };
		    expectedCohorts[betualle] = new ushort[] {
		        //  age  biomass
		            40,     95,
		            10,     65
		    };
		    Util.CheckCohorts(expectedCohorts, cohorts);

		    SiteCohorts clone = cohorts.Clone();
		    Util.CheckCohorts(expectedCohorts, clone);

		    //  Modify the original set of cohorts by growing them for 2 more
		    //  succession timesteps.  Check that clone doesn't change.
            for (int time = 80; time <= 90; time += successionTimestep) {
                Util.Grow(cohorts, successionTimestep, activeSite, true);
		    }
		    Util.CheckCohorts(expectedCohorts, clone);

            expectedCohorts.Clear();
		    expectedCohorts[abiebals] = new ushort[] {
		        //  age  biomass
		            90,    145,
		            70,    125,
		            50,    105,
		            30,     85
		    };
		    expectedCohorts[betualle] = new ushort[] {
		        //  age  biomass
		            60,    115,
		            30,     85
		    };
		    Util.CheckCohorts(expectedCohorts, cohorts);
        }