コード例 #1
0
        private void AddStatistics()
        {
            // Add simple statistics for default HD results
            _resultSpec = _mike1DData.ResultSpecifications.Find(x => x.ID == "DefaultHDResults");
            _resultSpec = CreateStatisticsResultSpecification(_resultSpec, ResultTypes.HD);
            _mike1DData.ResultSpecifications.Add(_resultSpec);

            // Water level
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.WaterLevel, DerivedQuantityType.Max));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.WaterLevel, DerivedQuantityType.MaxTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.WaterLevel, DerivedQuantityType.MinTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.WaterLevel, DerivedQuantityType.Min));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.WaterLevel, DerivedQuantityType.Average));

            // Discharge
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.TimeIntegrate));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.Max));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.MaxTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.MinTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.Min));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.Average));

            // Flow velocity
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.FlowVelocity, DerivedQuantityType.Max));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.FlowVelocity, DerivedQuantityType.MaxTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.FlowVelocity, DerivedQuantityType.MinTime));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.FlowVelocity, DerivedQuantityType.Min));
            AddQuantity(DerivedQuantity.Create(PredefinedQuantity.FlowVelocity, DerivedQuantityType.Average));
        }
コード例 #2
0
        public virtual DataReaderBuilder FakeResultDataBuilder(ResultSpecification specification, int count)
        {
            var builder = new TabularResultDataReaderBuilder(specification)
                          .CreateNewTable()
                          .GenerateBogusRows(count);

            return(builder);
        }
コード例 #3
0
        private void Initialize()
        {
            _powerPlants = new List <PowerPlantData>();

            // Proxy, used for getting access to engine variables
            ProxyUtil proxy = new ProxyUtil(_controller.EngineNet);

            // Quantities
            Quantity powerQuantity  = new Quantity("EnergyPower", "Energy Power", eumItem.eumIPower, eumUnit.eumUkwatt);
            Quantity energyQuantity = new Quantity("EnergyProduced", "Energy produced", eumItem.eumIenergy, eumUnit.eumUKiloWattHour);

            // Add quantities to default HD results
            ResultSpecification hdResults = _controller.Mike1DData.ResultSpecifications.Find(rs => rs.ID == "DefaultHDResults");

            hdResults.What.Add(powerQuantity);
            hdResults.What.Add(energyQuantity);

            // Setup all powerplants
            foreach (string powerPlantStructureId in _powerPlantStructureIds)
            {
                // Find structure with Id - returns null if not found
                IStructure structure = _controller.Mike1DData.Network.StructureCollection.Structures.FirstOrDefault(
                    s => StringComparer.OrdinalIgnoreCase.Equals(s.ID, powerPlantStructureId));

                // Only applicable for Discharge structures
                DischargeStructure dischargeStructure = structure as DischargeStructure;

                // null if structure was not an IDischargeStructure, or powerPlantStructureId was not found
                if (dischargeStructure == null)
                {
                    continue;
                }

                // Find reach and grid point of structure
                ILocation   location    = dischargeStructure.Location;
                EngineReach engineReach = _controller.EngineNet.FindReach(location);
                GridPoint   gridPoint   = engineReach.GetClosestGridPoint <GridPoint>(dischargeStructure.Location);

                // Getters for waterlevels upstream and downstream of structure.
                DDoubleGetter upWl = proxy.GetterUnboxed(engineReach, gridPoint.PointIndex - 1, Quantity.Create(PredefinedQuantity.WaterLevel));
                DDoubleGetter doWl = proxy.GetterUnboxed(engineReach, gridPoint.PointIndex + 1, Quantity.Create(PredefinedQuantity.WaterLevel));

                // Data for this reach. Id of structure is added to description of quantity
                var powerDataReach  = CreateEngineDataReach(CreateIdQuantity(powerQuantity, structure.ID), engineReach, gridPoint);
                var energyDataReach = CreateEngineDataReach(CreateIdQuantity(energyQuantity, structure.ID), engineReach, gridPoint);

                PowerPlantData powerPlantData = new PowerPlantData();
                powerPlantData.Structure  = dischargeStructure;
                powerPlantData.UpWl       = upWl;
                powerPlantData.DoWl       = doWl;
                powerPlantData.PowerData  = powerDataReach;
                powerPlantData.EnergyData = energyDataReach;

                _powerPlants.Add(powerPlantData);
            }

            _controller.EngineNet.PostTimeStepEvent += PostTimestep;
        }
コード例 #4
0
 private void AddAccumulatedTimeSeries()
 {
     // Find HD result specification
     _resultSpec = _mike1DData.ResultSpecifications.Find(x => x.ID == "DefaultHDResults");
     // Accumulated values of discharge
     AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.TimeIntegrate));
     AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.TimeIntegratePositive));
     AddQuantity(DerivedQuantity.Create(PredefinedQuantity.Discharge, DerivedQuantityType.TimeIntegrateNegative));
 }
