コード例 #1
0
ファイル: Irrigation.cs プロジェクト: kiwiroy/ApsimX
        /// <summary>Apply irrigatopm.</summary>
        /// <param name="amount">The amount.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="efficiency">The efficiency.</param>
        /// <param name="willRunoff">if set to <c>true</c> [will runoff].</param>
        /// <exception cref="ApsimXException">Efficiency value for irrigation event must bet between 0 and 1 </exception>
        public void Apply(double amount, double depth = 0.0, double efficiency = 1.0, bool willRunoff = false)
        {
            if (Irrigated != null && amount > 0)
            {
                if(efficiency > 1.0 || efficiency < 0)
                    throw new ApsimXException(this, "Efficiency value for irrigation event must bet between 0 and 1 ");

                Models.Soils.IrrigationApplicationType water = new Models.Soils.IrrigationApplicationType();
                water.Amount = amount * efficiency;
                water.Depth = depth;
                water.will_runoff = willRunoff;
                IrrigationApplied += amount;
                Irrigated.Invoke(this, water);
                Summary.WriteMessage(this, string.Format("{0:F1} mm of water added at depth {1}", amount * efficiency, depth));
            }
        }
コード例 #2
0
        /// <summary>Apply irrigatopm.</summary>
        /// <param name="amount">The amount.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="efficiency">The efficiency.</param>
        /// <param name="willRunoff">if set to <c>true</c> [will runoff].</param>
        /// <exception cref="ApsimXException">Efficiency value for irrigation event must bet between 0 and 1 </exception>
        public void Apply(double amount, double depth = 0.0, double efficiency = 1.0, bool willRunoff = false)
        {
            if (Irrigated != null && amount > 0)
            {
                if (efficiency > 1.0 || efficiency < 0)
                {
                    throw new ApsimXException(this, "Efficiency value for irrigation event must bet between 0 and 1 ");
                }

                Models.Soils.IrrigationApplicationType water = new Models.Soils.IrrigationApplicationType();
                water.Amount      = amount * efficiency;
                water.Depth       = depth;
                water.will_runoff = willRunoff;
                IrrigationApplied = amount;
                Irrigated.Invoke(this, water);
                Summary.WriteMessage(this, string.Format("{0:F1} mm of water added at depth {1}", amount * efficiency, depth));
            }
        }
コード例 #3
0
ファイル: Irrigation.cs プロジェクト: mcauliffer/ApsimX
        /// <summary>Apply some irrigation.</summary>
        /// <param name="amount">The amount to apply (mm).</param>
        /// <param name="depth">The depth of application (mm).</param>
        /// <param name="startTime">The time to start the irrigation (minutes).</param>
        /// <param name="duration">The duration of the irrigation event (minutes).</param>
        /// <param name="efficiency">The irrigation efficiency (mm/mm).</param>
        /// <param name="willIntercept">Whether irrigation can be intercepted by canopy (<c>true</c>/<c>false</c>).</param>
        /// <param name="willRunoff">Whether irrigation can run off (<c>true</c>/<c>false</c>).</param>
        /// <exception cref="ApsimXException">Check the depth for irrigation, it cannot be deeper than the soil depth</exception>
        /// <exception cref="ApsimXException">Check the duration for the irrigation, it must be less than 1440 minutes</exception>
        /// <exception cref="ApsimXException">Check the start time for irrigation, it must be less than 1440 minutes</exception>
        /// <exception cref="ApsimXException">Check the start time and duration of irrigation, the sum must be smaller than 1440 minutes</exception>
        /// <exception cref="ApsimXException">Check the value of irrigation efficiency, it must be between 0 and 1</exception>
        public void Apply(double amount, double depth = -1.0, double startTime = -1.0, double duration = -1.0, double efficiency = -1.0, bool willIntercept = false, bool willRunoff = false)
        {
            if (Irrigated != null && amount > 0.0)
            {
                // Check the parameters given
                if (depth < 0.0)
                {
                    Depth = defaultDepth;
                }
                else
                {
                    if (depth > soil.Thickness.Sum())
                    {
                        throw new ApsimXException(this, "Check the depth for irrigation, it cannot be deeper than the soil depth");
                    }
                    Depth = depth;
                }

                if (startTime < 0.0)
                {
                    StartTime = defaultStartTime;
                }
                else
                {
                    if (startTime >= 1440.0)
                    {
                        throw new ApsimXException(this, "Check the start time for irrigation, it must be less than 1440 minutes");
                    }
                    StartTime = startTime;
                }

                if (duration < 0.0)
                {
                    Duration = defaultDuration;
                }
                else
                {
                    if (duration > 1440.0)
                    {
                        throw new ApsimXException(this, "Check the duration for the irrigation, it must be less than 1440 minutes");
                    }
                    Duration = duration;
                }

                if (StartTime + Duration > 1440.0)
                {
                    throw new ApsimXException(this, "Check the start time and duration of irrigation, the sum must be smaller than 1440 minutes");
                }

                if (efficiency < 0.0)
                {
                    Efficiency = defaultEfficiency;
                }
                else
                {
                    if (efficiency > 1.0)
                    {
                        throw new ApsimXException(this, "Check the value of irrigation efficiency, it must be between 0 and 1");
                    }
                    Efficiency = efficiency;
                }

                if (Depth > 0.0)
                { // Sub-surface irrigation: it cannot be intercepted nor run off directly
                    willIntercept = false;
                    willRunoff    = false;
                }

                IrrigationTotal   = amount;
                IrrigationApplied = IrrigationTotal * Efficiency;
                WillRunoff        = willRunoff;
                WillIntercept     = willIntercept;

                // Prepare the irrigation data
                Models.Soils.IrrigationApplicationType irrigData = new Models.Soils.IrrigationApplicationType();
                irrigData.Amount        = IrrigationApplied;
                irrigData.Depth         = Depth;
                irrigData.StartTime     = StartTime;
                irrigData.Duration      = Duration;
                irrigData.WillIntercept = WillIntercept;
                irrigData.WillRunoff    = WillRunoff;

                // Raise event and write log
                Irrigated.Invoke(this, irrigData);
                summary.WriteMessage(this, string.Format("{0:F1} mm of water added via irrigation at depth {1} mm", IrrigationApplied, Depth));
            }
            else
            {
                // write log of aborted event
                summary.WriteMessage(this, "Irrigation did not occur because the amount given was negative");
            }
        }