public double AreaForHeightLookup(double height)
        {
            var ratingCurve = _division.Link.RatingCurveLibrary.GetCurve(SimulationNow);

            //TODO This looks a little messy. We've taken the same Linear Interpolation Method used in Flow Routing for consistancy. For some reason the first two params are a List and an IList which seems inconsistant.
            var widthForHeight = AbstractLumpedFlowRouting.Lintrpl(
                ratingCurve.Levels.ToList(),
                ratingCurve.Widths,
                height,
                ratingCurve.Levels.Length);

            // Determine the area by multiplying the width by the length of a division.
            return(widthForHeight * _division.Link.Length / _division.Link.NumberOfDivisions);
        }
Beispiel #2
0
        protected override void ProcessDoc()
        {
            if (Zones.Count == 0)
            {
                var newZone = new FloodplainData(false);
                newZone.AreaM2 = Fac * EffectiveMaximumArea;
                newZone.LeafDryMatterNonReadilyDegradable = InitialLeafDryMatterNonReadilyDegradable;
                newZone.LeafDryMatterReadilyDegradable    = InitialLeafDryMatterReadilyDegradable;
                newZone.NewAreaM2 = newZone.AreaM2;
                Zones.Add(newZone);
            }

            UpdateFloodedAreas();

            double existingDOCMassKg = ConcentrationDoc * WorkingVolume; // kg/m^3 * m^3 = kg

            var docMilligrams = existingDOCMassKg * KG_TO_MG;

            if (Areal.Area.LessOrEqual(0.0))
            {
                FloodCounter = 0;
            }

            //!the DOC dissolution rate constant is temp dependent
            Leach1 = AbstractLumpedFlowRouting.Lintrpl(tempX.ToList(), DOC_k.ToList(), TemperatureEst,
                                                       DOC_k.Length);
            DocMax = AbstractLumpedFlowRouting.Lintrpl(tempX.ToList(), DOC_max.ToList(), TemperatureEst,
                                                       DOC_max.Length); // presumably a concentration?

            DOCEnteringWater = 0;
            TotalWetLeaf     = 0;
            LeachingRate     = 1 - Math.Exp(-Leach1 * Sigma);
            foreach (var zone in Zones)
            {
                if (Areal.Area.Less(zone.AreaM2))
                {
                    continue;
                }

                double wetleafKg = zone.NewAreaM2 * M2_TO_HA *
                                   ((zone.LeafDryMatterReadilyDegradable + zone.LeafDryMatterNonReadilyDegradable) +
                                    LeafAccumulationConstant);

                TotalWetLeaf += wetleafKg;
                double leafDOC = wetleafKg * 1000 * DocMax * (LeachingRate); // ??? How is this converting kg->mg (*1e-6)
                DOCEnteringWater += leafDOC;

                /*
                 * zone(floodrch,isub,ii,2) = max(0.,zone(floodrch,isub,ii,2)-(zone(floodrch,isub,ii,2) * (1 - Exp(-decomp1 * sigma *  86400))))
                 * zone(floodrch,isub,ii,3) = max(0.,zone(floodrch,isub,ii,3)-(zone(floodrch,isub,ii,3) * (1 - Exp(-decomp1 * sigma *  86400))))
                 */
                zone.LeafDryMatterReadilyDegradable    = Math.Max(0, zone.LeafDryMatterReadilyDegradable * (1 - LeachingRate));
                zone.LeafDryMatterNonReadilyDegradable = Math.Max(0, zone.LeafDryMatterNonReadilyDegradable * (1 - LeachingRate));
            }

            docMilligrams += DOCEnteringWater;

            foreach (var zone in Zones)
            {
                if (Areal.Area.Less(zone.AreaM2) && zone.Dry)
                {
                    zone.LeafDryMatterReadilyDegradable = zone.LeafDryMatterReadilyDegradable * Math.Exp(-LeafK1) +
                                                          (LeafAccumulationConstant * LeafA);
                    double MaxmimumNonReadilyDegradable = 2850d;
                    zone.LeafDryMatterNonReadilyDegradable = Math.Min(MaxmimumNonReadilyDegradable,
                                                                      zone.LeafDryMatterNonReadilyDegradable * Math.Exp(-LeafK2) +
                                                                      (LeafAccumulationConstant * (1 - LeafA)));
                }
            }

            //ConsumedDoc = (existingDOCMassKg * KG_TO_MG) * DocConsumptionCoefficient*Sigma;
            ConsumedDocMilligrams = docMilligrams * DocConsumptionCoefficient * Sigma;

            docMilligrams = Math.Max(docMilligrams - ConsumedDocMilligrams, 0.0);

            DissolvedOrganicCarbonLoad = docMilligrams * MG_TO_KG;


/*
 *                                              ! consumption of DOC by microbial activity (temp dependent)
 *
 *                                              Rchlod(Irch,2)=1.
 *                                          Valcon(Ircvld(Irch,WQno))=subloadDOC/fac
 *                                          DOCcalc(irch,isub,1)=1.
 *                                          if ( subrchdata(irch,isub,4).le.zerost ) then
 *                                              Valcon(Ircvld(Irch,WQno))=0.
 *                                          endif
 *                                          continue
 *
 */
        }