| | |
| | | /// <summary> |
| | | /// 计算 |
| | | /// </summary> |
| | | public static CalcuResult Calcu(this Network network) |
| | | public static CalcuResult Calcu(this Network network,bool MinorLossPreCalc=true) |
| | | { |
| | | var result = new CalcuResult(); |
| | | |
| | | |
| | | //Null验证 |
| | | if (network == null) |
| | | { |
| | | result.Succeed = false; |
| | | return result; |
| | | } |
| | | |
| | | |
| | | string inpString = null; |
| | | if (MinorLossPreCalc) |
| | | { |
| | | CalcuResult minorLossResult = network.CalcuMinorLoss(); |
| | | if (!minorLossResult.Succeed) |
| | | { |
| | | result.Succeed = false; |
| | | result.FailedList.AddRange(minorLossResult.FailedList); |
| | | return result; |
| | | } |
| | | inpString = network.ToInpString(minorLossResult); |
| | | } |
| | | else |
| | | { |
| | | inpString = network.ToInpString(); |
| | | } |
| | | //获取系统临时文件目录,创建inp临时文件 |
| | | var inpFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N") + ".inp"); |
| | | var inpString = network.ToInpString(); |
| | | |
| | | File.WriteAllText(inpFilePath, inpString); |
| | | |
| | | //加载管网 |
| | |
| | | epanet.getnodeid(i, sb); |
| | | var arr = new string[] { "Head", "Press", "Demand" }; //System.Enum.GetValues(typeof(HydraulicModel.NodeValueType)); |
| | | var arrnum = new int[] { 10, 11, 9 }; |
| | | var resultNode = new CalcuNode() |
| | | var resultNode = new Node() |
| | | { |
| | | Id = sb.ToString(), |
| | | }; |
| | |
| | | } |
| | | } |
| | | result.NodeList.Add(resultNode); |
| | | result.NodeDict.Add(resultNode.Id, resultNode); |
| | | } |
| | | |
| | | for (int i = 1; i <= linkCount; i++) |
| | |
| | | //var arr = System.Enum.GetValues(typeof(HydraulicModel.LinkValueType)); |
| | | var arr = new string[] { "Flow", "Velocity", "Headloss" }; //System.Enum.GetValues(typeof(HydraulicModel.NodeValueType)); |
| | | var arrnum = new int[] { 8, 9, 10 }; |
| | | var resultLink = new CalcuLink() |
| | | var resultLink = new Link() |
| | | { |
| | | Id = sb.ToString(), |
| | | }; |
| | |
| | | } |
| | | } |
| | | result.LinkList.Add(resultLink); |
| | | result.LinkDict.Add(resultLink.Id, resultLink); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |