Example #1
0
    public void DoRadiationPartition()
    {
        double incomingSolarRadiation = Radn * FractIncidentRadn;

        foreach (string OrganName in RadiationPartitioningOrder)
        {
            Organ1 Organ = My.LinkByName(OrganName) as Organ1;

            // calc the total interception from this part - what is left is transmitted
            // to the other parts.
            incomingSolarRadiation -= Organ.interceptRadiation(incomingSolarRadiation);
        }
        Util.Debug("RadiationPartitioning.IncomingSolarRadiation=%f", incomingSolarRadiation);
    }
Example #2
0
    public void OnSow(SowPlant2Type Sow)
    {
        if (Sow.Cultivar == "")
        {
            throw new Exception("Cultivar not specified on sow line.");
        }

        SowingData = Sow;

        // Go through all our children and find all organs.
        Organ1s.Clear();
        foreach (object ChildObject in My.ChildrenAsObjects)
        {
            Organ1 Child1 = ChildObject as Organ1;
            if (Child1 != null)
            {
                Organ1s.Add(Child1);
                if (Child1 is AboveGround)
                {
                    Tops.Add(Child1);
                }
            }
        }

        if (NewCrop != null)
        {
            NewCropType Crop = new NewCropType();
            Crop.crop_type = CropType;
            Crop.sender    = Name;
            NewCrop.Invoke(Crop);
        }

        if (Sowing != null)
        {
            Sowing.Invoke();
        }

        WriteSowReport(Sow);
    }
Example #3
0
        /// <summary>Partitions the dm.</summary>
        /// <param name="Organs">The organs.</param>
        /// <exception cref="System.Exception">Unknown Partition Rule  + PartitionRules[i]</exception>
        internal void PartitionDM(List <Organ1> Organs)
        {
            // Get all DM supply terms.
            DMSupply = 0;
            foreach (Organ1 Organ in Organs)
            {
                DMSupply += Organ.DMSupply;
            }

            // Tell each organ to do it's DM Demand
            foreach (Organ1 Organ in Organs)
            {
                Organ.DoDMDemand(DMSupply);
            }

            foreach (Organ1 Organ in Organs)
            {
                Organ.Growth.Clear();
            }

            double dm_remaining     = DMSupply;
            double dlt_dm_green_tot = 0.0;

            for (int i = 0; i != PartitionOrgans.Length; i++)
            {
                Organ1 Organ = FindOrgan(PartitionOrgans[i], Organs);

                if (PartitionRules[i] == "magic")
                {
                    Organ.GiveDmGreen(RatioRootShoot.Value * DMSupply);
                }
                else if (PartitionRules[i] == "seasonal")                  // (PFR)
                {
                    double uptake = RatioRootPlant * dm_remaining;
                    Organ.GiveDmGreen(uptake);                               // (PFR)
                    dm_remaining     = dm_remaining - uptake;                // Here total RUE is used so remaining discounts root uptake(PFR)
                    dlt_dm_green_tot = dlt_dm_green_tot + uptake;
                }

                else
                {
                    double uptake;
                    if (PartitionRules[i] == "demand")
                    {
                        uptake = Math.Min(Organ.DMGreenDemand, dm_remaining);
                    }
                    else if (PartitionRules[i] == "frac")
                    {
                        uptake = Math.Min(FracDMRemainingInPart(Organ.Name) * dm_remaining, Organ.DMGreenDemand);
                    }
                    else if (PartitionRules[i] == "remainder")
                    {
                        uptake = dm_remaining;
                    }
                    else
                    {
                        throw new Exception("Unknown Partition Rule " + PartitionRules[i]);
                    }

                    Organ.GiveDmGreen(uptake);
                    dm_remaining     = dm_remaining - uptake;
                    dlt_dm_green_tot = dlt_dm_green_tot + uptake;
                }
            }


            if (!MathUtilities.FloatsAreEqual(dlt_dm_green_tot, DMSupply, 1.0E-4f))
            {
                string msg = "dlt_dm_green_tot mass balance is off: "
                             + dlt_dm_green_tot.ToString("f6")
                             + " vs "
                             + DMSupply.ToString("f6");
                Summary.WriteWarning(this, msg);
            }

            Util.Debug("Arbitrator.DMSupply=%f", DMSupply);
            Util.Debug("Arbitrator.dlt_dm_green_tot=%f", dlt_dm_green_tot);
        }