public PhenologyAuxiliary(PhenologyAuxiliary toCopy, bool copyAll) // copy constructor { if (copyAll) { _currentdate = toCopy._currentdate; _cumulTT = toCopy._cumulTT; _dayLength = toCopy._dayLength; _deltaTT = toCopy._deltaTT; _gAI = toCopy._gAI; _pAR = toCopy._pAR; _grainCumulTT = toCopy._grainCumulTT; _fixPhyll = toCopy._fixPhyll; _cumulTTFromZC_39 = toCopy._cumulTTFromZC_39; _cumulTTFromZC_91 = toCopy._cumulTTFromZC_91; _cumulTTFromZC_65 = toCopy._cumulTTFromZC_65; } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double cumulTT = a.cumulTT; double leafNumber = s.leafNumber; List <string> calendarMoments = s.calendarMoments; List <DateTime> calendarDates = s.calendarDates; List <double> calendarCumuls = s.calendarCumuls; DateTime currentdate = a.currentdate; double finalLeafNumber = s.finalLeafNumber; int hasFlagLeafLiguleAppeared_t1 = s1.hasFlagLeafLiguleAppeared; double phase = s.phase; int hasFlagLeafLiguleAppeared; hasFlagLeafLiguleAppeared = 0; if (phase >= 1.0d && phase < 4.0d) { if (leafNumber > 0.0d) { if (hasFlagLeafLiguleAppeared == 0 && (finalLeafNumber > 0.0d && leafNumber >= finalLeafNumber)) { hasFlagLeafLiguleAppeared = 1; if (!calendarMoments.Contains("FlagLeafLiguleJustVisible")) { calendarMoments.Add("FlagLeafLiguleJustVisible"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } } } } s.calendarMoments = calendarMoments; s.calendarDates = calendarDates; s.calendarCumuls = calendarCumuls; s.hasFlagLeafLiguleAppeared = hasFlagLeafLiguleAppeared; }
public string TestPostConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.averageShootNumberPerPlant.CurrentValue = s.averageShootNumberPerPlant; Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber.CurrentValue = s.canopyShootNumber; Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray.CurrentValue = s.leafTillerNumberArray; Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile.CurrentValue = s.tilleringProfile; Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort.CurrentValue = s.numberTillerCohort; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r8 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.averageShootNumberPerPlant); if (r8.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.averageShootNumberPerPlant.ValueType)) { prc.AddCondition(r8); } RangeBasedCondition r9 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber); if (r9.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber.ValueType)) { prc.AddCondition(r9); } RangeBasedCondition r10 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray); if (r10.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray.ValueType)) { prc.AddCondition(r10); } RangeBasedCondition r11 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile); if (r11.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile.ValueType)) { prc.AddCondition(r11); } RangeBasedCondition r12 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort); if (r12.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort.ValueType)) { prc.AddCondition(r12); } string postConditionsResult = pre.VerifyPostconditions(prc, callID); if (!string.IsNullOrEmpty(postConditionsResult)) { pre.TestsOut(postConditionsResult, true, "PostConditions errors in strategy " + this.GetType().Name); } return(postConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running post-condition test. "; throw new Exception(msg, exception); } }
public string TestPostConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.phyllochron.CurrentValue = s.phyllochron; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r20 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.phyllochron); if (r20.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.phyllochron.ValueType)) { prc.AddCondition(r20); } string postConditionsResult = pre.VerifyPostconditions(prc, callID); if (!string.IsNullOrEmpty(postConditionsResult)) { pre.TestsOut(postConditionsResult, true, "PostConditions errors in strategy " + this.GetType().Name); } return(postConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running post-condition test. "; throw new Exception(msg, exception); } }
public void Estimate(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { try { CalculateModel(s, s1, r, a, ex); } catch (Exception exception) { string msg = "Error in component Phenology, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message; throw new Exception(msg, exception); } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { List <string> calendarMoments_t1 = s1.calendarMoments; List <double> calendarCumuls_t1 = s1.calendarCumuls; double cumulTT = a.cumulTT; double cumulTTFromZC_65; double cumulTTFromZC_39; double cumulTTFromZC_91; cumulTTFromZC_65 = 0.0d; cumulTTFromZC_39 = 0.0d; cumulTTFromZC_91 = 0.0d; if (calendarMoments_t1.Contains("Anthesis")) { cumulTTFromZC_65 = cumulTT - calendarCumuls_t1[calendarMoments_t1.IndexOf("Anthesis")]; } if (calendarMoments_t1.Contains("FlagLeafLiguleJustVisible")) { cumulTTFromZC_39 = cumulTT - calendarCumuls_t1[calendarMoments_t1.IndexOf("FlagLeafLiguleJustVisible")]; } if (calendarMoments_t1.Contains("EndGrainFilling")) { cumulTTFromZC_91 = cumulTT - calendarCumuls_t1[calendarMoments_t1.IndexOf("EndGrainFilling")]; } a.cumulTTFromZC_65 = cumulTTFromZC_65; a.cumulTTFromZC_39 = cumulTTFromZC_39; a.cumulTTFromZC_91 = cumulTTFromZC_91; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double gAI = a.gAI; double deltaTT = a.deltaTT; double pastMaxAI_t1 = s1.pastMaxAI; List <double> listTTShootWindowForPTQ1_t1 = s1.listTTShootWindowForPTQ1; List <double> listGAITTWindowForPTQ_t1 = s1.listGAITTWindowForPTQ; double gAImean; double pastMaxAI; List <double> listTTShootWindowForPTQ1 = new List <double>(); List <double> listGAITTWindowForPTQ = new List <double>(); List <double> TTList = new List <double>(); List <double> GAIList = new List <double>(); double SumTT; int count = 0; double gai_ = 0.0d; double gaiMean_ = 0.0d; int countGaiMean = 0; int i; for (i = 0; i != listTTShootWindowForPTQ1_t1.Count; i += 1) { TTList.Add(listTTShootWindowForPTQ1_t1[i]); GAIList.Add(listGAITTWindowForPTQ_t1[i]); } TTList.Add(deltaTT); GAIList.Add(gAI); SumTT = TTList.Sum(); while (SumTT > tTWindowForPTQ) { SumTT = SumTT - TTList[count]; count = count + 1; } for (i = count; i != TTList.Count; i += 1) { listTTShootWindowForPTQ1.Add(TTList[i]); listGAITTWindowForPTQ.Add(GAIList[i]); } for (i = 0; i != listGAITTWindowForPTQ.Count; i += 1) { gaiMean_ = gaiMean_ + listGAITTWindowForPTQ[i]; countGaiMean = countGaiMean + 1; } gaiMean_ = gaiMean_ / countGaiMean; gai_ = Math.Max(pastMaxAI_t1, gaiMean_); pastMaxAI = gai_; gAImean = gai_; s.gAImean = gAImean; s.pastMaxAI = pastMaxAI; s.listTTShootWindowForPTQ1 = listTTShootWindowForPTQ1; s.listGAITTWindowForPTQ = listGAITTWindowForPTQ; }
public string TestPostConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.gAImean.CurrentValue = s.gAImean; Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI.CurrentValue = s.pastMaxAI; Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1.CurrentValue = s.listTTShootWindowForPTQ1; Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ.CurrentValue = s.listGAITTWindowForPTQ; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r7 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.gAImean); if (r7.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.gAImean.ValueType)) { prc.AddCondition(r7); } RangeBasedCondition r8 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI); if (r8.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI.ValueType)) { prc.AddCondition(r8); } RangeBasedCondition r9 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1); if (r9.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1.ValueType)) { prc.AddCondition(r9); } RangeBasedCondition r10 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ); if (r10.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ.ValueType)) { prc.AddCondition(r10); } string postConditionsResult = pre.VerifyPostconditions(prc, callID); if (!string.IsNullOrEmpty(postConditionsResult)) { pre.TestsOut(postConditionsResult, true, "PostConditions errors in strategy " + this.GetType().Name); } return(postConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running post-condition test. "; throw new Exception(msg, exception); } }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sowingDay"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("latitude"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sDsa_sh"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("rp"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sDws"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sDsa_nh"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("p"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double cumulTT = a.cumulTT; double phase = s.phase; double leafNumber = s.leafNumber; List <string> calendarMoments = s.calendarMoments; List <DateTime> calendarDates = s.calendarDates; List <double> calendarCumuls = s.calendarCumuls; double cumulTTFromZC_65 = a.cumulTTFromZC_65; DateTime currentdate = a.currentdate; double finalLeafNumber = s.finalLeafNumber; string currentZadokStage = s.currentZadokStage; int hasZadokStageChanged_t1 = s1.hasZadokStageChanged; int hasZadokStageChanged; int roundedFinalLeafNumber; roundedFinalLeafNumber = (int)(finalLeafNumber + 0.5d); if (leafNumber >= 4.0d && !calendarMoments.Contains("MainShootPlus1Tiller")) { calendarMoments.Add("MainShootPlus1Tiller"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "MainShootPlus1Tiller"; } else if (leafNumber >= 5.0d && !calendarMoments.Contains("MainShootPlus2Tiller")) { calendarMoments.Add("MainShootPlus2Tiller"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "MainShootPlus2Tiller"; } else if (leafNumber >= 6.0d && !calendarMoments.Contains("MainShootPlus3Tiller")) { calendarMoments.Add("MainShootPlus3Tiller"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "MainShootPlus3Tiller"; } else if (finalLeafNumber > 0.0d && (leafNumber >= slopeTSFLN * finalLeafNumber - intTSFLN && !calendarMoments.Contains("TerminalSpikelet"))) { calendarMoments.Add("TerminalSpikelet"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "TerminalSpikelet"; } else if (leafNumber >= roundedFinalLeafNumber - 4.0d && roundedFinalLeafNumber - 4 > 0 && !calendarMoments.Contains("PseudoStemErection")) { calendarMoments.Add("PseudoStemErection"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "PseudoStemErection"; } else if (leafNumber >= roundedFinalLeafNumber - 3.0d && roundedFinalLeafNumber - 3 > 0 && !calendarMoments.Contains("1stNodeDetectable")) { calendarMoments.Add("1stNodeDetectable"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "1stNodeDetectable"; } else if (leafNumber >= roundedFinalLeafNumber - 2.0d && roundedFinalLeafNumber - 2 > 0 && !calendarMoments.Contains("2ndNodeDetectable")) { calendarMoments.Add("2ndNodeDetectable"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "2ndNodeDetectable"; } else if (leafNumber >= roundedFinalLeafNumber - 1.0d && roundedFinalLeafNumber - 1 > 0 && !calendarMoments.Contains("FlagLeafJustVisible")) { calendarMoments.Add("FlagLeafJustVisible"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "FlagLeafJustVisible"; } else if (!calendarMoments.Contains("MidGrainFilling") && (phase == 4.5d && cumulTTFromZC_65 >= der)) { calendarMoments.Add("MidGrainFilling"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); hasZadokStageChanged = 1; currentZadokStage = "MidGrainFilling"; } else { hasZadokStageChanged = 0; } s.calendarMoments = calendarMoments; s.calendarDates = calendarDates; s.calendarCumuls = calendarCumuls; s.currentZadokStage = currentZadokStage; s.hasZadokStageChanged = hasZadokStageChanged; }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.CurrentValue = a.cumulTT; Phenology.DomainClass.PhenologyStateVarInfo.phase.CurrentValue = s.phase; Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.CurrentValue = s.leafNumber; Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.CurrentValue = s.calendarMoments; Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.CurrentValue = s.calendarDates; Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.CurrentValue = s.calendarCumuls; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTTFromZC_65.CurrentValue = a.cumulTTFromZC_65; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate.CurrentValue = a.currentdate; Phenology.DomainClass.PhenologyStateVarInfo.finalLeafNumber.CurrentValue = s.finalLeafNumber; Phenology.DomainClass.PhenologyStateVarInfo.currentZadokStage.CurrentValue = s.currentZadokStage; Phenology.DomainClass.PhenologyStateVarInfo.hasZadokStageChanged.CurrentValue = s.hasZadokStageChanged; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.phase); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.phase.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.ValueType)) { prc.AddCondition(r4); } RangeBasedCondition r5 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates); if (r5.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.ValueType)) { prc.AddCondition(r5); } RangeBasedCondition r6 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls); if (r6.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.ValueType)) { prc.AddCondition(r6); } RangeBasedCondition r7 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTTFromZC_65); if (r7.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTTFromZC_65.ValueType)) { prc.AddCondition(r7); } RangeBasedCondition r8 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate); if (r8.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate.ValueType)) { prc.AddCondition(r8); } RangeBasedCondition r9 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.finalLeafNumber); if (r9.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.finalLeafNumber.ValueType)) { prc.AddCondition(r9); } RangeBasedCondition r10 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.currentZadokStage); if (r10.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.currentZadokStage.ValueType)) { prc.AddCondition(r10); } RangeBasedCondition r11 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.hasZadokStageChanged); if (r11.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.hasZadokStageChanged.ValueType)) { prc.AddCondition(r11); } prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("der"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("slopeTSFLN"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("intTSFLN"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sowingDate"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
public void Init(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double canopyShootNumber_t1; double leafNumber; List <double> tilleringProfile_t1 = new List <double>(); List <int> leafTillerNumberArray_t1 = new List <int>(); int numberTillerCohort_t1; double averageShootNumberPerPlant; double canopyShootNumber; List <int> leafTillerNumberArray = new List <int>(); List <double> tilleringProfile = new List <double>(); int numberTillerCohort; canopyShootNumber = sowingDensity; averageShootNumberPerPlant = 1.0d; tilleringProfile.Add(sowingDensity); numberTillerCohort = 1; leafTillerNumberArray = new List <int> { }; s.averageShootNumberPerPlant = averageShootNumberPerPlant; s.canopyShootNumber = canopyShootNumber; s.leafTillerNumberArray = leafTillerNumberArray; s.tilleringProfile = tilleringProfile; s.numberTillerCohort = numberTillerCohort; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double canopyShootNumber_t1 = s1.canopyShootNumber; double leafNumber = s.leafNumber; List <double> tilleringProfile_t1 = s1.tilleringProfile; List <int> leafTillerNumberArray_t1 = s1.leafTillerNumberArray; int numberTillerCohort_t1 = s1.numberTillerCohort; double averageShootNumberPerPlant; double canopyShootNumber; List <int> leafTillerNumberArray = new List <int>(); List <double> tilleringProfile = new List <double>(); int numberTillerCohort; int emergedLeaves; int shoots; int i; List <int> lNumberArray_rate = new List <int>(); emergedLeaves = Math.Max(1, (int)Math.Ceiling(leafNumber - 1.0d)); shoots = fibonacci(emergedLeaves); canopyShootNumber = Math.Min(shoots * sowingDensity, targetFertileShoot); averageShootNumberPerPlant = canopyShootNumber / sowingDensity; if (canopyShootNumber != canopyShootNumber_t1) { tilleringProfile = new List <double>(tilleringProfile_t1); tilleringProfile.Add(canopyShootNumber - canopyShootNumber_t1); } numberTillerCohort = tilleringProfile.Count; for (i = leafTillerNumberArray_t1.Count; i != (int)Math.Ceiling(leafNumber); i += 1) { lNumberArray_rate.Add(numberTillerCohort); } leafTillerNumberArray = new List <int>(leafTillerNumberArray_t1); leafTillerNumberArray.AddRange(lNumberArray_rate); s.averageShootNumberPerPlant = averageShootNumberPerPlant; s.canopyShootNumber = canopyShootNumber; s.leafTillerNumberArray = leafTillerNumberArray; s.tilleringProfile = tilleringProfile; s.numberTillerCohort = numberTillerCohort; }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber.CurrentValue = s.canopyShootNumber; Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.CurrentValue = s.leafNumber; Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile.CurrentValue = s.tilleringProfile; Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray.CurrentValue = s.leafTillerNumberArray; Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort.CurrentValue = s.numberTillerCohort; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.canopyShootNumber.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.tilleringProfile.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafTillerNumberArray.ValueType)) { prc.AddCondition(r4); } RangeBasedCondition r5 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort); if (r5.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.numberTillerCohort.ValueType)) { prc.AddCondition(r5); } prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sowingDensity"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("targetFertileShoot"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.CurrentValue = a.deltaTT; Phenology.DomainClass.PhenologyStateVarInfo.phyllochron.CurrentValue = s.phyllochron; Phenology.DomainClass.PhenologyStateVarInfo.hasFlagLeafLiguleAppeared.CurrentValue = s.hasFlagLeafLiguleAppeared; Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.CurrentValue = s.leafNumber; Phenology.DomainClass.PhenologyStateVarInfo.phase.CurrentValue = s.phase; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.phyllochron); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.phyllochron.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.hasFlagLeafLiguleAppeared); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.hasFlagLeafLiguleAppeared.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.ValueType)) { prc.AddCondition(r4); } RangeBasedCondition r5 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.phase); if (r5.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.phase.ValueType)) { prc.AddCondition(r5); } string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double deltaTT = a.deltaTT; double phyllochron_t1 = s1.phyllochron; int hasFlagLeafLiguleAppeared = s.hasFlagLeafLiguleAppeared; double leafNumber_t1 = s1.leafNumber; double phase = s.phase; double leafNumber; leafNumber = leafNumber_t1; double phyllochron_; if (phase >= 1.0d && phase < 4.0d) { if (hasFlagLeafLiguleAppeared == 0) { if (phyllochron_t1 == 0.0d) { phyllochron_ = 0.0000001d; } else { phyllochron_ = phyllochron_t1; } leafNumber = leafNumber_t1 + Math.Min(deltaTT / phyllochron_, 0.999d); } } s.leafNumber = leafNumber; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double fixPhyll; if (latitude < 0.0d) { if (sowingDay > (int)(sDsa_sh)) { fixPhyll = p * (1 - (rp * Math.Min((sowingDay - sDsa_sh), sDws))); } else { fixPhyll = p; } } else { if (sowingDay < (int)(sDsa_nh)) { fixPhyll = p * (1 - (rp * Math.Min(sowingDay, sDws))); } else { fixPhyll = p; } } a.fixPhyll = fixPhyll; }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyAuxiliaryVarInfo.gAI.CurrentValue = a.gAI; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.CurrentValue = a.deltaTT; Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI.CurrentValue = s.pastMaxAI; Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1.CurrentValue = s.listTTShootWindowForPTQ1; Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ.CurrentValue = s.listGAITTWindowForPTQ; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.gAI); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.gAI.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.pastMaxAI.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.listTTShootWindowForPTQ1.ValueType)) { prc.AddCondition(r4); } RangeBasedCondition r5 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ); if (r5.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.listGAITTWindowForPTQ.ValueType)) { prc.AddCondition(r5); } prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("tTWindowForPTQ"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
public string TestPostConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the outputs to the static VarInfo representing the output properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.vernaprog.CurrentValue = s.vernaprog; Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber.CurrentValue = s.minFinalNumber; Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.CurrentValue = s.calendarMoments; Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.CurrentValue = s.calendarDates; Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.CurrentValue = s.calendarCumuls; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r21 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.vernaprog); if (r21.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.vernaprog.ValueType)) { prc.AddCondition(r21); } RangeBasedCondition r22 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber); if (r22.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber.ValueType)) { prc.AddCondition(r22); } RangeBasedCondition r23 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments); if (r23.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.ValueType)) { prc.AddCondition(r23); } RangeBasedCondition r24 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates); if (r24.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.ValueType)) { prc.AddCondition(r24); } RangeBasedCondition r25 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls); if (r25.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.ValueType)) { prc.AddCondition(r25); } string postConditionsResult = pre.VerifyPostconditions(prc, callID); if (!string.IsNullOrEmpty(postConditionsResult)) { pre.TestsOut(postConditionsResult, true, "PostConditions errors in strategy " + this.GetType().Name); } return(postConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running post-condition test. "; throw new Exception(msg, exception); } }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.CurrentValue = s.calendarMoments; Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.CurrentValue = s.calendarCumuls; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.CurrentValue = a.cumulTT; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.ValueType)) { prc.AddCondition(r3); } string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyAuxiliaryVarInfo.dayLength.CurrentValue = a.dayLength; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.CurrentValue = a.deltaTT; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.CurrentValue = a.cumulTT; Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.CurrentValue = s.leafNumber; Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.CurrentValue = s.calendarMoments; Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.CurrentValue = s.calendarDates; Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.CurrentValue = s.calendarCumuls; Phenology.DomainClass.PhenologyStateVarInfo.vernaprog.CurrentValue = s.vernaprog; Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate.CurrentValue = a.currentdate; Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber.CurrentValue = s.minFinalNumber; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.dayLength); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.dayLength.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.deltaTT.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.cumulTT.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.ValueType)) { prc.AddCondition(r4); } RangeBasedCondition r5 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments); if (r5.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarMoments.ValueType)) { prc.AddCondition(r5); } RangeBasedCondition r6 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates); if (r6.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarDates.ValueType)) { prc.AddCondition(r6); } RangeBasedCondition r7 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls); if (r7.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.calendarCumuls.ValueType)) { prc.AddCondition(r7); } RangeBasedCondition r8 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.vernaprog); if (r8.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.vernaprog.ValueType)) { prc.AddCondition(r8); } RangeBasedCondition r9 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate); if (r9.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.currentdate.ValueType)) { prc.AddCondition(r9); } RangeBasedCondition r10 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber); if (r10.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.minFinalNumber.ValueType)) { prc.AddCondition(r10); } prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("minTvern"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("intTvern"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("vAI"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("vBEE"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("minDL"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("maxDL"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("maxTvern"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("pNini"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("aMXLFNO"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("isVernalizable"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { List <string> calendarMoments_t1 = s1.calendarMoments; int isMomentRegistredZC_39; isMomentRegistredZC_39 = calendarMoments_t1.Contains("FlagLeafLiguleJustVisible") ? 1 : 0; s.isMomentRegistredZC_39 = isMomentRegistredZC_39; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double dayLength = a.dayLength; double deltaTT = a.deltaTT; double cumulTT = a.cumulTT; double leafNumber_t1 = s1.leafNumber; List <string> calendarMoments_t1 = s1.calendarMoments; List <DateTime> calendarDates_t1 = s1.calendarDates; List <double> calendarCumuls_t1 = s1.calendarCumuls; double vernaprog_t1 = s1.vernaprog; DateTime currentdate = a.currentdate; double minFinalNumber_t1 = s1.minFinalNumber; double vernaprog; double minFinalNumber; List <string> calendarMoments = new List <string>(); List <DateTime> calendarDates = new List <DateTime>(); List <double> calendarCumuls = new List <double>(); double maxVernaProg; double dLverna; double primordno; double minLeafNumber; double potlfno; double tt; calendarMoments = new List <string>(calendarMoments_t1); calendarCumuls = new List <double>(calendarCumuls_t1); calendarDates = new List <DateTime>(calendarDates_t1); minFinalNumber = minFinalNumber_t1; vernaprog = vernaprog_t1; if (isVernalizable == 1 && vernaprog_t1 < 1.0d) { tt = deltaTT; if (tt >= minTvern && tt <= intTvern) { vernaprog = vernaprog_t1 + (vAI * tt) + vBEE; } else { vernaprog = vernaprog_t1; } if (tt > intTvern) { maxVernaProg = vAI * intTvern + vBEE; dLverna = Math.Max(minDL, Math.Min(maxDL, dayLength)); vernaprog = vernaprog + Math.Max(0.0d, maxVernaProg * (1.0d + ((intTvern - tt) / (maxTvern - intTvern) * ((dLverna - minDL) / (maxDL - minDL))))); } primordno = 2.0d * leafNumber_t1 + pNini; minLeafNumber = minFinalNumber_t1; if (vernaprog >= 1.0d || primordno >= aMXLFNO) { minFinalNumber = Math.Max(primordno, minFinalNumber_t1); calendarMoments.Add("EndVernalisation"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); vernaprog = Math.Max(1.0d, vernaprog); } else { potlfno = aMXLFNO - ((aMXLFNO - minLeafNumber) * vernaprog); if (primordno >= potlfno) { minFinalNumber = Math.Max((potlfno + primordno) / 2.0d, minFinalNumber_t1); vernaprog = Math.Max(1.0d, vernaprog); calendarMoments.Add("EndVernalisation"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } } } s.vernaprog = vernaprog; s.minFinalNumber = minFinalNumber; s.calendarMoments = calendarMoments; s.calendarDates = calendarDates; s.calendarCumuls = calendarCumuls; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double fixPhyll = a.fixPhyll; double leafNumber = s.leafNumber; double ptq = s.ptq; double gAImean = s.gAImean; double phyllochron; double gaiLim; double LAR; phyllochron = 0.0d; LAR = 0.0d; gaiLim = lNeff * ((areaSL + areaSS) / 10000.0d) * sowingDensity; if (choosePhyllUse == "Default") { if (leafNumber < ldecr) { phyllochron = fixPhyll * pdecr; } else if (leafNumber >= ldecr && leafNumber < lincr) { phyllochron = fixPhyll; } else { phyllochron = fixPhyll * pincr; } } if (choosePhyllUse == "PTQ") { if (gAImean > gaiLim) { LAR = (lARmin + ((lARmax - lARmin) * ptq / (pTQhf + ptq))) / (B * gAImean); } else { LAR = (lARmin + ((lARmax - lARmin) * ptq / (pTQhf + ptq))) / (B * gaiLim); } phyllochron = 1.0d / LAR; } if (choosePhyllUse == "Test") { if (leafNumber < ldecr) { phyllochron = p * pdecr; } else if (leafNumber >= ldecr && leafNumber < lincr) { phyllochron = p; } else { phyllochron = p * pincr; } } s.phyllochron = phyllochron; }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { List <double> listTTShootWindowForPTQ_t1 = s1.listTTShootWindowForPTQ; List <double> listPARTTWindowForPTQ_t1 = s1.listPARTTWindowForPTQ; List <double> listGAITTWindowForPTQ = s.listGAITTWindowForPTQ; double pAR = a.pAR; double deltaTT = a.deltaTT; List <double> listPARTTWindowForPTQ = new List <double>(); List <double> listTTShootWindowForPTQ = new List <double>(); double ptq; List <double> TTList = new List <double>(); List <double> PARList = new List <double>(); int i; int count; double SumTT; double parInt = 0.0d; double TTShoot; for (i = 0; i != listTTShootWindowForPTQ_t1.Count; i += 1) { TTList.Add(listTTShootWindowForPTQ_t1[i]); PARList.Add(listPARTTWindowForPTQ_t1[i]); } TTList.Add(deltaTT); PARList.Add(pAR); SumTT = TTList.Sum(); count = 0; while (SumTT > tTWindowForPTQ) { SumTT = SumTT - TTList[count]; count = count + 1; } for (i = count; i != TTList.Count; i += 1) { listTTShootWindowForPTQ.Add(TTList[i]); listPARTTWindowForPTQ.Add(PARList[i]); } for (i = 0; i != listTTShootWindowForPTQ.Count; i += 1) { parInt = parInt + (listPARTTWindowForPTQ[i] * (1 - Math.Exp(-kl * listGAITTWindowForPTQ[i]))); } TTShoot = listTTShootWindowForPTQ.Sum(); ptq = parInt / TTShoot; s.listPARTTWindowForPTQ = listPARTTWindowForPTQ; s.listTTShootWindowForPTQ = listTTShootWindowForPTQ; s.ptq = ptq; }
public string TestPreConditions(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex, string callID) { try { //Set current values of the inputs to the static VarInfo representing the inputs properties of the domain classes Phenology.DomainClass.PhenologyAuxiliaryVarInfo.fixPhyll.CurrentValue = a.fixPhyll; Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.CurrentValue = s.leafNumber; Phenology.DomainClass.PhenologyStateVarInfo.ptq.CurrentValue = s.ptq; Phenology.DomainClass.PhenologyStateVarInfo.gAImean.CurrentValue = s.gAImean; ConditionsCollection prc = new ConditionsCollection(); Preconditions pre = new Preconditions(); RangeBasedCondition r1 = new RangeBasedCondition(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.fixPhyll); if (r1.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyAuxiliaryVarInfo.fixPhyll.ValueType)) { prc.AddCondition(r1); } RangeBasedCondition r2 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber); if (r2.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.leafNumber.ValueType)) { prc.AddCondition(r2); } RangeBasedCondition r3 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.ptq); if (r3.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.ptq.ValueType)) { prc.AddCondition(r3); } RangeBasedCondition r4 = new RangeBasedCondition(Phenology.DomainClass.PhenologyStateVarInfo.gAImean); if (r4.ApplicableVarInfoValueTypes.Contains(Phenology.DomainClass.PhenologyStateVarInfo.gAImean.ValueType)) { prc.AddCondition(r4); } prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("lincr"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("ldecr"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("pdecr"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("pincr"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("kl"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("pTQhf"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("B"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("p"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("choosePhyllUse"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("areaSL"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("areaSS"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("lARmin"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("lARmax"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("sowingDensity"))); prc.AddCondition(new RangeBasedCondition(_modellingOptionsManager.GetParameterByName("lNeff"))); string preConditionsResult = pre.VerifyPreconditions(prc, callID); if (!string.IsNullOrEmpty(preConditionsResult)) { pre.TestsOut(preConditionsResult, true, "PreConditions errors in strategy " + this.GetType().Name); } return(preConditionsResult); } catch (Exception exception) { string msg = ".Phenology, " + this.GetType().Name + ": Unhandled exception running pre-condition test. "; throw new Exception(msg, exception); } }
private void CalculateModel(Phenology.DomainClass.PhenologyState s, Phenology.DomainClass.PhenologyState s1, Phenology.DomainClass.PhenologyRate r, Phenology.DomainClass.PhenologyAuxiliary a, Phenology.DomainClass.PhenologyExogenous ex) { double cumulTT = a.cumulTT; List <string> calendarMoments = s.calendarMoments; List <DateTime> calendarDates = s.calendarDates; List <double> calendarCumuls = s.calendarCumuls; DateTime currentdate = a.currentdate; double phase = s.phase; if (phase >= 1.0d && phase < 2.0d && !calendarMoments.Contains("Emergence")) { calendarMoments.Add("Emergence"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase >= 2.0d && phase < 3.0d && !calendarMoments.Contains("FloralInitiation")) { calendarMoments.Add("FloralInitiation"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase >= 3.0d && phase < 4.0d && !calendarMoments.Contains("Heading")) { calendarMoments.Add("Heading"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase == 4.0d && !calendarMoments.Contains("Anthesis")) { calendarMoments.Add("Anthesis"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase == 4.5d && !calendarMoments.Contains("EndCellDivision")) { calendarMoments.Add("EndCellDivision"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase >= 5.0d && phase < 6.0d && !calendarMoments.Contains("EndGrainFilling")) { calendarMoments.Add("EndGrainFilling"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } else if (phase >= 6.0d && phase < 7.0d && !calendarMoments.Contains("Maturity")) { calendarMoments.Add("Maturity"); calendarCumuls.Add(cumulTT); calendarDates.Add(currentdate); } s.calendarMoments = calendarMoments; s.calendarDates = calendarDates; s.calendarCumuls = calendarCumuls; }