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(); } } }