Ejemplo n.º 1
0
    def testNetworkToDEMSimple(self):

        st1 = "Home"
        st2 = "Grid"
        kv = "115"
        nd1 = "HomeNode"
        nd2 = "GridNode"
        sgen = "SolarGen"
        ggen = "GridGen"
        ld1 = "HomeLoad"

        n = Network()

        #HOME
        n.AddStationByDef(st1)
        n.AddNodeByDef(st1, kv, nd1)
        sg = Unit(st1, kv, nd1, sgen, "", 10, 0, 0, 0, 1, False, 0)
        ld = Load(st1, kv, nd1, ld1, "", 13, 0, 1)
        n.AddDevice(sg)
        n.AddDevice(ld)

        #GRID
        n.AddStationByDef(st2)
        n.AddNodeByDef(st2, kv, nd2)
        gg = Unit(st2, kv, nd2, ggen, "", 1e6, 0, 0, 0, 1, False, 0)
        n.AddDevice(gg)

        #LINE
        br = Branch(st1, kv, nd1, st2, kv, nd2, "Line", "", True, 0, 0, "1",
                    RatingSet(25, 25, 25), RatingSet(25, 25, 25))
        n.AddNodeConnector(br)

        gp = NetworkToDEMSimple(n)
        gp.init_problem()
        gp.problem.solve()
        print(gp.results.summary())
Ejemplo n.º 2
0
    def test_AddDevice(self):
        st1 = "ST1"
        st2 = "ST2"
        kv115 = "115"
        kv365 = "365"
        ndid1 = "N1"
        ndid2 = "N2"
        ndid3 = "N3"
        ndid4 = "N4"
        company = "ABC"
        ldid = "LD1"
        shid = "SH1"
        uid = "U1"
        n = Network()
        #Station #1
        s1 = Station(st1)
        nd11 = Node(st1, kv115, ndid1, company)
        nd12 = Node(st1, kv115, ndid2, company)
        nd13 = Node(st1, kv365, ndid3, company)
        nd14 = Node(st1, kv365, ndid4, company)
        l1 = Load(st1, kv115, ndid1, ldid, company, 1,1,.97)
        sh1 = Shunt(st1, kv115, ndid2, shid, company, 1)
        u1 = Unit(st1, kv365, ndid3, uid, company, 10, 10,5,5,.8, False, 7)

        with self.assertRaises(Exception):
            n.AddDevice(l1)

        n.AddStation(s1)

        with self.assertRaises(Exception):
            n.AddDevice(l1)

        n.AddNode(nd12)
        n.AddNode(nd11)
        n.AddNode(nd13)
        n.AddNode(nd14)
        n.AddDevice(l1)
        n.AddDevice(sh1)
        n.AddDevice(u1)
        #duplicate device
        with self.assertRaises(Exception):
            n.AddDevice(l1)



        self.assertEqual(len(n.Devices), 3)
        self.assertEqual(len(n.Loads), 1)
        self.assertEqual(len(n.Units), 1)
        self.assertEqual(len(n.Shunts), 1)
        self.assertEqual(len(nd11.Devices), 1)
        self.assertEqual(len(nd12.Devices), 1)
        self.assertEqual(len(nd13.Devices), 1)
        return
Ejemplo n.º 3
0
    def ImportUnits(self, network: Network):

        filename = UnitCSVStream.DefaultFileName
        if FileType.Unit in self.CSVFileNames:
            filename = self.CSVFileNames[FileType.Unit]

        propertymap = UnitCSVStream.DefaultPropertyToFileMap
        if FileType.Unit in self.CSVPropertyMaps:
            propertymap = self.CSVPropertyMaps[FileType.Unit]

        with UnitCSVStream(filename, propertymap, self.Encoding) as csv:
            i = 0
            d = 0
            for UN in csv:
                network.AddDevice(csv.getUnit())
                i += 1
                while i > ((d + 1) * .10 * len(csv)):
                    print("", end='.')
                    d += 1

        return