private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation


            //Mean irradiance intercepted over GAI mean (on TTWindowForPTQ window)
            double PTQ = phenologystate.PTQ;

            //GAI mean on TTWindowForPTQ window (maximum over the cultivation period)
            double GAImean = phenologystate.GAImean;

            //GAI until the nubmer LNeff of leaves is reached
            double potentialGAISL = ((AreaSL + AreaSS) / 10000);     //convert cm²->m²
            double GAILim         = LNeff * potentialGAISL * SowingDensity;

            double LAR = 0.0;

            if (GAImean > GAILim)
            {
                LAR = (LARmin + (((LARmax - LARmin) * PTQ) / (PTQhf + PTQ))) / (B * GAImean);
            }
            else
            {
                LAR = (LARmin + (((LARmax - LARmin) * PTQ) / (PTQhf + PTQ))) / (B * GAILim);
            }


            phenologystate.Phyllochron = 1.0 / LAR;



            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
 //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
 //Code written below will not be overwritten by a future code generation
 ///<summary>Init this phytomers for a new simulation</summary>
 public void Init(SiriusQualityPhenology.PhenologyState phenologystate1)
 {
     phenologystate1.CanopyShootNumber          = SowingDensity;
     phenologystate1.AverageShootNumberPerPlant = 1;
     phenologystate1.tilleringProfile.Add(SowingDensity);
     phenologystate1.TillerNumber = 1;
 }
        string choosePhyllUse      = "Default"; //"Default" for segmented linear modeled phyllocron with Sowing date correction
        //string choosePhyllUse = "PTQ"; //for photoThermal Quotient parametrization of phyllochron
        //string choosePhyllUse = "Test"; //for segmented linear modeled phyllochron without Sowing date correction
        //With "Test" it is possible to test a linear modeled phyllochron by setting
        //parameters Pdecr an Pincr to 1.0


        #endregion

        #region Constructor

        public PhenologyWrapper()
        {
            phenologyComponent     = new SiriusQualityPhenology.Strategies.Phenology();
            phenologyState         = new SiriusQualityPhenology.PhenologyState();
            previousphenologyState = new SiriusQualityPhenology.PhenologyState();
            loadParameters();
        }
