private bool empty = true; // tracks if the header has been printed for the interval value data [EventHandler] public void Ondodcapst() { int DOY = 0; double latitude = 0; double maxT = 0; double minT = 0; double radn = 0; double RootShootRatio = 0; double SLN = 0; double SWAvailable = 0; double lai = 0; MyPaddock.Get("DCAPSTDOY", out DOY); MyPaddock.Get("DCAPSTsln", out SLN); MyPaddock.Get("DCAPSTRootShootRatio", out RootShootRatio); MyPaddock.Get("DCAPSTswAvail", out SWAvailable); MyPaddock.Get("latitude", out latitude); MyPaddock.Get("maxT", out maxT); MyPaddock.Get("minT", out minT); MyPaddock.Get("radn", out radn); MyPaddock.Get("lai", out lai); // Model the photosynthesis DCAPSTModel DM = Classic.SetUpModel(CP, PP, DOY, latitude, maxT, minT, radn); // Optional values DM.PrintIntervalValues = false; // Switch to print extra data (default = false) DM.Biolimit = 0; // Biological transpiration limit of the crop (0 disables mechanism) DM.Reduction = 0; // Excess water reduction fraction for bio-limited transpiration (0 disables mechanism) // Run the simulation DM.DailyRun(lai, SLN, SWAvailable, RootShootRatio); if (DM.PrintIntervalValues) { if (empty) { writer.WriteLine(DM.PrintResultHeader()); empty = false; } writer.WriteLine(DM.IntervalResults); } // Outputs RootShoot = RootShootRatio; BIOshootDAY = dcapst[0] = DM.ActualBiomass; BIOtotalDAY = BIOshootDAY * (1 + RootShoot); EcanDemand = dcapst[1] = DM.WaterDemanded; EcanSupply = dcapst[2] = DM.WaterSupplied; RadIntDcaps = dcapst[3] = DM.InterceptedRadiation; RUE = (RadIntDcaps == 0 ? 0 : BIOshootDAY / RadIntDcaps); TE = (EcanSupply == 0 ? 0 : BIOshootDAY / EcanSupply); BIOshootDAYPot = dcapst[4] = DM.PotentialBiomass; SoilWater = SWAvailable; }
public void Ondodcapst() { int DOY = 0; double latitude = 0; double maxT = 0; double minT = 0; double radn = 0; double RootShootRatio = 0; double sln = 0; double greenN = 0; double SWAvailable = 0; double lai = 0; MyPaddock.Get("DCAPSTDOY", out DOY); MyPaddock.Get("DCAPSTRootShootRatio", out RootShootRatio); MyPaddock.Get("DCAPSTswAvail", out SWAvailable); MyPaddock.Get("LeafGreenN", out greenN); MyPaddock.Get("latitude", out latitude); MyPaddock.Get("maxT", out maxT); MyPaddock.Get("minT", out minT); MyPaddock.Get("radn", out radn); MyPaddock.Get("lai", out lai); // Model the photosynthesis double rpar = 0.5; DCAPSTModel DM = Classic.SetUpModel(CP, PP, DOY, latitude, maxT, minT, radn, rpar); // OPTIONAL VALUES: // Biological transpiration limit of the crop DM.Biolimit = 0; // default = 0 (disabled) // Excess water reduction fraction for bio-limited transpiration DM.Reduction = 0; // default = 0 (disabled) if (lai > LAITrigger && lai < NLAITrigger) { sln = Math.Max(greenN, NLowLimit); } else { sln = greenN / lai; } // Run the simulation DM.DailyRun(lai, sln, SWAvailable, RootShootRatio); // Daily outputs RootShoot = RootShootRatio; BIOshootDAY = dcapst[0] = DM.ActualBiomass; BIOtotalDAY = BIOshootDAY * (1 + RootShoot); EcanDemand = dcapst[1] = DM.WaterDemanded; EcanSupply = dcapst[2] = DM.WaterSupplied; RadIntDcaps = dcapst[3] = DM.InterceptedRadiation; RUE = (RadIntDcaps == 0 ? 0 : BIOshootDAY / RadIntDcaps); TE = (EcanSupply == 0 ? 0 : BIOshootDAY / EcanSupply); BIOshootDAYPot = dcapst[4] = DM.PotentialBiomass; SoilWater = SWAvailable; dsln = sln; // Interval outputs // For reasons unknown, wheat calls this method twice, but only the 2nd call is used/valid. // This skipper just stops the bad data from showing up in the interval report skipper = !skipper; if (skipper) { foreach (var interval in DM.Intervals) { Hour = interval.Time; SunlitTemperature = interval.Sunlit.Temperature; ShadedTemperature = interval.Shaded.Temperature; SunlitAc1 = interval.Sunlit.Ac1.Assimilation; SunlitAc2 = interval.Sunlit.Ac2.Assimilation; SunlitAj = interval.Sunlit.Aj.Assimilation; ShadedAc1 = interval.Shaded.Ac1.Assimilation; ShadedAc2 = interval.Shaded.Ac2.Assimilation; ShadedAj = interval.Shaded.Aj.Assimilation; if (IntervalStep != null) { IntervalStep.Invoke(); } } } }
public void Ondodcaps() { int DOY = 0; double latitude = 0; double maxT = 0; double minT = 0; double radn = 0; double RootShootRatio = 0; double SLN = 0; double SWAvailable = 0; double lai = 0; MyPaddock.Get("DOY", out DOY); MyPaddock.Get("latitude", out latitude); MyPaddock.Get("maxT", out maxT); MyPaddock.Get("minT", out minT); MyPaddock.Get("radn", out radn); MyPaddock.Get("RootShootRatio", out RootShootRatio); MyPaddock.Get("SLN", out SLN); MyPaddock.Get("SWAvailable", out SWAvailable); MyPaddock.Get("lai", out lai); // Model the photosynthesis double rpar = 0.5; DCAPSTModel DM = Classic.SetUpModel(CP, PP, DOY, latitude, maxT, minT, radn, rpar); // Optional values DM.PrintIntervalValues = false; // Switch to print extra data (default = false) DM.Biolimit = 0; // Biological transpiration limit of the crop (0 disables mechanism) DM.Reduction = 0; // Excess water reduction fraction for bio-limited transpiration (0 disables mechanism) // Run the simulation DM.DailyRun(lai, SLN, SWAvailable, RootShootRatio); // Daily Outputs RootShoot = RootShootRatio; BIOshootDAY = dcaps[0] = DM.ActualBiomass; BIOtotalDAY = BIOshootDAY * (1 + RootShoot); EcanDemand = dcaps[1] = DM.WaterDemanded; EcanSupply = dcaps[2] = DM.WaterSupplied; RadIntDcapst = dcaps[3] = DM.InterceptedRadiation; RUE = (RadIntDcapst == 0 ? 0 : BIOshootDAY / RadIntDcapst); TE = (EcanSupply == 0 ? 0 : BIOshootDAY / EcanSupply); BIOshootDAYPot = dcaps[4] = DM.PotentialBiomass; SoilWater = SWAvailable; // Interval outputs foreach (var interval in DM.Intervals) { Hour = interval.Time; SunlitTemperature = interval.Sunlit.Temperature; ShadedTemperature = interval.Shaded.Temperature; SunlitAc1 = interval.Sunlit.Ac1.Assimilation; SunlitAc2 = interval.Sunlit.Ac2.Assimilation; SunlitAj = interval.Sunlit.Aj.Assimilation; ShadedAc1 = interval.Shaded.Ac1.Assimilation; ShadedAc2 = interval.Shaded.Ac2.Assimilation; ShadedAj = interval.Shaded.Aj.Assimilation; if (IntervalStep != null) { IntervalStep.Invoke(); } } }
public static DCAPSTModel SetUpModel( ICanopyParameters CP, IPathwayParameters PP, int DOY, double latitude, double maxT, double minT, double radn) { // Model the solar geometry var SG = new SolarGeometry { Latitude = latitude.ToRadians(), DayOfYear = DOY }; // Model the solar radiation var SR = new SolarRadiation(SG) { Daily = radn, RPAR = 0.5 }; // Model the environmental temperature var TM = new Temperature(SG) { MaxTemperature = maxT, MinTemperature = minT, AtmosphericPressure = 1.01325 }; // Model the pathways var SunlitAc1 = new AssimilationPathway(CP, PP); var SunlitAc2 = new AssimilationPathway(CP, PP); var SunlitAj = new AssimilationPathway(CP, PP); var ShadedAc1 = new AssimilationPathway(CP, PP); var ShadedAc2 = new AssimilationPathway(CP, PP); var ShadedAj = new AssimilationPathway(CP, PP); // Model the canopy IAssimilation A; if (CP.Type == CanopyType.C3) { A = new AssimilationC3(CP, PP); } else if (CP.Type == CanopyType.C4) { A = new AssimilationC4(CP, PP); } else { A = new AssimilationCCM(CP, PP); } var sunlit = new AssimilationArea(SunlitAc1, SunlitAc2, SunlitAj, A); var shaded = new AssimilationArea(ShadedAc1, ShadedAc2, ShadedAj, A); var CA = new CanopyAttributes(CP, PP, sunlit, shaded); // Model the transpiration var WI = new WaterInteraction(TM); var TR = new TemperatureResponse(CP, PP); var TS = new Transpiration(CP, PP, WI, TR); // Model the photosynthesis var DM = new DCAPSTModel(SG, SR, TM, PP, CA, TS) { B = 0.409 }; return(DM); }