Scenario class

deflex.DeflexScenario([meta, input_data, …]) The Deflex Scenario is the center of a deflex energy model.

Read/Write a scenario

deflex.DeflexScenario.read_xlsx(filename) Load scenario data from an xlsx file.
deflex.DeflexScenario.read_csv(path) Load scenario from a csv-collection.
deflex.create_scenario(path[, file_type]) Create a deflex scenario object from file.
deflex.search_input_scenarios(path[, csv, …]) Search for files with an .xlsx extension or directories ending with ‘_csv’.
deflex.DeflexScenario.to_xlsx(filename) Store the input data into an xlsx-file.
deflex.DeflexScenario.to_csv(path) Store the input data as a csv-collection.
deflex.DeflexScenario.dump(filename) Store a solved scenario class into the binary pickle format.
deflex.DeflexScenario.store_graph(filename, …) Store the EnergySystem graph into a .graphml file.

Compute scenario

deflex.DeflexScenario.compute([solver, …]) Create a solph.Model from the input data and optimise it using an external solver.

Advanced scenario methods

deflex.DeflexScenario.check_input_data() Check the input data for NaN values.
deflex.DeflexScenario.table2es() Create a populated solph.EnergySystem from the input data.
deflex.DeflexScenario.create_model() Create a solph model from an EnergySystem object.
deflex.DeflexScenario.create_nodes() Creates solph components and buses from the input data and store them in a dictionary with unique IDs as keys.
deflex.DeflexScenario.solve(model[, solver, …]) Solve the solph.Model.
deflex.DeflexScenario.initialise_energy_system() Create a solph.EnergySystem and store it in the es attribute.
deflex.DeflexScenario.add_nodes_to_es(nodes) Add nodes to an existing solph.EnergySystem.


Python scripts

deflex.model_scenario([path, file_type, …]) Compute a deflex scenario with the full work flow:
deflex.batch_model_scenario(path[, …]) Model a single scenario in batch mode.
deflex.model_multi_scenarios(scenarios[, …]) Model multi scenarios in parallel.

Console scripts

deflex.console_scripts.main() deflex-compute [-h] [–version] [–results [RESULTS]] [–dump [DUMP]] [–solver [SOLVER]] path
deflex.console_scripts.result() deflex-results [-h] [–version] [–filetype [FILETYPE]] function in_path out_path


Restore dumped scenarios

deflex.search_dumped_scenarios(path[, extension]) Filter results by extension and meta data.
deflex.restore_scenario(filename[, …]) Restore a full Scenario from a dump file (.dflx).
deflex.restore_results(file_names[, …]) Restore only the result dictionary from a dumped scenario or a list of dumped scenarios.

Analyse and draw graph

deflex.postprocessing.graph.Edge(**kwargs) An edge of a DeflexGraph
deflex.DeflexGraph(results, **kwargs) The deflex model graph with a networkx representation.
deflex.DeflexGraph.nxgraph(**kwargs) Get a networkx.DiGraph() from the deflex results.
deflex.DeflexGraph.write(filename, **kwargs) Write the graph into a .graphml file.
deflex.DeflexGraph.color_edges_by_weight([…]) Color all edges by their weight using a matplotlib color map (cmap).
deflex.DeflexGraph.color_nodes_by_type(colors) Color all nodes in a specific color according to their class.
deflex.DeflexGraph.color_nodes_by_substring(colors) Color all nodes in a specific color according to a given substring.
deflex.DeflexGraph.group_nodes_by_type([…]) Group all nodes by types returning a dictionary with the types or the name of the types as keys and the list of nodes as value.

Analyse cycles

deflex.Cycles(results[, storages, lines, digits]) Detect all simple cycles in the directed graph.
deflex.Cycles.cycles Get all cycles of the model.
deflex.Cycles.used_cycles Get all cycles from a list of cycles that are used.
deflex.Cycles.suspicious_cycles Get all cycles from a list of cycles that are suspicious.
deflex.Cycles.get_suspicious_time_steps() Detect the time steps of a cycle in which all flows are non-zero.
deflex.Cycles.print() Print an overview of the cycles.
deflex.Cycles.details() Print out a more detailed overview over the existing cycles.

Basic results processing

deflex.get_all_results(results) Get all results from a computed deflex scenario.
deflex.nodes2table(results[, no_sums]) Get a table with all nodes as a MultiIndex with the sum of their in an out flows.
deflex.solver_results2series(results) Get the meta results from the solver.
deflex.fetch_dual_results(results[, bus, …]) Collect all the results of the dual variables.
deflex.meta_results2series(results) Get meta results as a pandas.Series
deflex.get_time_index(results) Get the time index of the model.
deflex.calculate_key_values(results[, …]) Get time series of typical key values.

Advanced results processing

deflex.group_buses(buses, fields) Group buses by parts of the label.
deflex.fetch_converter_parameters(results, …) Fetch relevant parameters of every Transformer of the energy system.
deflex.fetch_attributes_of_commodity_sources(results) Get the attributes of the commodity sources.
deflex.get_combined_bus_balance(results[, …]) Combine different buses of the same type.
deflex.get_converter_balance(results[, cat, …]) Get the balance around the converters of the system.

Tools for Electricity models

deflex.merit_order_from_scenario(scenario[, …]) Create a merit order from a deflex scenario.
deflex.merit_order_from_results(result) Create a merit order from deflex results.

Geometry examples for plotting

deflex.deflex_geo(rmap) Fetch default deflex geometries as a named tuple with the following fields:
deflex.divide_off_and_onshore(regions) Sort regions into onshore and offshore regions (Germany).

General tools

deflex.dict2file(tables, path[, filetype, …])
param tables:

CHP allocation tools

deflex.allocate_fuel_deflex(method, eta_e, …) Allocate the fuel input of chp plants to the two output flows.
deflex.allocate_fuel(method, eta_e, eta_th, …) Allocate the fuel input of chp plants to the two output flows: heat and electricity.
deflex.efficiency_method(eta_e, eta_th) Efficiency Method - a method to allocate the fuel input of chp plants to the two output flows: heat and electricity
deflex.exergy_method(eta_e, eta_th, eta_c) Exergy Method or Carnot Method- a method to allocate the fuel input of chp plants to the two output flows: heat and electricity
deflex.finnish_method(eta_e, eta_th, …) Alternative Generation or Finnish Method - a method to allocate the fuel input of chp plants to the two output flows: heat and electricity
deflex.iea_method(eta_e, eta_th) IEA Method (International Energy Association - a method to allocate the fuel input of chp plants to the two output flows: heat and electricity