Exemple #4
0
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (phenologystate.LeafNumber > 0)
            {
                if (phenologystate1.HasFlagLeafLiguleAppeared == 0 && (phenologystate.FinalLeafNumber > 0 && phenologystate.LeafNumber >= phenologystate.FinalLeafNumber))
                {
                    phenologystate.HasFlagLeafLiguleAppeared = 1;
                    if (!phenologystate1.Calendar[GrowthStage.ZC_39_FlagLeafLiguleJustVisible].HasValue)
                    {
                        phenologystate.Calendar.Set(GrowthStage.ZC_39_FlagLeafLiguleJustVisible, phenologystate.currentdate, phenologystate.cumulTT);
                    }
                }
            }
            else
            {
                phenologystate.HasFlagLeafLiguleAppeared = 0;
                phenologystate.Calendar = phenologystate1.Calendar;
            }


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        //Parameters static VarInfo list of the composite class


        #endregion

        #region pre/post conditions management

        /// <summary>
        /// Test to verify the postconditions
        /// </summary>
        public string TestPostConditions(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, string callID)
        {
            try
            {
                //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes

                SiriusQualityPhenology.PhenologyStateVarInfo.hasZadokStageChanged.CurrentValue = phenologystate.hasZadokStageChanged;
                SiriusQualityPhenology.PhenologyStateVarInfo.currentZadokStage.CurrentValue    = phenologystate.currentZadokStage;
                SiriusQualityPhenology.PhenologyStateVarInfo.Calendar.CurrentValue             = phenologystate.Calendar;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r7 = new RangeBasedCondition(SiriusQualityPhenology.PhenologyStateVarInfo.hasZadokStageChanged);
                if (r7.ApplicableVarInfoValueTypes.Contains(SiriusQualityPhenology.PhenologyStateVarInfo.hasZadokStageChanged.ValueType))
                {
                    prc.AddCondition(r7);
                }
                RangeBasedCondition r8 = new RangeBasedCondition(SiriusQualityPhenology.PhenologyStateVarInfo.currentZadokStage);
                if (r8.ApplicableVarInfoValueTypes.Contains(SiriusQualityPhenology.PhenologyStateVarInfo.currentZadokStage.ValueType))
                {
                    prc.AddCondition(r8);
                }
                RangeBasedCondition r9 = new RangeBasedCondition(SiriusQualityPhenology.PhenologyStateVarInfo.Calendar);
                if (r9.ApplicableVarInfoValueTypes.Contains(SiriusQualityPhenology.PhenologyStateVarInfo.Calendar.ValueType))
                {
                    prc.AddCondition(r9);
                }



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section4
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section4

                //Get the evaluation of postconditions
                string postConditionsResult = pre.VerifyPostconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(postConditionsResult))
                {
                    pre.TestsOut(postConditionsResult, true, "PostConditions errors in component SiriusQualityPhenology.Strategies, strategy " + this.GetType().Name);
                }
                return(postConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1001,	"Strategy: " + this.GetType().Name + " - Unhandled exception running post-conditions");

                string msg = "Component SiriusQualityPhenology.Strategies, " + this.GetType().Name + ": Unhandled exception running post-condition test. ";
                throw new Exception(msg, exception);
            }
        }
        private void CalcShootNumber(SiriusQualityPhenology.PhenologyState phenologystate)
        {
            int EmergedLeaves = (int)Math.Max(1, Math.Ceiling(phenologystate.LeafNumber - 1));
            int Shoots        = Fibonacci(EmergedLeaves);

            phenologystate.CanopyShootNumber          = Math.Min(Shoots * SowingDensity, TargetFertileShoot);
            phenologystate.AverageShootNumberPerPlant = phenologystate.CanopyShootNumber / SowingDensity;
        }
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes

                SiriusQualityPhenology.PhenologyStateVarInfo.LeafNumber.CurrentValue = phenologystate.LeafNumber;
                SiriusQualityPhenology.PhenologyStateVarInfo.Fixphyll.CurrentValue   = phenologystate.Fixphyll;

                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();


                RangeBasedCondition r1 = new RangeBasedCondition(SiriusQualityPhenology.PhenologyStateVarInfo.LeafNumber);
                if (r1.ApplicableVarInfoValueTypes.Contains(SiriusQualityPhenology.PhenologyStateVarInfo.LeafNumber.ValueType))
                {
                    prc.AddCondition(r1);
                }
                RangeBasedCondition r2 = new RangeBasedCondition(SiriusQualityPhenology.PhenologyStateVarInfo.Fixphyll);
                if (r2.ApplicableVarInfoValueTypes.Contains(SiriusQualityPhenology.PhenologyStateVarInfo.Fixphyll.ValueType))
                {
                    prc.AddCondition(r2);
                }
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("Ldecr")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("Lincr")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("Pdecr")));
                prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("Pincr")));



                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityPhenology.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityPhenology.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }
