Exemplo n.º 1
0
        private void ProcessDo()
        {
            // Bring existing concentration into it?

            SoilO2Kg = SoilO2Scaling * 1e-6 * SoilO2mg();

            DoCo2 = 1e-6 * ConsumedDocMilligrams * 2.667;

            var saturatedo2mg_L = 14.652 - 0.41022 * WaterTemperatureEst + 0.00799 * eWater.Utilities.Math.Pow(WaterTemperatureEst, 2) - 7.7774e-5 * eWater.Utilities.Math.Pow(WaterTemperatureEst, 3); //Cox (2003)
            var waterColumnConcentrationDOKg_M3 = Math.Min(ConcentrationDo, saturatedo2mg_L * MG_L_to_KG_M3);
            var existingWaterColumnDOKg         = WorkingVolume * waterColumnConcentrationDOKg_M3;
            var waterColumnConcentrationDOmg_L  = waterColumnConcentrationDOKg_M3 * KG_M3_to_MG_L;

            // +++TODO Check unit conversions!
            //Add temperature dependance for rearation coefficient
            var reaerationmg = ReaerationCoefficient * eWater.Utilities.Math.Pow(1.024, WaterTemperatureEst - 20) * Math.Max(0, (saturatedo2mg_L /*mg.L-1*/ - waterColumnConcentrationDOmg_L)) * WorkingVolume * M3_to_L;

            Reaeration = reaerationmg * MG_TO_KG;

            int i;
            var concentrationDOCmgL = ConcentrationDoc * KG_M3_to_MG_L;

            for (i = 0; i < ProductionBreaks.Length; i++)
            {
                // +++TODO Should this concentration be the updated concentration, post DOC run?
                if (concentrationDOCmgL <= ProductionBreaks[i])
                {
                    break;
                }
            }
            Production = (PrimaryProductionReaeration * MG_L_to_KG_M3) * WorkingVolume * ProductionCoefficients[i];

            var totalOxygenUnconstrainedKg = (existingWaterColumnDOKg + Production + Reaeration) - (SoilO2Kg + DoCo2);

            var saturationOxygenKg = saturatedo2mg_L * MG_L_to_KG_M3 * WorkingVolume;

            // extra DO from generated from regulated scructures
            var deficitRatio = 1 + 0.38 * StructureRerationCoefficient * WaterQualityFactor * StaticHeadLoss * (1 - 0.11 * StaticHeadLoss) * (1 + 0.046 * WaterTemperature);
            var doFromRegulatedScructureKg = saturationOxygenKg - (saturationOxygenKg - totalOxygenUnconstrainedKg) / deficitRatio;

            var totalOxygen = Math.Min(doFromRegulatedScructureKg, saturationOxygenKg);

            if (WorkingVolume.Greater(0.0))
            {
                DissolvedOxygenLoad = Math.Max(totalOxygen, 0.0);
            }
            else
            {
                DissolvedOxygenLoad = 0.0;
            }
        }
