foldername = 'Data_été'
filename = 'results_name.txt'
xlsname = 'results_name.xls'
mapname = 'map_name.png'

# Extracting data from xls files and creating 4 ppc matrices
os.chdir(foldername)
ppc = loadcase(caseproject())
bus, gen, branch, gencost = freadexcel()
ppc["bus"] = bus
ppc["branch"] = branch
ppc["gen"] = gen
ppc["gencost"] = gencost

# Running the simulation
r = rundcopf(ppc, fname=filename)

# Storing results
results_gen, results_load_lambda, results_branch = fstoreresult(r)

# Writing results in xls file
# fwriteinexcel(xlsname, results_gen, results_load_lambda, results_branch)

# Creating a map with the results
results_branch_map = []
for i in range(len(branch)):
    inter = [results_branch[i, 0], results_branch[i, 1], results_branch[i, 2], branch[i, 5]]
    results_branch_map.append(inter)
results_branch_map = np.asarray(results_branch_map, dtype=np.float64)
fmap(results_branch_map, results_gen, results_load_lambda, mapname)
Пример #2
0
from pypower.api import rundcopf
from pypower.caseproject import caseproject
from pypower.loadcase import loadcase
from freadexcel import freadexcel
from fstoreresult import fstoreresult
from fupdate import fupdate
from fwriteinexcel import fwriteinexcel

ppc = loadcase(caseproject())

# On va chercher les 4 matrices statiques et les variables demand
bus, gen, branch, gencost = freadexcel()
ppc["branch"] = branch
ppc["gen"] = gen
ppc["gencost"] = gencost

# for loop (0 to 8759)
for i in range(8760):
    # On update la matrice bus avec les variables demand
    bus = fupdate()
    ppc["bus"] = bus
    # On lance la simulation
    r = rundcopf(ppc)
    # On stocke les résultats à chaque itération
    results_1, results_2, results_3 = fstoreresult(r)

# On écrit les résultats des 8760 simulations dans un fichier Excel
fwriteinexcel(results_1, results_2, results_3)