コード例 #5
0
        public void AddToOutput(Mike1DData mike1DData)
        {
            // Add Water Depth to default HD result output
            ResultSpecification hdResSpec = mike1DData.ResultSpecifications.Find(rs => rs.ID == "DefaultHDResults");

            if (hdResSpec != null)
            {
                hdResSpec.What.Add(Quantity.Create(PredefinedQuantity.WaterDepth));
            }
        }
コード例 #6
0
        public void AddADUserOutput(Mike1DData mike1DData, IDiagnostics diagnostics)
        {
            ResultSpecification adUserResSpec = mike1DData.GetDefaultResultSpecification(ResultSpecificationTypes.AD);

            adUserResSpec.ID = "ADUserOutput";

            // How often to store
            adUserResSpec.StoringFrequencyType = StoringFrequencyUnitTypes.Minutes;
            adUserResSpec.StoringFrequency     = 15;

            // Where to store the file
            adUserResSpec.Connection.FilePath = new FilePath(mike1DData.Id + mike1DData.ScenarioId + "UserAD.res1d");

            // What to store
            ADComponent adComp = mike1DData.ADComponentData.Components.Find(comp => comp.Id == "Spill");

            if (adComp == null)
            {
                diagnostics.Error(new DiagnosticItem("Could not find AD component with Id: Spill"));
                return;
            }
            // Mass transport of "Spill" AD component
            // IQuantity massTransport = ADComponentQuantities.FaceTransport(adComp.Quantity);                // For Release 2019 (17.0), this works
            IQuantity massTransport = ADComponentQuantities.Create(adComp, PredefinedQuantityAD.Transport); // For later releases (>17.0), this is recommended

            adUserResSpec.What.Add(massTransport);

            // Which data in the network to store
            var spatialFilter = new Res1DNetworkFilter();

            // Links, output at all grid points
            spatialFilter.AddGlobalReachValue("Link_1", true);
            spatialFilter.AddGlobalReachValue("Link_2", true);
            // Links, output at inflow to link only
            spatialFilter.AddGlobalReachValue("Link_3", Res1DSpatialFilterTypeEnum.First);
            spatialFilter.AddGlobalReachValue("Link_4", Res1DSpatialFilterTypeEnum.First);
            // Weirs
            spatialFilter.AddGlobalReachValue("Weir:Weir_1", true);
            spatialFilter.AddGlobalReachValue("Weir:Weir_2", true);
            // Set filter for specific quantity or for all quantities
            //adUserResSpec.SetFilter(massTransport, spatialFilter);
            adUserResSpec.DefaultFilter = spatialFilter;

            // Add to list of result files
            mike1DData.ResultSpecifications.Add(adUserResSpec);
        }
コード例 #7
0
        public void ModifySetup(Mike1DData mike1DData, IDiagnostics diagnostics, bool addWaterDepth = false, double alpha = 1.0)
        {
            // Use diagnostics object to add to setup log file
            diagnostics.Info(string.Format("Modifying setup, adding depth: {0}", addWaterDepth));

            // Add Water Depth to default HD result output
            ResultSpecification hdResSpec = mike1DData.ResultSpecifications.Find(rs => rs.ID == "DefaultHDResults");

            if (hdResSpec != null)
            {
                if (addWaterDepth)
                {
                    hdResSpec.What.Add(Quantity.Create(PredefinedQuantity.WaterDepth));
                }
            }

            // Change alpha parameter
            mike1DData.HDParameters.SolverSettings.Alpha = alpha;
        }
コード例 #8
0
        private ResultSpecification CreateStatisticsResultSpecification(ResultSpecification resultSpec, ResultTypes resultType)
        {
            var fileName = resultSpec.Connection.FilePath.Path.Replace(".res1d", "Stat.res1d");

            var conn = new Connection
            {
                BridgeName = "res1d",
                FilePath   = { Path = fileName }
            };

            var statisticsResultSpec = new ResultSpecification
            {
                ID = "HDStatistics",
                StoringFrequency     = 1,
                StoringFrequencyType = StoringFrequencyUnitTypes.PerTimeStep,
                Connection           = conn,
                Mode       = ResultSpecification.FileMode.Overwrite,
                ResultType = resultType,
                StartTime  = _mike1DData.SimulationEnd,
                EndTime    = _mike1DData.SimulationEnd
            };

            return(statisticsResultSpec);
        }
コード例 #9
0
        protected Mock <IDynamicQueryProxy> MockDynamicQueryProxyWithFakeData(int testItemCount, ResultSpecification fakeSpecification)
        {
            var fakeResultDataBuilder = FakeResultDataBuilder(fakeSpecification, testItemCount);
            var fakeDataTable         = fakeResultDataBuilder.DataTable;
            var mockQueryProxy        = new MockDynamicQueryProxyFactory().Create(fakeDataTable);

            return(mockQueryProxy);
        }