Exemplo n.º 2
0
        protected virtual void ProcessDo()
        {
            // Bring existing concentration into it?

            SoilO2Kg = SoilO2Scaling * 1e-6 * SoilO2mg();

            DoCo2 = 1e-6 * ConsumedDocMilligrams * 2.667;

            var saturatedo2mg_L = 13.41 * Math.Exp(-0.01905 * TemperatureEst); // +++TODO CONFIRM UNITS????
            var waterColumnConcentrationDOKg_M3 = Math.Min(ConcentrationDo, saturatedo2mg_L * MG_L_to_KG_M3);
            var existingWaterColumnDOKg         = WorkingVolume * waterColumnConcentrationDOKg_M3;
            var waterColumnConcentrationDOmg_L  = waterColumnConcentrationDOKg_M3 * KG_M3_to_MG_L;

            // +++TODO Check unit conversions!
            var reaerationmg = ReaerationCoefficient * Math.Max(0, (saturatedo2mg_L /*mg.L-1*/ - waterColumnConcentrationDOmg_L)) * WorkingVolume * M3_to_L;

            Reaeration = reaerationmg * MG_TO_KG;

            int i;
            var concentrationDOCmgL = ConcentrationDoc * KG_M3_to_MG_L;

            for (i = 0; i < ProductionBreaks.Length; i++)
            {
                // +++TODO Should this concentration be the updated concentration, post DOC run?
                if (concentrationDOCmgL <= ProductionBreaks[i])
                {
                    break;
                }
            }
            Production = (PrimaryProductionReaeration * MG_L_to_KG_M3) * WorkingVolume * ProductionCoefficients[i];

            var totalOxygenUnconstrainedKg = (existingWaterColumnDOKg + Production + Reaeration) - (SoilO2Kg + DoCo2);
            var saturationOxygenKg         = saturatedo2mg_L * MG_L_to_KG_M3 * WorkingVolume;
            var totalOxygen = Math.Min(totalOxygenUnconstrainedKg, saturationOxygenKg);
            var subloadO2   = totalOxygen / Fac;

            if (WorkingVolume.Greater(0.0))
            {
                DissolvedOxygenLoad = Math.Max(subloadO2, 0.0);
            }
            else
            {
                DissolvedOxygenLoad = 0.0;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Main processing update of the Zone state
        /// </summary>
        private void UpdateFloodedAreas()
        {
            // Find whether the water level has increased or decreased
            double deltaArea = Areal.Area - PreviousArea;

            PreviousArea = Areal.Area;

            if (WorkingVolume.Less(0.0)) // Storage vs Flood storage???
            {
                deltaArea = 0.0;         // +++TODO Hack hack hack...
            }

            // Decide what to do based on how the area has changed
            if (deltaArea > 0)
            {
                IncreaseFloodedZones(deltaArea);
            }
            else if (deltaArea < 0)
            {
                ContractFloodedZones(Math.Abs(deltaArea));
            }
            else if (Areal.Area.Greater(0.0))
            {
                StableFloodZones();
            }
            else
            {
                EndOfFlood();
            }


            RemoveInsignificantZones();

            // Sort the Zones so the collection is back in the required order
            GroupDryZones();

            if (Debug)
            {
                PrintZones(deltaArea);
            }
        }
Exemplo n.º 4
0
        protected int CalculateAdditionalItemsPackedWithThisOrientation(OrientatedItem prevItem,
                                                                        ItemList nextItems,
                                                                        int originalWidthLeft,
                                                                        int originalLengthLeft,
                                                                        int depthLeft,
                                                                        int currentRowLengthBeforePacking)
        {
            var currentRowLength = Math.Max(prevItem.Length, currentRowLengthBeforePacking);

            // cap lookahead as this gets recursive and slow
            var itemsToPack = nextItems.TopN(8);

            var tempBox    = new WorkingVolume(originalWidthLeft - prevItem.Width, currentRowLength, depthLeft, int.MaxValue);
            var tempPacker = new VolumePacker(tempBox, itemsToPack.Clone());

            tempPacker.LookAheadMode = true;

            var remainigRowPacked = tempPacker.Pack();

            foreach (var packedItem in remainigRowPacked.PackedItems)
            {
                itemsToPack.Remove(packedItem.Item);
            }

            var tempBox2    = new WorkingVolume(originalWidthLeft, originalLengthLeft - currentRowLength, depthLeft, int.MaxValue);
            var tempPacker2 = new VolumePacker(tempBox2, itemsToPack.Clone());

            tempPacker2.LookAheadMode = true;
            var nextRowPacked = tempPacker2.Pack();

            foreach (var packedItem in nextRowPacked.PackedItems)
            {
                itemsToPack.Remove(packedItem.Item);
            }

            return(nextItems.Count() - itemsToPack.Count());
        }
Exemplo n.º 5
0
        private void UpdateFloodedAreas()
        {
            double deltaArea = Areal.Area - PreviousArea;

            PreviousArea = Areal.Area;

            if (WorkingVolume.Less(0.0)) // Storage vs Flood storage???
            {
                deltaArea = 0.0;         // +++TODO Hack hack hack...
            }

            if (deltaArea > 0)
            {
                IncreaseFloodedZones(deltaArea);
            }
            else if (deltaArea < 0)
            {
                ContractFloodedZones(Math.Abs(deltaArea));
            }
            else if (Areal.Area.Greater(0.0))
            {
                StableFloodZones();
            }
            else
            {
                EndOfFlood();
            }

            RemoveInsignificantZones();

            GroupDryZones();

            if (Debug)
            {
                PrintZones(deltaArea);
            }
        }