/// <summary>
        /// Calculate and return the amount of biom carbon on the same layer structure as OC. Units: kg/ha
        /// </summary>
        public double[] BiomC(Soil Soil)
        {
            double[] BD = Soil.BDMapped(Thickness);
            if (BD == null)
                return null;
            double[] InertC = this.InertC(Soil);

            double[] BiomC = new double[Thickness.Length];
            for (int i = 0; i < Thickness.Length; i++)
            {
                if (OC[i] == double.NaN ||
                    FBiom[i] == double.NaN ||
                    BD[i] == double.NaN ||
                    InertC[i] == double.NaN)
                    BiomC[i] = double.NaN;
                else
                {
                    double soiln2_fac = 100.0 / (BD[i] * Thickness[i]);
                    double oc_ppm = OCTotal[i] / 100 * ppm;
                    double carbon_tot = oc_ppm / soiln2_fac;
                    BiomC[i] = ((carbon_tot - InertC[i]) * FBiom[i]) / (1.0 + FBiom[i]);
                }
            }
            return BiomC;
        }
Beispiel #2
0
 public void SWUnitsSet(SWUnitsEnum ToUnits, Soil Soil)
 {
     if (ToUnits != SWUnits && SW != null)
     {
         // convert the numbers
         if (SWUnits == SWUnitsEnum.Volumetric)
         {
             if (ToUnits == SWUnitsEnum.Gravimetric)
             {
                 SW = MathUtility.Divide(SW, Soil.BDMapped(Thickness));
             }
             else if (ToUnits == SWUnitsEnum.mm)
             {
                 SW = MathUtility.Multiply(SW, Thickness);
             }
         }
         else if (SWUnits == SWUnitsEnum.Gravimetric)
         {
             if (ToUnits == SWUnitsEnum.Volumetric)
             {
                 SW = MathUtility.Multiply(SW, Soil.BDMapped(Thickness));
             }
             else if (ToUnits == SWUnitsEnum.mm)
             {
                 SW = MathUtility.Multiply(MathUtility.Multiply(SW, Soil.BDMapped(Thickness)), Thickness);
             }
         }
         else
         {
             if (ToUnits == SWUnitsEnum.Volumetric)
             {
                 SW = MathUtility.Divide(SW, Thickness);
             }
             else if (ToUnits == SWUnitsEnum.Gravimetric)
             {
                 SW = MathUtility.Divide(MathUtility.Divide(SW, Thickness), Soil.BDMapped(Thickness));
             }
         }
     }
     SWUnits = ToUnits;
 }
Beispiel #3
0
        public void NH4UnitsSet(NUnitsEnum ToUnits, Soil Soil)
        {
            double[] BD = Soil.BDMapped(Thickness);

            if (ToUnits != NH4Units)
            {
                // convert the numbers
                if (ToUnits == NUnitsEnum.ppm)
                {
                    NH4 = NH4ppm(Soil);
                }
                else
                {
                    NH4 = NH4kgha(Soil);
                }
                NH4Units = ToUnits;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Return NH4. Units: kg/ha.
 /// </summary>
 public double[] NH4kgha(Soil Soil)
 {
     if (NH4 == null)
     {
         return(null);
     }
     double[] NH4Values = (double[])NH4.Clone();
     if (NH4Units != NUnitsEnum.kgha)
     {
         double[] BD = Soil.BDMapped(Thickness);
         for (int i = 0; i < NH4Values.Length; i++)
         {
             if (!double.IsNaN(NH4Values[i]))
             {
                 NH4Values[i] = NH4Values[i] / 100 * (BD[i] * Thickness[i]);
             }
         }
     }
     return(NH4Values);
 }
Beispiel #5
0
 /// <summary>
 /// Return NO3. Units: ppm.
 /// </summary>
 public double[] NO3ppm(Soil Soil)
 {
     if (NO3 == null)
     {
         return(null);
     }
     double[] NO3Values = (double[])NO3.Clone();
     if (NO3Units != NUnitsEnum.ppm)
     {
         double[] BD = Soil.BDMapped(Thickness);
         for (int i = 0; i < NO3Values.Length; i++)
         {
             if (!double.IsNaN(NO3Values[i]))
             {
                 NO3Values[i] = NO3Values[i] * 100 / (BD[i] * Thickness[i]);
             }
         }
     }
     return(NO3Values);
 }
        /// <summary>
        /// Calculate and return amount of inert carbon on the same layer structure as OC. Units: kg/ha
        /// </summary>
        public double[] InertC(Soil Soil)
        {
            double[] BD = Soil.BDMapped(Thickness);
            if (BD == null)
                return null;

            double[] InertC = new double[Thickness.Length];

            for (int i = 0; i < OC.Length; i++)
            {
                if (FInert[i] == double.NaN ||
                    OC[i] == double.NaN ||
                    BD[i] == double.NaN)
                    InertC[i] = double.NaN;
                else
                {
                    double soiln2_fac = 100.0 / (BD[i] * Thickness[i]);
                    double oc_ppm = OCTotal[i] / 100 * ppm;
                    double carbon_tot = oc_ppm / soiln2_fac;
                    InertC[i] = FInert[i] * carbon_tot;
                }
            }
            return InertC;
        }
        /// <summary>
        /// Calculate and return the amount of humic carbon on the same layer structure as OC. Units: kg/ha
        /// </summary>
        public double[] HumC(Soil Soil)
        {
            double[] BD = Soil.BDMapped(Thickness);
            if (BD == null)
                return null;
            double[] InertC = this.InertC(Soil);
            double[] BiomC = this.BiomC(Soil);

            double[] HumC = new double[Thickness.Length];

            for (int i = 0; i < Thickness.Length; i++)
            {
                if (BiomC[i] == double.NaN)
                    HumC[i] = double.NaN;
                else
                {
                    double soiln2_fac = 100.0 / (BD[i] * Thickness[i]);
                    double oc_ppm = OCTotal[i] / 100 * ppm;
                    double carbon_tot = oc_ppm / soiln2_fac;
                    HumC[i] = carbon_tot - BiomC[i];
                }
            }
            return HumC;
        }