csv files

Naming of files

A naming strategy provides a mapping between model classes and the human readable names of those entities to be used within e.g. the data sinks, in which the serialized representation of several objects of this class can be found. Currently we offer two different, pre-defined naming strategies, which you might extend to fit your needs:

  1. EntityPersistenceNamingStrategy: A basic naming strategy that is able to add prefix and suffix to the names of the entities. A flat folder structure is considered. For more details see Default naming strategy.

  2. HierarchicFileNamingStrategy: An extended version of the EntityPersistenceNamingStrategy. Additionally, the Default directory hierarchy is taken into account. Please note, that this directory hierarchy is only meant to be used in conjunction with input models.

However, you can control the behaviour of serialization and de-serialization of models by injecting the desired naming strategy you like into CsvDataSource and CsvFileSink.

Default naming strategy

There is a default mapping from model class to naming of entities 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 EntityPersistenceNamingStrategy("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

Time Series

Model

File Name

individual time series

prefix_its_columnScheme_UUID_suffix

load profile input

prefix_rts_profileKey_UUID_suffix

Let’s spend a few more words on the individual time series: Those files are meant to carry different types of content - one might give information about wholesale market prices, the other is a record of power values provided by a real system. To be able to understand, what’s inside of the file, the columnScheme part of the file name gives insight of it’s content. The following keys are supported until now:

Key

Information and supported head line

c

An energy price (e.g. in €/MWh; c stands for charge).
Permissible head line: uuid,time,price

p

Active power
Permissible head line: uuid,time,p

pq

Active and reactive power
Permissible head line: uuid,time,p,q

h

Heat power demand
Permissible head line: uuid,time,h

ph

Active and heat power
Permissible head line: uuid,time,p,h

pqh

Active, reactive and heat power
Permissible head line: uuid,time,p,q,h

weather

Weather information
Permissible head line:
uuid,time,coordinate,direct_irradiation,diffuse_irradiation,temperature,wind_velocity,wind_direction

As the uuid and time field are mandatory, they are not mentioned explicitly, here.

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

Default directory hierarchy

Although there is no fixed structure of files mandatory, there is something, we consider to be a good idea of structuring things. You may either ship your csv files directly in this structure or compress everything in a .tar.gz file. However, following this form, we are able to provide you some helpful tools in obtaining and saving your models a bit easier.

Default directory hierarchy for input classes

Default directory hierarchy for input classes

Default directory hierarchy for result classes

Default directory hierarchy for result classes

The italic parts are optional and the others are mandatory. As you see, this still is a pretty flexible approach, as you only need to provide, what you really need. However, note that this hierarchy is only meant to be used in conjunction with input models, yet.

The class DefaultInputHierarchy offers some helpful methods to validate and create a default input file hierarchy.

De-Serialization (loading models)

Having an instance of Grid Container is most of the time the target whenever you load your grid. 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 gridName = "exampleGrid";
String csvSep = ",";
String folderPath = "./exampleGrid";
EntityPersistenceNamingStrategy namingStrategy = new EntityPersistenceNamingStrategy(); // 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);
SystemParticipantSource systemParticipantSource = 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.getSystemParticipants().orElseThrow(
        () -> new SourceException("Error during reading of system participant data."));
GraphicElements graphicElements = graphicsSource.getGraphicElements().orElseThrow(
        () -> new SourceException("Error during reading of graphic elements."));
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 is an implementation of the different interfaces for the desired data source.

Serialization (writing models)

Serializing models is a bit easier:

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

/* Instantiating the sink */
CsvFileSink sink = new CsvFileSink(folderPath, namingStrategy, initEmptyFiles, csvSep);
sink.persistJointGridContainer(grid);

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.

Compression and extraction of files

We consider either regular directories or compressed tarball archives (*.tar.gz) as source of input files. The class TarballUtils offers some helpful functions to compress or extract input data files for easier shipping.