Esempio n. 1
0
    public void OnEndCrop()
    {
        NewCropType Crop = new NewCropType();

        Crop.crop_type = CropType;
        Crop.sender    = Name;
        if (CropEnding != null)
        {
            CropEnding.Invoke(Crop);
        }

        // Keep track of some variables for reporting.
        Biomass AboveGroundBiomass = new Biomass(AboveGround);
        Biomass BelowGroundBiomass = new Biomass(BelowGround);

        // Call each organ's OnHarvest. They fill a BiomassRemoved structure. We then publish a
        // BiomassRemoved event.
        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.OnEndCrop(BiomassRemovedData);
        }
        BiomassRemovedData.crop_type = CropType;
        BiomassRemoved.Invoke(BiomassRemovedData);

        Console.WriteLine("    Organic matter from crop:-      Tops to surface residue      Roots to soil FOM");
        Console.WriteLine(string.Format("                      DM (kg/ha) = {0,21:F1}{1,24:F1}",
                                        AboveGroundBiomass.Wt, BelowGroundBiomass.Wt));
        Console.WriteLine(string.Format("                      N  (kg/ha) = {0,22:F2}{1,24:F2}",
                                        AboveGroundBiomass.N, BelowGroundBiomass.N));
        //Console.WriteLine(string.Format("                      P  (kg/ha) = {0,22:F2}{1,24:F2}",
        //                                AboveGroundBiomass.P, BelowGroundBiomass.P));
    }
Esempio n. 2
0
    private void DoBiomassRemoved()
    {
        List <Biomass> Detaching  = new List <Biomass>();
        List <string>  OrganNames = new List <string>();

        foreach (Organ1 Organ in Organ1s)
        {
            if (Organ is AboveGround && !Organ.Detaching.IsEmpty)
            {
                Detaching.Add(Organ.Detaching);
                OrganNames.Add(Organ.Name);
            }
        }
        BiomassRemovedType chopped = new BiomassRemovedType();

        chopped.crop_type           = CropType;
        chopped.dm_type             = new string[Detaching.Count];
        chopped.dlt_crop_dm         = new float[Detaching.Count];
        chopped.dlt_dm_n            = new float[Detaching.Count];
        chopped.dlt_dm_p            = new float[Detaching.Count];
        chopped.fraction_to_residue = new float[Detaching.Count];

        for (int i = 0; i < Detaching.Count; i++)
        {
            chopped.dm_type[i]     = OrganNames[i];
            chopped.dlt_crop_dm[i] = (float)Detaching[i].Wt;
            chopped.dlt_dm_n[i]    = (float)Detaching[i].N;
            //chopped.dlt_dm_p[i] = (float) Detaching[i].P;
            chopped.fraction_to_residue[i] = 1.0f;
        }
        BiomassRemoved.Invoke(chopped);
    }
Esempio n. 3
0
        private void OnDoPlantGrowth(object sender, EventArgs e)
        {
            DoWaterBalance();
            DoGrowth();
            DoNBalance();

            // Now add today's growth to the soil - ie assume plants are in steady state.
            BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

            BiomassRemovedData.crop_type = Crop_Type;
            BiomassRemovedData.dm_type   = new string[1] {
                "litter"
            };
            BiomassRemovedData.dlt_crop_dm = new float[1] {
                (float)(DltDM * 10)
            };
            BiomassRemovedData.dlt_dm_n = new float[1] {
                (float)(NFixation + MathUtilities.Sum(NUptake))
            };
            BiomassRemovedData.dlt_dm_p = new float[1] {
                0
            };
            BiomassRemovedData.fraction_to_residue = new float[1] {
                1
            };
            BiomassRemoved.Invoke(BiomassRemovedData);
        }
