示例#1
0
    /// <summary>
    ///  Calculate an approximate nitrogen demand for today's growth.
    ///   The estimate basically = n to fill the plant up to maximum
    ///   nitrogen concentration.
    /// </summary>
    void DoNDemandEstimate()
    {
        // Assume that the distribution of plant
        // C will be similar after today and so N demand is that
        // required to raise all plant parts to max N conc.

        double dltDmPotRue = 0;

        foreach (Organ1 Organ in Organ1s)
        {
            dltDmPotRue += Organ.dltDmPotRue;
        }

        foreach (Organ1 Organ in Organ1s)
        {
            Organ.DoNDemand1Pot(dltDmPotRue);
        }

        ext_n_demand = 0;
        foreach (Organ1 Organ in Organ1s)
        {
            ext_n_demand += Organ.NDemand;
        }

        //nh  use zero growth value here so that estimated n fix is always <= actual;
        double n_fix_pot = NFixRate.Value * AboveGroundLive.Wt * SWStress.Fixation;

        if (NSupplyPreference == "active")
        {
            // Nothing extra to do here
        }
        else if (NSupplyPreference == "fixation")
        {
            // Remove potential fixation from demand term
            ext_n_demand = ext_n_demand - n_fix_pot;
            ext_n_demand = MathUtility.Constrain(ext_n_demand, 0.0, Double.MaxValue);
        }
        else
        {
            throw new Exception("bad n supply preference");
        }
        Util.Debug("Plant.ext_n_demand=%f", ext_n_demand);
    }