VeraGridEngine.IO.matpower.legacy package

Submodules

VeraGridEngine.IO.matpower.legacy.matpower_branch_definitions module

VeraGridEngine.IO.matpower.legacy.matpower_bus_definitions module

VeraGridEngine.IO.matpower.legacy.matpower_gen_definitions module

VeraGridEngine.IO.matpower.legacy.matpower_gen_definitions.gen_headers = ['bus', 'Pg', 'Qg', 'Qmax', 'Qmin', 'Vg', 'mBase', 'status', 'Pmax', 'Pmin', 'Pc1', 'Pc2', 'Qc1min', 'Qc1max', 'Qc2min', 'Qc2max', 'ramp_agc', 'ramp_10', 'ramp_30', 'ramp_q', 'apf', 'MU_PMAX', 'MU_PMIN', 'MU_QMAX', 'MU_QMIN', 'Dispatchable', 'Fix_power']

Defines constants for named column indices to gencost matrix.

Some examples of usage, after defining the constants using the line above, are:

start = gencost[3, STARTUP]       # get startup cost of generator 4
gencost[2, [MODEL, NCOST:COST+2]] = [POLYNOMIAL, 2, 30, 0]
# set the cost of generator 2 to a linear function COST = 30 * Pg

The index, name and meaning of each column of the gencost matrix is given below:

columns 1-5
  1. C{MODEL} cost model, 1 - piecewise linear, 2 - polynomial

  2. C{STARTUP} startup cost in US dollars

  3. C{SHUTDOWN} shutdown cost in US dollars

4. C{NCOST} number of cost coefficients to follow for polynomial cost function, or number of data points for piecewise linear 5. C{COST} 1st column of cost parameters cost data defining total cost function For polynomial cost (highest order coeff first):

e.g. cn, ..., c1, c0

where the polynomial is C{c0 + c1*P + … + cn*P^n} For piecewise linear cost:

x0, y0, x1, y1, x2, y2, ...

where C{x0 < x1 < x2 < …} and the points C{(x0,y0), (x1,y1), (x2,y2), …} are the end- and break-points of the total cost function.

additional constants, used to assign/compare values in the C{MODEL} column
  1. C{PW_LINEAR} piecewise linear generator cost model

  2. C{POLYNOMIAL} polynomial generator cost model

@author: Ray Zimmerman (PSERC Cornell) @author: Richard Lincoln

VeraGridEngine.IO.matpower.legacy.matpower_parser module

VeraGridEngine.IO.matpower.legacy.matpower_parser.arr_to_dict(hdr, arr)[source]

Match header-data pair into a dictionary :param hdr: array of header data :param arr: array of values :return:

VeraGridEngine.IO.matpower.legacy.matpower_parser.find_between(s: str, first: str, last: str) str[source]

Find sting between two sub-strings Args:

s: Main string first: first sub-string last: second sub-string

Example find_between(β€˜[Hello]’, β€˜[’, β€˜]’) -> returns β€˜Hello’ Returns:

String between the first and second sub-strings, if any was found otherwise returns an empty string

VeraGridEngine.IO.matpower.legacy.matpower_parser.get_branches(circuit: MultiCircuit, bus_dict: Dict[Bus, int]) List[Dict[str, float]][source]
Parameters:
  • circuit

  • bus_dict

Returns:

VeraGridEngine.IO.matpower.legacy.matpower_parser.get_buses(circuit: MultiCircuit) Tuple[List[Dict[str, float]], Dict[Bus, int]][source]

Get matpower buses structure :param circuit: MultiCircuit :return: list of buses structure, buses dictionary {Bus: bus int}

VeraGridEngine.IO.matpower.legacy.matpower_parser.get_generation(circuit: MultiCircuit, bus_dict: Dict[Bus, int]) Tuple[List[Dict[str, float]], List[Dict[str, float]]][source]

Get generation and generation cost data :param circuit: :param bus_dict: :return:

VeraGridEngine.IO.matpower.legacy.matpower_parser.get_matpower_case_data(filename, force_linear_cost=False) Dict[source]

Parse matpower .m file and get the case data structure :param filename: Name of the file :param force_linear_cost: Force linear cost when costs are found? :return: Matpower case data dictionary

VeraGridEngine.IO.matpower.legacy.matpower_parser.interpret_data_v1(data, logger: Logger) MultiCircuit[source]

Pass the loaded table-like data to the structures :param data: Data dictionary :param logger: Logger :return:

VeraGridEngine.IO.matpower.legacy.matpower_parser.parse_areas_data(circuit: MultiCircuit, data: Dict[str, ndarray], logger: Logger)[source]

Parse Matpower / FUBM Matpower area data into VeraGrid :param circuit: MultiCircuit instance :param data: data dictionary :param logger: Logger :return: area index -> object dictionary

VeraGridEngine.IO.matpower.legacy.matpower_parser.parse_branches_data(circuit: MultiCircuit, data: Dict[str, ndarray], bus_idx_dict, logger: Logger)[source]

Parse Matpower / FUBM Matpower branch data into VeraGrid :param circuit: MultiCircuit instance :param data: data dictionary :param bus_idx_dict: bus index -> object dictionary :param logger: Logger :return: Nothing

VeraGridEngine.IO.matpower.legacy.matpower_parser.parse_buses_data(circuit: MultiCircuit, data: Dict[str, ndarray], area_idx_dict, logger: Logger)[source]

Parse Matpower / FUBM Matpower bus data into VeraGrid :param circuit: MultiCircuit instance :param data: data dictionary :param area_idx_dict: area index -> object dictionary :param logger: Logger :return: bus index -> object dictionary

VeraGridEngine.IO.matpower.legacy.matpower_parser.parse_generators(circuit: MultiCircuit, data: Dict[str, ndarray], bus_idx_dict, logger: Logger)[source]

Parse Matpower / FUBM Matpower generator data into VeraGrid :param circuit: MultiCircuit instance :param data: data dictionary :param bus_idx_dict: bus index -> object dictionary :param logger: Logger :return:

VeraGridEngine.IO.matpower.legacy.matpower_parser.parse_matpower_file(filename, export=False) [<class 'VeraGridEngine.Devices.multi_circuit.MultiCircuit'>, <class 'VeraGridEngine.basic_structures.Logger'>][source]
Args:

filename: export:

Returns:

VeraGridEngine.IO.matpower.legacy.matpower_parser.read_matpower_file(filename: str, logger: Logger) Dict[str, ndarray][source]

Read a Matpower case and return the structures :param filename: :param logger: :return:

VeraGridEngine.IO.matpower.legacy.matpower_parser.to_matpower(circuit: MultiCircuit, logger: Logger = <VeraGridEngine.basic_structures.Logger object>, t_idx: int | None = None) Dict[str, float | List][source]
Parameters:
  • circuit

  • logger

  • t_idx

Returns:

VeraGridEngine.IO.matpower.legacy.matpower_parser.txt2mat(txt: str, line_splitter=';', to_float=True)[source]
Parameters:
  • txt

  • line_splitter

  • to_float

Returns:

Module contents