VeraGridEngine.IO.ucte packageο
Subpackagesο
- VeraGridEngine.IO.ucte.devices package
- Submodules
- VeraGridEngine.IO.ucte.devices.ucte_base module
- VeraGridEngine.IO.ucte.devices.ucte_circuit module
- VeraGridEngine.IO.ucte.devices.ucte_comment module
- VeraGridEngine.IO.ucte.devices.ucte_exchange_power module
- VeraGridEngine.IO.ucte.devices.ucte_line module
- VeraGridEngine.IO.ucte.devices.ucte_node module
- VeraGridEngine.IO.ucte.devices.ucte_transformer module
- VeraGridEngine.IO.ucte.devices.ucte_transformer_regulation module
- VeraGridEngine.IO.ucte.devices.ucte_transformer_tap_table module
- Module contents
Submodulesο
VeraGridEngine.IO.ucte.ucte_to_veragrid moduleο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_fixed_shunt_from_ucte_line(grid: MultiCircuit, ucte_elm, bus: Bus)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_standard_line(grid: MultiCircuit, ucte_elm, bus_f: Bus, bus_t: Bus, active: bool, reducible: bool, logger: Logger)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_switch(grid: MultiCircuit, code: str, name: str, current_limit: float | None, bus_f: Bus, bus_t: Bus, active: bool, reducible: bool)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_switch_from_line(grid: MultiCircuit, ucte_elm, bus_f: Bus, bus_t: Bus, active: bool, reducible: bool)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_switch_from_transformer(grid: MultiCircuit, ucte_elm, bus_f: Bus, bus_t: Bus, active: bool, reducible: bool)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.add_transformer_from_mismatch_line(grid: MultiCircuit, ucte_elm, bus_f: Bus, bus_t: Bus)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.apply_tap_table(elm: Transformer2W, ucte_elm, tap_tables, low_tap_position: int, current_tap_number: int, logger: Logger)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.build_current_tap_state(regulator, tap_type: TapChangerTypes) tuple[float, float][source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.build_tap_changer_type(regulator) TapChangerTypes[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.build_technologies(grid: MultiCircuit) dict[str, Technology][source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.build_transformer_tap_data(ucte_elm, regulator, tap_tables, bus_f: Bus, bus_t: Bus, invert_fixed_tap: bool, logger: Logger)[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.build_xnode_active_line_counts(ucte_grid: UcteCircuit, logger: Logger) dict[str, int][source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.compute_switch_rate(bus_f: Bus, bus_t: Bus, current_limit: float | None) float[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.compute_tap_span(regulator, tap_tables) tuple[int, int][source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.convert_ucte_to_veragrid(ucte_grid: UcteCircuit, logger: Logger) MultiCircuit[source]ο
Convert UCTE grid to VeraGrid.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.discover_nominal_voltages(ucte_grid: UcteCircuit) Dict[str, float][source]ο
Attempt to discover the nominal voltage for each level character.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.get_current_limit_a(current_limit: float | None) float[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.get_current_limit_ka(current_limit: float | None) float[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.has_zero_transformer_impedance(ucte_elm, tol: float = 1e-09) bool[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.is_fictitious_shunt_line(ucte_elm, tol: float = 1e-09) bool[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.is_standard_ucte_country_code(country_code: str) bool[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.parse_exchange_power(ucte_grid: UcteCircuit, grid: MultiCircuit, bus_dict: Dict[str, Bus], logger: Logger)[source]ο
Exchange powers are currently ignored by the VeraGrid UCTE importer.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.parse_lines(ucte_grid: UcteCircuit, grid: MultiCircuit, bus_dict: Dict[str, Bus], logger: Logger)[source]ο
Parse UCTE lines and couplers.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.parse_nodes(ucte_grid: UcteCircuit, grid: MultiCircuit, logger: Logger) Dict[str, Bus][source]ο
Create buses and their injections.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.parse_transformer(ucte_grid: UcteCircuit, grid: MultiCircuit, bus_dict: Dict[str, Bus], logger: Logger)[source]ο
Parse UCTE transformers.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.repair_nominal_voltages_from_references(ucte_grid: UcteCircuit, logger: Logger)[source]ο
Fix clearly inconsistent nominal voltages in non-canonical UCTE variants.
If Vref/Vnom is outside a realistic range for steady-state operation, infer Vnom from Vref directly using a conservative nominal-level palette.
- VeraGridEngine.IO.ucte.ucte_to_veragrid.same_nominal_voltage(bus_f: Bus, bus_t: Bus, tol: float = 1e-06) bool[source]ο
- VeraGridEngine.IO.ucte.ucte_to_veragrid.should_import_mismatch_line_as_transformer(ucte_elm, bus_f: Bus, bus_t: Bus) bool[source]ο
VeraGridEngine.IO.ucte.veragrid_to_ucte moduleο
- class VeraGridEngine.IO.ucte.veragrid_to_ucte.UcteBranchCounter[source]ο
Bases:
objectAssign one-character UCTE order codes per branch endpoint pair.
- class VeraGridEngine.IO.ucte.veragrid_to_ucte.UcteBusAggregate[source]ο
Bases:
objectStore the bus-level values required by one exported UCTE node.
- active_gen_mw: floatο
- active_load_mw: floatο
- has_generation_limits: boolο
- has_generation_record: boolο
- max_gen_mvar: floatο
- max_gen_mw: floatο
- min_gen_mvar: floatο
- min_gen_mw: floatο
- node_type: intο
- plant_type: strο
- reactive_gen_mvar: floatο
- reactive_load_mvar: floatο
- shunt_b_mvar: floatο
- status: intο
- voltage_reference_kv: floatο
- VeraGridEngine.IO.ucte.veragrid_to_ucte.add_generator_like_device(aggregate: UcteBusAggregate, device: Generator | Battery | StaticGenerator, t_idx: int | None) None[source]ο
Add one generator-like device to the bus aggregate using UCTE sign semantics.
- Parameters:
aggregate β Target bus aggregate.
device β Generator-like device.
t_idx β Optional profile index.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.add_load_like_device(aggregate: UcteBusAggregate, device: Load | ExternalGrid, t_idx: int | None, logger: Logger) None[source]ο
Add one load-like device to the bus aggregate.
- Parameters:
aggregate β Target bus aggregate.
device β Load or load-mode external grid.
t_idx β Optional profile index.
logger β Export logger.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.build_bus_aggregate(circuit: MultiCircuit, bus: Bus, bus_injections: Dict[Bus, Dict[object, List[object]]], t_idx: int | None, logger: Logger) UcteBusAggregate[source]ο
Aggregate all supported VeraGrid injections attached to one bus.
- Parameters:
circuit β Circuit to export.
bus β Bus to aggregate.
bus_injections β Bus-grouped injection lookup.
t_idx β Optional profile index.
logger β Export logger.
- Returns:
Filled node aggregate.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.build_bus_node_code_map(circuit: MultiCircuit, logger: Logger) Dict[Bus, str][source]ο
Build one deterministic UCTE node-code map for every exported bus.
- Parameters:
circuit β Circuit to export.
logger β Export logger.
- Returns:
Bus-to-node-code mapping.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.build_shunt_node_code(bus_code: str) str[source]ο
Build the fictitious-shunt node code paired to one exported bus code.
- Parameters:
bus_code β Main bus node code.
- Returns:
Fictitious-shunt node code.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.format_line_row(node_1: str, node_2: str, order_code: str, status: int, resistance_ohm: float, reactance_ohm: float, susceptance_us: float, current_limit_a: float, name: str) str[source]ο
Format one UCTE line record.
- Parameters:
node_1 β First node code.
node_2 β Second node code.
order_code β One-character order code.
status β UCTE status code.
resistance_ohm β Series resistance in ohm.
reactance_ohm β Series reactance in ohm.
susceptance_us β Total shunt susceptance in uS.
current_limit_a β Current limit in A.
name β Device name.
- Returns:
Line row text.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.format_node_row(node_code: str, bus: Bus, aggregate: UcteBusAggregate) str[source]ο
Format one UCTE node record.
- Parameters:
node_code β Exported node code.
bus β Source bus.
aggregate β Aggregated node state.
- Returns:
Node row text.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.format_optional_float(value: float, decimals: int) str[source]ο
Format one optional float for tolerant UCTE text output.
- Parameters:
value β Numeric value.
decimals β Number of decimal places.
- Returns:
Formatted text or an empty string.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.format_optional_float_width(value: float, width: int, decimals: int) str[source]ο
Format one optional float using one strict fixed-width UCTE field.
- Parameters:
value β Numeric value.
width β Field width.
decimals β Number of decimal places.
- Returns:
Fixed-width text or blanks.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.format_transformer_row(node_1: str, node_2: str, order_code: str, status: int, rated_voltage_1_kv: float, rated_voltage_2_kv: float, nominal_power_mva: float, resistance_ohm: float, reactance_ohm: float, susceptance_us: float, conductance_us: float, current_limit_a: float, name: str) str[source]ο
Format one UCTE transformer record.
- Parameters:
node_1 β Non-regulated winding node code.
node_2 β Regulated winding node code.
order_code β One-character order code.
status β UCTE status code.
rated_voltage_1_kv β Rated voltage on node1 side.
rated_voltage_2_kv β Rated voltage on node2 side.
nominal_power_mva β Nominal power in MVA.
resistance_ohm β Series resistance in ohm.
reactance_ohm β Series reactance in ohm.
susceptance_us β Total shunt susceptance in uS.
conductance_us β Total shunt conductance in uS.
current_limit_a β Current limit in A.
name β Device name.
- Returns:
Transformer row text.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_bus_voltage_reference(bus: Bus) float[source]ο
Convert the VeraGrid bus voltage seed to the UCTE
Urefvalue.- Parameters:
bus β VeraGrid bus.
- Returns:
Voltage reference in kV.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_country_code(bus: Bus) str[source]ο
Get the UCTE country code to use for one bus block.
- Parameters:
bus β VeraGrid bus.
- Returns:
Two-letter country code or
XX.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_line_current_limit_a(line: Line, vnom_kv: float, t_idx: int | None) float[source]ο
Convert one VeraGrid line rate to a UCTE current limit.
- Parameters:
line β VeraGrid line.
vnom_kv β Nominal voltage in kV.
t_idx β Optional profile index.
- Returns:
Current limit in A or
nan.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_line_ucte_impedance(line: Line, circuit: MultiCircuit) tuple[float, float, float][source]ο
Convert one VeraGrid line impedance to UCTE units.
- Parameters:
line β VeraGrid line.
circuit β Circuit base values.
- Returns:
Resistance in ohm, reactance in ohm, susceptance in uS.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_snapshot_datetime(circuit: MultiCircuit, t_idx: int | None) datetime[source]ο
Get the export timestamp represented by one UCTE file.
- Parameters:
circuit β Circuit to export.
t_idx β Optional profile index.
- Returns:
Snapshot datetime.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_transformer_current_limit_a(transformer: Transformer2W, t_idx: int | None) float[source]ο
Convert one VeraGrid transformer rate to a UCTE current limit.
- Parameters:
transformer β VeraGrid transformer.
t_idx β Optional profile index.
- Returns:
Current limit in A or
nan.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_transformer_ucte_impedance(transformer: Transformer2W, circuit: MultiCircuit, rated_voltage_1_kv: float) tuple[float, float, float, float][source]ο
Convert one VeraGrid transformer impedance to UCTE units.
- Parameters:
transformer β VeraGrid transformer.
circuit β Circuit base values.
rated_voltage_1_kv β UCTE rated voltage on node1 side.
- Returns:
Resistance in ohm, reactance in ohm, susceptance in uS, conductance in uS.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.get_ucte_voltage_code(voltage_kv: float) str[source]ο
Map one nominal voltage value to the closest standard UCTE voltage code.
- Parameters:
voltage_kv β Nominal voltage in kV.
- Returns:
One-character voltage code.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.is_standard_ucte_country_code(country_code: str) bool[source]ο
Check if one country code matches the standard UCTE two-letter form.
- Parameters:
country_code β Country code to inspect.
- Returns:
Truewhen the code is standard.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.is_usable_ucte_bus_code(node_code: str, bus: Bus) bool[source]ο
Check if one bus code can be reused directly as a canonical UCTE node code.
- Parameters:
node_code β Candidate node code.
bus β VeraGrid bus.
- Returns:
Truewhen the code is already UCTE-safe.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.normalize_reusable_noncanonical_ucte_bus_code(node_code: str) str | None[source]ο
Normalize one existing non-canonical node code for roundtrip preservation.
This keeps non-canonical UCTE identifiers from imported synthetic datasets so that the importer can continue applying its nominal-voltage repair heuristics on roundtrip.
- Parameters:
node_code β Candidate node code.
- Returns:
Normalized 8-character code or
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.update_aggregate_from_external_grid(aggregate: UcteBusAggregate, bus: Bus, external_grid: ExternalGrid, t_idx: int | None, logger: Logger) None[source]ο
Apply one external-grid device to the UCTE node aggregate.
- Parameters:
aggregate β Target bus aggregate.
bus β Parent bus.
external_grid β External-grid device.
t_idx β Optional profile index.
logger β Export logger.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.update_aggregate_voltage_control_from_generator(aggregate: UcteBusAggregate, bus: Bus, generator: Generator | Battery, t_idx: int | None) None[source]ο
Apply one generator voltage-control mode to the aggregate node state.
- Parameters:
aggregate β Target bus aggregate.
bus β Parent bus.
generator β Generator or battery.
t_idx β Optional profile index.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.update_generation_limits_from_generator(aggregate: UcteBusAggregate, generator: Generator | Battery) None[source]ο
Accumulate UCTE generation limits from one VeraGrid generator-like device.
- Parameters:
aggregate β Target bus aggregate.
generator β Generator or battery device.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.use_legacy_transformer_orientation(bus_from: Bus, bus_to: Bus) bool[source]ο
Select the transformer orientation expected by the UCTE importer.
Standard country-coded UCTE data uses the legacy regulated/non-regulated winding convention, while IEEE-like synthetic files use the direct
node1 -> node2orientation.- Parameters:
bus_from β VeraGrid transformer
bus_fromside.bus_to β VeraGrid transformer
bus_toside.
- Returns:
Truewhen the legacy UCTE orientation must be exported.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_comment_block(circuit: MultiCircuit, t_idx: int | None, file_pointer: TextIO) None[source]ο
Write the UCTE comment block.
- Parameters:
circuit β Circuit to export.
t_idx β Optional profile index.
file_pointer β Open output file.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_empty_regulation_blocks(file_pointer: TextIO) None[source]ο
Write the optional UCTE blocks that are not populated yet.
- Parameters:
file_pointer β Open output file.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_line_block(circuit: MultiCircuit, bus_code_map: Dict[Bus, str], aggregate_by_bus: Dict[Bus, UcteBusAggregate], t_idx: int | None, logger: Logger, file_pointer: TextIO) None[source]ο
Write the UCTE line block, including switch couplers and fictitious shunts.
- Parameters:
circuit β Circuit to export.
bus_code_map β Bus-to-node-code mapping.
aggregate_by_bus β Precomputed bus aggregates.
t_idx β Optional profile index.
logger β Export logger.
file_pointer β Open output file.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_node_blocks_from_aggregates(circuit: MultiCircuit, bus_code_map: Dict[Bus, str], aggregate_by_bus: Dict[Bus, UcteBusAggregate], file_pointer: TextIO) None[source]ο
Write the UCTE node sections grouped by country block.
- Parameters:
circuit β Circuit to export.
bus_code_map β Bus-to-node-code mapping.
aggregate_by_bus β Precomputed bus aggregates.
file_pointer β Open output file.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_transformer_block(circuit: MultiCircuit, bus_code_map: Dict[Bus, str], t_idx: int | None, logger: Logger, file_pointer: TextIO) None[source]ο
Write the UCTE transformer block.
- Parameters:
circuit β Circuit to export.
bus_code_map β Bus-to-node-code mapping.
t_idx β Optional profile index.
logger β Export logger.
file_pointer β Open output file.
- Returns:
None.
- VeraGridEngine.IO.ucte.veragrid_to_ucte.write_ucte(file_name: str, circuit: MultiCircuit, t_idx: int | None = None, logger: Logger | None = None) Logger[source]ο
Write one VeraGrid circuit as one UCTE text file.
- Parameters:
file_name β Target file path.
circuit β Circuit to export.
t_idx β Optional profile index.
Nonemeans snapshot export.logger β Optional logger.
- Returns:
Logger with export messages.