Exemple #8
0
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (phenologystate.HasFlagLeafLiguleAppeared == 0)  //sowingToAnthesis
            {
                if (SwitchMaize == 0)
                {
                    if (phenologystate.Phyllochron == 0.0)
                    {
                        phenologystate.Phyllochron = 0.0000001;
                        //phenologyState_.TagPhenoWarnOut = "Suspicious phenology phase transition occured";
                    }
                    phenologystate.LeafNumber = phenologystate1.LeafNumber + Math.Min(phenologystate.DeltaTT / phenologystate.Phyllochron, 0.999);
                }
                else
                {
                    //non continuous version of LN based on startExp
                    if (phenologystate1.LeafNumber < Leaf_tip_emerg)
                    {
                        phenologystate.LeafNumber = Leaf_tip_emerg;
                    }
                    else
                    {
                        //calcul startExp of next leaf
                        double nextstartExpTT = 0;

                        double nexttipTT = ((phenologystate1.LeafNumber + 1) - Leaf_tip_emerg) / atip + phenologystate.cumulTTPhenoMaizeAtEmergence;

                        double abl        = k_bl * atip;
                        double tt_lim_lip = ((Nlim - Leaf_tip_emerg) / atip) + phenologystate.cumulTTPhenoMaizeAtEmergence;
                        double bbl        = Nlim - (abl * tt_lim_lip);

                        double tt_bl = ((phenologystate1.LeafNumber + 1) - bbl) / abl;
                        if (tt_bl > nexttipTT)
                        {
                            nextstartExpTT = nexttipTT;
                        }
                        else
                        {
                            nextstartExpTT = tt_bl;
                        }
                        if (phenologystate.cumulTT[6] >= nextstartExpTT)
                        {
                            phenologystate.LeafNumber = phenologystate1.LeafNumber + 1;
                        }
                        else
                        {
                            phenologystate.LeafNumber = phenologystate1.LeafNumber;
                        }
                    }
                    phenologystate.Ntip = atip * (phenologystate.cumulTT[6] - phenologystate.cumulTTPhenoMaizeAtEmergence) + Leaf_tip_emerg;
                }
            }
            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            double dTTshoot = phenologystate.DeltaTT;
            double dailyPAR = phenologystate.PAR;

            List <double> TTList  = new List <double>();
            List <double> PARList = new List <double>();

            for (int i = 0; i < phenologystate1.ListTTShootTTWindowForPTQ.Count; i++)
            {
                TTList.Add(phenologystate1.ListTTShootTTWindowForPTQ[i]);
                PARList.Add(phenologystate1.ListPARTTWindowForPTQ[i]);
            }


            TTList.Add(dTTshoot);
            PARList.Add(dailyPAR);


            double SumTT = TTList.Sum();
            int    count = 0;

            while (SumTT > TTWindowForPTQ)
            {
                SumTT -= TTList[count];
                count++;
            }

            phenologystate.ListTTShootTTWindowForPTQ = new List <double>();
            phenologystate.ListPARTTWindowForPTQ     = new List <double>();

            for (int i = count; i < TTList.Count; i++)
            {
                phenologystate.ListTTShootTTWindowForPTQ.Add(TTList[i]);
                phenologystate.ListPARTTWindowForPTQ.Add(PARList[i]);
            }


            double parInt = 0.0;

            for (int i = 0; i < phenologystate.ListTTShootTTWindowForPTQ.Count; i++)
            {
                parInt += phenologystate.ListPARTTWindowForPTQ[i] * (1 - Math.Exp(-Kl * phenologystate.ListGAITTWindowForPTQ[i]));
            }

            double TTShoot = phenologystate.ListTTShootTTWindowForPTQ.Sum();

            phenologystate.PTQ = parInt / TTShoot;


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            phenologystate.Fixphyll = CalculateFixphyll();

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Exemple #11
0
        //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
        //Code written below will not be overwritten by a future code generation

        ///<param name="cumulTTatSowing"> array of the different types of cumulTT at sowing date which will be saved in the calendar</param>
        public void Init(List <double> cumulTTatSowing, DateTime sowingDate, SiriusQualityPhenology.PhenologyState phenologystate1)
        {
            //recordSowing
            phenologystate1.Calendar.Set(GrowthStage.ZC_00_Sowing, sowingDate, cumulTTatSowing);
            phenologystate1.MinFinalNumber = AMNFLNO;
            //Debug
            //phenologystate.LeafNumber = 0.0;
            //phenologystate.Ntip = 0.0;
            //Debug
            _calculateshootnumber.Init(phenologystate1);
        }
Exemple #12
0
        /* public string TagPhenoWarnOut
         * {
         *   get { return phenologyState.TagPhenoWarnOut;}
         *   set { phenologyState.TagPhenoWarnOut=value; }
         * }*/

        #endregion

        public PhenologyBiomaWrapper(Universe universe) : base(universe)
        {
            phenologyComponent     = new SiriusQualityPhenology.Strategies.Phenology();
            phenologyState         = new SiriusQualityPhenology.PhenologyState();
            previousphenologyState = new SiriusQualityPhenology.PhenologyState();
            loadParameters();
            if (SwitchMaize)
            {
                phenologyState.FinalLeafNumber = Nfinal;
            }
        }
