flixopt 1.0.12__py3-none-any.whl → 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of flixopt might be problematic. Click here for more details.

Files changed (73) hide show
  1. docs/examples/00-Minimal Example.md +5 -0
  2. docs/examples/01-Basic Example.md +5 -0
  3. docs/examples/02-Complex Example.md +10 -0
  4. docs/examples/03-Calculation Modes.md +5 -0
  5. docs/examples/index.md +5 -0
  6. docs/faq/contribute.md +49 -0
  7. docs/faq/index.md +3 -0
  8. docs/images/architecture_flixOpt-pre2.0.0.png +0 -0
  9. docs/images/architecture_flixOpt.png +0 -0
  10. docs/images/flixopt-icon.svg +1 -0
  11. docs/javascripts/mathjax.js +18 -0
  12. docs/release-notes/_template.txt +32 -0
  13. docs/release-notes/index.md +7 -0
  14. docs/release-notes/v2.0.0.md +93 -0
  15. docs/release-notes/v2.0.1.md +12 -0
  16. docs/user-guide/Mathematical Notation/Bus.md +33 -0
  17. docs/user-guide/Mathematical Notation/Effects, Penalty & Objective.md +132 -0
  18. docs/user-guide/Mathematical Notation/Flow.md +26 -0
  19. docs/user-guide/Mathematical Notation/LinearConverter.md +21 -0
  20. docs/user-guide/Mathematical Notation/Piecewise.md +49 -0
  21. docs/user-guide/Mathematical Notation/Storage.md +44 -0
  22. docs/user-guide/Mathematical Notation/index.md +22 -0
  23. docs/user-guide/Mathematical Notation/others.md +3 -0
  24. docs/user-guide/index.md +124 -0
  25. {flixOpt → flixopt}/__init__.py +5 -2
  26. {flixOpt → flixopt}/aggregation.py +113 -140
  27. flixopt/calculation.py +455 -0
  28. {flixOpt → flixopt}/commons.py +7 -4
  29. flixopt/components.py +630 -0
  30. {flixOpt → flixopt}/config.py +9 -8
  31. {flixOpt → flixopt}/config.yaml +3 -3
  32. flixopt/core.py +970 -0
  33. flixopt/effects.py +386 -0
  34. flixopt/elements.py +534 -0
  35. flixopt/features.py +1042 -0
  36. flixopt/flow_system.py +409 -0
  37. flixopt/interface.py +265 -0
  38. flixopt/io.py +308 -0
  39. flixopt/linear_converters.py +331 -0
  40. flixopt/plotting.py +1340 -0
  41. flixopt/results.py +898 -0
  42. flixopt/solvers.py +77 -0
  43. flixopt/structure.py +630 -0
  44. flixopt/utils.py +62 -0
  45. flixopt-2.0.1.dist-info/METADATA +145 -0
  46. flixopt-2.0.1.dist-info/RECORD +57 -0
  47. {flixopt-1.0.12.dist-info → flixopt-2.0.1.dist-info}/WHEEL +1 -1
  48. flixopt-2.0.1.dist-info/top_level.txt +6 -0
  49. pics/architecture_flixOpt-pre2.0.0.png +0 -0
  50. pics/architecture_flixOpt.png +0 -0
  51. pics/flixopt-icon.svg +1 -0
  52. pics/pics.pptx +0 -0
  53. scripts/gen_ref_pages.py +54 -0
  54. site/release-notes/_template.txt +32 -0
  55. flixOpt/calculation.py +0 -629
  56. flixOpt/components.py +0 -614
  57. flixOpt/core.py +0 -182
  58. flixOpt/effects.py +0 -410
  59. flixOpt/elements.py +0 -489
  60. flixOpt/features.py +0 -942
  61. flixOpt/flow_system.py +0 -351
  62. flixOpt/interface.py +0 -203
  63. flixOpt/linear_converters.py +0 -325
  64. flixOpt/math_modeling.py +0 -1145
  65. flixOpt/plotting.py +0 -712
  66. flixOpt/results.py +0 -563
  67. flixOpt/solvers.py +0 -21
  68. flixOpt/structure.py +0 -733
  69. flixOpt/utils.py +0 -134
  70. flixopt-1.0.12.dist-info/METADATA +0 -174
  71. flixopt-1.0.12.dist-info/RECORD +0 -29
  72. flixopt-1.0.12.dist-info/top_level.txt +0 -3
  73. {flixopt-1.0.12.dist-info → flixopt-2.0.1.dist-info/licenses}/LICENSE +0 -0
