| | |
| | | using Hydro.CommonBase; |
| | | using System.Diagnostics.Metrics; |
| | | using System.Drawing; |
| | | using System.Text; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading.Tasks; |
| | | using System.Xml.Linq; |
| | | |
| | | using Hydro.CommonBase; |
| | | |
| | | namespace Yw.EPAnet |
| | | { |
| | |
| | | { |
| | | string tempString = ""; |
| | | var tempPath = Path.Combine(Directory.GetCurrentDirectory(), @"template\template.inp"); |
| | | |
| | | |
| | | if (!File.Exists(tempPath)) |
| | | { |
| | | throw new Exception("模板文件不存在," + tempPath); |
| | |
| | | net.Junctions.ForEach(o => |
| | | { |
| | | var pTemp = o.DemandPattern; |
| | | if (string.IsNullOrEmpty(pTemp) || pTemp == ";" || pTemp=="_") pTemp = ""; |
| | | |
| | | if (string.IsNullOrEmpty(pTemp) || pTemp == ";" || pTemp == "_") pTemp = ""; |
| | | |
| | | junctionStringBuilder.AppendLine($"{o.Id}\t{o.Elev}\t{o.Demand}\t{pTemp}\t;\t" + $"0\tJunction"); |
| | | coorStringBuilder.AppendLine(o.Id + " " + o.Position.X + " " + o.Position.Y); |
| | | |
| | |
| | | { |
| | | |
| | | tankStringBuilder.AppendLine($"{o.Id}\t{o.PoolElev}\t{o.InitLevel}\t{o.MinLevel}\t{o.MaxLevel}\t{o.Diameter}\t{o.MinVol}\t{o.VolCurve}\t{o.Overflow}\t;\t");// + $"0"); |
| | | coorStringBuilder.AppendLine(o.Id + " " + o.Position.X+" "+o.Position.Y); |
| | | coorStringBuilder.AppendLine(o.Id + " " + o.Position.X + " " + o.Position.Y); |
| | | }); |
| | | string tankString = tankStringBuilder.ToString(); |
| | | |
| | |
| | | net.Pipes.ForEach(o => |
| | | { |
| | | if (o.Roughness == 0) o.Roughness = 110; |
| | | string statusString = o.LinkStatus == LinkStatus.Closed ? "CLOSED" : ""; |
| | | |
| | | string statusString = o.LinkStatus == PipeStatus.Closed ? "CLOSED" : ""; |
| | | |
| | | pipeStringBuilder.AppendLine($"{o.Id}\t{o.StartNode.Id}\t{o.EndNode.Id}\t{o.Length}\t{o.Diameter}\t{o.Roughness}\t{o.MinorLoss}\t{statusString}\t;\t");// + $"{p.Level}"); |
| | | if (o.LinkStatus!=LinkStatus.Open) |
| | | if (o.LinkStatus != PipeStatus.Open) |
| | | { |
| | | statusStringBuilder.AppendLine(o.Id + "\t" + statusString); |
| | | } |
| | | }); |
| | | |
| | | string pipeString = pipeStringBuilder.ToString(); |
| | |
| | | net.Valves.ForEach(o => |
| | | { |
| | | valveStringBuilder.AppendLine($"{o.Id}\t{o.StartNode.Id}\t{o.EndNode.Id}\t{o.Diameter:F4}\t{o.ValveType}\t{o.ValveSetting}\t{o.MinorLoss:F4}\t;\t");// + $"0"); |
| | | if (!string.IsNullOrEmpty(o.LinkStatus )) |
| | | if (!string.IsNullOrEmpty(o.LinkStatus)) |
| | | statusStringBuilder.AppendLine(o.Id + "\t" + o.LinkStatus); |
| | | }); |
| | | string valveString = valveStringBuilder.ToString(); |
| | |
| | | { |
| | | pumpStringBuilder.AppendLine($"{o.Id}\t{o.StartNode.Id}\t{o.EndNode.Id}\tHead\t{o.CurveQH}\tSPEED\t{o.SpeedRatio}\t;\t");// + $"0"); |
| | | if (!string.IsNullOrEmpty(o.LinkStatus)) |
| | | statusStringBuilder.AppendLine(o.Id+"\t"+ o.LinkStatus); |
| | | statusStringBuilder.AppendLine(o.Id + "\t" + o.LinkStatus); |
| | | }); |
| | | string pumpString = pumpStringBuilder.ToString(); |
| | | StringBuilder curveStringBuilder = new StringBuilder(); |
| | |
| | | output = ReplaceContent(output, "STATUS", statusString); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | return output; |
| | | } |
| | | |
| | | |
| | | |
| | | private static string ReplaceContent(string text, string content, string replaceString) |
| | | { |
| | | |
| | |
| | | { |
| | | InpPipe p = new InpPipe(); |
| | | p.Id = parts[0]; |
| | | p.Node1 = parts[1] ; |
| | | p.Node1 = parts[1]; |
| | | p.Node2 = parts[2]; |
| | | float length; |
| | | if (float.TryParse(parts[3], out length)) |
| | |
| | | float minorLoss; |
| | | if (float.TryParse(parts[6], out minorLoss)) |
| | | p.MinorLoss = minorLoss; |
| | | p.LinkStatus = parts.Length > 7 ? LinkStatus.Closed : LinkStatus.Open; |
| | | p.LinkStatus = parts.Length > 7 ? PipeStatus.Closed : PipeStatus.Open; |
| | | //int level; |
| | | //if (int.TryParse(parts[8], out level)) |
| | | // p.Level = level; |
| | |
| | | float minorLoss; |
| | | if (float.TryParse(parts[6], out minorLoss)) |
| | | valve.MinorLoss = minorLoss; |
| | | |
| | | |
| | | net.Valves.Add(valve); |
| | | } |
| | | break; |
| | |
| | | } |
| | | sr.Close(); |
| | | |
| | | |
| | | |
| | | #region 优化方案 |
| | | int k1 = 0; |
| | | int k2 = 0; |
| | | |
| | | var Nodes= net.GetAllNodes(); |
| | | var Nodes = net.GetAllNodes(); |
| | | var Links = net.GetAllLinks(); |
| | | Nodes.Sort((a, b) => string.Compare(a.Id, b.Id)); |
| | | points.Sort((a, b) => string.Compare(a.Id, b.Id)); |
| | |
| | | //throw new Exception($"未找到Node[{J.Id}]的坐标"); |
| | | } |
| | | |
| | | J.Position=new Position2d(); |
| | | J.Position = new Position2d(); |
| | | J.Position.X = coor.Position.X; |
| | | J.Position.Y = coor.Position.Y; |
| | | |
| | |
| | | //throw new Exception($"未找到Link[{p.Id}]的起始节点[{((IInpParser)p).Node1}]"); |
| | | } |
| | | p.StartNode = J; |
| | | if (J.Links==null) J.Links = new List<ILink>(); |
| | | if (J.Links == null) J.Links = new List<ILink>(); |
| | | J.Links.Add(p); |
| | | k2++; |
| | | } |