VeraGridEngine.IO.raw package

Subpackages

Submodules

VeraGridEngine.IO.raw.psse_circuit module

class VeraGridEngine.IO.raw.psse_circuit.PsseCircuit[source]

Bases: RawObject, BaseCircuit

CLASS_PROPERTIES: Tuple[PsseProperty, ...] = (<VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>)

PSSeObject

CLASS_REGISTERED_PROPERTIES: Dict[str, PsseProperty] = {'areas': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'branches': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'buses': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'equipment_terminals': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'facts': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'fixed_shunts': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'generators': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'gne': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'idtag': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'indiction_tables': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'induction_machines': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'inter_areas': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'loads': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'multi_line_sections': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'nodes': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'owners': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'substation_switching_devices': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'substations': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'switched_shunts': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'switches': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'transformers': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'two_terminal_dc_lines': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'vsc_dc_lines': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, 'zones': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>}
LOCAL_PROPERTIES: Tuple[PsseProperty, ...] = (<VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>, <VeraGridEngine.IO.raw.psse_property.PsseProperty object>)
check_primary_keys(logger: Logger = <VeraGridEngine.basic_structures.Logger object>)[source]

Check all primary keys locally and globally :param logger: :return:

get_class_properties() List[PsseProperty][source]
Returns:

parse(data: List[int | float], logger: Logger) None[source]

Parse the basic data :param data: line with information :param logger: logger object :return:

VeraGridEngine.IO.raw.psse_object module

class VeraGridEngine.IO.raw.psse_object.RawObject(class_name)[source]

Bases: object

PSSeObject

CLASS_PROPERTIES: Tuple[PsseProperty, ...] = (<VeraGridEngine.IO.raw.psse_property.PsseProperty object>,)

PSSeObject

CLASS_REGISTERED_PROPERTIES: Dict[str, PsseProperty] = {'idtag': <VeraGridEngine.IO.raw.psse_property.PsseProperty object>}
LOCAL_PROPERTIES: Tuple[PsseProperty, ...] = (<VeraGridEngine.IO.raw.psse_property.PsseProperty object>,)
static extend_or_curtail(data: List[Any], n: int) List[Any][source]

Extends of curtails the input so that it marches what’s expected :param data: list of values :param n: expected number of items :return: extended or curtailed data

format_raw_line(props: List[str]) str[source]

Format a list of values :param props: list of property names :return:

format_raw_line_prop(props: List[str])[source]

Format a list of property names :param props: list of property names :return:

get_id() str[source]

Get a PSSe ID Each device will implement its own way of generating this :return: id

get_prop_value(prop: PsseProperty)[source]

Get property value :param prop: :return:

get_properties() List[PsseProperty][source]

Get list of properties :return: List[PsseProperty]

get_raw_line(version: int) str[source]

Get raw line :param version: PSSe version :return: Raw string representing this object

get_rawx_dict() Dict[str, PsseProperty][source]

Get the RAWX property dictionary :return: Dict[str, PsseProperty]

get_rdfid() str[source]

Convert the idtag to RDFID :return: UUID converted to RDFID

get_registered_property_value(property_name: str) Any[source]

Get a registered property value using explicit object attribute access.

Parameters:

property_name – Registered property name.

Returns:

Property value.

Raises:

KeyError – If the property is not registered.

get_seed() str[source]

Get seed ID :return: seed ID

get_uuid5()[source]

Generate UUID with the seed given by get_id() :return: UUID based on the PSSe seed

register_property(property_name: str, rawx_key: str, class_type: TypeVar | object, unit: Unit = <VeraGridEngine.IO.base.units.Unit object>, denominator_unit: Unit = <VeraGridEngine.IO.base.units.Unit object>, description: str = '', max_chars=None, min_value=-1e+20, max_value=1e+20, format_rule=None)[source]

Register property of this object :param property_name: :param rawx_key: :param class_type: :param unit: :param denominator_unit: :param description: :param max_chars: :param min_value: :param max_value: :param format_rule: some formatting rule

set_registered_property_value(property_name: str, value: Any) bool[source]

Set a registered property value using explicit object attribute assignment.

Parameters:
  • property_name – Registered property name.

  • value – Value to assign.

Returns:

True when the property exists and was assigned.

try_parse(values: Sequence[Any]) None[source]

Copy values into this object following _ATTR_ORDER. Extra elements are ignored; missing ones keep their default.

try_parse2(values: Sequence[Any], prop_names: Sequence[str]) None[source]

Copy values into this object following _ATTR_ORDER. Extra elements are ignored; missing ones keep their default. :param values: values to set :param prop_names: array of names

class VeraGridEngine.IO.raw.psse_object.RawObjectMeta(name, bases, namespace)[source]

Bases: type

Metaclass that builds RAW property schema per class from class-level declarations.

VeraGridEngine.IO.raw.psse_object.format_raw_float(value: float) str[source]

Format a float in engineering notation with 5 decimals. Ensure the formatted string doesn’t exceed 8 characters when possible.

VeraGridEngine.IO.raw.psse_object.uuid_from_seed(seed: str)[source]
Parameters:

seed

Returns:

VeraGridEngine.IO.raw.psse_property module

class VeraGridEngine.IO.raw.psse_property.PsseProperty(property_name: str, rawx_key: str, class_type: TypeVar, unit: Unit = None, denominator_unit: Unit = None, description: str = '', max_chars=None, min_value=-1e+20, max_value=1e+20, format_rule=None)[source]

Bases: BaseProperty

Psse Property

VeraGridEngine.IO.raw.psse_to_veragrid_utils module

Shared helpers for versioned PSSE<->VeraGrid conversion logic.

VeraGridEngine.IO.raw.raw_functions module

VeraGridEngine.IO.raw.raw_functions.get_psse_transformer_impedances(CW, CZ, CM, V1, V2, sbase, logger, code, MAG1, MAG2, WINDV1, WINDV2, ANG1, NOMV1, NOMV2, R1_2, X1_2, SBASE1_2)[source]
Parameters:
  • CW

  • CZ

  • CM

  • V1

  • V2

  • sbase

  • logger

  • code

  • MAG1

  • MAG2

  • WINDV1

  • WINDV2

  • ANG1

  • NOMV1

  • NOMV2

  • R1_2

  • X1_2

  • SBASE1_2

Returns:

VeraGridEngine.IO.raw.raw_parser_writer module

VeraGridEngine.IO.raw.raw_parser_writer.check_end_of_impedance_table(row: List[int | float | str]) bool[source]

Check the insane impedance line termination criteria :param row: :return:

VeraGridEngine.IO.raw.raw_parser_writer.delete_comment(raw_line)[source]
Parameters:

raw_line

Returns:

VeraGridEngine.IO.raw.raw_parser_writer.format_lines(data1: List[List[int | float | str]], logger: Logger) List[List[int | float | str]][source]

Format PSSe lines :param data1: :param logger: :return:

VeraGridEngine.IO.raw.raw_parser_writer.interpret_line(raw_line: str, splitter=',')[source]

Split text into arguments and parse each of them to an appropriate format (int, float or string) Args:

raw_line: text line splitter: value to split by

Returns: list of arguments

VeraGridEngine.IO.raw.raw_parser_writer.is_3w(row, bus_set)[source]

If this a 3W transformer? :param row: transformer file row :param bus_set: Set of raw bus information :return:

VeraGridEngine.IO.raw.raw_parser_writer.is_one_line_for_induction_machine(row)[source]

Is this a one line induction machine? :param row: file row :return:

VeraGridEngine.IO.raw.raw_parser_writer.is_valid(value: float | int | str)[source]
VeraGridEngine.IO.raw.raw_parser_writer.normalize_psse_version(version: int) int[source]

Normalize a RAW version to the supported range.

Parameters:

version – Requested or detected PSSE version.

Returns:

Supported PSSE version.

VeraGridEngine.IO.raw.raw_parser_writer.parse_substation_data_group(lines: List[List[int | float | str]], version: int, logger: Logger, grid: PsseCircuit, raw_substation_t, raw_node_t, raw_substation_switching_device_t, raw_equipment_terminal_t) None[source]

Parse the nested PSSE 34+ substation data group.