Exemple #13
0
        /// <summary>
        /// Test to verify the preconditions
        /// </summary>
        public string TestPreConditions(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, string callID)
        {
            try
            {
                //Set current values of the inputs to the static VarInfo representing the input properties of the domain classes


                //Create the collection of the conditions to test
                ConditionsCollection prc = new ConditionsCollection();
                Preconditions        pre = new Preconditions();



                string ret = "";
                ret += _calculateleafnumber.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.CalculateLeafNumber");
                ret += _calculatephyllochron.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.CalculatePhyllochron");
                ret += _calculateshootnumber.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.CalculateShootNumber");
                ret += _calculatevernalizationprogress.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.CalculateVernalizationProgress");
                ret += _registerzadok.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.RegisterZadok");
                ret += _updateleafflag.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.UpdateLeafFlag");
                ret += _updatephase.TestPreConditions(phenologystate, phenologystate1, "strategy SiriusQualityPhenology.Strategies.UpdatePhase");
                if (ret != "")
                {
                    pre.TestsOut(ret, true, "   preconditions tests of associated classes");
                }

                //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section3
                //Code written below will not be overwritten by a future code generation



                //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
                //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section3

                //Get the evaluation of preconditions;
                string preConditionsResult = pre.VerifyPreconditions(prc, callID);
                //if we have errors, send it to the configured output
                if (!string.IsNullOrEmpty(preConditionsResult))
                {
                    pre.TestsOut(preConditionsResult, true, "PreConditions errors in component SiriusQualityPhenology.Strategies, strategy " + this.GetType().Name);
                }
                return(preConditionsResult);
            }
            catch (Exception exception)
            {
                //Uncomment the next line to use the trace
                //	TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1002,"Strategy: " + this.GetType().Name + " - Unhandled exception running pre-conditions");

                string msg = "Component SiriusQualityPhenology.Strategies, " + this.GetType().Name + ": Unhandled exception running pre-condition test. ";
                throw new Exception(msg, exception);
            }
        }
        /// <summary>
        /// Calculate method for the component with test of preconditions
        /// </summary>
        /// <param name=p>PhenologyState Domain class contains the accessors to values</param>
        /// <param name=p1>PhenologyState Domain class contains the accessors to values</param>
        /// <param name=ae>AgroManagement objects of impact parameters</param>
        /// <param name="saveLog">Save log via a writer or show on screen</param>
        /// <param name="callID">Context description for violations</param>
        public void Estimate
            (IStrategySiriusQualityPhenology st, PhenologyState s, PhenologyState s1, ActEvents ae, bool saveLog, string callID)
        {
            _resultPreConditions  = String.Empty;
            _resultPostConditions = String.Empty;
            _resultPreConditions  = st.TestPreConditions(s, s1, callID);
            st.Estimate(s, s1, ae);
            _resultPostConditions = st.TestPostConditions(s, s1, callID);

            if (_resultPreConditions != String.Empty || _resultPostConditions != String.Empty)
            {
                p.TestsOut(_resultPreConditions + _resultPostConditions, saveLog, callID);
            }
        }
