Esempio n. 1
0
        /// <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="duration">The duration of the irrigation event (minutes).</param>
        /// <param name="efficiency">The irrigation efficiency (mm/mm).</param>
        /// <param name="willRunoff">Whether irrigation can run off (<c>true</c>/<c>false</c>).</param>
        /// <param name="no3">Amount of NO3 in irrigation water</param>
        /// <param name="nh4">Amount of NH4 in irrigation water</param>
        public void Apply(double amount, double depth = 0.0, double duration = 1440.0, double efficiency = 1.0, bool willRunoff = false,
                          double no3 = -1.0, double nh4 = -1.0)
        {
            if (Irrigated != null && amount > 0.0)
            {
                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 (duration > 1440.0)
                {
                    throw new ApsimXException(this, "Check the duration for the irrigation, it must be less than 1440 minutes");
                }
                Duration = duration;

                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
                    willRunoff = false;
                }

                IrrigationApplied = amount;
                WillRunoff        = willRunoff;

                // Prepare the irrigation data
                IrrigationApplicationType irrigData = new IrrigationApplicationType();
                irrigData.Amount     = IrrigationApplied;
                irrigData.Depth      = Depth;
                irrigData.Duration   = Duration;
                irrigData.WillRunoff = WillRunoff;
                if (no3 != -1)
                {
                    irrigData.NO3 = no3;
                }
                if (nh4 != -1)
                {
                    irrigData.NH4 = nh4;
                }

                // 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");
            }
        }
Esempio n. 2
0
        /// <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="duration">The duration of the irrigation event (minutes).</param>
        /// <param name="efficiency">The irrigation efficiency (mm/mm).</param>
        /// <param name="willRunoff">Whether irrigation can run off (<c>true</c>/<c>false</c>).</param>
        /// <param name="no3">Amount of NO3 in irrigation water</param>
        /// <param name="nh4">Amount of NH4 in irrigation water</param>
        /// <param name="doOutput">If true, output will be written to the summary.</param>
        public void Apply(double amount, double depth = 0.0, double duration = 1440.0, double efficiency = 1.0, bool willRunoff = false,
                          double no3 = 0.0, double nh4 = 0.0, bool doOutput = true)
        {
            if (Irrigated != null && amount > 0.0)
            {
                if (depth > soilPhysical.Thickness.Sum())
                {
                    throw new ApsimXException(this, "Check the depth for irrigation, it cannot be deeper than the soil depth");
                }
                Depth = depth;

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

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

                // Sub-surface irrigation cannot run off
                if (Depth > 0.0)
                {
                    willRunoff = false;
                }

                WillRunoff = willRunoff;

                // Prepare the irrigation data
                IrrigationApplicationType irrigData = new IrrigationApplicationType();
                irrigData.Amount     = amount * efficiency;
                irrigData.Depth      = Depth;
                irrigData.Duration   = Duration;
                irrigData.WillRunoff = WillRunoff;
                irrigData.NO3        = no3;
                irrigData.NH4        = nh4;

                // Raise event and write log
                Irrigated.Invoke(this, irrigData);
                if (doOutput)
                {
                    summary.WriteMessage(this, string.Format("{0:F1} mm of water added via irrigation at depth {1} mm", irrigData.Amount, Depth), MessageType.Diagnostic);
                }

                IrrigationApplied += irrigData.Amount;
            }
            else if (doOutput && amount < 0)
            {
                summary.WriteMessage(this, "Irrigation did not occur because the amount given was negative", MessageType.Warning);
            }
        }
Esempio n. 3
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));
            }
        }
Esempio n. 4
0
 public void Apply(double amount, double depth = 0.0, double startTime = 0.0, double duration = 1.0, double efficiency = 1.0, bool willIntercept = false, bool willRunoff = false, double no3 = -1, double nh4 = -1)
 {
     Irrigated.Invoke(this, new IrrigationApplicationType());
 }
Esempio n. 5
0
 public void Apply(double amount, double depth = 0, double efficiency = 1, bool willRunoff = false, double Duration = 1)
 {
     Irrigated.Invoke(this, new IrrigationApplicationType());
 }
Esempio n. 6
0
        /// <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");
            }
        }
Esempio n. 7
0
 public void Apply(double amount, double depth = 0.0, double duration = 1.0, double efficiency = 1.0, bool willRunoff = false, double no3 = -1, double nh4 = -1, bool doOutput = true)
 {
     Irrigated.Invoke(this, new IrrigationApplicationType());
 }