The RAW substation section is not a flat list of homogeneous records. Each substation block contains one substation record, a node list terminated by zero, a station-switch list terminated by zero, and an equipment-terminal list terminated by zero.

Parameters:
  • lines – Flat list of already tokenized RAW records from the section.

  • version – PSSE version.

  • logger – Logger instance.

  • grid – Destination PSSE circuit.

  • raw_substation_t – Version-specific substation class.

  • raw_node_t – Version-specific node class.

  • raw_substation_switching_device_t – Version-specific station-switch class.

  • raw_equipment_terminal_t – Version-specific terminal class.

Returns:

None

VeraGridEngine.IO.raw.raw_parser_writer.read_and_split(file_name: str, text_func=None, progress_func=None)[source]

Read the text file and split it into sections :return: list of sections, dictionary of sections by type

VeraGridEngine.IO.raw.raw_parser_writer.read_raw(filename, text_func=None, progress_func=None, logger=<VeraGridEngine.basic_structures.Logger object>) PsseCircuit[source]
Parameters:
  • filename

  • text_func

  • progress_func

  • logger

Returns:

VeraGridEngine.IO.raw.raw_parser_writer.write_raw(file_name: str, psse_model: PsseCircuit, version=33) Logger[source]

Write PsseCircuit as .raw version 33 :param file_name: name of the file :param psse_model: PsseCircuit instance :param version: RAW version

VeraGridEngine.IO.raw.raw_parser_writer.write_substation_data_group(handle, psse_model: PsseCircuit, version: int) None[source]

Write the nested PSSE 34+ substation data group.

Parameters:
  • handle – Open output handle.

  • psse_model – PSSE model to serialize.

  • version – Target RAW version.

Returns:

None

VeraGridEngine.IO.raw.raw_to_veragrid module

VeraGridEngine.IO.raw.raw_to_veragrid.build_terminal_bus_lookup(terminals: List[RawEquipmentTerminalV34 | RawEquipmentTerminalV35 | RawEquipmentTerminalV36], node_bus_by_bus_and_node: Dict[tuple[int, int], Bus], logger: Logger) Dict[tuple[str, int, int, int, str], Bus][source]

Build a lookup from terminal records to VeraGrid node buses.

Parameters:
  • terminals – Parsed equipment terminal records.

  • node_bus_by_bus_and_node – Node buses keyed by electrical bus and node number.

  • logger – Logger.

Returns:

Terminal lookup dictionary.

VeraGridEngine.IO.raw.raw_to_veragrid.create_node_breaker_buses(psse_nodes: List[RawNodeV34 | RawNodeV35 | RawNodeV36], raw_bus_by_number: Dict[int, RawBusV29 | RawBusV30 | RawBusV31 | RawBusV32 | RawBusV33 | RawBusV34 | RawBusV35 | RawBusV36], area_dict: Dict[int, Area], zone_dict: Dict[int, Zone], substation_dict: Dict[int, Substation], circuit: MultiCircuit, logger: Logger) tuple[Dict[tuple[int, int], Bus], Dict[tuple[int, int], Bus], Dict[int, Bus], set[int]][source]

Create VeraGrid buses for PSSE node-breaker nodes.

Each PSSE node becomes a VeraGrid bus. The PSSE electrical bus record is kept as metadata for voltage level, area, zone, and solved-state defaults.

Parameters:
  • psse_nodes – Node records.

  • raw_bus_by_number – RAW bus records keyed by bus number.

  • area_dict – Area dictionary.

  • zone_dict – Zone dictionary.

  • substation_dict – Substation dictionary.

  • circuit – Destination circuit.

  • logger – Logger.

Returns:

Node-bus lookup dictionaries and the set of electrical bus numbers with node-breaker data.

VeraGridEngine.IO.raw.raw_to_veragrid.create_substation_objects(psse_substations: List[RawSubstationV29 | RawSubstationV30 | RawSubstationV31 | RawSubstationV32 | RawSubstationV33 | RawSubstationV34 | RawSubstationV35 | RawSubstationV36], circuit: MultiCircuit) Dict[int, Substation][source]

Create VeraGrid substations from the RAW substation records.

Parameters:
  • psse_substations – PSSE substation records.

  • circuit – Destination circuit.

