Exemplo n.º 1
0
    void Apply(double Amount)
    {
        IrrigationApplicationType Irrigation = new IrrigationApplicationType();

        Irrigation.Amount = (float)Amount;
        Comp.Publish("Apply2", Irrigation);
    }
Exemplo 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>
        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");
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
 private void OnIrrigated(object sender, IrrigationApplicationType e)
 {
     irrigations.Add(e);
 }
Exemplo n.º 5
0
 private void OnIrrigated(object sender, IrrigationApplicationType data)
 {
     irrig += data.Amount;
 }