Esempio n. 4
0
    private void DoUnderstory()
    {
        DoUnderstoryWaterBalance();
        DoUnderstoryGrowth();
        DoUnderstoryNBalance();

        // Now add today's growth to the soil - ie assume plants are in steady state.
        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        BiomassRemovedData.crop_type = "OilPalmUnderstory";
        BiomassRemovedData.dm_type   = new string[1] {
            "litter"
        };
        BiomassRemovedData.dlt_crop_dm = new float[1] {
            (float)(UnderstoryDltDM * 10)
        };
        BiomassRemovedData.dlt_dm_n = new float[1] {
            (float)(UnderstoryNFixation + MathUtility.Sum(UnderstoryNUptake))
        };
        BiomassRemovedData.dlt_dm_p = new float[1] {
            0
        };
        BiomassRemovedData.fraction_to_residue = new float[1] {
            1
        };
        BiomassRemoved.Invoke(BiomassRemovedData);
    }
        /// <summary>Add dung to the soil surface.</summary>
        private void AddDungToSurface()
        {
            var SOMData = new BiomassRemovedType();

            SOMData.crop_type           = "RuminantDung_PastureFed";
            SOMData.dm_type             = new string[] { SOMData.crop_type };
            SOMData.dlt_crop_dm         = new float[] { (float)AmountDungCReturned };
            SOMData.dlt_dm_n            = new float[] { (float)AmountDungNReturned };
            SOMData.dlt_dm_p            = new float[] { 0.0F };
            SOMData.fraction_to_residue = new float[] { 1.0F };
            BiomassRemoved.Invoke(SOMData);
        }
Esempio n. 6
0
    public void OnHarvest(HarvestType Harvest)
    {
        WriteHarvestReport();

        // Tell the rest of the system we are about to harvest
        if (Harvesting != null)
        {
            Harvesting.Invoke();
        }

        // Check some bounds
        if (Harvest.Remove < 0 || Harvest.Remove > 1.0)
        {
            throw new Exception("Harvest remove fraction needs to be between 0 and 1");
        }
        if (Harvest.Height < 0 || Harvest.Height > 1000.0)
        {
            throw new Exception("Harvest height needs to be between 0 and 1000");
        }

        // Set the population denisty if one was provided by user.
        if (Harvest.Plants != 0)
        {
            Population.Density = Harvest.Plants;
        }

        // Call each organ's OnHarvest. They fill a BiomassRemoved structure. We then publish a
        // BiomassRemoved event.
        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.OnHarvest(Harvest, BiomassRemovedData);
        }
        BiomassRemovedData.crop_type = CropType;
        BiomassRemoved.Invoke(BiomassRemovedData);
        WriteBiomassRemovedReport(BiomassRemovedData);

        // now update new canopy covers
        PlantSpatial.Density     = Population.Density;
        PlantSpatial.CanopyWidth = Leaf.width;
        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoCover();
        }
        UpdateCanopy();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNConccentrationLimits();
        }
    }
Esempio n. 7
0
    public void OnEndCrop()
    {
        NewCropType Crop = new NewCropType();

        Crop.crop_type = CropType;
        Crop.sender    = Name;
        if (CropEnding != null)
        {
            CropEnding.Invoke(Crop);
        }

        BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

        BiomassRemovedData.crop_type           = CropType;
        BiomassRemovedData.dm_type             = new string[Organs.Count];
        BiomassRemovedData.dlt_crop_dm         = new float[Organs.Count];
        BiomassRemovedData.dlt_dm_n            = new float[Organs.Count];
        BiomassRemovedData.dlt_dm_p            = new float[Organs.Count];
        BiomassRemovedData.fraction_to_residue = new float[Organs.Count];
        int i = 0;

        foreach (Organ O in Organs)
        {
            if (O is AboveGround)
            {
                BiomassRemovedData.dm_type[i]             = O.Name;
                BiomassRemovedData.dlt_crop_dm[i]         = (float)(O.Live.Wt + O.Dead.Wt) * 10f;
                BiomassRemovedData.dlt_dm_n[i]            = (float)(O.Live.N + O.Dead.N) * 10f;
                BiomassRemovedData.dlt_dm_p[i]            = 0f;
                BiomassRemovedData.fraction_to_residue[i] = 1f;
            }
            else
            {
                BiomassRemovedData.dm_type[i]             = O.Name;
                BiomassRemovedData.dlt_crop_dm[i]         = 0f;
                BiomassRemovedData.dlt_dm_n[i]            = 0f;
                BiomassRemovedData.dlt_dm_p[i]            = 0f;
                BiomassRemovedData.fraction_to_residue[i] = 0f;
            }
            i++;
        }
        BiomassRemoved.Invoke(BiomassRemovedData);

        // tell all our children about sow
        foreach (Organ Child in Organs)
        {
            Child.OnEndCrop();
        }
    }