コード例 #10
0
 public static ResultConfig Create(Facet facet, ResultSpecification resultSpecification, string viewTypeId)
 {
     return(Create(facet, new List <ResultSpecification> {
         resultSpecification
     }, viewTypeId));
 }
コード例 #11
0
ファイル: UnitTestLoadXML.cs プロジェクト: Morgfrimen/WPFApp
        public void Test_SpecificationXmlWork_AlgoritmOneThread()
        {
            Specification specification = new Specification
            {
                Orders = new List <Order>
                {
                    new Order
                    {
                        Id = Guid.NewGuid().ToString(), Name = "Заказ 1"
                    },
                    new Order
                    {
                        Id = Guid.NewGuid().ToString(), Name = "Заказ 2"
                    },
                    new Order
                    {
                        Id = Guid.NewGuid().ToString(), Name = "Заказ 3"
                    },
                    new Order
                    {
                        Id = Guid.NewGuid().ToString(), Name = "Заказ 4"
                    },
                    new Order
                    {
                        Id = Guid.NewGuid().ToString(), Name = "Заказ 5"
                    }
                }
            };

            //Определяем 5 заказов
            //Определяем части заказа
            specification.Items = new List <Item>
            {
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 1",
                    OrderId = specification.Orders[index : 1 - 1].Id, Weight = 10
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 1",
                    OrderId = specification.Orders[index : 1 - 1].Id, Weight = 10
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 1",
                    OrderId = specification.Orders[index : 1 - 1].Id, Weight = 10
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 1",
                    OrderId = specification.Orders[index : 1 - 1].Id, Weight = 10
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 2",
                    OrderId = specification.Orders[index : 2 - 1].Id, Weight = 100
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 2",
                    OrderId = specification.Orders[index : 2 - 1].Id, Weight = 100
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 2",
                    OrderId = specification.Orders[index : 2 - 1].Id, Weight = 5
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 3",
                    OrderId = specification.Orders[index : 3 - 1].Id, Weight = 10
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 3",
                    OrderId = specification.Orders[index : 3 - 1].Id, Weight = 20
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 4",
                    OrderId = specification.Orders[index : 4 - 1].Id, Weight = 50
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 4",
                    OrderId = specification.Orders[index : 4 - 1].Id, Weight = 50
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 4",
                    OrderId = specification.Orders[index : 4 - 1].Id, Weight = 50
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 4",
                    OrderId = specification.Orders[index : 4 - 1].Id, Weight = 50
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 5",
                    OrderId = specification.Orders[index : 5 - 1].Id, Weight = 100
                },
                new Item
                {
                    Id      = Guid.NewGuid().ToString(), Name = "Часть 5",
                    OrderId = specification.Orders[index : 5 - 1].Id, Weight = 100
                }
            };

            SpecificationXmlWork specificationXmlWork = new SpecificationXmlWork
                                                            (model: specification)
            {
                MaxWeight = 30
            };

            ViewTableData expected = new ViewTableData
            {
                ArrayList = new ArrayList
                {
                    new ResultSpecification
                    {
                        NumberOrder = "Заказ 1", CountContainer = 2, CountNotDimensional = 0
                    },
                    new ResultSpecification
                    {
                        NumberOrder = "Заказ 2", CountContainer = 1, CountNotDimensional = 2
                    },
                    new ResultSpecification
                    {
                        NumberOrder = "Заказ 3", CountContainer = 1, CountNotDimensional = 0
                    },
                    new ResultSpecification
                    {
                        NumberOrder = "Заказ 4", CountContainer = 0, CountNotDimensional = 4
                    },
                    new ResultSpecification
                    {
                        NumberOrder = "Заказ 5", CountContainer = 0, CountNotDimensional = 2
                    }
                }
            };

            ViewTableData actual = specificationXmlWork.GetResult();

            Assert.AreEqual(expected: expected.ArrayList.Count, actual: actual.ArrayList.Count);

            for (int index = 0; index < actual.ArrayList.Count; index++)
            {
                ResultSpecification expect =
                    expected.ArrayList[index : index] as ResultSpecification;
                ResultSpecification ac = actual.ArrayList[index : index] as ResultSpecification;
                Console.WriteLine(value: index);

                // ReSharper disable once PossibleNullReferenceException
                // ReSharper disable once ArgumentsStyleNamedExpression
                Assert.AreEqual(expect.CountContainer, actual: ac.CountContainer);
                Assert.AreEqual
                    (expected: expect.CountNotDimensional, actual: ac.CountNotDimensional);
            }
        }
コード例 #12
0
 public TabularResultDataReaderBuilder(ResultSpecification resultSpecification) : base("TabuleResult")
 {
     ResultSpecification = resultSpecification;
 }