Returns:

Mapping from PSSE substation number to VeraGrid substation.

VeraGridEngine.IO.raw.raw_to_veragrid.create_substation_switch(psse_switch: RawSubstationSwitchingDeviceV34 | RawSubstationSwitchingDeviceV35 | RawSubstationSwitchingDeviceV36, node_bus_by_substation_node: Dict[tuple[int, int], Bus], logger: Logger) Switch | None[source]

Create a VeraGrid switch from a PSSE substation switching device.

Parameters:
  • psse_switch – PSSE substation switching device.

  • node_bus_by_substation_node – Node buses keyed by substation and node number.

  • logger – Logger.

Returns:

VeraGrid switch or None.

VeraGridEngine.IO.raw.raw_to_veragrid.find_control_node_bus(node_bus_by_bus_and_node: Dict[tuple[int, int], Bus], bus_number: int, node_number: int) Bus | None[source]

Resolve a control target defined by electrical bus and node number.

Parameters:
  • node_bus_by_bus_and_node – Node buses keyed by electrical bus and node number.

  • bus_number – Electrical bus number.

  • node_number – Node number.

Returns:

Node bus or None.

VeraGridEngine.IO.raw.raw_to_veragrid.find_terminal_bus(terminal_bus_lookup: Dict[tuple[str, int, int, int, str], Bus], type_code: str, ibus: int, jbus: int, kbus: int, eqid: int | float | str) Bus | None[source]

Resolve a RAW equipment terminal to a VeraGrid node bus.

Parameters:
  • terminal_bus_lookup – Terminal lookup dictionary.

  • type_code – Terminal type code.

  • ibus – Primary bus number.

  • jbus – Secondary bus number.

  • kbus – Tertiary bus number.

  • eqid – Equipment identifier.

Returns:

Node bus or None.

VeraGridEngine.IO.raw.raw_to_veragrid.get_hvdc_from_twotermdc(psse_elm: RawTwoTerminalDCLineV29 | RawTwoTerminalDCLineV30 | RawTwoTerminalDCLineV31 | RawTwoTerminalDCLineV32 | RawTwoTerminalDCLineV33 | RawTwoTerminalDCLineV34 | RawTwoTerminalDCLineV35 | RawTwoTerminalDCLineV36, psse_bus_dict: Dict[int, Bus], Sbase: float, logger: Logger) HvdcLine | None[source]
Parameters:
  • psse_elm

  • psse_bus_dict

  • Sbase

  • logger

Returns:

VeraGridEngine.IO.raw.raw_to_veragrid.get_hvdc_from_vscdc(psse_elm: RawVscDCLineV29 | RawVscDCLineV30 | RawVscDCLineV31 | RawVscDCLineV32 | RawVscDCLineV33 | RawVscDCLineV34 | RawVscDCLineV35 | RawVscDCLineV36, psse_bus_dict: Dict[int, Bus], Sbase: float, logger: Logger) HvdcLine | None[source]

Get equivalent object :param psse_elm: :param psse_bus_dict: :param Sbase: Base power in MVA :param logger: :return:

VeraGridEngine.IO.raw.raw_to_veragrid.get_upfc_from_facts(psse_elm: RawFACTSV29 | RawFACTSV30 | RawFACTSV31 | RawFACTSV32 | RawFACTSV33 | RawFACTSV34 | RawFACTSV35 | RawFACTSV36, psse_bus_dict: Dict[int, Bus], Sbase: float, logger: Logger, circuit: MultiCircuit)[source]

Get equivalent object :param psse_elm: :param psse_bus_dict: :param Sbase: :param logger: :param circuit: :return:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_bus(psse_bus: RawBusV29 | RawBusV30 | RawBusV31 | RawBusV32 | RawBusV33 | RawBusV34 | RawBusV35 | RawBusV36, area_dict: Dict[int, Area], zone_dict: Dict[int, Zone], logger: Logger) Tuple[Bus, Shunt | None][source]
Returns:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_generator(psse_elm: RawGeneratorV29 | RawGeneratorV30 | RawGeneratorV31 | RawGeneratorV32 | RawGeneratorV33 | RawGeneratorV34 | RawGeneratorV35 | RawGeneratorV36, psse_bus_dict: Dict[int, Bus], logger: Logger) Generator[source]
Parameters:
  • psse_elm

  • psse_bus_dict

  • logger

