Пример #1
0
        public CClimDay(int Latitude, DateTime CurrentDate, float PAR0, float TMin, float TMax, float Prec, float CO2)
        {
            try
            {
                this.CurrentDate = CurrentDate;
                par0             = PAR0;
                tmin             = TMin;
                tmax             = TMax;
                prec             = Prec;

                if (prec < 0)
                {
                    throw new System.Exception("Precipitation = " + prec + "\t" + CurrentDate);
                }

                co2 = CO2;

                float hr = Calculate_hr(CurrentDate.DayOfYear, Latitude);
                daylength   = Calculate_DayLength(hr);
                nightlength = Calculate_NightLength(hr);
                dayspan     = Calculate_DaySpan(CurrentDate.Month);
                tave        = Calculate_Tave(TMin, TMax);
                tday        = Calculate_TDay(TMax, Tave);
                vpd         = Calculate_VPD(Tday, TMin);

                dtemp        = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                dvpd         = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                netpsn_pot   = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                wue          = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                delamax      = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                fResp        = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                resp_pot     = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                wue_co2_corr = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                grossPsn_pot = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                resp_folbase = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                IsActive     = new Biomass.Species.AuxParm <bool>(PlugIn.ModelCore.Species);
                dt_night     = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                dt_day       = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);
                gdd          = new Landis.Extension.Succession.Biomass.Species.AuxParm <float>(PlugIn.ModelCore.Species);

                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    gdd[spc] = 0;
                }

                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    float dGDD = Math.Max(0, (Tave - SpeciesData.PsnTMin[spc]) * DaySpan);
                    if (CurrentDate.Month == 1)
                    {
                        gdd[spc] = dGDD;
                    }
                    else
                    {
                        DateTime last_month = new DateTime(CurrentDate.Year, CurrentDate.Month - 1, 15);
                        gdd[spc] = ClimateData.Data[last_month].GDD[spc] + dGDD;
                    }

                    if (tday < SpeciesData.PsnTMin[spc])
                    {
                        IsActive[spc] = false;
                    }
                    else
                    {
                        IsActive[spc] = true;
                    }

                    float psntmax             = SpeciesData.PsnTOpt[spc] + (SpeciesData.PsnTOpt[spc] - SpeciesData.PsnTMin[spc]); // assumed symmetrical
                    float PsnTRange           = psntmax - SpeciesData.PsnTMin[spc];
                    float PsnTRangeHalfSquare = (float)Math.Pow((PsnTRange) / 2.0, 2);

                    dtemp[spc] = (float)Math.Max(((psntmax - tday) * (tday - SpeciesData.PsnTMin[spc])) / (PsnTRangeHalfSquare), 0);
                    dvpd[spc]  = Math.Max(0, 1 - SpeciesData.DVPD1[spc] * (float)Math.Pow(vpd, SpeciesData.DVPD2[spc]));


                    cicaRatio = (-0.075f * SpeciesData.FolNCon[spc]) + 0.875f;
                    ci350     = 350 * cicaRatio;
                    Arel350   = 1.22f * ((ci350 - 68) / (ci350 + 136));

                    ciElev       = co2 * cicaRatio;
                    ArelElev     = 1.22f * ((ciElev - 68) / (ciElev + 136));
                    DelAmax[spc] = 1 + ((ArelElev - Arel350) / Arel350);


                    // CO2 effect on photosynthesis
                    // Calculate CO2 effect on conductance and set slope and intercept for A-gs relationship
                    //List<string> file = new List<string>();
                    //for (int c = 0; c <= 10000; c++)
                    //{
                    //    co2 = 10 * c;
                    //    float dlgs = DelAmax[spc] / ((co2 - co2 * cicaRatio) / (350.0f - ci350));
                    //    file.Add(c + "\t" + dlgs);
                    //}
                    //System.IO.File.WriteAllLines("output/delgs.txt", file.ToArray());
                    float Delgs = DelAmax[spc] / ((co2 - co2 * cicaRatio) / (350.0f - ci350));

                    wue[spc] = (SpeciesData.WUEConst[spc] / vpd) * (1 + 1 - Delgs);    //DWUE determined from CO2 effects on conductance

                    wue_co2_corr[spc] = wue[spc] / DelAmax[spc];


                    //wue_co2_corr[spc] = SpeciesData.WUEConst[spc];

                    //float wue_co2_cor1 = wue_co2_corr[spc];
                    //float wue_co2_cor2 = wue_co2_corr[spc] = wue[spc] / DelAmax[spc];

                    /*
                     * Delgs = DelAmax / ((site.CaMo[mo] - CiElev) / (350.0 - Ci350));
                     * DWUE = 1.0 + (1 - Delgs);
                     * gsSlope = (-1.1309 * DelAmax) + 1.9762;   // used to determine ozone uptake
                     * gsInt = (0.4656 * DelAmax) - 0.9701;
                     */

                    netpsn_pot[spc] = delamax[spc] * (SpeciesData.AmaxA[spc] + SpeciesData.AmaxB[spc] * SpeciesData.FolNCon[spc]);  // nmole CO2/g Fol.sec

                    dt_day[spc]   = (float)Math.Pow(SpeciesData.RespQ10[spc], (tday - SpeciesData.PsnTOpt[spc]) / 10);
                    dt_night[spc] = (float)Math.Pow(SpeciesData.RespQ10[spc], (tmin - SpeciesData.PsnTOpt[spc]) / 10);


                    fResp[spc]    = (dt_day[spc] * daylength + dt_night[spc] * nightlength) / (float)daylength;
                    resp_pot[spc] = SpeciesData.BaseFolRespFrac[spc] * netpsn_pot[spc]; //

                    float HoursPerDay = 24 * daylength / (daylength + nightlength);
                    grossPsn_pot[spc] = Constants.DaySpan * Constants.SecondsPerHour * HoursPerDay * Constants.MC * Constants.ngPerG * (netpsn_pot[spc] + resp_pot[spc]); // gr/gr/mo
                }

                SetTreesAreActive();
            }
            catch
            {
                throw new System.Exception("Cannot find climate date for (year,month) " + CurrentDate.Year.ToString() + " " + CurrentDate.Month.ToString());
            }
        }
        public CClimDay(int Latitude, DateTime CurrentDate ,float PAR0, float TMin, float TMax, float Prec, float CO2)
        {
            try
            {
                this.CurrentDate = CurrentDate;
                par0 = PAR0;
                tmin = TMin;
                tmax = TMax;
                prec = Prec;

                if (prec < 0) throw new System.Exception("Precipitation = " + prec + "\t" + CurrentDate);

                co2 = CO2;

                float hr = Calculate_hr(CurrentDate.DayOfYear, Latitude);
                daylength = Calculate_DayLength(hr);
                nightlength = Calculate_NightLength(hr);
                dayspan = Calculate_DaySpan(CurrentDate.Month);
                tave = Calculate_Tave(TMin, TMax);
                tday = Calculate_TDay(TMax, Tave);
                vpd = Calculate_VPD(Tday, TMin);

                dtemp = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                dvpd = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                netpsn_pot = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                wue = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                delamax = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                fResp = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                resp_pot = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                wue_co2_corr = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                grossPsn_pot = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                resp_folbase = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                IsActive = new Biomass.Species.AuxParm<bool>(PlugIn.ModelCore.Species);
                dt_night = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                dt_day = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);
                gdd = new Landis.Extension.Succession.Biomass.Species.AuxParm<float>(PlugIn.ModelCore.Species);

                foreach (ISpecies spc in PlugIn.ModelCore.Species) gdd[spc] = 0;

                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    float dGDD = Math.Max(0, (Tave - SpeciesData.PsnTMin[spc]) * DaySpan);
                    if (CurrentDate.Month == 1) gdd[spc] = dGDD;
                    else
                    {
                        DateTime last_month = new DateTime(CurrentDate.Year, CurrentDate.Month - 1, 15);
                        gdd[spc] = ClimateData.Data[last_month].GDD[spc] + dGDD;
                    }

                    if (tday < SpeciesData.PsnTMin[spc]) IsActive[spc] = false;
                    else IsActive[spc] = true;

                    float psntmax = SpeciesData.PsnTOpt[spc] + (SpeciesData.PsnTOpt[spc] - SpeciesData.PsnTMin[spc]);    // assumed symmetrical
                    float PsnTRange = psntmax - SpeciesData.PsnTMin[spc];
                    float PsnTRangeHalfSquare = (float)Math.Pow((PsnTRange) / 2.0, 2);

                    dtemp[spc] = (float)Math.Max(((psntmax - tday) * (tday - SpeciesData.PsnTMin[spc])) / (PsnTRangeHalfSquare), 0);
                    dvpd[spc] = Math.Max(0, 1 - SpeciesData.DVPD1[spc] * (float)Math.Pow(vpd, SpeciesData.DVPD2[spc]));

                    cicaRatio = (-0.075f * SpeciesData.FolNCon[spc]) + 0.875f;
                    ci350 = 350 * cicaRatio;
                    Arel350 = 1.22f * ((ci350 - 68) / (ci350 + 136));

                    ciElev = co2 * cicaRatio;
                    ArelElev = 1.22f * ((ciElev - 68) / (ciElev + 136));
                    DelAmax[spc] = 1 + ((ArelElev - Arel350) / Arel350);

                    // CO2 effect on photosynthesis
                    // Calculate CO2 effect on conductance and set slope and intercept for A-gs relationship
                    //List<string> file = new List<string>();
                    //for (int c = 0; c <= 10000; c++)
                    //{
                    //    co2 = 10 * c;
                    //    float dlgs = DelAmax[spc] / ((co2 - co2 * cicaRatio) / (350.0f - ci350));
                    //    file.Add(c + "\t" + dlgs);
                    //}
                    //System.IO.File.WriteAllLines("output/delgs.txt", file.ToArray());
                    float Delgs = DelAmax[spc] / ((co2 - co2 * cicaRatio) / (350.0f - ci350));

                    wue[spc] = (SpeciesData.WUEConst[spc] / vpd) * (1 + 1 - Delgs);    //DWUE determined from CO2 effects on conductance

                    wue_co2_corr[spc] = wue[spc] / DelAmax[spc];

                    //wue_co2_corr[spc] = SpeciesData.WUEConst[spc];

                    //float wue_co2_cor1 = wue_co2_corr[spc];
                    //float wue_co2_cor2 = wue_co2_corr[spc] = wue[spc] / DelAmax[spc];

                    /*
                    Delgs = DelAmax / ((site.CaMo[mo] - CiElev) / (350.0 - Ci350));
                    DWUE = 1.0 + (1 - Delgs);
                    gsSlope = (-1.1309 * DelAmax) + 1.9762;   // used to determine ozone uptake
                    gsInt = (0.4656 * DelAmax) - 0.9701;
                    */

                    netpsn_pot[spc] = delamax[spc] * (SpeciesData.AmaxA[spc] + SpeciesData.AmaxB[spc] * SpeciesData.FolNCon[spc]);  // nmole CO2/g Fol.sec

                    dt_day[spc] = (float)Math.Pow(SpeciesData.RespQ10[spc], (tday - SpeciesData.PsnTOpt[spc]) / 10);
                    dt_night[spc] = (float)Math.Pow(SpeciesData.RespQ10[spc], (tmin - SpeciesData.PsnTOpt[spc]) / 10);

                    fResp[spc] = (dt_day[spc] * daylength + dt_night[spc] * nightlength) / (float)daylength;
                    resp_pot[spc] = SpeciesData.BaseFolRespFrac[spc] * netpsn_pot[spc]; //

                    float HoursPerDay = 24 * daylength / (daylength + nightlength);
                    grossPsn_pot[spc] = Constants.DaySpan * Constants.SecondsPerHour * HoursPerDay * Constants.MC * Constants.ngPerG * (netpsn_pot[spc] + resp_pot[spc]); // gr/gr/mo
                }

                SetTreesAreActive();
            }
            catch
            {
                throw new System.Exception("Cannot find climate date for (year,month) " + CurrentDate.Year.ToString() + " " + CurrentDate.Month.ToString());
            }
        }