Exemple #15
0
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            double dTTshoot = phenologystate.DeltaTT;
            double dailyGAI = phenologystate.GAI;

            List <double> TTList  = new List <double>();
            List <double> GAIList = new List <double>();

            for (int i = 0; i < phenologystate1.ListTTShootTTWindowForPTQ.Count; i++)
            {
                TTList.Add(phenologystate1.ListTTShootTTWindowForPTQ[i]);
                GAIList.Add(phenologystate1.ListGAITTWindowForPTQ[i]);
            }


            TTList.Add(dTTshoot);
            GAIList.Add(dailyGAI);



            double SumTT = TTList.Sum();
            int    count = 0;

            while (SumTT > TTWindowForPTQ /*+ dTTshoot*/)
            {
                SumTT -= TTList[count];
                count++;
            }

            phenologystate.ListTTShootTTWindowForPTQ = new List <double>();
            phenologystate.ListGAITTWindowForPTQ     = new List <double>();

            for (int i = count; i < TTList.Count; i++)
            {
                phenologystate.ListTTShootTTWindowForPTQ.Add(TTList[i]);
                phenologystate.ListGAITTWindowForPTQ.Add(GAIList[i]);
            }

            double GAI = Math.Max(phenologystate1.pastGAI, phenologystate.ListGAITTWindowForPTQ.Average());

            phenologystate.pastGAI = GAI;
            phenologystate.GAImean = GAI;

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Exemple #16
0
 /// <summary>copy constructor</summary>
 public PhenologyState(PhenologyState toCopy, bool copyAll)
 {
     _parametersIO = new ParametersIO(this);
     _phase_       = (toCopy._phase_ != null) ? new Phase(toCopy._phase_) : null;
     _Calendar     = (toCopy._Calendar != null) ? new Calendar(toCopy._Calendar) : null;
     _currentdate  = toCopy._currentdate;
     _cumulTT      = toCopy._cumulTT;
     _DayLength    = toCopy._DayLength;
     _DeltaTT      = toCopy._DeltaTT;
     _GrainCumulTT = toCopy._GrainCumulTT;
     _GAI          = toCopy._GAI;
     _LeafNumber   = toCopy._LeafNumber;
     //_TagPhenoWarnOut = toCopy._TagPhenoWarnOut;
     _FinalLeafNumber            = toCopy._FinalLeafNumber;
     _Phyllochron                = toCopy._Phyllochron;
     _Vernaprog                  = toCopy._Vernaprog;
     _currentZadokStage          = toCopy._currentZadokStage;
     _CanopyShootNumber          = toCopy._CanopyShootNumber;
     _TillerNumber               = toCopy._TillerNumber;
     _AverageShootNumberPerPlant = toCopy._AverageShootNumberPerPlant;
     tilleringProfile            = new List <double>();
     for (int i = 0; i < toCopy.tilleringProfile.Count; i++)
     {
         tilleringProfile.Add(toCopy.tilleringProfile[i]);
     }
     leafTillerNumberArray = new List <double>();
     for (int i = 0; i < toCopy.leafTillerNumberArray.Count; i++)
     {
         leafTillerNumberArray.Add(toCopy.leafTillerNumberArray[i]);
     }
     if (copyAll)
     {
         _Ntip = toCopy._Ntip;
         _hasLastPrimordiumAppeared = toCopy._hasLastPrimordiumAppeared;
         _isMomentRegistredZC_39    = toCopy._isMomentRegistredZC_39;
         _cumulTTFromZC_39          = toCopy._cumulTTFromZC_39;
         _cumulTTFromZC_91          = toCopy._cumulTTFromZC_91;
         _cumulTTFromZC_65          = toCopy._cumulTTFromZC_65;
         _IsLatestLeafInternodeLengthPotPositive = toCopy._IsLatestLeafInternodeLengthPotPositive;
         _HasFlagLeafLiguleAppeared    = toCopy._HasFlagLeafLiguleAppeared;
         _MinFinalNumber               = toCopy._MinFinalNumber;
         _cumulTTPhenoMaizeAtEmergence = toCopy._cumulTTPhenoMaizeAtEmergence;
         _hasZadokStageChanged         = toCopy._hasZadokStageChanged;
     }
 }
Exemple #17
0
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (phenologystate.LeafNumber < Ldecr)
            {
                phenologystate.Phyllochron = FixPhyll * Pdecr;
            }
            else if (phenologystate.LeafNumber >= Ldecr && phenologystate.LeafNumber < Lincr)
            {
                phenologystate.Phyllochron = FixPhyll;
            }
            else
            {
                phenologystate.Phyllochron = FixPhyll * Pincr;
            }

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            var OldCanopyShootNumber = phenologystate1.CanopyShootNumber;

            CalcShootNumber(phenologystate);

            if (phenologystate.CanopyShootNumber != OldCanopyShootNumber)
            {
                // New tiller has emerged.
                phenologystate1.tilleringProfile.Add(phenologystate.CanopyShootNumber - OldCanopyShootNumber);
            }

            phenologystate.tilleringProfile = new List <double>();
            for (int i = 0; i < phenologystate1.tilleringProfile.Count; i++)
            {
                phenologystate.tilleringProfile.Add(phenologystate1.tilleringProfile[i]);
            }

            phenologystate.TillerNumber = phenologystate.tilleringProfile.Count;


            for (int i = phenologystate1.leafTillerNumberArray.Count; i < Math.Ceiling(phenologystate.LeafNumber); i++)
            {
                phenologystate1.leafTillerNumberArray.Add(phenologystate.TillerNumber);
            }


            phenologystate.leafTillerNumberArray = new List <double>();
            for (int i = 0; i < phenologystate1.leafTillerNumberArray.Count; i++)
            {
                phenologystate.leafTillerNumberArray.Add(phenologystate1.leafTillerNumberArray[i]);
            }

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
Exemple #19
0
 //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
 //Code written below will not be overwritten by a future code generation
 public void Init(SiriusQualityPhenology.PhenologyState phenologystate)
 {
 }
