Beispiel #1
0
        /// <summary>
        /// Returns the reduction in kg/s
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CurrentMass"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public double GetReduction(Catchment c, double CurrentMass, DateTime CurrentTime)
        {
            double red = 0;

            if (c.BigLake != null && c.BigLake.Start <= CurrentTime && c.BigLake.End >= CurrentTime)
            {
                double Reducer;
                if (c.BigLake.RetentionTime > 1)
                {
                    Reducer = (Par1 * MO5[CurrentTime.Month] - c.Temperature.GetValue(CurrentTime, InterpolationMethods.DeleteValue)) / 100.0;
                }
                else
                {
                    //Get the lake temperature
                    double T = LakeTemperatureFromAir(c.Temperature.GetValue(CurrentTime, InterpolationMethods.DeleteValue), c.Temperature.GetValue(CurrentTime.AddMonths(-1), InterpolationMethods.DeleteValue), CurrentTime);
                    c.BigLake.Temperature.Items.Add(new TimeStampValue(CurrentTime, T));

                    Reducer = Alpha * Math.Pow(Beta, T - 20.0);
                }

                c.BigLake.CurrentNMass += CurrentMass;
                double removedN = Reducer * c.BigLake.CurrentNMass;
                //From m3/s to m3
                double mflow = c.M11Flow.GetTs(TimeStepUnit.Month).GetValue(CurrentTime) * DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400;

                if (mflow > 0)
                {
                    double NOut = (c.BigLake.CurrentNMass - removedN) / (c.BigLake.Volume + mflow) * mflow;
                    //        NOut = Math.Max(0,Math.Min(c.BigLake.CurrentNMass - removedN, NOut));

                    c.BigLake.CurrentNMass = c.BigLake.CurrentNMass - removedN - NOut;

                    //Store some results
                    c.BigLake.NitrateReduction.Items.Add(new TimeStampValue(CurrentTime, removedN));
                    c.BigLake.NitrateConcentration.Items.Add(new TimeStampValue(CurrentTime, c.BigLake.CurrentNMass / c.BigLake.Volume));
                    c.BigLake.FlushingRatio.Items.Add(new TimeStampValue(CurrentTime, mflow / c.BigLake.Volume));

                    red = (CurrentMass - NOut) / (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0);
                }
            }
            red = red * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    red *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    red += AdditionFactors[c.ID];
                }
            }

            return(red);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the value in kg/s
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public double GetValue(Catchment c, DateTime CurrentTime)
        {
            double        value = 0;
            List <double> data;

            if (deposition.TryGetValue(c.ID, out data))
            {
                value = Math.Max(0, data[CurrentTime.Year - FirstYear] * (c.NetInflow.GetTs(TimeStepUnit.Month).GetValue(CurrentTime)));
            }
            value = value * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    value *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    value += AdditionFactors[c.ID];
                }
            }

            return(value);
        }
        /// <summary>
        /// Returns the source rate to the catchment in kg/s at the current time
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public double GetValue(Catchment c, DateTime CurrentTime)
        {
            double value = 0;

            if (GWInput.ContainsKey(c.ID))
            {
                value = GWInput[c.ID][(CurrentTime.Year - Start.Year) * 12 + CurrentTime.Month - Start.Month];
            }

            value = value * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    value *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    value += AdditionFactors[c.ID];
                }
            }

            return(value);
        }
Beispiel #4
0
        public double GetReduction(Catchment c, double CurrentInflowRate, DateTime CurrentTime)
        {
            double red = 0;

            CurrentInflowRate /= DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0;
            if (CurrentTime.Month >= FirstSummerMonth & CurrentTime.Month <= LastSummerMonth)
            {
                red = ReductionFactors[c.ID].Item1 * CurrentInflowRate; //Summer
            }
            else
            {
                red = ReductionFactors[c.ID].Item2 * CurrentInflowRate; //Winter
            }
            red = red * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    red *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    red += AdditionFactors[c.ID];
                }
            }

            return(red);
        }
