deflex.Cycles¶
-
class
deflex.
Cycles
(results, storages=True, lines=True, digits=10)[source]¶ Detect all simple cycles in the directed graph.
Furthermore, get the flows of each cycle as pandas.DataFrame. For a large number of cycles getting the values may take a while so check the simple_cycles attribute first and consider setting storages and lines to False.
Cycles are a list of nodes with a flow between one node and the following node in the list and a flow from the last node of the lsit to the first node. Therefore, the number of nodes equals the number of flows.
Parameters: - results (dict) – A valid deflex results dictionary.
- storages (bool) – Storages are always cycles and you may want to exclude them from the results setting storages=False. Nevertheless, sometimes storages are charged and discharged in one time step, which indicates a modelling problem. To detect such behaviour storages should be True. (default: True)
- lines (bool) – Transmission lines will create multiple cycles especially in models with a high number of regions and line. Setting lines to False will exclude cycles that are caused by lines. Cycles with e.g. an electrolyses in one region and a H2 power plant in another will cause a hydrogen-electricity cycle. In this cycle is a transmission line include but this cycle will not(!) be excluded if lines=False. (default: True)
- digits (int) – To detect used or critical cycles the flows are rounded to avoid a detection for very small flow values. Use digits to define the number of digits to be rounded. A high number will make the detection very sensitive. (default: 10)
-
name
¶ Name of the cycle object.
Type: str
-
simple_cycles
¶ A list of all cycles. Each cycle is a list of nodes.
Type: list of lists
Examples
>>> from deflex import restore_results, fetch_test_files >>> fn = fetch_test_files("de03_fictive.dflx") >>> c = Cycles(restore_results(fn), storages=True, lines=True) >>> len(list(c.simple_cycles)) 9 >>> c = Cycles(restore_results(fn), storages=False, lines=True) >>> len(list(c.simple_cycles)) 7 >>> c = Cycles(restore_results(fn), storages=False, lines=False) >>> len(list(c.simple_cycles)) 2
-
__init__
(results, storages=True, lines=True, digits=10)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(results[, storages, lines, digits])Initialize self. details
()Print out a more detailed overview over the existing cycles. get_suspicious_time_steps
()Detect the time steps of a cycle in which all flows are non-zero. print
()Print an overview of the cycles. Attributes
cycles
Get all cycles of the model. suspicious_cycles
Get all cycles from a list of cycles that are suspicious. used_cycles
Get all cycles from a list of cycles that are used.