I/O

The PowerSystemDataModel library additionally offers I/O-capabilities. In the long run, it is our aim to provide many different source and sink technologies. Therefore, the I/O-package is structured as highly modular.

Implemented Data Connectors

  • influxdb
  • csvfiles

De-Serialization (loading models)

At the end, having an instance of Grid Container is the goal. It consists of the three main blocks:

Those blocks are also reflected in the structure of data source interface definitions. There is one source for each of the containers, respectively.

Class diagram of data sources

Class diagram of data sources

As a full data set has references among the models (e.g. a line model points to its’ nodes it connects), there is a hierarchical structure, in which models have to be loaded. Therefore, the different sources have also references among themselves. An application example to load an exampleGrid from csv files located in ./exampleGrid could look like this:

/* Parameterization */
String csvSep = ";"
String folderPath = "./exampleGrid"
FileNamingStrategy namingStrategy = new FileNamingStrategy() // Default naming strategy

/* Instantiating sources */
TypeSource typeSource = new CsvTypeSource(csvSep, folderPath, namingStrategy)
RawGridSource rawGridSource = new CsvRawGridSource(csvSep, folderPath, namingStrategy, typeSource)
ThermalSource thermalSource = new CsvThermalSource(csvSep, folderPath, namingStrategy, typeSource)
ParticipantSource participantSource = new CsvSystemParticipantSource(
  csvSep,
  folderPath,
  namingStrategy,
  typeSource,
  thermalSource,
  rawGridSource
)
GraphicSource graphicsSource = new CsvGraphicSource(
  csvSep,
  folderPath,
  namingStrategy,
  typeSource,
  rawGridSource
)

/* Loading models */
RawGridElements rawGridElements = rawGridSource.getGridData.orElseThrow(
      () -> new SourceException("Error during reading of raw grid data.")
   )
SystemParticipants systemParticipants = systemParticipantSource.getGridData.orElseThrow(
      () -> new SourceException("Error during reading of raw grid data.")
   )
GraphicElements graphicElements = graphicsSource.getGraphicElements.orElseThrow(
      () -> new SourceException("Error during reading of graphic elements data.")
   )
JointGridContainer fullGrid = new JointGridContainer(
  gridName,
  rawGridElements,
  systemParticipants,
  graphicElements
)

As observable from the code, it doesn’t play a role, where the different parts come from. It is also a valid solution, to receive types from file, but participants and raw grid elements from a data base. Only prerequisite: An implementation of the different interfaces for the desired data sink.

Serialization (writing models)

Serializing models is a bit easier:

/* Parameterization */
String csvSep = ";"
String folderPath = "./exampleGrid"
FileNamingStrategy namingStrategy = new FileNamingStrategy()
boolean initEmptyFiles = false

/* Instantiating the sink */
DataSink sink = new CsvFileSink(folderPath, namingStrategy, initEmptyFiles, csvSep)
sink.persistAll(grid.allEntitiesAsList())

The sink takes a collection of model suitable for serialization and handles the rest (e.g. unboxing of nested models) on its own. But caveat: As the (csv) writers are implemented in a concurrent, non-blocking way, duplicates of nested models could occur.

Default naming strategy

There is a default mapping from model class to file naming in the case you would like to use csv files for (de) serialization of models. You may extend / alter the naming with pre- or suffix by calling new FileNamingStrategy("prefix", "suffix").

Input

Model File Name
operator prefix_operator_input_suffix
node prefix_node_input_suffix
line
prefix_line_input_suffix
prefix_line_type_input_suffix
switch prefix_switch_input_suffix
two winding transformer
prefix_transformer2w_input_suffix
prefix_transformer2w_type_input_suffix
three winding transformer
prefix_transformer3w_input_suffix
prefix_transformer3w_type_input_suffix
measurement unit prefix_measurement_unit_input_suffix
biomass plant
prefix_bm_input_suffix
prefix_bm_type_input_suffix
combined heat and power plant
prefix_chp_input_suffix
prefix_chp_type_input_suffix
electric vehicle
prefix_ev_input_suffix
prefix_ev_type_input_suffix
electric vehicle charging station prefix_evcs_input_suffix
fixed feed in facility prefix_fixed_feed_in_input_suffix
heat pump
prefix_hp_input_suffix
prefix_hp_type_input_suffix
load prefix_load_input_suffix
photovoltaic power plant prefix_pc_input_suffix
electrical energy storage
prefix_storage_input_suffix
prefix_storage_type_input_suffix
wind energy converter
prefix_wec_input_suffix
prefix_wec_type_input_suffix
schematic node graphic prefix_node_graphic_input_suffix
schematic line graphic prefix_line_graphic_input_suffix

Results

Model File Name
node prefix_node_res_suffix
line prefix_line_res_suffix
switch prefix_switch_res_suffix
two winding transformer prefix_transformer2w_res_suffix
three winding transformer | prefix_transformer3w_res_suffix
biomass plant prefix_bm_res_suffix
combined heat and power plant prefix_chp_res_suffix
electric vehicle prefix_ev_res_suffix
electric vehicle charging station prefix_evcs_res_suffix
fixed feed in prefix_fixed_feed_in_res_suffix
heat pump prefix_hp_res_suffix
load prefix_load_res_suffix
photovoltaic power plant prefix_pv_res_suffix
storage prefix_storage_res_suffix
wind energy converter prefix_wec_res_suffix
thermal house model prefix_thermal_house_res_suffix
cylindrical thermal storage prefix_cylindrical_storage_res_suffix

Time Series

Model File Name
individual time series prefix_individual_time_series_UUID_suffix
load profile input prefix_load_profile_time_series_profileKey_UUID_suffix