Returns:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_line(psse_elm: RawBranchV29 | RawBranchV30 | RawBranchV31 | RawBranchV32 | RawBranchV33 | RawBranchV34 | RawBranchV35 | RawBranchV36, psse_bus_dict: Dict[int, Bus], Sbase: float, logger: Logger, simple_naming: bool) Line[source]
Parameters:
  • psse_elm

  • psse_bus_dict

  • Sbase

  • logger

:param simple_naming :return:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_load(psse_load: RawLoadV29 | RawLoadV30 | RawLoadV31 | RawLoadV32 | RawLoadV33 | RawLoadV34 | RawLoadV35 | RawLoadV36, bus: Bus, logger: Logger) Load[source]

Return VeraGrid Load object Returns:

Newton Load object

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_shunt_fixed(psse_elm: RawFixedShuntV29 | RawFixedShuntV30 | RawFixedShuntV31 | RawFixedShuntV32 | RawFixedShuntV33 | RawFixedShuntV34 | RawFixedShuntV35 | RawFixedShuntV36, bus: Bus, logger: Logger)[source]

Return VeraGrid Shunt object Returns:

VeraGrid Shunt object

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_shunt_switched(psse_elm: RawSwitchedShuntV29 | RawSwitchedShuntV30 | RawSwitchedShuntV31 | RawSwitchedShuntV32 | RawSwitchedShuntV33 | RawSwitchedShuntV34 | RawSwitchedShuntV35 | RawSwitchedShuntV36, bus: Bus, psse_bus_dict: Dict[int, Bus], logger: Logger) ControllableShunt[source]
Parameters:
  • psse_elm

  • bus

  • psse_bus_dict

  • logger

Returns:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_switch(psse_elm: RawSystemSwitchingDeviceV29 | RawSystemSwitchingDeviceV30 | RawSystemSwitchingDeviceV31 | RawSystemSwitchingDeviceV32 | RawSystemSwitchingDeviceV33 | RawSystemSwitchingDeviceV34 | RawSystemSwitchingDeviceV35 | RawSystemSwitchingDeviceV36, psse_bus_dict: Dict[int, Bus], logger: Logger) Switch | None[source]

Return VeraGrid Switch object :param psse_elm :param psse_bus_dict: :param logger:

VeraGridEngine.IO.raw.raw_to_veragrid.get_veragrid_transformer(psse_elm: RawTransformerV29 | RawTransformerV30 | RawTransformerV31 | RawTransformerV32 | RawTransformerV33 | RawTransformerV34 | RawTransformerV35 | RawTransformerV36, psse_bus_dict: Dict[int, Bus], Sbase: float, logger: Logger, adjust_taps_to_discrete_positions: bool, simple_naming: bool, flatten_virtual_taps: bool) Tuple[Transformer2W | Transformer3W, int][source]
Parameters:
  • psse_elm

  • psse_bus_dict

  • Sbase

  • logger

  • adjust_taps_to_discrete_positions – Modify the tap angle and module to the discrete positions

  • simple_naming

  • flatten_virtual_taps

Returns:

VeraGridEngine.IO.raw.raw_to_veragrid.normalize_terminal_identifier(value: int | float | str) str[source]

Normalize a terminal identifier for cross-record matching.

Parameters:

value – Terminal identifier from RAW.

Returns:

Normalized identifier.

VeraGridEngine.IO.raw.raw_to_veragrid.psse_to_veragrid(psse_circuit: PsseCircuit, logger: Logger, branch_connection_voltage_tolerance: float = 0.1, adjust_taps_to_discrete_positions: bool = False, use_short_names: bool = True, flatten_virtual_taps: bool = False) MultiCircuit[source]
Parameters:
  • psse_circuit – PsseCircuit instance

  • logger – Logger

  • branch_connection_voltage_tolerance – tolerance in p.u. of a branch voltage to be considered a transformer

  • adjust_taps_to_discrete_positions – Modify the tap angle and module to the discrete positions

  • use_short_names – use from_to_ckt, instead of

  • use_short_names – use a short name (bus_from_bus_to_ckt)

  • flatten_virtual_taps – flatten virtual taps (like psse, instead of properly using the voltage differences)

