ÎļþÃû´Ó WinFrmUI/PBS.WinFrmUI.Hydro/01-water-supply-system-curve/SystemCurvePage.cs ÐÞ¸Ä |
| | |
| | | |
| | | public class CalcNodeViewModel |
| | | { |
| | | public int NodeIndex { get; set; } |
| | | public int NodeIndex { get; set; } |
| | | public double Elevation { get; set; } |
| | | public double Flow { get; set; } |
| | | public double Pressure { get; set; } |
| | | } |
| | |
| | | _constantLineDynamicPressure.ShowInLegend = false; |
| | | _constantLineStaticPressure.ShowInLegend = false; |
| | | |
| | | _constantLineDynamicPressure.Title.Alignment = ConstantLineTitleAlignment.Far; |
| | | _constantLineStaticPressure.Title.Alignment = ConstantLineTitleAlignment.Far; |
| | | |
| | | _constantLineDynamicPressure.LineStyle.Thickness = 2; |
| | | _constantLineStaticPressure.LineStyle.Thickness = 2; |
| | | |
| | | _xyDiagram.EnableAxisXZooming = true; |
| | | _xyDiagram.EnableAxisYZooming = true; |
| | |
| | | var minDemand = 0; // æå°æ»éæ°´é(m³/h) |
| | | var maxDemand = 43; // æå¤§æ»éæ°´é(m³/h) |
| | | var reservoirElevation = -4; //æ°´æ± æ é« |
| | | var calcCount = 5000; // è®¡ç®æ¬¡æ° |
| | | var staticPressure = 22; //éå |
| | | var calcCount = 1000; // è®¡ç®æ¬¡æ° |
| | | var staticPressure = 22.5; //éå |
| | | var requiredEndPressure = 18; //éå |
| | | |
| | | CalcSystemCurve(file_path, minDemand, maxDemand, reservoirElevation, staticPressure, calcCount); |
| | | CalcSystemCurve(file_path, minDemand, maxDemand, reservoirElevation, staticPressure, requiredEndPressure, calcCount); |
| | | } |
| | | |
| | | private void CalcSystemCurve( |
| | |
| | | double maxDemand, |
| | | double reservoirElevation, |
| | | double staticPressure, |
| | | double requiredEndPressure, |
| | | int calcCount) |
| | | { |
| | | |
| | | var pressure = 0d; |
| | | |
| | | var nodeConfig = new List<WaterDistributionCalculator.NodeConfig>(); |
| | | var userNodeList = new List<int>(); |
| | | var calcResultList = new List<CalcResultViewModel>(calcCount); |
| | | |
| | | using (var helper = new Yw.Epanet.InteropXHelper()) |
| | | { |
| | | var code = helper.Open(inpFilePath, "", ""); |
| | |
| | | helper.GetNodeType(nodeIndex, out Yw.Epanet.eNodeType nodeType); |
| | | if (nodeType == Yw.Epanet.eNodeType.Junction) |
| | | { |
| | | userNodeList.Add(nodeIndex); |
| | | helper.GetNodeValue(nodeIndex, Yw.Epanet.eNodeProperty.Elevation, out double elevation); |
| | | nodeConfig.Add(new WaterDistributionCalculator.NodeConfig() |
| | | { |
| | | NodeIndex = nodeIndex, |
| | | Elevation = elevation, |
| | | MinFlow = 0, |
| | | MaxFlow = rand.NextDouble() * 5 |
| | | }); |
| | |
| | | } |
| | | } |
| | | |
| | | var userNodeCount = userNodeList.Count; |
| | | var userNodeCount = nodeConfig.Count; |
| | | var calculator = new WaterDistributionCalculator(nodeConfig, calcCount, minDemand, maxDemand); |
| | | var allDemands = calculator.CalculateDistributions(); |
| | | |
| | | code = helper.OpenH(); |
| | | for (int count = 0; count < allDemands.Count; count++) |
| | | { |
| | |
| | | |
| | | helper.InitH(false); |
| | | var demands = allDemands[count]; |
| | | foreach (var userNodeIndex in userNodeList) |
| | | foreach (var node in nodeConfig) |
| | | { |
| | | var userNodeIndex = node.NodeIndex; |
| | | double demand = demands.NodeFlows[userNodeIndex]; |
| | | code = helper.SetNodeValue(userNodeIndex, Yw.Epanet.eNodeProperty.BaseDemand, demand); |
| | | CheckCode(code); |
| | |
| | | helper.RunH(out long t); |
| | | |
| | | |
| | | foreach (var userNodeIndex in userNodeList) |
| | | foreach (var node in nodeConfig) |
| | | { |
| | | var userNodeIndex = node.NodeIndex; |
| | | pressure = 0; |
| | | //code = helper.GetNodeValue(userNodeIndex, Yw.Epanet.eNodeProperty.Pressure, out pressure); |
| | | code = helper.GetNodeValue(userNodeIndex, Yw.Epanet.eNodeProperty.Head, out pressure); |
| | | CheckCode(code); |
| | | calcNodelDict[userNodeIndex].Pressure = pressure; |
| | | |
| | | if (calcEndPressure > pressure) |
| | | //code = helper.GetNodeValue(userNodeIndex, Yw.Epanet.eNodeProperty.Pressure, out pressure); |
| | | //CheckCode(code); |
| | | //var endPressure = pressure + node.Elevation; |
| | | |
| | | code = helper.GetNodeValue(userNodeIndex, Yw.Epanet.eNodeProperty.Pressure, out pressure); |
| | | CheckCode(code); |
| | | var endPressure = pressure + node.Elevation; |
| | | calcNodelDict[userNodeIndex].Pressure = endPressure; |
| | | |
| | | if (calcEndPressure > endPressure) |
| | | { |
| | | calcEndPressure = pressure; |
| | | calcEndPressure = endPressure; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | | this.chartControl1.BeginInit(); |
| | | |
| | | |
| | |
| | | _waterPointList = null; |
| | | |
| | | |
| | | // _seriesWaterPoint.BindToData(null, "", ""); |
| | | // _seriesUpperPressure.Points.Clear(); |
| | | //_seriesLowerPressure.Points.Clear(); |
| | | // _seriesAveragePressure.Points.Clear(); |
| | | _seriesWaterPoint.Points.Clear(); |
| | | _seriesUpperPressure.Points.Clear(); |
| | | _seriesLowerPressure.Points.Clear(); |
| | | _seriesAveragePressure.Points.Clear(); |
| | | |
| | | _constantLineDynamicPressure.Visible = false; |
| | | _constantLineStaticPressure.Visible = false; |
| | | |
| | | if (calcResultList.Any()) |
| | | { |
| | | _waterPointList = calcResultList.Select(x => new PointViewModel(x.TotalFlow, x.EndPressure + staticPressure)).ToList(); |
| | | _waterPointList = calcResultList.Select(x => new PointViewModel(x.TotalFlow, x.EndPressure + staticPressure + requiredEndPressure)).ToList(); |
| | | //_waterPointList = calcResultList.Select(x => new PointViewModel(x.TotalFlow, x.EndPressure + staticPressure)).ToList(); |
| | | |
| | | var waterPointGroup = _waterPointList.GroupBy(x => Math.Round(x.X, 1)); |
| | | var upperPressurePtList = new List<Yw.Geometry.Point2d>(); |
| | |
| | | var lowerPressureCurvePtList = _curveLowerPressure.GetPointList(100); |
| | | var averagePressureCurvePtList = _curveAveragePressure.GetPointList(100); |
| | | |
| | | _seriesWaterPoint.BindToData(_waterPointList, "X", "Y"); |
| | | _seriesUpperPressure.BindToData(upperPressureCurvePtList, "X", "Y"); |
| | | _seriesLowerPressure.BindToData(lowerPressureCurvePtList, "X", "Y"); |
| | | _seriesAveragePressure.BindToData(averagePressureCurvePtList, "X", "Y"); |
| | | |
| | | foreach (var item in _waterPointList) |
| | | { |
| | | _seriesWaterPoint.Points.Add(new SeriesPoint(item.X, item.Y)); |
| | | } |
| | | foreach (var item in upperPressureCurvePtList) |
| | | { |
| | | _seriesUpperPressure.Points.Add(new SeriesPoint(item.X, item.Y)); |
| | | } |
| | | foreach (var item in lowerPressureCurvePtList) |
| | | { |
| | | _seriesLowerPressure.Points.Add(new SeriesPoint(item.X, item.Y)); |
| | | } |
| | | foreach (var item in averagePressureCurvePtList) |
| | | { |
| | | _seriesAveragePressure.Points.Add(new SeriesPoint(item.X, item.Y)); |
| | | } |
| | | |
| | | var minX = _waterPointList.Min(x => x.X); |
| | | var maxX = _waterPointList.Max(x => x.X); |
| | | |
| | | var minY = _waterPointList.Min(x => x.Y); |
| | | var maxY = _waterPointList.Max(x => x.Y); |
| | | |
| | | |
| | | var minDynamicPressure = minY; |
| | | _constantLineDynamicPressure.AxisValue = minDynamicPressure; |
| | | _constantLineDynamicPressure.Title.Text = $"æä½ä¾æ°´åå:{minDynamicPressure:N2}m"; |
| | | _constantLineDynamicPressure.Visible = true; |
| | | |
| | | var totalStaticPressure = staticPressure + Math.Abs(reservoirElevation); |
| | | _constantLineStaticPressure.AxisValue = totalStaticPressure; |
| | | _constantLineStaticPressure.Title.Text = $"éå:{totalStaticPressure:N2}"; |
| | | _constantLineStaticPressure.Title.Text = $"æé«æ¥¼å±é«åº¦:{totalStaticPressure:N2}m"; |
| | | _constantLineStaticPressure.Visible = true; |
| | | |
| | | minY = Math.Min(staticPressure, minY); |
| | | maxY = Math.Max(staticPressure, maxY); |
| | | |
| | | minY = Math.Min(staticPressure, minY); |
| | | maxY = Math.Max(staticPressure, maxY); |
| | | |
| | | maxY = Math.Floor(maxY); |
| | | maxX = Math.Floor(maxX); |
| | | |
| | | _xyDiagram.AxisX.WholeRange.Auto = true; |
| | | _xyDiagram.AxisX.VisualRange.Auto = true; |
| | | _xyDiagram.AxisX.WholeRange.SideMarginsValue = 0; |
| | | _xyDiagram.AxisX.VisualRange.SideMarginsValue = 0; |
| | | _xyDiagram.AxisX.NumericScaleOptions.AutoGrid = true; |
| | | _xyDiagram.AxisX.WholeRange.SetMinMaxValues(minX, 50); |
| | | _xyDiagram.AxisX.VisualRange.SetMinMaxValues(minX, 50); |
| | | |
| | | _xyDiagram.AxisY.WholeRange.Auto = true; |
| | | _xyDiagram.AxisY.VisualRange.Auto = true; |
| | | _xyDiagram.AxisY.NumericScaleOptions.AutoGrid = true; |
| | | _xyDiagram.AxisY.WholeRange.SideMarginsValue = 0; |
| | | _xyDiagram.AxisY.VisualRange.SideMarginsValue = 0; |
| | | _xyDiagram.AxisY.WholeRange.SetMinMaxValues(minY, 70); |
| | | _xyDiagram.AxisY.VisualRange.SetMinMaxValues(minY, 70); |
| | | |
| | | } |
| | | this.chartControl1.EndInit(); |
| | | } |