Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        void PopulateBaseVoltageProperties(BaseVoltage x, ResourceDescription rd)
        {
            PopulateIdentifiedObjectProperties(x, rd);

            if (x.NominalVoltageHasValue)
            {
                rd.AddProperty(new FloatProperty(ModelCode.BASEVOLTAGE_NOMINALVOLTAGE, x.NominalVoltage));
            }
        }
Exemplo n.º 4
0
        public static string BaseVoltageToString(BaseVoltage baseV, string num)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"BV {num}\n\t");
            sb.AppendLine($"\tNAME: {baseV.Name}");
            sb.AppendLine($"\tMRDI: {baseV.MRID}");
            sb.AppendLine($"\tNOMINAL VOLTAGE: { baseV.NominalVoltage.ToString()}");
            return(sb.ToString());
        }
        /// <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.CONNECTIVITYNODE:
                io = new ConnectivityNode(globalId);
                break;

            case DMSType.ENERGYCONSUMER:
                io = new EnergyConsumer(globalId);
                break;

            case DMSType.ENERGYSOURCE:
                io = new EnergySource(globalId);
                break;

            case DMSType.POWERTRANSFORMER:
                io = new PowerTransformer(globalId);
                break;

            case DMSType.PTRANSFORMEREND:
                io = new PowerTransformerEnd(globalId);
                break;

            case DMSType.SWITCH:
                io = new Switch(globalId);
                break;

            case DMSType.ACLINESEGMENT:
                io = new ACLineSegment(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);
                Logger.LogError(message);
                throw new Exception(message);
            }

            // Add entity to map
            this.AddEntity(io);

            return(io);
        }
        private ResourceDescription CreateBaseVoltageResourceDecription(BaseVoltage cimBaseVoltage)
        {
            ResourceDescription rd = null;

            if (cimBaseVoltage != null)
            {
                long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.BASEVOLTAGE, importHelper.CheckOutIndexForDMSType(DMSType.BASEVOLTAGE));
                rd = new ResourceDescription(gid);
                importHelper.DefineIDMapping(cimBaseVoltage.ID, gid);

                ////populate ResourceDescription
                LoadFlowConverter.PopulateBaseVoltageProperties(cimBaseVoltage, rd);
            }
            return(rd);
        }
