Ejemplo n.º 1
0
    public void OnProcess()
    {
        Util.Debug("\r\nPROCESS=%s", Today.ToString("d/M/yyyy"));
        Util.Debug("       =%i", Today.DayOfYear);
        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoSWUptake(TopsSWDemand);
        }

        SWStress.DoPlantWaterStress(TopsSWDemand);
        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNSupply();
        }
        Phenology.DoTimeStep();
        Stem.Morphology();
        Leaf.DoCanopyExpansion();

        foreach (Organ1 Organ in Organ1s)   // NIH - WHY IS THIS HERE!!!!?????  Not needed I hope.
        {
            Organ.DoPotentialRUE();         // DPH - It does make a small difference!
        }
        Arbitrator1.PartitionDM(Organ1s);
        Arbitrator1.RetranslocateDM(Organ1s);
        Leaf.Actual();
        Pod.CalcDltPodArea();
        Root.RootLengthGrowth();
        Leaf.LeafDeath();
        Leaf.LeafAreaSenescence();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoSenescence();
        }

        Root.DoSenescenceLength();
        Grain.DoNDemandGrain();

        //  g.n_fix_pot = _fixation->Potential(biomass, swStress->swDef.fixation);
        double n_fix_pot = 0;

        if (DoRetranslocationBeforeNDemand)
        {
            Arbitrator1.DoNRetranslocate(Grain.NDemand, Organ1s);
        }

        bool IncludeRetranslocationInNDemand = !DoRetranslocationBeforeNDemand;

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNDemand(IncludeRetranslocationInNDemand);
        }

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNSenescence();
        }
        Arbitrator1.doNSenescedRetranslocation(Organ1s);

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoSoilNDemand();
        }
        // PotNFix = _fixation->NFixPot();
        double PotNFix = 0;

        Root.DoNUptake(PotNFix);

        double n_fix_uptake = Arbitrator1.DoNPartition(n_fix_pot, Organ1s);

        // DoPPartition();
        if (!DoRetranslocationBeforeNDemand)
        {
            Arbitrator1.DoNRetranslocate(Grain.NDemand2, Tops);
        }

        // DoPRetranslocate();
        bool PlantIsDead = Population.PlantDeath();

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoDetachment();
        }

        Update();

        CheckBounds();
        SWStress.DoPlantWaterStress(TopsSWDemand);
        NStress.DoPlantNStress();
        if (PhenologyEventToday)
        {
            Console.WriteLine(string.Format("{0}(Day of year = {1}), {2}:",
                                            Today.ToString("d MMMMMM yyyy"),
                                            Today.DayOfYear,
                                            Name));
            Console.WriteLine("      " + Phenology.CurrentPhase.Start);
            if (Phenology.CurrentPhase.Start != "Germination")
            {
                double biomass = 0;

                double StoverWt = 0;
                double StoverN  = 0;
                foreach (Organ1 Organ in Tops)
                {
                    biomass += Organ.Live.Wt + Organ.Dead.Wt;
                    if (!(Organ is Reproductive))
                    {
                        StoverWt += Organ.Live.Wt + Organ.Dead.Wt;
                        StoverN  += Organ.Live.N + Organ.Dead.N;
                    }
                }
                double StoverNConc = MathUtility.Divide(StoverN, StoverWt, 0) * Conversions.fract2pcnt;
                Console.WriteLine(string.Format("           biomass =       {0,8:F2} (g/m^2)   lai          = {1,7:F2} (m^2/m^2)",
                                                biomass, Leaf.LAI));
                Console.WriteLine(string.Format("           stover N conc = {0,8:F2} (%)     extractable sw = {1,7:F2} (mm)",
                                                StoverNConc, Root.ESWInRootZone));
            }
            PhenologyEventToday = false;
        }
        //Root.UpdateWaterBalance();

        LAIMax = Math.Max(LAIMax, Leaf.LAI);
    }