Beispiel #5
0
        /// <summary>
        /// Returns the source rate to the catchment in kg/s at the current time
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public double GetValue(Catchment c, DateTime CurrentTime)
        {
            double value = 0;
            Dictionary <int, double> timevalues;

            if (YearlyData.TryGetValue(c.ID, out timevalues))
            {
                timevalues.TryGetValue(CurrentTime.Year, out value);
            }
            value = value * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    value *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    value += AdditionFactors[c.ID];
                }
            }

            return(value);
        }
Beispiel #6
0
        public double GetReduction(Catchment c, double CurrentMass, DateTime CurrentTime)
        {
            double red = 0;

            var CurrentWetLands = c.Wetlands.Where(w => w.StartTime <= CurrentTime).ToList();

            if (CurrentWetLands.Count > 0)
            {
                if (CurrentTime > new DateTime(2010, 1, 1))
                {
                    int k = 0;
                }



                var precip = c.Precipitation.GetTs(TimeStepUnit.Month).GetValue(CurrentTime);

                double accurain = c.Precipitation.GetTs(TimeStepUnit.Month).Average;
                double afs      = Math.Abs((precip - accurain) / accurain * Par1 + Par2);

                foreach (var w in CurrentWetLands)
                {
                    red += SoilEquations[w.SoilString].GetReduction(CurrentTime, afs) * XYGeometryTools.CalculateSharedArea(c.Geometry, w.Geometry) / 10000.0;
                }

                //Make sure we do not reduce more than what is available
                red  = Math.Max(0, Math.Min(CurrentMass, red));
                red /= (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0);
            }
            red = red * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    red *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    red += AdditionFactors[c.ID];
                }
            }

            return(red);
        }
        public double GetReduction(Catchment c, double CurrentMass, DateTime CurrentTime)
        {
            double sourcevalue;

            if (string.IsNullOrEmpty(SourceModelName))
            {
                sourcevalue = CurrentMass;
            }
            else
            {
                sourcevalue = (double)c.StateVariables.Rows.Find(new object[] { c.ID, CurrentTime })[SourceModelName];
            }
            sourcevalue /= (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0);

            double red = 0;

            if (Reduction.ContainsKey(c.ID))
            {
                red = (Reduction[c.ID] * sourcevalue);
            }

            red = red * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    red *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    red += AdditionFactors[c.ID];
                }
            }

            return(red);
        }
Beispiel #8
0
        public double GetReduction(Catchment c, double CurrentMass, DateTime CurrentTime)
        {
            double red = 0;
            double rate;

            if (Reduction.TryGetValue(c.ID, out rate) & c.M11Flow != null)
            {
                double NormalizedMonthlyFlow = 0;
                double yearlyinflow          = c.NetInflow.GetTs(TimeStepUnit.Year).GetValue(CurrentTime);
                double monthlyflow           = c.NetInflow.GetTs(TimeStepUnit.Month).GetValue(CurrentTime);
                if (yearlyinflow > 0 & monthlyflow > 0)
                {
                    NormalizedMonthlyFlow = monthlyflow / yearlyinflow;
                }
                red = Math.Min(rate * NormalizedMonthlyFlow * YearFactors[CurrentTime.Year], CurrentMass) / (DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400.0);
                red = Math.Max(0, red);
            }
            red = red * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    red *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    red += AdditionFactors[c.ID];
                }
            }

            return(red);
        }
        /// <summary>
        /// Returns the atmospheric deposition in kg/s
        /// </summary>
        /// <param name="c"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public double GetValue(Catchment c, DateTime CurrentTime)
        {
            double value = deposition[c.ID][CurrentTime.Year - FirstYear];

            value = value * MultiplicationPar + AdditionPar;

            if (MultiplicationFactors != null)
            {
                if (MultiplicationFactors.ContainsKey(c.ID))
                {
                    value *= MultiplicationFactors[c.ID];
                }
            }

            if (AdditionFactors != null)
            {
                if (AdditionFactors.ContainsKey(c.ID))
                {
                    value += AdditionFactors[c.ID];
                }
            }

            return(value);
        }