Esempio n. 8
0
    virtual public void DoActualGrowth(double TT)
    {
        if (IsAppeared)
        {
            //Acellerate thermal time accumulation if crop is water stressed.
            double _ThermalTime;
            if ((DroughtInducedSenAcceleration != null) && (IsFullyExpanded))
            {
                _ThermalTime = TT * DroughtInducedSenAcceleration.Value;
            }
            else
            {
                _ThermalTime = TT;
            }

            //Growing leaf area after DM allocated
            double DeltaCarbonConstrainedArea = (StructuralDMAllocation + MetabolicDMAllocation) * SpecificLeafAreaMax; //Fixme.  Live.Nonstructural should probably be included in DM supply for leaf growth also
            double DeltaActualArea            = Math.Min(DeltaWaterConstrainedArea, DeltaCarbonConstrainedArea);
            LiveArea += DeltaActualArea;                                                                                /// Integrates leaf area at each cohort? FIXME-EIT is this the one integrated at leaf.cs?

            //Senessing leaf area
            double AreaSenescing  = LiveArea * SenescedFrac;
            double AreaSenescingN = 0;
            if ((Live.MetabolicNConc <= MinimumNConc) & ((MetabolicNRetranslocated - MetabolicNAllocation) > 0.0))
            {
                AreaSenescingN = LeafStartArea * (MetabolicNRetranslocated - MetabolicNAllocation) / LiveStart.MetabolicN;
            }

            double LeafAreaLoss = Math.Max(AreaSenescing, AreaSenescingN);
            if (LeafAreaLoss > 0)
            {
                SenescedFrac = Math.Min(1.0, LeafAreaLoss / LeafStartArea);
            }


            /* RFZ why variation between using LiveStart and Live
             * double StructuralWtSenescing = SenescedFrac * Live.StructuralWt;
             * double StructuralNSenescing = SenescedFrac * Live.StructuralN;
             * double MetabolicWtSenescing = SenescedFrac * Live.MetabolicWt;
             * double MetabolicNSenescing = SenescedFrac * LiveStart.MetabolicN;
             * double NonStructuralWtSenescing = SenescedFrac * Live.NonStructuralWt;
             * double NonStructuralNSenescing = SenescedFrac * LiveStart.NonStructuralN;
             */


            double StructuralWtSenescing    = SenescedFrac * LiveStart.StructuralWt;
            double StructuralNSenescing     = SenescedFrac * LiveStart.StructuralN;
            double MetabolicWtSenescing     = SenescedFrac * LiveStart.MetabolicWt;
            double MetabolicNSenescing      = SenescedFrac * LiveStart.MetabolicN;
            double NonStructuralWtSenescing = SenescedFrac * LiveStart.NonStructuralWt;
            double NonStructuralNSenescing  = SenescedFrac * LiveStart.NonStructuralN;

            DeadArea = DeadArea + LeafAreaLoss;
            LiveArea = LiveArea - LeafAreaLoss; // Final leaf area of cohort that will be integrated in Leaf.cs? (FIXME-EIT)

            Live.StructuralWt -= StructuralWtSenescing;
            Dead.StructuralWt += StructuralWtSenescing;

            Live.StructuralN -= StructuralNSenescing;
            Dead.StructuralN += StructuralNSenescing;

            Live.MetabolicWt -= Math.Max(0.0, MetabolicWtSenescing - MetabolicWtReallocated);
            Dead.MetabolicWt += Math.Max(0.0, MetabolicWtSenescing - MetabolicWtReallocated);


            Live.MetabolicN -= Math.Max(0.0, (MetabolicNSenescing - MetabolicNReallocated - MetabolicNRetranslocated));  //Don't Seness todays N if it has been taken for reallocation
            Dead.MetabolicN += Math.Max(0.0, (MetabolicNSenescing - MetabolicNReallocated - MetabolicNRetranslocated));

            Live.NonStructuralN -= Math.Max(0.0, NonStructuralNSenescing - NonStructuralNReallocated - NonStructuralNRetrasnlocated);  //Dont Senesess todays NonStructural N if it was retranslocated or reallocated
            Dead.NonStructuralN += Math.Max(0.0, NonStructuralNSenescing - NonStructuralNReallocated - NonStructuralNRetrasnlocated);

            Live.NonStructuralWt -= Math.Max(0.0, NonStructuralWtSenescing - DMRetranslocated);
            Live.NonStructuralWt  = Math.Max(0.0, Live.NonStructuralWt);

            //RFZ
            //Reallocated gos to to reallocation pool but not into dead pool.
            Dead.NonStructuralWt += Math.Max(0.0, NonStructuralWtSenescing - DMRetranslocated - NonStructuralWtReallocated);



            Age = Age + _ThermalTime;

            // Do Detachment of this Leaf Cohort
            // ---------------------------------
            DetachedFrac = FractionDetaching(_ThermalTime);
            if (DetachedFrac > 0.0)
            {
                double DetachedArea = DeadArea * DetachedFrac;
                double DetachedWt   = Dead.Wt * DetachedFrac;
                double DetachedN    = Dead.N * DetachedFrac;

                DeadArea             *= (1 - DetachedFrac);
                Dead.StructuralWt    *= (1 - DetachedFrac);
                Dead.StructuralN     *= (1 - DetachedFrac);
                Dead.NonStructuralWt *= (1 - DetachedFrac);
                Dead.NonStructuralN  *= (1 - DetachedFrac);
                Dead.MetabolicWt     *= (1 - DetachedFrac);
                Dead.MetabolicN      *= (1 - DetachedFrac);


                BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();

                BiomassRemovedData.crop_type           = Plant.CropType;
                BiomassRemovedData.dm_type             = new string[1];
                BiomassRemovedData.dlt_crop_dm         = new float[1];
                BiomassRemovedData.dlt_dm_n            = new float[1];
                BiomassRemovedData.dlt_dm_p            = new float[1];
                BiomassRemovedData.fraction_to_residue = new float[1];

                BiomassRemovedData.dm_type[0]             = "leaf";
                BiomassRemovedData.dlt_crop_dm[0]         = (float)DetachedWt * 10f;
                BiomassRemovedData.dlt_dm_n[0]            = (float)DetachedN * 10f;
                BiomassRemovedData.dlt_dm_p[0]            = 0f;
                BiomassRemovedData.fraction_to_residue[0] = 1f;
                BiomassRemoved.Invoke(BiomassRemovedData);
            }
        }
    }
