def __init__(self,fcn): currDir = os.getcwd() if platform == "linux" or platform == "linux2": mdir_ = currDir +"/cases/"+fcn elif platform == "win32": mdir_ = currDir +"/cases/"+fcn if not hasattr(pyp,fcn): currDir = os.getcwd() mdir = mdir_ +".py" if not os.path.isfile(mdir): mdir = mdir_ +".mat" if not os.path.isfile(mdir): print("\nNo case could be detected!\n") self.System = pyp.loadcase(mdir) else: sysfcn = getattr(pyp,fcn) self.System = sysfcn() self.busdata = self.System['bus'] self.branchdata = self.System['branch'] self.gen = self.System['gen'] if 'gencost' in self.System: self.gencost= self.System['gencost'] else: self.System['gencost'] = "" self.gencost= ""
def case_as_data(casename): ''' Loads the case according to its name. Possible names are: ['case4gs', 'case6ww', 'case9', 'case9Q', 'case14', 'case24_ieee_rts', 'case30', 'case30Q', 'case30pwl', 'case39', 'case57', 'case118', 'case300', 'case30_userfcns']. ''' # list of available cases cases = [ 'case4gs', 'case6ww', 'case9', 'case9Q', 'case14', 'case24_ieee_rts', 'case30', 'case30Q', 'case30pwl', 'case39', 'case57', 'case118', 'case300', 'case30_userfcns' ] if casename not in cases: print('Case not found, defaults to case9') casename_ = 'case9' else: casename_ = casename case_path = join('pypower', casename_) data = ext2int(loadcase(case_path)) return data
def __init__(self, path_casedata, set_disturb, mode): self.path_casedata = path_casedata self.mode = mode self.set_disturb = set_disturb self.casedata = loadcase(path_casedata) self._get_param() self.dict_int_l() self.dict_der_l() self.param_collocation() self.make_clique_tree_theta()
import numpy as np import scipy as sp from sksparse.cholmod import cholesky import networkx as nx from os.path import dirname, join from pypower.api import makeYbus, runpf, loadcase, ext2int, ppoption from networkx.algorithms import approximation from copy import deepcopy from itertools import combinations casename = 'case200' path_casedata = join(dirname(__file__), 'data//casedata//' + casename + '.py') casedata = loadcase(path_casedata) ####code for generate the extra parameters # last two columns of the bus data for i in range(len(casedata['bus'])): if casedata['bus'][i, 1] == 2 or casedata['bus'][i, 1] == 3: print('0.01', ',\t', '0.01', '\t') else: if casedata['bus'][i, 2] != 0: print('0', ',\t', '0.01', '\t') else: print('0', ',\t', '0', '\t') # gen_control data for i in range(len(casedata['gen'])): max_pp = casedata['gen'][i, 8] / 100 max_m = round((2 * 5 * max_pp) / (2 * np.pi * 50), 6)