Returns:

MultiCircuit instance

VeraGridEngine.IO.raw.raw_types module

Aggregate RAW object typing aliases across supported PSSE versions.

VeraGridEngine.IO.raw.raw_writer_comment_map module

VeraGridEngine.IO.raw.rawx_parser_writer module

class VeraGridEngine.IO.raw.rawx_parser_writer.NpEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return super().default(o)
VeraGridEngine.IO.raw.rawx_parser_writer.parse_rawx(file_name: str, logger: Logger = <VeraGridEngine.basic_structures.Logger object>) PsseCircuit[source]

Parse a rawx file from PSSe :param file_name: file name :param logger: Logger :return: PsseCircuit

VeraGridEngine.IO.raw.rawx_parser_writer.write_rawx(file_name: str, circuit: PsseCircuit, logger: Logger = <VeraGridEngine.basic_structures.Logger object>) Logger[source]

RAWx export :param file_name: file name to save to :param circuit: MultiCircuit instance :param logger: Logger instance

VeraGridEngine.IO.raw.veragrid_to_raw module

class VeraGridEngine.IO.raw.veragrid_to_raw.RawCounter(grid: MultiCircuit)[source]

Bases: object

Items to count stuff for the raw files

get_ckt(branch: Line | DcLine | Transformer2W | HvdcLine | VSC | UPFC | Winding | Switch | SeriesReactance) int[source]

Count the circuit number in the PSSe sense :param branch: some branch :return: CKT

get_id(bus: Bus) int[source]

Query the dictionary for the internal number and increase that number for the next time :param bus: Bus :return: integer

get_next_psse_number()[source]
Returns:

get_suggested_psse_number(bus: Bus, logger: Logger) int[source]
Parameters:
  • bus

  • logger

Returns:

property psse_numbers_dict: Dict[Bus, int]
Returns:

register_psse_number(bus: Bus, psse_I: int)[source]
Parameters:
  • bus

  • psse_I

Returns:

class VeraGridEngine.IO.raw.veragrid_to_raw.RawNodeBreakerExportData[source]

Bases: object

Typed storage for the optional PSSE 34+ node-breaker projection.

bus_number_by_bus: Dict[Bus, int]
equipment_terminals: List[RawEquipmentTerminalV34 | RawEquipmentTerminalV35 | RawEquipmentTerminalV36]
node_number_by_bus: Dict[Bus, int]
nodes: List[RawNodeV34 | RawNodeV35 | RawNodeV36]
substation_number_by_substation: Dict[Substation, int]
substation_switching_devices: List[RawSubstationSwitchingDeviceV34 | RawSubstationSwitchingDeviceV35 | RawSubstationSwitchingDeviceV36]
substations: List[RawSubstationV29 | RawSubstationV30 | RawSubstationV31 | RawSubstationV32 | RawSubstationV33 | RawSubstationV34 | RawSubstationV35 | RawSubstationV36]
VeraGridEngine.IO.raw.veragrid_to_raw.append_psse_terminal(node_breaker_data: RawNodeBreakerExportData, bus: Bus, type_code: str, eqid: int | str, version: int, ibus: int, jbus: int = 0, kbus: int = 0, t_idx: int | None = None) None[source]

Append one PSSE equipment terminal when the endpoint bus is exported as a node.

Parameters:
  • node_breaker_data – Node-breaker export context.

  • bus – VeraGrid bus that owns the node.

  • type_code – PSSE terminal type code.

  • eqid – Equipment identifier.

  • version – Target PSSE RAW version.

  • ibus – Electrical bus number of the local terminal side.

  • jbus – Secondary bus number.

  • kbus – Tertiary bus number.

Returns:

None

VeraGridEngine.IO.raw.veragrid_to_raw.get_area(area: Area, i: int, version: int) RawAreaV29 | RawAreaV30 | RawAreaV31 | RawAreaV32 | RawAreaV33 | RawAreaV34 | RawAreaV35 | RawAreaV36[source]
Parameters:
  • area

  • i

  • version

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_export_substations(grid: MultiCircuit) List[Substation][source]