Exemplo n.º 7
0
        Complex GetVoltageFromEnergySource(EnergySource es)
        {
            float re = float.NaN;
            float im = float.NaN;

            for (int i = 0; i < es.Measurements.Count; ++i)
            {
                Analog analog = Get(es.Measurements[i]) as Analog;

                if (analog == null)
                {
                    continue;
                }

                switch (analog.MeasurementType)
                {
                case MeasurementType.VoltageR:
                    if (!analogs.TryGetValue(analog.GID, out re))
                    {
                        re = analog.NormalValue;
                    }

                    break;

                case MeasurementType.VoltageI:
                    if (!analogs.TryGetValue(analog.GID, out im))
                    {
                        im = analog.NormalValue;
                    }

                    break;
                }
            }

            if (float.IsNaN(re) || float.IsNaN(im))
            {
                BaseVoltage bv = Get(es.BaseVoltage) as BaseVoltage;

                if (bv != null)
                {
                    re = bv.NominalVoltage;
                    im = 0;
                }
            }

            return(new Complex(re, im));
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        public DodajTrafo(String name, String alias, String desc, float voltage)
        {
            s.name        = name;
            s.description = desc;
            Random r = new Random();

            s.mRID              = 'a' + r.Next(1000).ToString();
            s.aliasName         = alias;
            s.connectivityNodes = new List <ConnectivityNode>();

            s.x             = -1;
            s.y             = -1;
            s.Bays          = new List <Bay>();
            s.Equipments    = new List <Equipment>();
            s.VoltageLevels = new List <VoltageLevel>();



            BaseVoltage bv = new BaseVoltage()
            {
                aliasName           = "sub_-" + s.mRID + "_bv_" + s.aliasName,
                mRID                = "sub_-" + s.mRID + "-_bv_-" + s.mRID,
                name                = "sub_-" + s.mRID + "-_bv_-" + s.name,
                description         = name = "sub_-" + s.mRID + "-_bv_-" + s.description,
                nominalVoltage      = voltage,
                ConductingEquipment = new List <ConductingEquipment>()
            };

            VoltageLevel vl = new VoltageLevel()
            {
                aliasName   = "sub_" + s.mRID + "_vl_" + s.aliasName,
                mRID        = "sub_-" + s.mRID + "-_vl_-" + s.mRID,
                name        = "sub_-" + s.mRID + "-_vl_-" + s.name,
                description = name = "sub_-" + s.mRID + "-_vl_-" + s.description,
                BaseVoltage = bv,
                Bays        = new List <Bay>(),
                Equipments  = new List <Equipment>()
            };

            s.VoltageLevels.Add(vl);
        }
Exemplo n.º 10
0
        private static void Main(string[] args)
        {
            var base1 = new BaseVoltage()
            {
                Name = "BaseVoltage1", NominalVoltage = 5, MRID = Guid.NewGuid().ToString()
            };
            var base2 = new BaseVoltage()
            {
                Name = "BaseVoltage2", NominalVoltage = 15, MRID = Guid.NewGuid().ToString()
            };

            List <PowerTransformer>   transformers = new List <PowerTransformer>();
            List <TransformerWinding> windings     = new List <TransformerWinding>();
            List <WindingTest>        windingTests = new List <WindingTest>();

            for (int i = 0; i < 20; i++)
            {
                PowerTransformer transformer = new PowerTransformer
                {
                    Name        = $"Transformer {i}",
                    MRID        = Guid.NewGuid().ToString(),
                    Description = $"Description for power transformer {i}"
                };
                transformers.Add(transformer);
                List <TransformerWinding> windingList = new List <TransformerWinding> {
                    new TransformerWinding {
                        Name             = $"Winding {2 * i}",
                        MRID             = Guid.NewGuid().ToString(),
                        BaseVoltage      = base1,
                        Description      = $"Description for transformer winding {2 * i}",
                        PowerTransformer = transformer
                    },
                    new TransformerWinding {
                        Name             = $"Winding {2 * i + 1}",
                        MRID             = Guid.NewGuid().ToString(),
                        BaseVoltage      = base2,
                        Description      = $"Description for transformer winding {2 * i + 1}",
                        PowerTransformer = transformer
                    }
                };
                windings.AddRange(windingList);

                List <WindingTest> windingTestList = new List <WindingTest> {
                    new WindingTest {
                        Name = $"Winding test {2 * i}",
                        MRID = Guid.NewGuid().ToString(),
                        From_TransformerWinding = windingList[0],
                        Description             = $"Description for winding test {2 * i}"
                    },
                    new WindingTest {
                        Name = $"Winding test {2 * i + 1}",
                        MRID = Guid.NewGuid().ToString(),
                        From_TransformerWinding = windingList[1],
                        Description             = $"Description for winding test {2 * i + 1}"
                    }
                };

                windingTests.AddRange(windingTestList);
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(BaseVoltageToString(base1, "1"));
            sb.AppendLine(BaseVoltageToString(base2, "2"));

            for (int i = 0; i < 20; i++)
            {
                sb.AppendLine(TranformerToString(transformers[i], i.ToString()));

                sb.AppendLine(WindingToString(windings[2 * i], $"{i}, 1"));
                sb.AppendLine(WindingTestToString(windingTests[2 * i], $"{i}, 1"));

                sb.AppendLine(WindingToString(windings[2 * i + 1], $"{i}, 2"));
                sb.AppendLine(WindingTestToString(windingTests[2 * i + 1], $"{i}, 2"));
            }
            //Console.WriteLine(sb.ToString());
            System.IO.File.WriteAllText("pisi.txt", sb.ToString());
            Console.ReadLine();
        }
Exemplo n.º 11
0
        /// <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);
        }