flixOpt/utils.py DELETED
@@ -1,134 +0,0 @@
1
- """
2
- This module contains several utility functions used throughout the flixOpt framework.
3
- """
4
-
5
- import logging
6
- from typing import Any, Dict, List, Literal, Optional, Union
7
-
8
- import numpy as np
9
-
10
- logger = logging.getLogger('flixOpt')
11
-
12
-
13
- def as_vector(value: Union[int, float, np.ndarray, List], length: int) -> np.ndarray:
14
- """
15
- Macht aus Skalar einen Vektor. Vektor bleibt Vektor.
16
- -> Idee dahinter: Aufruf aus abgespeichertem Vektor schneller, als für jede i-te Gleichung zu Checken ob Vektor oder Skalar)
17
-
18
- Parameters
19
- ----------
20
-
21
- aValue: skalar, list, np.array
22
- aLen : skalar
23
- """
24
- # dtype = 'float64' # -> muss mit übergeben werden, sonst entstehen evtl. int32 Reihen (dort ist kein +/-inf möglich)
25
- # TODO: as_vector() -> int32 Vektoren möglich machen
26
-
27
- # Wenn Skalar oder None, return directly as array
28
- if value is None:
29
- return np.array([None] * length)
30
- if np.isscalar(value):
31
- return np.ones(length) * value
32
-
33
- if len(value) != length: # Wenn Vektor nicht richtige Länge
34
- raise Exception(f'error in changing to {length=}; vector has already {len(value)=}')
35
-
36
- if isinstance(value, np.ndarray):
37
- return value
38
- else:
39
- return np.array(value)
40
-
41
-
42
- def is_number(number_alias: Union[int, float, str]):
43
- """Returns True is string is a number."""
44
- try:
45
- float(number_alias)
46
- return True
47
- except ValueError:
48
- return False
49
-
50
-
51
- def check_time_series(label: str, time_series: np.ndarray[np.datetime64]):
52
- # check sowohl für globale Zeitreihe, als auch für chosenIndexe:
53
-
54
- # Zeitdifferenz:
55
- # zweites bis Letztes - erstes bis Vorletztes
56
- dt = time_series[1:] - time_series[0:-1]
57
- # dt_in_hours = dt.total_seconds() / 3600
58
- dt_in_hours = dt / np.timedelta64(1, 'h')
59
-
60
- # unterschiedliche dt:
61
- if np.max(dt_in_hours) - np.min(dt_in_hours) != 0:
62
- logger.warning(f'{label}: !! Achtung !! unterschiedliche delta_t von {min(dt)} h bis {max(dt)} h')
63
- # negative dt:
64
- if np.min(dt_in_hours) < 0:
65
- raise Exception(label + ': Zeitreihe besitzt Zurücksprünge - vermutlich Zeitumstellung nicht beseitigt!')
66
-
67
-
68
- def apply_formating(
69
- data_dict: Dict[str, Union[int, float]],
70
- key_format: str = '<17',
71
- value_format: str = '>10.2f',
72
- indent: int = 0,
73
- sort_by: Optional[Literal['key', 'value']] = None,
74
- ) -> str:
75
- if sort_by == 'key':
76
- sorted_keys = sorted(data_dict.keys(), key=str.lower)
77
- elif sort_by == 'value':
78
- sorted_keys = sorted(data_dict, key=lambda k: data_dict[k], reverse=True)
79
- else:
80
- sorted_keys = data_dict.keys()
81
-
82
- lines = [f'{indent * " "}{key:{key_format}}: {data_dict[key]:{value_format}}' for key in sorted_keys]
83
- return '\n'.join(lines)
84
-
85
-
86
- def label_is_valid(label: str) -> bool:
87
- """Function to make sure '__' is reserved for internal splitting of labels"""
88
- if label.startswith('_') or label.endswith('_') or '__' in label:
89
- return False
90
- return True
91
-
92
-
93
- def convert_numeric_lists_to_arrays(
94
- d: Union[Dict[str, Any], List[Any], tuple],
95
- ) -> Union[Dict[str, Any], List[Any], tuple]:
96
- """
97
- Recursively converts all lists of numeric values in a nested dictionary to numpy arrays.
98
- Handles nested lists, tuples, and dictionaries. Does not alter the original dictionary.
99
- """
100
-
101
- def convert_list_to_array_if_numeric(sequence: Union[List[Any], tuple]) -> Union[np.ndarray, List[Any]]:
102
- """
103
- Converts a Sequence to a numpy array if all elements are numeric.
104
- Recursively processes each element.
105
- Does not alter the original sequence.
106
- Returns an empty list if the sequence is empty.
107
- """
108
- # Check if the list is empty
109
- if len(sequence) == 0:
110
- return []
111
- # Check if all elements are numeric in the list
112
- elif isinstance(sequence, list) and all(isinstance(item, (int, float)) for item in sequence):
113
- return np.array(sequence)
114
- else:
115
- return [
116
- convert_numeric_lists_to_arrays(item) if isinstance(item, (dict, list, tuple)) else item
117
- for item in sequence
118
- ]
119
-
120
- if isinstance(d, dict):
121
- d_copy = {} # Reconstruct the dict from ground up to not modify the original dictionary.'
122
- for key, value in d.items():
123
- if isinstance(value, (list, tuple)):
124
- d_copy[key] = convert_list_to_array_if_numeric(value)
125
- elif isinstance(value, dict):
126
- d_copy[key] = convert_numeric_lists_to_arrays(value) # Recursively process nested dictionaries
127
- else:
128
- d_copy[key] = value
129
- return d_copy
130
- elif isinstance(d, (list, tuple)):
131
- # If the input itself is a list or tuple, process it as a sequence
132
- return convert_list_to_array_if_numeric(d)
133
- else:
134
- return d
@@ -1,174 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: flixopt
3
- Version: 1.0.12
4
- Summary: Vector based energy and material flow optimization framework in Python.
5
- Author-email: "Chair of Building Energy Systems and Heat Supply, TU Dresden" <peter.stange@tu-dresden.de>, Felix Bumann <felixbumann387@gmail.com>, Felix Panitz <baumbude@googlemail.com>, Peter Stange <peter.stange@tu-dresden.de>
6
- Maintainer-email: Felix Bumann <felixbumann387@gmail.com>, Peter Stange <peter.stange@tu-dresden.de>
7
- License: MIT License
8
- Project-URL: homepage, https://tu-dresden.de/ing/maschinenwesen/iet/gewv/forschung/forschungsprojekte/flixopt
9
- Project-URL: repository, https://github.com/flixOpt/flixopt
10
- Keywords: optimization,energy systems,numerical analysis
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Classifier: Intended Audience :: Developers
17
- Classifier: Intended Audience :: Science/Research
18
- Classifier: Topic :: Scientific/Engineering
19
- Classifier: License :: OSI Approved :: MIT License
20
- Requires-Python: <3.13,>=3.10
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: numpy<2,>=1.21.5
24
- Requires-Dist: PyYAML>=6.0
25
- Requires-Dist: Pyomo>=6.4.2
26
- Requires-Dist: rich>=13.0.1
27
- Requires-Dist: highspy>=1.5.3
28
- Requires-Dist: pandas<3,>=2
29
- Requires-Dist: matplotlib>=3.5.2
30
- Requires-Dist: plotly>=5.15
31
- Requires-Dist: tomli>=2.0.1
32
- Provides-Extra: dev
33
- Requires-Dist: pytest; extra == "dev"
34
- Requires-Dist: ruff; extra == "dev"
35
- Requires-Dist: pyvis==0.3.1; extra == "dev"
36
- Requires-Dist: tsam>=2.3.1; extra == "dev"
37
- Provides-Extra: full
38
- Requires-Dist: pyvis==0.3.1; extra == "full"
39
- Requires-Dist: tsam>=2.3.1; extra == "full"
40
-
41
- # flixOpt: Energy and Material Flow Optimization Framework
42
-
43
- **flixOpt** is a Python-based optimization framework designed to tackle energy and material flow problems using mixed-integer linear programming (MILP). Combining flexibility and efficiency, it provides a powerful platform for both dispatch and investment optimization challenges.
44
-
45
- ---
46
-
47
- ## 🚀 Introduction
48
-
49
- flixOpt was developed by [TU Dresden](https://github.com/gewv-tu-dresden) as part of the SMARTBIOGRID project, funded by the German Federal Ministry for Economic Affairs and Energy (FKZ: 03KB159B). Building on the Matlab-based flixOptMat framework (developed in the FAKS project), flixOpt also incorporates concepts from [oemof/solph](https://github.com/oemof/oemof-solph).
50
-
51
- Although flixOpt is in its early stages, it is fully functional and ready for experimentation. It is used for investment and operation decisions by energy providing companys as well as research institutions. Feedback and collaboration are highly encouraged to help shape its future.
52
-
53
- ---
54
-
55
- ## 📦 Installation
56
-
57
- Install flixOpt directly into your environment using pip. Thanks to [HiGHS](https://github.com/ERGO-Code/HiGHS?tab=readme-ov-file), flixOpt can be used without further setup.
58
- `pip install git+https://github.com/flixOpt/flixopt.git`
59
-
60
- We recommend installing flixOpt with all dependencies, which enables interactive network visualizations by [pyvis](https://github.com/WestHealth/pyvis) and time series aggregation by [tsam](https://github.com/FZJ-IEK3-VSA/tsam).
61
- `pip install "flixOpt[full] @ git+https://github.com/flixOpt/flixopt.git"`
62
-
63
- ---
64
-
65
- ## 🌟 Key Features and Concepts
66
-
67
- ### 💡 High-level Interface...
68
- - flixOpt aims to provide a user-friendly interface for defining and solving energy systems, without sacrificing fine-grained control where necessary.
69
- - This is achieved through a high-level interface with many optional or default parameters.
70
- - The most important concepts are:
71
- - **FlowSystem**: Represents the System that is modeled.
72
- - **Flow**: A Flow represents a stream of matter or energy. In an Energy-System, it could be electricity [kW]
73
- - **Bus**: A Bus represents a balancing node in the Energy-System, typically connecting a demand to a supply.
74
- - **Component**: A Component is a physical entity that consumes or produces matter or energy. It can also transform matter or energy into other kinds of matter or energy.
75
- - **Effect**: Flows and Components can have Effects, related to their usage (or size). Common effects are *costs*, *CO2-emissions*, *primary-energy-demand* or *area-demand*. One Effect is used as the optimization target. The others can be constrained.
76
- - To simplify the modeling process, high-level **Components** (CHP, Boiler, Heat Pump, Cooling Tower, Storage, etc.) are availlable.
77
-
78
- ### 🎛️ ...with low-level control
79
- - **Segmented Linear Correlations**
80
- - Accurate modeling for efficiencies, investment effects, and sizes.
81
- - **On/Off Variables**
82
- - Modeling On/Off-Variables and their constraints.
83
- - On-Hours/Off-Hours
84
- - Consecutive On-Hours/ Off-Hours
85
- - Switch On/Off
86
-
87
- ### 💰 Investment Optimization
88
- - flixOpt combines dispatch optimization with investment optimization in one model.
89
- - Size and/or discrete investment decisions can be modeled
90
- - Investment decisions can be combined with Modeling On/Off-Variables and their constraints
91
-
92
- ### Further Features
93
- - **Multiple Effects**
94
- - Couple effects (e.g., specific CO2 costs) and set constraints (e.g., max CO2 emissions).
95
- - Easily switch between optimization targets (e.g., minimize CO2 or costs).
96
- - This allows to solve questions like "How much does it cost to reduce CO2 emissions by 20%?"
97
-
98
- - **Advanced Time Handling**
99
- - Non-equidistant timesteps supported.
100
- - Energy prices or effects in general can always be defined per hour (or per MWh...)
101
-
102
- - A variety of predefined constraints for operational and investment optimization can be applied.
103
- - Many of these are optional and only applied when necessary, keeping the amount o variables and equations low.
104
-
105
- ---
106
-
107
- ## 🖥️ Usage Example
108
- ![Usage Example](https://github.com/user-attachments/assets/fa0e12fa-2853-4f51-a9e2-804abbefe20c)
109
-
110
- **Plotting examples**:
111
- ![flixOpt plotting](/pics/flixOpt_plotting.jpg)
112
-
113
- ## ⚙️ Calculation Modes
114
-
115
- flixOpt offers three calculation modes, tailored to different performance and accuracy needs:
116
-
117
- - **Full Mode**
118
- - Provides exact solutions with high computational requirements.
119
- - Recommended for detailed analyses and investment decision problems.
120
-
121
- - **Segmented Mode**
122
- - Solving a Model segmentwise, this mode can speed up the solving process for complex systems, while being fairly accurate.
123
- - Utilizes variable time overlap to improve accuracy.
124
- - Not suitable for large storage systems or investment decisions.
125
-
126
- - **Aggregated Mode**
127
- - Automatically generates typical periods using [TSAM](https://github.com/FZJ-IEK3-VSA/tsam).
128
- - Balances speed and accuracy, making it ideal for large-scale simulations.
129
-
130
-
131
- ## 🏗️ Architecture
132
-
133
- - **Minimal coupling to Pyomo**
134
- - Included independent module is used to organize variables and equations, independently of a specific modeling language.
135
- - While currently only working with [Pyomo](http://www.pyomo.org/), flixOpt is designed to work with different modeling languages with minor modifications ([cvxpy](https://www.cvxpy.org)).
136
-
137
- - **File-based Post-Processing Unit**
138
- - Results are saved to .json and .yaml files for easy access and analysis anytime.
139
- - Internal plotting functions utilizing matplotlib, plotly and pandas simplify results visualization and reporting.
140
-
141
- ![Architecture Diagram](/pics/architecture_flixOpt.png)
142
-
143
- ---
144
-
145
- ## 🛠️ Solver Integration
146
-
147
- By default, flixOpt uses the open-source solver [HiGHS](https://highs.dev/) which is installed by default. However, it is compatible with additional solvers such as:
148
-
149
- - [CBC](https://github.com/coin-or/Cbc)
150
- - [GLPK](https://www.gnu.org/software/glpk/)
151
- - [Gurobi](https://www.gurobi.com/)
152
- - [CPLEX](https://www.ibm.com/analytics/cplex-optimizer)
153
-
154
- Executables can be found for example [here for CBC](https://portal.ampl.com/dl/open/cbc/) and [here for GLPK](https://sourceforge.net/projects/winglpk/) (Windows: You have to put solver-executables to the PATH-variable)
155
-
156
- For detailed licensing and installation instructions, refer to the respective solver documentation.
157
-
158
- ---
159
-
160
- ## 📖 Citation
161
-
162
- If you use flixOpt in your research or project, please cite the following:
163
-
164
- - **Main Citation:** [DOI:10.18086/eurosun.2022.04.07](https://doi.org/10.18086/eurosun.2022.04.07)
165
- - **Short Overview:** [DOI:10.13140/RG.2.2.14948.24969](https://doi.org/10.13140/RG.2.2.14948.24969)
166
-
167
- ---
168
-
169
- ## 🔧 Development and Testing
170
-
171
- Run the tests using:
172
-
173
- ```bash
174
- python -m unittest discover -s tests
@@ -1,29 +0,0 @@
1
- flixOpt/__init__.py,sha256=6TKjBgxKAH9jPmyq7kgbl5v7JPswpOG7vkmU_nu0QSM,568
2
- flixOpt/aggregation.py,sha256=e3X1Mf1tYYcMve8TV7X8TGvpHaWWw6K180ShwJgY1uY,18274
3
- flixOpt/calculation.py,sha256=UgxhMEwN5uNQ_BlW8RinBq8d8PvK2kMG_KV9oZkQ8Rw,27565
4
- flixOpt/commons.py,sha256=8eAyWgJJsxiZhlw08p8c6DROo6gUVvYNvWC1gL1HaCg,1170
5
- flixOpt/components.py,sha256=AZ6CqXdsP-V1cTA827Sfw01VLARnjNurHxcOCb5ihh0,27914
6
- flixOpt/config.py,sha256=QyONJ7pBEGwYZYhHiuvsXSIPqBaB7Hptj-q0c5ch6VI,9074
7
- flixOpt/config.yaml,sha256=othy1lY-YFb1DcDc__Ub3QRYMW7W_DI8JQDUYoiCzuU,392
8
- flixOpt/core.py,sha256=46jKUxeJMSeWczv52IOwIyPFaH0m9eMpvYyeWPoACac,7223
9
- flixOpt/effects.py,sha256=InL5OtwuwHVcJaerplqeaDCMmMCw9T08HjuvAc23aTg,17188
10
- flixOpt/elements.py,sha256=HXe_Y89q5rarFR7t8iY75FwW0cTEBNCEFmqvv9wyxOY,21275
11
- flixOpt/features.py,sha256=MzWYY9qDcVVIY4hjxzgEjVZIUB04RFZZlUsbnjOzs5E,44650
12
- flixOpt/flow_system.py,sha256=L0_Ycqn_ypY9ZdWp36YxEcxIuFpj6swuZ_oHkdya314,14668
13
- flixOpt/interface.py,sha256=mIYff3n5egBDZlslFIrcaH1hVjFSK1Ue1po8o0J_uEk,9236
14
- flixOpt/linear_converters.py,sha256=SYW01vxglL3XJT5YWtqCL7DljSULv9nYEmXZEY3n2w8,9040
15
- flixOpt/math_modeling.py,sha256=IIiV-ey2zMxCR_kMYKiUSGHBv8UPYZcmdFXqp6bCUmQ,44580
16
- flixOpt/plotting.py,sha256=scd5A9kdI6H_neYXy2mowX1xd5a_mh2xZYhvBPDnSpY,27328
17
- flixOpt/results.py,sha256=8zCCthlHMiXdOkVXqrJeu_Fk3FASgm3yo-mkvZFFMyY,23651
18
- flixOpt/solvers.py,sha256=sxPO7UWN-uQhRBysL8k94Fh9lCUkKS5CrHjeeidaLaU,372
19
- flixOpt/structure.py,sha256=eyyRtfvaSJUYAg1rmXB07S7Yq9q7GQgssgbEblYF68w,31281
20
- flixOpt/utils.py,sha256=MiAjFomptEKTMJTrCbQCfz_KawGGwGzMcZ1I2uJ6SH8,4879
21
- pics/architecture_flixOpt.png,sha256=9RWSA3vys588aadr2437zor-_-xBTQNQ0bAf8xGcu5g,70605
22
- pics/flixOpt_plotting.jpg,sha256=zn7ZPAtXm5eRTxtOj86e4-PPhHpCar1jqGh7vMBgQGY,518862
23
- pics/pics.pptx,sha256=qoKyHscmFVcsQouk1u5cSOHE0cQB81iSW7hOz3-chZo,46213
24
- tests/ressources/Zeitreihen2020.csv,sha256=kbsDTKZS0iUsNZAS7m3DohzZI_OHHWe44s3GwLvcTLw,1918412
25
- flixopt-1.0.12.dist-info/LICENSE,sha256=HKsZnbrM_3Rvnr_u9cWSG90cBsj5_slaqI_z_qcxnGI,1118
26
- flixopt-1.0.12.dist-info/METADATA,sha256=LEXaB8LXOgPaX98dt5V04aTq-vJ9hdG2-Izxy2ke0Ic,8626
27
- flixopt-1.0.12.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
28
- flixopt-1.0.12.dist-info/top_level.txt,sha256=vJmCV_Cs0sqibC1u7Z4WWpwlh_q7KPwOLWJSZ7C1DrU,19
29
- flixopt-1.0.12.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- flixOpt
2
- pics
3
- tests