private void CalculateModel(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, 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 // For leaf tips appearance : // -------------------------- if (maizelaistate.newLeafHasAppeared == 1) { var newNbLayer = (int)Math.Ceiling(maizelaistate.leafNumber); var curNbLayer = (int)Math.Ceiling(maizelaistate.previousLeafNumber); double cumulTT = maizelaistate.cumulTTPHenoMaize - maizelaistate.deltaTTPhenoMaize; for (var index = curNbLayer; index < newNbLayer; ++index) { double leafnum = index + 1; if (cumulTT <= btip) { maizeleafstate.tipTT[index] = Dse; } else { maizeleafstate.tipTT[index] = leafnum * atip + btip + Dse; } } } //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 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 }
public void Estimate(SiriusQualityEnergybalance.EnergybalanceState s, SiriusQualityEnergybalance.Energybalance s1, SiriusQualityEnergybalance.EnergybalanceRAte r, SiriusQualityEnergybalance.EnergybalanceAuxiliary a, SiriusQualityEnergybalance.EnergybalanceExogenous ex, CRA.AgroManagement.ActEvents actevents) { try { CalculateModel(s, s1, r, a, ex) } catch (Exception exception) { string msg = "Error in component SiriusQualityEnergybalance, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message; throw new Exception(msg, exception); } }
private void CalculateModel(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, CRA.AgroManagement.ActEvents actevents) { EstimateOfAssociatedClasses(maizelaistate, maizeleafstate, maizeleafstate1, actevents); //GENERATED CODE END - PLACE YOUR CUSTOM CODE BELOW - Section1 //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 - 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 if (phenologystate.LeafNumber < Ldecr) { phenologystate.Phyllochron = P * Pdecr; } else if (phenologystate.LeafNumber >= Ldecr && phenologystate.LeafNumber < Lincr) { phenologystate.Phyllochron = P; } else { phenologystate.Phyllochron = P * 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 }
/// <summary> /// Run the strategy to calculate the outputs. In case of error during the execution, the preconditions tests are executed. /// </summary> public void Estimate(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, CRA.AgroManagement.ActEvents actevents) { try { CalculateModel(rates, exogenous, states, actevents); //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1005,"Strategy: " + this.GetType().Name + " - Model executed"); } catch (Exception exception) { //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1003, "Strategy: " + this.GetType().Name + " - Unhandled exception running model"); string msg = "Error in component INRA.SiriusQualityIrradiance.Strategies, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message; throw new Exception(msg, exception); } }
private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, 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 (wheatleafstate.isSmallPhytomer[wheatlaistate.index] == 0) { wheatleafstate.TTmat[wheatlaistate.index] = PlagLL * wheatleafstate.Phyllochron[wheatlaistate.index]; } else { wheatleafstate.TTmat[wheatlaistate.index] = PlagSL * wheatleafstate.Phyllochron[wheatlaistate.index]; } //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 }
//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); }
private void CalculateModel(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, 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 (maizelaistate.newLeafHasAppeared == 1) { var newNbLayer = (int)Math.Ceiling(maizelaistate.leafNumber); var curNbLayer = (int)Math.Ceiling(maizelaistate.previousLeafNumber); for (var index = curNbLayer; index < newNbLayer; ++index) { // For beginning of linear elongation : // ------------------------------------ double leafnum = index + 1; double abl = k_bl * atip; double bbl = atip * Nlim * (1 - k_bl) + btip; if (leafnum <= Nlim) { maizeleafstate.startExpTT[index] = maizeleafstate.tipTT[index]; } else { maizeleafstate.startExpTT[index] = abl * leafnum + bbl + Dse; } } } //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(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 //Inputs double rho = states.rhoLeaf; double tau = states.tauLeaf; double alphaMean = states.ala; Dictionary <int, Tuple <double, double> > gai = states.layersGAI; double L_tot = gai.Sum(x => x.Value.Item1 + x.Value.Item2); double sigma = rho + tau; double Sum_kd = 0.0; Func <double, double> f = null; if (useSphericalLeafDistrib == 1) { f = x => (1 - Math.Exp(-(CI * Math.Sqrt(1.0 - sigma) * 0.5 / Math.Sin(Math.Max(0.00174533, x))) * L_tot)) * Math.Cos(x) * Math.Sin(x); } else { double Chi = Math.Pow(alphaMean / 9.65, -0.6061) - 3; f = x => (1 - Math.Exp(-(CI * Math.Sqrt(1.0 - sigma) * (Math.Sqrt(Math.Pow(Chi, 2) + (1 / Math.Pow(Math.Tan(x), 2)))) / (Chi + 1.774 * Math.Pow(Chi + 1.182, -0.733))) * L_tot)) * Math.Cos(x) * Math.Sin(x); } Sum_kd = Math.Max(1E-06, GaussLegendreRule.Integrate(f, 0.0, Math.PI / 2.0, 30)); //Outputs states.k_dif = Math.Min(1.0, -(1 / L_tot) * Math.Log(1.0 - 2.0 * Sum_kd)); double Sum_kdBlack = 0.0; Func <double, double> fBlack = null; if (useSphericalLeafDistrib == 1) { fBlack = x => (1 - Math.Exp(-(CI * 0.5 / Math.Sin(Math.Max(0.00174533, x))) * L_tot)) * Math.Cos(x) * Math.Sin(x); } else { double Chi = Math.Pow(alphaMean / 9.65, -0.6061) - 3; fBlack = x => (1 - Math.Exp(-(CI * (Math.Sqrt(Math.Pow(Chi, 2) + (1 / Math.Pow(Math.Tan(x), 2)))) / (Chi + 1.774 * Math.Pow(Chi + 1.182, -0.733))) * L_tot)) * Math.Cos(x) * Math.Sin(x); } Sum_kdBlack = Math.Max(1E-06, GaussLegendreRule.Integrate(fBlack, 0.0, Math.PI / 2.0, 30)); //Outputs states.k_difBlack = Math.Min(1.0, -(1 / L_tot) * Math.Log(1.0 - 2.0 * Sum_kdBlack)); //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(SiriusQualityEnergyBalanceDomainClass.EnergyBalanceState energybalancestate, SiriusQualityEnergyBalanceDomainClass.EnergyBalanceState energybalancestate1, SiriusQualityEnergyBalanceDomainClass.EnergyBalanceExogenous energybalanceexogenous, 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 #region Inputs //double[] soilHeatFlux = energybalancestate.hourlySoilHeatFlux; double[] As = energybalancestate.hourlyNetRadSoil; Dictionary <string, Dictionary <int, Dictionary <int, double> > > Av = energybalancestate.hourlyNetRadVeg; #endregion #region Auxilliary double[] AvTot = new double[24]; foreach (string isunshade in Av.Keys) { foreach (int ihour in Av[isunshade].Keys) { foreach (int ilayer in Av[isunshade][ihour].Keys) { AvTot[ihour] += Av[isunshade][ihour][ilayer]; } } } #endregion #region Outputs //for (int ihour = 0; ihour < 24; ihour++) energybalancestate.hourlyNetRadTotAv[ihour] = As[ihour] + AvTot[ihour] - soilHeatFlux[ihour]; for (int ihour = 0; ihour < 24; ihour++) { energybalancestate.hourlyNetRadTotAv[ihour] = As[ihour] + AvTot[ihour]; } #endregion //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> /// Run the strategy to calculate the outputs. In case of error during the execution, the preconditions tests are executed. /// </summary> public void Estimate(SiriusQualityEnergyBalanceDomainClass.EnergyBalanceState energybalancestate, SiriusQualityEnergyBalanceDomainClass.EnergyBalanceState energybalancestate1, SiriusQualityEnergyBalanceDomainClass.EnergyBalanceExogenous energybalanceexogenous, CRA.AgroManagement.ActEvents actevents) { try { CalculateModel(energybalancestate, energybalancestate1, energybalanceexogenous, actevents); //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1005,"Strategy: " + this.GetType().Name + " - Model executed"); } catch (Exception exception) { //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1003, "Strategy: " + this.GetType().Name + " - Unhandled exception running model"); string msg = "Error in component SiriusQualityEnergyBalance, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message; throw new Exception(msg, exception); } }
private void CalculateModel(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 #region Inputs double GAITot = states.layersGAI.Sum(x => x.Value.Item1 + x.Value.Item2); //Ellipse double alphaMean = states.ala; double rho = states.rhoLeaf; double tau = states.tauLeaf; double sigma = rho + tau; #endregion Dictionary <int, double> K_dirDict = new Dictionary <int, double>(); double[] angles = new double[6] { 15.0, 30.0, 45.0, 60.0, 75.0, 90.0 }; double[] anglesRad = new double[6]; for (int ia = 0; ia < 6; ia++) { anglesRad[ia] = angles[ia] * Math.PI / 180; } if (useSphericalLeafDistrib == 0) { for (int ia = 0; ia < 6; ia++) { double k1_dir = 0.0; double Chi = Math.Pow(alphaMean / 9.65, -0.6061) - 3; k1_dir = CI * (Math.Sqrt(Math.Pow(Chi, 2) + (Math.Pow(1 / Math.Tan(anglesRad[ia]), 2)))) / (Chi + 1.774 * Math.Pow(Chi + 1.182, -0.733)); K_dirDict.Add(ia, Math.Min(k1_dir * Math.Sqrt(1.0 - sigma), 999)); } } else { // Extinction coefficient for direct irradiances (beam and scattered) // Note: a spherical distribution for leaf inclination angle is assumed. for (int ia = 0; ia < 6; ia++) { double beta_sun_Hourly = Math.Max(0.00174533, anglesRad[ia]); // Minium allowed angle is 0.1 � to avoid numerical instability double k1_dir = CI * 0.5 / Math.Sin(beta_sun_Hourly); // beam coef K_dirDict.Add(ia, Math.Min(k1_dir * Math.Sqrt(1.0 - sigma), 999)); } } Dictionary <double, double> fipb = new Dictionary <double, double>(); for (int iangle = 0; iangle < 6; iangle++) { fipb.Add(angles[iangle], 1.0 - Math.Exp(-K_dirDict[iangle] * GAITot)); } #region Output states.fiPARb = new Dictionary <double, double>(fipb); #endregion //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 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 }
private void CalculateModel(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, 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 // calculate hLER CalcHLER(maizelaistate); double dailyLER = 0; for (int i = 0; i < 24; i++) { dailyLER += maizelaistate.hLER[i]; } maizelaistate.LER = dailyLER / 24.0; //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(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 //Input Dictionary <int, double> k1_dirDict = states.k1_dir; Dictionary <int, Tuple <double, double> > gaiDict = states.layersGAI; // Output Dictionary <int, Dictionary <int, double> > I_sun_absDict = new Dictionary <int, Dictionary <int, double> >(); Dictionary <int, Dictionary <int, double> > I_shade_absDict = new Dictionary <int, Dictionary <int, double> >(); // Auxiliary Tuple <Dictionary <int, double>, Dictionary <int, double> > absDicts; IEnumerable <int> layers; layers = gaiDict.Keys; // initialization foreach (int hour in Enumerable.Range(0, 24)) { I_sun_absDict.Add(hour, new Dictionary <int, double>()); I_shade_absDict.Add(hour, new Dictionary <int, double>()); foreach (int layerIndex in layers) { I_sun_absDict[hour].Add(layerIndex, 0.0); I_shade_absDict[hour].Add(layerIndex, 0.0); } } // Hourly calculations foreach (int hour in Enumerable.Range(0, 24)) { double k1_dir = k1_dirDict[hour]; absDicts = HourlyAbsorbedIrradiance(k1_dir, gaiDict); I_sun_absDict[hour] = absDicts.Item1; I_shade_absDict[hour] = absDicts.Item2; } states.sunlitFraction = I_sun_absDict; // absorbedSunlitIrradiance; states.shadeFraction = I_shade_absDict; // absorbedShadedIrradiance; //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 }
private void CalculateModel(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 //Input double[] beta_sun = exogenous.solarElevation; double alphaMean = states.ala; //Outpus Dictionary <int, double> K1_dirDict = new Dictionary <int, double>(); for (int hour = 0; hour < 24; hour++) { double k1_dir = 0.0; double Chi = Math.Pow(alphaMean / 9.65, -0.6061) - 3; k1_dir = CI * (Math.Sqrt(Math.Pow(Chi, 2) + (1 / Math.Pow(Math.Tan(beta_sun[hour]), 2)))) / (Chi + 1.774 * Math.Pow(Chi + 1.182, -0.733)); K1_dirDict.Add(hour, Math.Min(k1_dir, 999)); } states.k1_dir = K1_dirDict; //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(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 //Inpput Dictionary <int, Dictionary <int, double> > I_tot_absDict = rates.absorbedGlobalIrradianceLayeredHourly; // Return daily abs and inc irradiance values if needed Dictionary <int, Dictionary <int, double> > tempo = new Dictionary <int, Dictionary <int, double> >(); tempo.Add(99, new Dictionary <int, double>()); // 99 indicates a daily value (one timeStep key only) // Create an intial dictionary of 0 absorbed irradiance per layer. foreach (int layerIndex in I_tot_absDict[0].Keys) { tempo[99].Add(layerIndex, 0); } // Sum up aborbed irradiance over the day hours foreach (int hour in Enumerable.Range(0, 24)) { foreach (int layerIndex in I_tot_absDict[hour].Keys) { tempo[99][layerIndex] += I_tot_absDict[hour][layerIndex]; } } I_tot_absDict = SiriusQuality_IrradianceStrategies.Utilities.CloneDictionary.CloneDict(tempo); rates.absorbedGlobalIrradiance = I_tot_absDict; //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> /// copy constructor. We only need to copy the parameters (the strategies being stateless) /// </summary> public void UpdateLeafArea(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, CRA.AgroManagement.ActEvents actevents) { _updateleafarea.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); }
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 }
//Call of the associated strategies private void EstimateOfAssociatedClasses(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, CRA.AgroManagement.ActEvents actevents) { _calcfracpopn.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcler.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calclercoeff.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcinittt.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calctiptt.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcligulett.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcstartexptt.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcfullyexptt.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcbasewidth.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcstartenlargett.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _calcstopenlargett.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); _deltalaimaize.Estimate(maizelaistate, maizeleafstate, maizeleafstate1, actevents); resetDeltaAI(maizeleafstate); }
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 }
private void CalculateModel(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, 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 (wheatlaistate.isPotentialLAI == 1) { wheatlaistate.DEF = 1; wheatlaistate.DSF = 1; } else { wheatlaistate.DEF = CalculateDF(LowerFPAWexp, UpperFPAWexp, 0, 1, wheatlaistate.FPAW, wheatlaistate.VPDairCanopy); wheatlaistate.DSF = CalculateDF(LowerFPAWsen, UpperFPAWsen, MaxDSF, 1, wheatlaistate.FPAW, wheatlaistate.VPDairCanopy); } //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(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, 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 (maizelaistate.newLeafHasAppeared == 1) { var newNbLayer = (int)Math.Ceiling(maizelaistate.leafNumber); var curNbLayer = (int)Math.Ceiling(maizelaistate.previousLeafNumber); for (var index = curNbLayer; index < newNbLayer; ++index) { maizeleafstate.startEnlargeTT[index] = maizeleafstate.startExpTT[index]; } } //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 }
private void CalculateModel(INRA.SiriusQualityIrradiance.Interfaces.Rates rates, INRA.SiriusQualityIrradiance.Interfaces.Exogenous exogenous, INRA.SiriusQualityIrradiance.Interfaces.States states, 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 //Input double[] I_dir_incDict = exogenous.incidentDirectIrradiance; double[] I_dif_incDict = exogenous.incidentDiffuseIrradiance; Dictionary <int, Tuple <double, double> > gaiDict = states.layersGAI; //int useHourly = irradiancestate.useHourly; //int useLayered = irradiancestate.useLayered; Dictionary <int, double> result; Dictionary <int, Dictionary <int, double> > I_tot_absDict = new Dictionary <int, Dictionary <int, double> >(); rates.absorbedGlobalIrradianceLayeredHourly = new Dictionary <int, Dictionary <int, double> >(); // Calculate incident and absorbed irradiance for each leaf layer hourly. foreach (int hour in Enumerable.Range(0, 24)) { double I_dir = I_dir_incDict[hour]; double I_dif = I_dif_incDict[hour]; result = CalculateLayerHourly(I_dir, I_dif, Kl, gaiDict); Dictionary <int, double> absDict = result; //Dictionary<int, double> incDict = result.Item2; I_tot_absDict.Add(hour, absDict); } rates.absorbedGlobalIrradianceLayeredHourly = rates.absorbedGlobalIrradiance = I_tot_absDict; //irradiancestate.interceptedTotalIrradiance = I_tot_incDict; //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> /// Run the strategy to calculate the outputs. In case of error during the execution, the preconditions tests are executed. /// </summary> public void Estimate(SiriusQualityWheatLAI.WheatLAIState wheatlaistate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate, SiriusQualityWheatLAI.WheatLeafState wheatleafstate1, CRA.AgroManagement.ActEvents actevents) { try { CalculateModel(wheatlaistate, wheatleafstate, wheatleafstate1, actevents); //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 1005,"Strategy: " + this.GetType().Name + " - Model executed"); } catch (Exception exception) { //Uncomment the next line to use the trace //TraceStrategies.TraceEvent(System.Diagnostics.TraceEventType.Error, 1003, "Strategy: " + this.GetType().Name + " - Unhandled exception running model"); string msg = "Error in component SiriusQualityWheatLAI.Strategies, strategy: " + this.GetType().Name + ": Unhandled exception running model. " + exception.GetType().FullName + " - " + exception.Message; throw new Exception(msg, exception); } }
private void CalculateModel(SiriusQualityMaizeLAI.MaizeLAIState maizelaistate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate, SiriusQualityMaizeLAI.MaizeLeafState maizeleafstate1, 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 (maizelaistate.newLeafHasAppeared == 1) { var newNbLayer = (int)Math.Ceiling(maizelaistate.leafNumber); var curNbLayer = (int)Math.Ceiling(maizelaistate.previousLeafNumber); for (var index = curNbLayer; index < newNbLayer; ++index) { // For ligulation : // ---------------- double N_limll = alpha_tr * Nfinal; double b_ll2 = a_ll1 * N_limll * (1 - k_ll) + b_ll1; double a_ll2 = k_ll * a_ll1; double leafnum = index + 1; if (leafnum <= N_limll) { // Add tt_to_emerg (TTem): maizeleafstate.liguleTT[index] = a_ll1 * leafnum + b_ll1 + Dse; } else { // Add tt_to_emerg (TTem): maizeleafstate.liguleTT[index] = a_ll2 * leafnum + b_ll2 + Dse; } } } //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 }