Collect the substations that are actually referenced by buses.

Parameters:

grid – VeraGrid circuit.

Returns:

Ordered list of substations to export.

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_branch(branch: Line, bus_dict: Dict[Bus, int], ckt: int, version: int, t_idx: int | None = None) RawBranchV29 | RawBranchV30 | RawBranchV31 | RawBranchV32 | RawBranchV33 | RawBranchV34 | RawBranchV35 | RawBranchV36[source]
Parameters:
  • branch

  • bus_dict

  • ckt

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_bus(bus: Bus, area_dict: Dict[Area, int], zones_dict: Dict[Zone, int], suggested_psse_number: int, version: int, t_idx: int | None = None) RawBusV29 | RawBusV30 | RawBusV31 | RawBusV32 | RawBusV33 | RawBusV34 | RawBusV35 | RawBusV36[source]
Parameters:
  • bus

  • area_dict

  • zones_dict

  • suggested_psse_number

  • version

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_facts(upfc: UPFC, bus_dict: Dict[Bus, int], version: int, t_idx: int | None = None) RawFACTSV29 | RawFACTSV30 | RawFACTSV31 | RawFACTSV32 | RawFACTSV33 | RawFACTSV34 | RawFACTSV35 | RawFACTSV36[source]
Parameters:
  • upfc

  • bus_dict

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_fixed_shunt(shunt: Shunt, bus_dict: Dict[Bus, int], id_number: int, version: int, t_idx: int | None = None) RawFixedShuntV29 | RawFixedShuntV30 | RawFixedShuntV31 | RawFixedShuntV32 | RawFixedShuntV33 | RawFixedShuntV34 | RawFixedShuntV35 | RawFixedShuntV36[source]
Parameters:
  • shunt

  • bus_dict

  • id_number

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_generator(generator: Generator, bus_dict: Dict[Bus, int], id_number: int, version: int, t_idx: int | None = None) RawGeneratorV29 | RawGeneratorV30 | RawGeneratorV31 | RawGeneratorV32 | RawGeneratorV33 | RawGeneratorV34 | RawGeneratorV35 | RawGeneratorV36[source]
Parameters:
  • generator

  • bus_dict

  • id_number

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_load(load: Load, bus_dict: Dict[Bus, int], id_number: int, version: int, t_idx: int | None = None) RawLoadV29 | RawLoadV30 | RawLoadV31 | RawLoadV32 | RawLoadV33 | RawLoadV34 | RawLoadV35 | RawLoadV36[source]
Parameters:
  • load

  • bus_dict

  • id_number

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_load_from_external_grid(load: ExternalGrid, bus_dict: Dict[Bus, int], id_number: int, version: int, t_idx: int | None = None) RawLoadV29 | RawLoadV30 | RawLoadV31 | RawLoadV32 | RawLoadV33 | RawLoadV34 | RawLoadV35 | RawLoadV36[source]
Parameters:
  • load

  • bus_dict

  • id_number

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_node(bus: Bus, node_number: int, electrical_bus_number: int, version: int, t_idx: int | None = None) RawNodeV34 | RawNodeV35 | RawNodeV36[source]

Convert a VeraGrid bus into a PSSE node record.

Parameters:
  • bus – VeraGrid bus.

  • node_number – Node number within the substation.

  • electrical_bus_number – Derived PSSE electrical bus number.

  • version – Target PSSE RAW version.

Returns:

RAW node record.

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_substation(substation: Substation, psse_number: int, version: int, t_idx: int | None = None) RawSubstationV29 | RawSubstationV30 | RawSubstationV31 | RawSubstationV32 | RawSubstationV33 | RawSubstationV34 | RawSubstationV35 | RawSubstationV36[source]

Convert a VeraGrid substation into a PSSE substation record.

Parameters:
  • substation – VeraGrid substation.

  • psse_number – PSSE substation number.

  • version – Target PSSE RAW version.

Returns:

RAW substation record.

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_substation_switch(switch: Switch, node_breaker_data: RawNodeBreakerExportData, ckt: int, version: int, t_idx: int | None = None) RawSubstationSwitchingDeviceV34 | RawSubstationSwitchingDeviceV35 | RawSubstationSwitchingDeviceV36[source]

