Esempio n. 1
0
        /// <summary>
        /// Calculate a layered soil water using a FractionFull and filled from the top. Units: mm/mm
        /// </summary>
        private double[] SWFilledFromTop(double[] Thickness, double[] LL, double[] DUL, double[] XF)
        {
            double[] SW = new double[Thickness.Length];
            if (Thickness.Length != LL.Length ||
                Thickness.Length != DUL.Length)
            {
                return(SW);
            }
            double[] PAWCmm = MathUtility.Multiply(Soil.CalcPAWC(Thickness, LL, DUL, XF), Thickness);
            //MathUtility.Multiply(MathUtility.Subtract(DUL, LL), Thickness);

            double AmountWater = MathUtility.Sum(PAWCmm) * FractionFull;

            for (int Layer = 0; Layer < LL.Length; Layer++)
            {
                if (AmountWater >= 0 && XF != null && XF[Layer] == 0)
                {
                    SW[Layer] = LL[Layer];
                }
                else if (AmountWater >= PAWCmm[Layer])
                {
                    SW[Layer]   = DUL[Layer];
                    AmountWater = AmountWater - PAWCmm[Layer];
                }
                else
                {
                    double Prop = AmountWater / PAWCmm[Layer];
                    SW[Layer]   = Prop * (DUL[Layer] - LL[Layer]) + LL[Layer];
                    AmountWater = 0;
                }
            }
            return(SW);
        }
Esempio n. 2
0
            /// <summary>Constructor.</summary>
            /// <param name="property">The property.</param>
            /// <param name="obj">The instance containing the property.</param>
            public PAWCColumn(IModel soilCrop,
                              List <PropertyColumn> propertiesInGrid)
                : base(null, null)
            {
                ColumnName           = soilCrop.Name.Replace("Soil", "") + " PAWC\r\n(mm)";
                ColumnDataType       = typeof(double);
                IsReadOnly           = true;
                AddTotalToColumnName = true;
                Width            = 100;
                ForegroundColour = Color.Red;

                var cropName        = soilCrop.Name.Replace("Soil", "");
                var thicknessColumn = propertiesInGrid.Find(prop => prop.ColumnName.StartsWith("Depth"));
                var llColumn        = propertiesInGrid.Find(prop => prop.ColumnName.StartsWith(cropName + " LL"));
                var dulColumn       = propertiesInGrid.Find(prop => prop.ColumnName.StartsWith("DUL"));
                var xfColumn        = propertiesInGrid.Find(prop => prop.ColumnName.StartsWith(cropName + " XF"));

                // When user clicks on a SoilCrop, there is no DUL column. In
                // this situation get dul from the parent model.
                double[] dul;
                if (dulColumn == null)
                {
                    dul = (soilCrop.Parent as Physical).DUL;
                }
                else
                {
                    dul = dulColumn.Values as double[];
                }

                var thickness      = APSIM.Shared.APSoil.SoilUtilities.ToThickness((string[])thicknessColumn.Values);
                var pawcVolumetric = Soil.CalcPAWC(thickness, llColumn.Values as double[], dul, xfColumn.Values as double[]);

                Values = MathUtilities.Multiply(pawcVolumetric, thickness);
            }