Exemple #20
0
 //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section2
 //Code written below will not be overwritten by a future code generation
 public void Init(SiriusQualityPhenology.PhenologyState phenologyState_)
 {
     phenologyState_.LeafNumber = 0;        //we don't need to call updateflag because leafNumber =0;
     //TagPhenoWarnOut = "";
 }
Exemple #21
0
        //Call of the associated strategies
        private void EstimateOfAssociatedClasses(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            if (phenologystate.cumulTT.Count < 1)
            {
                throw new ArgumentException("cumulTT must have at least one element");
            }

            //previousphenologystate.Calendar = phenologystate.Calendar;
            //previousphenologystate.LeafNumber = phenologystate.LeafNumber;

            phenologystate.LeafNumber = phenologystate1.LeafNumber;

            phenologystate.isMomentRegistredZC_39 = phenologystate1.Calendar.IsMomentRegistred(GrowthStage.ZC_39_FlagLeafLiguleJustVisible);

            if (phenologystate1.Calendar.IsMomentRegistred(GrowthStage.ZC_65_Anthesis) == 1)
            {
                if (SwitchMaize == 0)
                {
                    phenologystate.cumulTTFromZC_65 = phenologystate1.Calendar.cumulTTFrom(0, GrowthStage.ZC_65_Anthesis, phenologystate.cumulTT[0]);
                }
                else
                {
                    phenologystate.cumulTTFromZC_65 = phenologystate1.Calendar.cumulTTFrom(6, GrowthStage.ZC_65_Anthesis, phenologystate.cumulTT[6]);
                }
            }
            if (phenologystate1.Calendar.IsMomentRegistred(GrowthStage.ZC_39_FlagLeafLiguleJustVisible) == 1)
            {
                if (SwitchMaize == 0)
                {
                    phenologystate.cumulTTFromZC_39 = phenologystate1.Calendar.cumulTTFrom(0, GrowthStage.ZC_39_FlagLeafLiguleJustVisible, phenologystate.cumulTT[0]);
                }
                else
                {
                    phenologystate.cumulTTFromZC_39 = phenologystate1.Calendar.cumulTTFrom(6, GrowthStage.ZC_39_FlagLeafLiguleJustVisible, phenologystate.cumulTT[6]);
                }
            }
            if (phenologystate1.Calendar.IsMomentRegistred(GrowthStage.ZC_91_EndGrainFilling) == 1)
            {
                if (SwitchMaize == 0)
                {
                    phenologystate.cumulTTFromZC_91 = phenologystate1.Calendar.cumulTTFrom(0, GrowthStage.ZC_91_EndGrainFilling, phenologystate.cumulTT[0]);
                }
                else
                {
                    phenologystate.cumulTTFromZC_91 = phenologystate1.Calendar.cumulTTFrom(6, GrowthStage.ZC_91_EndGrainFilling, phenologystate.cumulTT[6]);
                }
            }
            phenologystate.Calendar = phenologystate1.Calendar;
            _calculatevernalizationprogress.Estimate(phenologystate, phenologystate1, actevents);
            phenologystate1.Calendar = phenologystate.Calendar;
            _updatephase.Estimate(phenologystate, phenologystate1, actevents);


            if (phenologystate.phase_.phaseValue == 1 && phenologystate.cumulTTPhenoMaizeAtEmergence == 0)
            {
                phenologystate.cumulTTPhenoMaizeAtEmergence = phenologystate.cumulTT[6];
            }


            if (phenologystate.phase_.phaseValue >= 1 && phenologystate.phase_.phaseValue < 4)
            {
                _calculateleafnumber.Estimate(phenologystate, phenologystate1, actevents);
                _updateleafflag.Estimate(phenologystate, phenologystate1, actevents);    //need to be called after the update of the LeafNumber
                phenologystate1.Calendar = phenologystate.Calendar;
            }


            _calculatephyllochron.Estimate(phenologystate, phenologystate1, actevents);
            _registerzadok.Estimate(phenologystate, phenologystate1, actevents);

            //need to update the calendar after the update of the phase
            if (phenologystate.Calendar.IsMomentRegistred(phenologystate.phase_.PreviousMoment()) == 0)
            {
                GrowthStage stage = phenologystate.Calendar.LastGrowthStageSet;
                phenologystate.Calendar.Set(phenologystate.phase_.PreviousMoment(), phenologystate.currentdate, phenologystate.cumulTT);
                if (phenologystate.hasZadokStageChanged == 1)    //if a new zadok stage and  a new phase stage happen the same day, we set the lastGrowthStage to the zadock one.
                {
                    phenologystate.Calendar.LastGrowthStageSet = stage;
                }
            }

            //testBeginningStemExtension;
            if (phenologystate.Calendar[GrowthStage.BeginningStemExtension] == null)
            {
                if (phenologystate.IsLatestLeafInternodeLengthPotPositive == 1)
                {
                    GrowthStage growthStage = phenologystate.Calendar.LastGrowthStageSet;
                    phenologystate.Calendar.Set(GrowthStage.BeginningStemExtension, phenologystate.currentdate, phenologystate.cumulTT);
                    if (phenologystate.hasZadokStageChanged == 1)
                    {
                        phenologystate.Calendar.LastGrowthStageSet = growthStage;
                    }
                }
            }

            _calculateshootnumber.Estimate(phenologystate, phenologystate1, actevents);
        }