Esempio n. 9
0
    private void DoDevelopment()
    {
        Age = Age + 1.0 / 365.0;
        //for (int i = 0; i < Frond.Length; i++)
        //    Frond[i].Age += 1;
        foreach (FrondType F in Fronds)
        {
            F.Age += DeltaT;
            //F.Area = SizeFunction(F.Age);
        }
        if (Fronds[Fronds.Count - 1].Age >= FrondAppRate.Value)
        {
            FrondType F = new FrondType();
            Fronds.Add(F);
            CumulativeFrondNumber += 1;

            BunchType B = new BunchType();
            B.FemaleFraction = FemaleFlowerFraction.Value;
            Bunches.Add(B);
        }

        //if (Fronds[0].Age >= (40 * FrondAppRate.Value))
        if (FrondNumber > Math.Round(HarvestFrondNumber.Value))
        {
            HarvestBunches   = Bunches[0].FemaleFraction;
            HarvestYield     = Bunches[0].Mass * Population / (1.0 - RipeBunchWaterContent.Value);
            HarvestFFB       = HarvestYield / 100;
            HarvestNRemoved  = Bunches[0].N * Population * 10;
            HarvestBunchSize = Bunches[0].Mass / (1.0 - RipeBunchWaterContent.Value) / Bunches[0].FemaleFraction;
            if (Harvesting != null)
            {
                Harvesting.Invoke();
            }
            // Now rezero these outputs - they can only be output non-zero on harvesting event.
            HarvestBunches   = 0.0;
            HarvestYield     = 0.0;
            HarvestFFB       = 0.0;
            HarvestBunchSize = 0.0;
            HarvestNRemoved  = 0.0;


            CumulativeBunchNumber += Bunches[0].FemaleFraction;
            CumulativeYield       += Bunches[0].Mass * Population / (1.0 - RipeBunchWaterContent.Value);
            Bunches.RemoveAt(0);

            BiomassRemovedType BiomassRemovedData = new BiomassRemovedType();
            BiomassRemovedData.crop_type = Crop_Type;
            BiomassRemovedData.dm_type   = new string[1] {
                "frond"
            };
            BiomassRemovedData.dlt_crop_dm = new float[1] {
                (float)(Fronds[0].Mass * Population * 10)
            };
            BiomassRemovedData.dlt_dm_n = new float[1] {
                (float)(Fronds[0].N * Population * 10)
            };
            BiomassRemovedData.dlt_dm_p = new float[1] {
                0
            };
            BiomassRemovedData.fraction_to_residue = new float[1] {
                1
            };
            Fronds.RemoveAt(0);
            BiomassRemoved.Invoke(BiomassRemovedData);
        }
    }