double GetPowerTransformerRatio(PowerTransformer pt) { if (pt.TransformerWindings.Count != 2) { return(1); } TransformerWinding tw1 = Get(pt.TransformerWindings[0]) as TransformerWinding; TransformerWinding tw2 = Get(pt.TransformerWindings[1]) as TransformerWinding; BaseVoltage bv1 = Get(tw1.BaseVoltage) as BaseVoltage; BaseVoltage bv2 = Get(tw2.BaseVoltage) as BaseVoltage; Pair <double, double> u = MinMax(bv1.NominalVoltage, bv2.NominalVoltage); RatioTapChanger rt = null; if (tw1.RatioTapChanger.Count == 1) { rt = Get(tw1.RatioTapChanger[0]) as RatioTapChanger; } else if (tw2.RatioTapChanger.Count == 1) { rt = Get(tw2.RatioTapChanger[0]) as RatioTapChanger; } return(rt != null ? (u.Second + (GetRatioTapChangerStep(rt) - rt.NominalStep) * rt.VoltageStep) / u.First : u.Second / u.First); }
bool IsTransformerWindingPrimary(TransformerWinding tw) { PowerTransformer pt = Get(tw.PowerTransformer) as PowerTransformer; TransformerWinding other = null; for (int i = 0; i < pt.TransformerWindings.Count; ++i) { long otherGID = pt.TransformerWindings[i]; if (otherGID == tw.GID) { continue; } TransformerWinding tw2 = Get(otherGID) as TransformerWinding; if (tw2 != null) { other = tw2; break; } } BaseVoltage bv1 = Get(tw.BaseVoltage) as BaseVoltage; BaseVoltage bv2 = Get(other.BaseVoltage) as BaseVoltage; return(bv1.NominalVoltage > bv2.NominalVoltage); }
void PopulateTransformerWindingProperties(TransformerWinding x, ResourceDescription rd) { PopulateConductingEquipmentProperties(x, rd); if (x.PowerTransformerHasValue) { rd.AddProperty(new ReferenceProperty(ModelCode.TRANSFORMERWINDING_POWERTRANSFORMER, GetGID(x.PowerTransformer.ID))); } }
public static string WindingToString(TransformerWinding winding, string num) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"\t\tTW {num}"); sb.AppendLine($"\t\t\tNAME: {winding.Name}"); sb.AppendLine($"\t\t\tMRDI: {winding.MRID}"); sb.AppendLine($"\t\t\tDESCRIPTION: {winding.Description}"); sb.AppendLine($"\t\t\tNOMINAL VOLTAGE: {winding.BaseVoltage.NominalVoltage}"); return(sb.ToString()); }
private ResourceDescription CreateTransformerWindingResourceDescription(TransformerWinding cimTransformerWinding) { ResourceDescription rd = null; if (cimTransformerWinding != null) { long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.TRANSFORMERWINDING, importHelper.CheckOutIndexForDMSType(DMSType.TRANSFORMERWINDING)); rd = new ResourceDescription(gid); importHelper.DefineIDMapping(cimTransformerWinding.ID, gid); SCADAConverter.PopulateTransformerWindingProperties(cimTransformerWinding, rd, importHelper, report); } return(rd); }
Complex CalculateCurrentForTransformerWinding(Node node, IEnumerable <Complex> childCurrents, Dictionary <long, LoadFlowResult> lf) { TransformerWinding tw = node.IO as TransformerWinding; if (tw == null) { return(Complex.NaN()); } if (!IsTransformerWindingPrimary(tw)) { return(CalculateCurrentDefault(node, childCurrents, lf)); } return(CalculateCurrentDefault(node, childCurrents, lf).Scale(GetPowerTransformerRatio(Get(tw.PowerTransformer) as PowerTransformer))); }
/// <summary> /// Creates entity for specified global inside the container. /// </summary> /// <param name="globalId">Global id of the entity for insert</param> /// <returns>Created entity (identified object).</returns> public IdentifiedObject CreateEntity(long globalId) { short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId); IdentifiedObject io = null; switch ((DMSType)type) { case DMSType.BASEVOLTAGE: io = new BaseVoltage(globalId); break; case DMSType.LOCATION: io = new Location(globalId); break; case DMSType.POWERTR: io = new PowerTransformer(globalId); break; case DMSType.POWERTRWINDING: io = new TransformerWinding(globalId); break; case DMSType.WINDINGTEST: io = new WindingTest(globalId); break; case DMSType.TERMINAL: io = new Terminal(globalId); break; default: string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type); CommonTrace.WriteTrace(CommonTrace.TraceError, message); throw new Exception(message); } // Add entity to map this.AddEntity(io); return(io); }
private void ImportTransformerWinding() { SortedDictionary <string, object> cimTransformerWindings = concreteModel.GetAllObjectsOfType("FTN.TransformerWinding"); if (cimTransformerWindings != null) { foreach (KeyValuePair <string, object> item in cimTransformerWindings) { TransformerWinding cimTransformerWinding = item.Value as TransformerWinding; ResourceDescription rd = CreateTransformerWindingResourceDescription(cimTransformerWinding); if (rd != null) { delta.AddDeltaOperation(DeltaOpType.Insert, rd, true); report.Report.Append("TransformerWinding ID = ").Append(cimTransformerWinding.ID).Append(" SUCCESSFULLY converted to GID = ").AppendLine(rd.Id.ToString()); } else { report.Report.Append("TransformerWinding ID = ").Append(cimTransformerWinding.ID).AppendLine(" FAILED to be converted"); } } report.Report.AppendLine(); } }
Node BuildSubGraph(EnergySource source) { Dictionary <long, IdentifiedObject> terminals = containers[DMSType.Terminal]; Dictionary <long, IdentifiedObject> cNodes = containers[DMSType.ConnectivityNode]; Node sourceNode = new Node(source, 0, 0); Queue <Tuple <Node, Node> > queue = new Queue <Tuple <Node, Node> >(); queue.Enqueue(new Tuple <Node, Node>(null, sourceNode)); Dictionary <long, Node> visited = new Dictionary <long, Node>(); visited.Add(source.GID, sourceNode); while (queue.Count > 0) { Tuple <Node, Node> tuple = queue.Dequeue(); Node node = tuple.Item2; node.AdjacentOffset = adjacency.Count; adjacency.Add(tuple.Item1); ++node.AdjacentCount; DMSType type = ModelCodeHelper.GetTypeFromGID(node.IO.GID); if (type == DMSType.ConnectivityNode) { foreach (long tGID in ((ConnectivityNode)node.IO).Terminals) { IdentifiedObject terminal; if (!terminals.TryGetValue(tGID, out terminal)) { continue; } long ceGID = ((Terminal)terminal).ConductingEquipment; if (ceGID == 0) { continue; } Node adjacentNode; if (!visited.TryGetValue(ceGID, out adjacentNode)) { DMSType ceType = ModelCodeHelper.GetTypeFromGID(ceGID); IdentifiedObject ce; if (!containers[ceType].TryGetValue(ceGID, out ce)) { continue; } adjacentNode = new Node(ce, 0, 0); queue.Enqueue(new Tuple <Node, Node>(node, adjacentNode)); visited.Add(ceGID, adjacentNode); } adjacency.Add(adjacentNode); ++node.AdjacentCount; } } else if (type == DMSType.TransformerWinding) { TransformerWinding tw = node.IO as TransformerWinding; PowerTransformer pt = Get(tw.PowerTransformer) as PowerTransformer; if (pt == null) { continue; } foreach (long twGID in pt.TransformerWindings) { if (twGID == tw.GID) { continue; } Node adjacentNode; if (!visited.TryGetValue(twGID, out adjacentNode)) { TransformerWinding twAdjacent = Get(twGID) as TransformerWinding; if (twAdjacent == null) { continue; } adjacentNode = new Node(twAdjacent, 0, 0); queue.Enqueue(new Tuple <Node, Node>(node, adjacentNode)); visited.Add(twGID, adjacentNode); } adjacency.Add(adjacentNode); ++node.AdjacentCount; break; } foreach (long tGID in tw.Terminals) { IdentifiedObject terminal; if (!terminals.TryGetValue(tGID, out terminal)) { continue; } long cNodeGID = ((Terminal)terminal).ConnectivityNode; if (cNodeGID == 0) { continue; } Node adjacentNode; if (!visited.TryGetValue(cNodeGID, out adjacentNode)) { IdentifiedObject cNode; if (!cNodes.TryGetValue(cNodeGID, out cNode)) { continue; } adjacentNode = new Node(cNode, 0, 0); queue.Enqueue(new Tuple <Node, Node>(node, adjacentNode)); visited.Add(cNodeGID, adjacentNode); } adjacency.Add(adjacentNode); ++node.AdjacentCount; } } else { foreach (long tGID in ((ConductingEquipment)node.IO).Terminals) { IdentifiedObject terminal; if (!terminals.TryGetValue(tGID, out terminal)) { continue; } long cNodeGID = ((Terminal)terminal).ConnectivityNode; if (cNodeGID == 0) { continue; } Node adjacentNode; if (!visited.TryGetValue(cNodeGID, out adjacentNode)) { IdentifiedObject cNode; if (!cNodes.TryGetValue(cNodeGID, out cNode)) { continue; } adjacentNode = new Node(cNode, 0, 0); queue.Enqueue(new Tuple <Node, Node>(node, adjacentNode)); visited.Add(cNodeGID, adjacentNode); } adjacency.Add(adjacentNode); ++node.AdjacentCount; } } } return(sourceNode); }
double CalculateVoltageForTransformerWinding(Node node, Dictionary <long, LoadFlowResult> lf, Dictionary <long, Complex> currents) { TransformerWinding tw = node.IO as TransformerWinding; if (IsTransformerWindingPrimary(tw)) { return(0); } if (!currents.ContainsKey(node.IO.GID)) { return(double.MaxValue); } PowerTransformer pw = Get(tw.PowerTransformer) as PowerTransformer; TransformerWinding tw1 = null; for (int i = 0; i < pw.TransformerWindings.Count; ++i) { long twGid = pw.TransformerWindings[i]; if (twGid != tw.GID) { tw1 = Get(twGid) as TransformerWinding; break; } } long node1Gid = (Get(tw1.Terminals[0]) as Terminal).ConnectivityNode; long node2Gid = (Get(tw.Terminals[0]) as Terminal).ConnectivityNode; LoadFlowResult lfr1; if (!lf.TryGetValue(node1Gid, out lfr1)) { return(0); } Complex u1 = new Complex(lfr1.Get(LoadFlowResultType.UR), lfr1.Get(LoadFlowResultType.UI)); Complex u2 = u1.Scale(1.0 / GetPowerTransformerRatio(pw)); LoadFlowResult lfr2; double relDelta = double.MaxValue; if (!lf.TryGetValue(node2Gid, out lfr2)) { lfr2 = new LoadFlowResult(); lf[node2Gid] = lfr2; } else { relDelta = GetVoltageRelativeDifference(new Complex(lfr2.Get(LoadFlowResultType.UR), lfr2.Get(LoadFlowResultType.UI)), u2); } lfr2.Remove(LoadFlowResultType.UR); lfr2.Remove(LoadFlowResultType.UI); lfr2.Add(new LoadFlowResultItem(u2.X, LoadFlowResultType.UR)); lfr2.Add(new LoadFlowResultItem(u2.Y, LoadFlowResultType.UI)); return(relDelta); }
/// <summary> /// Creates entity for specified global inside the container. /// </summary> /// <param name="globalId">Global id of the entity for insert</param> /// <returns>Created entity (identified object).</returns> public IdentifiedObject CreateEntity(long globalId) { short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId); IdentifiedObject io = null; switch ((DMSType)type) { case DMSType.TERMINAL: io = new Terminal(globalId); break; case DMSType.ANALOG: io = new Analog(globalId); break; case DMSType.ASYNCHRONOUSMACHINE: io = new AsynchronousMachine(globalId); break; case DMSType.BREAKER: io = new Breaker(globalId); break; case DMSType.CONNECTIVITYNODE: io = new ConnectivityNode(globalId); break; case DMSType.DISCONNECTOR: io = new Disconnector(globalId); break; case DMSType.DISCRETE: io = new Discrete(globalId); break; case DMSType.POWERTRANSFORMER: io = new PowerTransformer(globalId); break; case DMSType.RATIOTAPCHANGER: io = new RatioTapChanger(globalId); break; case DMSType.SUBSTATION: io = new Substation(globalId); break; case DMSType.TRANSFORMERWINDING: io = new TransformerWinding(globalId); break; default: string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type); CommonTrace.WriteTrace(CommonTrace.TraceError, message); throw new Exception(message); } // Add entity to map this.AddEntity(io); return(io); }
/// <summary> /// Creates entity for specified global inside the container. /// </summary> /// <param name="globalId">Global id of the entity for insert</param> /// <returns>Created entity (identified object).</returns> public IdentifiedObject CreateEntity(long globalId) { short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId); IdentifiedObject io = null; switch ((DMSType)type) { case DMSType.BASEVOLTAGE: { io = new BaseVoltage(globalId); break; } case DMSType.TERMINAL: { io = new Terminal(globalId); break; } case DMSType.CONNECTIVITYNODE: { io = new ConnectivityNode(globalId); break; } case DMSType.POWERTRANSFORMER: { io = new PowerTransformer(globalId); break; } case DMSType.ENERGYSOURCE: { io = new EnergySource(globalId); break; } case DMSType.ENERGYCONSUMER: { io = new EnergyConsumer(globalId); break; } case DMSType.TRANSFORMERWINDING: { io = new TransformerWinding(globalId); break; } case DMSType.FUSE: { io = new Fuse(globalId); break; } case DMSType.DISCONNECTOR: { io = new Disconnector(globalId); break; } case DMSType.BREAKER: { io = new Breaker(globalId); break; } case DMSType.LOADBREAKSWITCH: { io = new LoadBreakSwitch(globalId); break; } case DMSType.ACLINESEGMENT: { io = new ACLineSegment(globalId); break; } case DMSType.DISCRETE: { io = new Discrete(globalId); break; } case DMSType.ANALOG: { io = new Analog(globalId); break; } case DMSType.SYNCHRONOUSMACHINE: { io = new SynchronousMachine(globalId); break; } default: { string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type); Logger.LogError(message); throw new Exception(message); } } // Add entity to map this.AddEntity(io); return(io); }
public NetworkModel(NetworkModelDownload download) { Dictionary <long, IdentifiedObject> terminalContainer = download.Containers[DMSType.Terminal]; Dictionary <long, IdentifiedObject> conNodeContainer = download.Containers[DMSType.ConnectivityNode]; List <Node> trees = new List <Node>(); Dictionary <long, RecloserNode> reclosers = new Dictionary <long, RecloserNode>(); foreach (KeyValuePair <long, IdentifiedObject> source in download.Containers[DMSType.EnergySource]) { if (source.Value == null) { continue; } Node root = new Node(null, source.Value); Stack <Node> stack = new Stack <Node>(); stack.Push(root); while (stack.Count > 0) { Node node = stack.Pop(); IdentifiedObject io = node.io; DMSType type = ModelCodeHelper.GetTypeFromGID(io.GID); switch (type) { case DMSType.ConnectivityNode: { foreach (long terminalGID in ((ConnectivityNode)io).Terminals) { long condEqGID = ((Terminal)terminalContainer[terminalGID]).ConductingEquipment; if (condEqGID == node.parent.io.GID) { continue; } DMSType condEqType = ModelCodeHelper.GetTypeFromGID(condEqGID); ConductingEquipment condEq = (ConductingEquipment)download.Containers[condEqType][condEqGID]; if (condEq is Recloser) { RecloserNode rn; if (reclosers.TryGetValue(condEqGID, out rn)) { if (rn.node2 == null) { rn.node2 = node; } } else { reclosers.Add(condEqGID, new RecloserNode(condEq) { node1 = node }); } continue; } Node childNode = new Node(node, condEq); node.children.Add(childNode); stack.Push(childNode); } } break; case DMSType.TransformerWinding: { TransformerWinding tw = io as TransformerWinding; if (tw == null) { break; } PowerTransformer pt = GetInternal(download.Containers, tw.PowerTransformer) as PowerTransformer; if (pt == null) { break; } foreach (long twGID in pt.TransformerWindings) { if (twGID == tw.GID || (node.parent != null && twGID == node.parent.io.GID)) { continue; } TransformerWinding twChild = GetInternal(download.Containers, twGID) as TransformerWinding; if (twChild == null) { continue; } Node childNode = new Node(node, twChild); node.children.Add(childNode); stack.Push(childNode); } foreach (long terminalGID in tw.Terminals) { long conNodeGID = ((Terminal)terminalContainer[terminalGID]).ConnectivityNode; if (node.parent != null && conNodeGID == node.parent.io.GID) { continue; } Node childNode = new Node(node, conNodeContainer[conNodeGID]); node.children.Add(childNode); stack.Push(childNode); } } break; default: { ConductingEquipment condEq = io as ConductingEquipment; if (condEq == null) { break; } foreach (long terminalGID in condEq.Terminals) { long conNodeGID = ((Terminal)terminalContainer[terminalGID]).ConnectivityNode; if (node.parent != null && conNodeGID == node.parent.io.GID) { continue; } Node childNode = new Node(node, conNodeContainer[conNodeGID]); node.children.Add(childNode); stack.Push(childNode); } } break; } } trees.Add(root); } this.trees = trees; this.reclosers = reclosers; this.containers = download.Containers; }