Exemple #22
0
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation
            if (IsVernalizable == 1 && phenologystate1.Vernaprog < 1)
            {
                double TT = phenologystate.DeltaTT;     // other sirius versions use previous temperature value

                if (TT >= MinTvern && TT <= IntTvern)
                {
                    phenologystate.Vernaprog = phenologystate1.Vernaprog + VAI * TT + VBEE;
                }
                else
                {
                    phenologystate.Vernaprog = phenologystate1.Vernaprog;
                }
                //  temperature response modified to allow for constant rate of vernalisation above IntermTvern under short days,
                //  based on Brooking et al., (2002) FCR 79:21-38 and Allard et al., (2012) JXB 63:847-857
                //  Here we make the assumption that the vernalising effect of shordays decreases linearly from 1 at minDL (set a 8h) to 0 at maxDL (set at 16h)
                if (TT > IntTvern)
                {
                    double maxVernaProg = VAI * IntTvern + VBEE;                                 // maximum vernalisation rate, for temperature = IntermTvern

                    double DLverna = Math.Max(MinDL, Math.Min(MaxDL, phenologystate.DayLength)); // limits the daylength between maxDL and minDL
                    phenologystate.Vernaprog += Math.Max(0, maxVernaProg * (1 + ((IntTvern - TT) / (MaxTvern - IntTvern)) * ((DLverna - MinDL) / (MaxDL - MinDL))));
                }


                double primordno     = 2.0 * phenologystate.LeafNumber + PNini;
                double minLeafNumber = phenologystate1.MinFinalNumber;

                // First stopping rule.  Vernalisation is completed when VPROG reaches 1
                // or the number of primordium exeeds the absolute maximal leaf number
                if (phenologystate.Vernaprog >= 1.0 || primordno >= AMXLFNO)
                {
                    //EndVernalization(primordno, phenologystate.cumulTT, phenologystate.calendar);
                    phenologystate.MinFinalNumber = Math.Max(primordno, phenologystate1.MinFinalNumber);;
                    phenologystate.Calendar.Set(GrowthStage.EndVernalisation, phenologystate.currentdate, phenologystate.cumulTT);
                    phenologystate.Vernaprog = Math.Max(1, phenologystate.Vernaprog);
                }
                else
                {
                    double potlfno = AMXLFNO - (AMXLFNO - minLeafNumber) * phenologystate.Vernaprog;

                    // Second stopping rule.  Vernalization is completed when primodia number
                    // exceeds potential number of leaves
                    if (primordno >= potlfno)
                    {
                        //EndVernalization((potlfno + primordno) / 2.0, phenologystate.cumulTT, phenologystate.calendar);
                        phenologystate.MinFinalNumber = Math.Max((potlfno + primordno) / 2.0, phenologystate1.MinFinalNumber);;
                        phenologystate.Calendar.Set(GrowthStage.EndVernalisation, phenologystate.currentdate, phenologystate.cumulTT);
                        phenologystate.Vernaprog = Math.Max(1, phenologystate.Vernaprog);
                    }
                    else
                    {
                        phenologystate.MinFinalNumber = phenologystate1.MinFinalNumber;
                    }
                }
            }
            else
            {
                phenologystate.Vernaprog      = phenologystate1.Vernaprog;
                phenologystate.MinFinalNumber = phenologystate1.MinFinalNumber;
            }

            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }
 /// <summary>
 /// Calculate method for the component
 /// </summary>
 /// <param name=p>PhenologyState Domain class contains the accessors to values</param>
 /// <param name=p1>PhenologyState Domain class contains the accessors to values</param>
 /// <param name=ae>AgroManagement objects of impact parameters</param>
 public void Estimate
     (IStrategySiriusQualityPhenology st, PhenologyState p, PhenologyState p1, ActEvents ae)
 {
     st.Estimate
         (p, p1, ae);
 }
        private void CalculateModel(SiriusQualityPhenology.PhenologyState phenologystate, SiriusQualityPhenology.PhenologyState phenologystate1, CRA.AgroManagement.ActEvents actevents)
        {
            //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1
            //Code written below will not be overwritten by a future code generation

            int roundedFinalLeafNumber = (int)(phenologystate.FinalLeafNumber + 0.5);

            if (HasReachedHaun(4, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_21_MainShootPlus1Tiller].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_21_MainShootPlus1Tiller, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_21_MainShootPlus1Tiller;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedHaun(5, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_22_MainShootPlus2Tiller].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_22_MainShootPlus2Tiller, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_22_MainShootPlus2Tiller;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedHaun(6, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_23_MainShootPlus3Tiller].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_23_MainShootPlus3Tiller, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_23_MainShootPlus3Tiller;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (phenologystate.FinalLeafNumber > 0 && HasReachedHaun(slopeTSFLN * phenologystate.FinalLeafNumber - intTSFLN, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.TerminalSpikelet].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.TerminalSpikelet, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.TerminalSpikelet;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedFlagLeaf(4, roundedFinalLeafNumber, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_30_PseudoStemErection].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_30_PseudoStemErection, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_30_PseudoStemErection;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedFlagLeaf(3, roundedFinalLeafNumber, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_31_1stNodeDetectable].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_31_1stNodeDetectable, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_31_1stNodeDetectable;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedFlagLeaf(2, roundedFinalLeafNumber, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_32_2ndNodeDetectable].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_32_2ndNodeDetectable, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_32_2ndNodeDetectable;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedFlagLeaf(1, roundedFinalLeafNumber, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_37_FlagLeafJustVisible].HasValue))
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_37_FlagLeafJustVisible, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_37_FlagLeafJustVisible;
                phenologystate.hasZadokStageChanged = 1;
            }
            else if (HasReachedFlagLeaf(0, roundedFinalLeafNumber, phenologystate.LeafNumber) && !(phenologystate1.Calendar[GrowthStage.ZC_39_FlagLeafLiguleJustVisible].HasValue))
            {
            }
            else if ((!(phenologystate1.Calendar[GrowthStage.ZC_85_MidGrainFilling].HasValue)) &&
                     phenologystate.phase_.phaseValue == 4.5 &&//EndCellDivisionToEndGrainFill
                     phenologystate.cumulTTFromZC_65 >= Der)
            {
                phenologystate.Calendar.Set(GrowthStage.ZC_85_MidGrainFilling, phenologystate.currentdate, phenologystate.cumulTT);
                phenologystate.currentZadokStage    = GrowthStage.ZC_85_MidGrainFilling;
                phenologystate.hasZadokStageChanged = 1;
            }
            else
            {
                phenologystate.hasZadokStageChanged = 0;
                phenologystate.Calendar             = phenologystate1.Calendar;
            }


            //End of custom code. Do not place your custom code below. It will be overwritten by a future code generation.
            //PLACE YOUR CUSTOM CODE ABOVE - GENERATED CODE START - Section1
        }