Ejemplo n.º 1
0
    def ImportDayAheadLMPs(self, network: Network):

        filename = DayAheadLMPsCSVStream.DefaultFileName
        if FileType.DayAheadLMPs in self.CSVFileNames:
            filename = self.CSVFileNames[FileType.DayAheadLMPs]

        filename = filename.format(self.MktDay)
        propertymap = DayAheadLMPsCSVStream.DefaultPropertyToFileMap
        if FileType.DayAheadLMPs in self.CSVPropertyMaps:
            propertymap = self.CSVPropertyMaps[FileType.DayAheadLMPs]

        with DayAheadLMPsCSVStream(filename, propertymap,
                                   self.Encoding) as csv:
            for pnode in csv:
                network.AddPNode(csv.getPNode())

        return
Ejemplo n.º 2
0
    def test_AddPNode(self):
        stname = "station"
        kv = "115"
        ndid = "AB"
        ndid2 = "AB2"
        company = "ABC"

        n = Network()
        s = Station(stname)
        n.AddStation(s)     
        nd = Node(stname, kv, ndid, company)
        n.AddNode(nd)
        n.AddNodeByDef(stname, kv, ndid2, company, "div")

        id =  122060565
        id2 = 122060564
        id3 = 122060562
        id4 = 122060563
        id5 = 34234234
        name = "nodename"
        name2 = "nodename2"
        name3 = "nodename3"
        name4 = "nodename4"
        name5 = "nodename5"
        ldun = "load1"
        sett = True
        sett2 = False
        rzid = 3

        cnd = CPNode(id, name, sett)
        cnd2=CPNode(id2,name2,sett2)
        pnd3 = PNode(id3, name3)
        end4=EPNode(id4, name4,234234,(stname,ndid), ldun, rzid)
        end5=EPNode(id5, name5,2634234,("",""), ldun, rzid)
    

        n.AddPNode(cnd)
        n.AddPNode(cnd2)
        n.AddPNode(pnd3)
        n.AddPNode(end4)
      
        with self.assertRaises(Exception):
            n.AddPNode(cnd)
        with self.assertRaises(Exception):
            n.AddPNode(end5)       

        self.assertEqual(n.PNodes[id].Name, name)
        self.assertEqual(n.CPNodes[id].Name, name)
        self.assertEqual(n.PNodes[id2].Name, name2)
        self.assertEqual(n.CPNodes[id2].Name, name2)
        self.assertEqual(n.PNodes[id3].Name, name3)
        self.assertEqual(n.PNodes[id4].Name, name4)
        self.assertEqual(n.EPNodes[id4].Name, name4)
        self.assertEqual(n.EPNodes[id4].Node.ID, nd.ID)

        self.assertEqual(n.CPNodes[id].FactorSum, 0)
        n.AddPNodeFactor(id, id4, .4)
        n.AddPNodeFactor(id, id3, .6)
        self.assertEqual(n.CPNodes[id].FactorSum, 1)
        self.assertEqual(n.CPNodes[id].PNodes[id4].Name, name4)
        self.assertEqual(n.CPNodes[id].PNodeFactors[id3], .6)

        with self.assertRaises(Exception):
            n.AddPNodeFactor(id, id4, .4)
        with self.assertRaises(Exception):
            n.AddPNodeFactor(34, id4, .4)
        with self.assertRaises(Exception):
            n.AddPNodeFactor(id, 45, .4)
        return