Convert an internal VeraGrid switch into a PSSE substation switching device.

Parameters:
  • switch – VeraGrid switch.

  • node_breaker_data – Node-breaker export context.

  • ckt – Switch identifier.

  • version – PSSE RAW version.

Returns:

RAW substation switching device record.

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_switch(switch: Switch, bus_dict: Dict[Bus, int], ckt: int, version: int, t_idx: int | None = None) RawSystemSwitchingDeviceV29 | RawSystemSwitchingDeviceV30 | RawSystemSwitchingDeviceV31 | RawSystemSwitchingDeviceV32 | RawSystemSwitchingDeviceV33 | RawSystemSwitchingDeviceV34 | RawSystemSwitchingDeviceV35 | RawSystemSwitchingDeviceV36[source]

Convert VeraGrid Switch to PSSE system switching device.

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_switched_shunt(shunt: ControllableShunt, bus_dict: Dict[Bus, int], version: int, t_idx: int | None = None) RawSwitchedShuntV29 | RawSwitchedShuntV30 | RawSwitchedShuntV31 | RawSwitchedShuntV32 | RawSwitchedShuntV33 | RawSwitchedShuntV34 | RawSwitchedShuntV35 | RawSwitchedShuntV36[source]
Parameters:
  • shunt

  • bus_dict

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_transformer2w(transformer: Transformer2W, bus_dict: Dict[Bus, int], ckt: int, version: int, t_idx: int | None = None) RawTransformerV29 | RawTransformerV30 | RawTransformerV31 | RawTransformerV32 | RawTransformerV33 | RawTransformerV34 | RawTransformerV35 | RawTransformerV36[source]
Parameters:
  • transformer

  • bus_dict

  • ckt

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_transformer3w(transformer: Transformer3W, bus_dict: Dict[Bus, int], version: int, t_idx: int | None = None) RawTransformerV29 | RawTransformerV30 | RawTransformerV31 | RawTransformerV32 | RawTransformerV33 | RawTransformerV34 | RawTransformerV35 | RawTransformerV36[source]
Parameters:
  • transformer

  • bus_dict

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_psse_two_terminal_dc_line(hvdc_line: HvdcLine, bus_dict: Dict[Bus, int], version: int, t_idx: int | None = None) RawTwoTerminalDCLineV29 | RawTwoTerminalDCLineV30 | RawTwoTerminalDCLineV31 | RawTwoTerminalDCLineV32 | RawTwoTerminalDCLineV33 | RawTwoTerminalDCLineV34 | RawTwoTerminalDCLineV35 | RawTwoTerminalDCLineV36[source]
Parameters:
  • hvdc_line

  • bus_dict

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_vsc_dc_line(hvdc_line: HvdcLine, bus_dict: Dict[Bus, int], version: int, t_idx: int | None = None) RawVscDCLineV29 | RawVscDCLineV30 | RawVscDCLineV31 | RawVscDCLineV32 | RawVscDCLineV33 | RawVscDCLineV34 | RawVscDCLineV35 | RawVscDCLineV36[source]
Parameters:
  • hvdc_line

  • bus_dict

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.get_zone(zone: Zone, i: int, version: int) RawZoneV29 | RawZoneV30 | RawZoneV31 | RawZoneV32 | RawZoneV33 | RawZoneV34 | RawZoneV35 | RawZoneV36[source]
Parameters:
  • zone

  • i

  • version

Returns:

VeraGridEngine.IO.raw.veragrid_to_raw.veragrid_to_raw(grid: MultiCircuit, version: int, logger: Logger, topology_mode: PsseTopologyExportMode = BusBranch, t_idx: int | None = None) PsseCircuit[source]

Convert a VeraGrid circuit into a PSSE RAW circuit.

Parameters:
  • grid – VeraGrid circuit.

  • version – Target PSSE RAW version.

  • logger – Logger.

  • topology_mode – Export topology strategy.

  • t_idx – Snapshot selector. None exports snapshot values, otherwise exports the selected profile step.

Returns:

PSSE RAW circuit.

Module contents