DES-sim 1.0.1__tar.gz

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.
des_sim-1.0.1/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT
2
+ BSD-3-Clause
3
+ MIT AND (Apache-2.0 OR BSD-2-Clause)
4
+ MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)
5
+ GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
6
+ LicenseRef-Special-License OR CC0-1.0 OR Unlicense
7
+ LicenseRef-Proprietary
des_sim-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.1
2
+ Name: DES_sim
3
+ Version: 1.0.1
4
+ Author-email: Leroy Tomas <leroy.tomas@hs-offenburg.de>
5
+ License: MIT
6
+ BSD-3-Clause
7
+ MIT AND (Apache-2.0 OR BSD-2-Clause)
8
+ MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)
9
+ GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
10
+ LicenseRef-Special-License OR CC0-1.0 OR Unlicense
11
+ LicenseRef-Proprietary
12
+ Keywords: DES,mosaik,simulation,HP,CHP,PV
13
+ Requires-Python: ==3.10.13
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: setuptools<81
17
+ Requires-Dist: mosaik==3.2.0
18
+ Requires-Dist: mosaik-api==3.0.3
19
+ Requires-Dist: mosaik-api-v3==3.0.9
20
+ Requires-Dist: mosaik-heatpump==1.0.1
21
+ Requires-Dist: mosaik-pv==1.2.1
22
+ Requires-Dist: mosaik-pvlib==1.0
23
+ Requires-Dist: mosaik-csv
24
+ Requires-Dist: pandas
25
+ Requires-Dist: numpy
26
+ Requires-Dist: matplotlib
27
+ Requires-Dist: plotly==5.24.1
28
+ Requires-Dist: nest_asyncio
29
+ Requires-Dist: nbformat==5.10.4
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: flake8; extra == "dev"
33
+ Provides-Extra: opti
34
+ Requires-Dist: ipykernel; extra == "opti"
35
+ Requires-Dist: ipynbname; extra == "opti"
36
+ Requires-Dist: tqdm; extra == "opti"
37
+ Requires-Dist: pyDOE; extra == "opti"
38
+ Provides-Extra: docs
39
+ Requires-Dist: sphinx==7.4.5; extra == "docs"
40
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "docs"
41
+ Requires-Dist: m2r2==0.3.3.post2; extra == "docs"
42
+
43
+ # District Energy System(DES)
44
+
45
+ This project uses the mosaik package to simulate heat pump in conjuction with a CHP unit to meet the heat and electricity demand of a housing district.
46
+
47
+ ## Installation
48
+
49
+ To get started first create a new conda env with:
50
+ conda create --name myenv python=3.10.13
51
+
52
+ Second, activate the environment and install the package:
53
+ conda activate myenv
54
+ pip install .
55
+
56
+ *(If you plan to modify the core models in the `src/` folder, install in editable mode instead using `pip install -e .`)*
57
+
58
+ After that you can run the simulation script from the project root with:
59
+ python main_sim.py
60
+
61
+ *Note: Configuration is pulled from data/inputs/input_params.json, and outputs are saved to data/outputs/.*
62
+
63
+ ### Installing dependencies
64
+ Install the recommended dependencies with:
65
+ ```
66
+ pip install . docs
67
+
68
+ ```
69
+ ## Documentation
70
+
71
+ The documentation for the individual models is available [here](docs/index.md)
72
+
73
+ ## Recommended vscode-extensions
74
+ - GitLens -Git supercharged: Nice graphical git support
75
+ - autopep8: Autoformatting in pep8. Install and press (strg+alt+F)
76
+ - Better Comments: Highlighting of comments syntax
77
+ - Code Spell Checker: Spelling checker
78
+ - Drawio.io Integration: UML-Diagrams, etc. in vs-code
79
+ - Edit csv: Editing csv files like tables in excel
80
+ - Rainbow CSV: Color highlighting in csv files
81
+ - autoDocstring: Python Docstring generator (Generates Docstrings in different styles (Google, sphinx, etc...))
82
+
83
+ ## Note:
84
+ **src** Folder:
85
+ - Do not rename it to "code". It will cause name clashes with the internal python module "code".
@@ -0,0 +1,43 @@
1
+ # District Energy System(DES)
2
+
3
+ This project uses the mosaik package to simulate heat pump in conjuction with a CHP unit to meet the heat and electricity demand of a housing district.
4
+
5
+ ## Installation
6
+
7
+ To get started first create a new conda env with:
8
+ conda create --name myenv python=3.10.13
9
+
10
+ Second, activate the environment and install the package:
11
+ conda activate myenv
12
+ pip install .
13
+
14
+ *(If you plan to modify the core models in the `src/` folder, install in editable mode instead using `pip install -e .`)*
15
+
16
+ After that you can run the simulation script from the project root with:
17
+ python main_sim.py
18
+
19
+ *Note: Configuration is pulled from data/inputs/input_params.json, and outputs are saved to data/outputs/.*
20
+
21
+ ### Installing dependencies
22
+ Install the recommended dependencies with:
23
+ ```
24
+ pip install . docs
25
+
26
+ ```
27
+ ## Documentation
28
+
29
+ The documentation for the individual models is available [here](docs/index.md)
30
+
31
+ ## Recommended vscode-extensions
32
+ - GitLens -Git supercharged: Nice graphical git support
33
+ - autopep8: Autoformatting in pep8. Install and press (strg+alt+F)
34
+ - Better Comments: Highlighting of comments syntax
35
+ - Code Spell Checker: Spelling checker
36
+ - Drawio.io Integration: UML-Diagrams, etc. in vs-code
37
+ - Edit csv: Editing csv files like tables in excel
38
+ - Rainbow CSV: Color highlighting in csv files
39
+ - autoDocstring: Python Docstring generator (Generates Docstrings in different styles (Google, sphinx, etc...))
40
+
41
+ ## Note:
42
+ **src** Folder:
43
+ - Do not rename it to "code". It will cause name clashes with the internal python module "code".
@@ -0,0 +1,57 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools]
6
+ license-files = ["LICENSE"]
7
+
8
+ [tool.setuptools.packages.find]
9
+ where = ["src"]
10
+
11
+ [project]
12
+ name = "DES_sim"
13
+ authors = [{name = "Leroy Tomas", email = "leroy.tomas@hs-offenburg.de"}]
14
+ version = "1.0.1"
15
+ license = {file = "LICENSE"}
16
+ requires-python = "==3.10.13"
17
+ readme = "README.md"
18
+ keywords = ["DES", "mosaik", "simulation", "HP", "CHP", "PV"]
19
+
20
+ # add necessary dependencies of the repo. They can be installed via "pip install ."
21
+ dependencies = [
22
+ "setuptools<81",
23
+ "mosaik==3.2.0",
24
+ "mosaik-api==3.0.3",
25
+ "mosaik-api-v3==3.0.9",
26
+ "mosaik-heatpump==1.0.1",
27
+ "mosaik-pv==1.2.1",
28
+ "mosaik-pvlib==1.0",
29
+ "mosaik-csv",
30
+ "pandas",
31
+ "numpy",
32
+ "matplotlib",
33
+ "plotly==5.24.1",
34
+ "nest_asyncio",
35
+ "nbformat==5.10.4"
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ # add optional dependencies of the repo. They could be installed via "pip install .[dev]"
40
+ dev = [
41
+ "pytest",
42
+ "flake8",
43
+ ]
44
+
45
+ opti = [
46
+ "ipykernel",
47
+ "ipynbname",
48
+ "tqdm",
49
+ "pyDOE"
50
+ ]
51
+
52
+ # add optional dependencies of the repo. They could be installed via "pip install .[docs]"
53
+ docs = [
54
+ "sphinx==7.4.5",
55
+ "sphinx-rtd-theme==2.0.0",
56
+ "m2r2==0.3.3.post2",
57
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.1
2
+ Name: DES_sim
3
+ Version: 1.0.1
4
+ Author-email: Leroy Tomas <leroy.tomas@hs-offenburg.de>
5
+ License: MIT
6
+ BSD-3-Clause
7
+ MIT AND (Apache-2.0 OR BSD-2-Clause)
8
+ MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)
9
+ GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
10
+ LicenseRef-Special-License OR CC0-1.0 OR Unlicense
11
+ LicenseRef-Proprietary
12
+ Keywords: DES,mosaik,simulation,HP,CHP,PV
13
+ Requires-Python: ==3.10.13
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: setuptools<81
17
+ Requires-Dist: mosaik==3.2.0
18
+ Requires-Dist: mosaik-api==3.0.3
19
+ Requires-Dist: mosaik-api-v3==3.0.9
20
+ Requires-Dist: mosaik-heatpump==1.0.1
21
+ Requires-Dist: mosaik-pv==1.2.1
22
+ Requires-Dist: mosaik-pvlib==1.0
23
+ Requires-Dist: mosaik-csv
24
+ Requires-Dist: pandas
25
+ Requires-Dist: numpy
26
+ Requires-Dist: matplotlib
27
+ Requires-Dist: plotly==5.24.1
28
+ Requires-Dist: nest_asyncio
29
+ Requires-Dist: nbformat==5.10.4
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: flake8; extra == "dev"
33
+ Provides-Extra: opti
34
+ Requires-Dist: ipykernel; extra == "opti"
35
+ Requires-Dist: ipynbname; extra == "opti"
36
+ Requires-Dist: tqdm; extra == "opti"
37
+ Requires-Dist: pyDOE; extra == "opti"
38
+ Provides-Extra: docs
39
+ Requires-Dist: sphinx==7.4.5; extra == "docs"
40
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "docs"
41
+ Requires-Dist: m2r2==0.3.3.post2; extra == "docs"
42
+
43
+ # District Energy System(DES)
44
+
45
+ This project uses the mosaik package to simulate heat pump in conjuction with a CHP unit to meet the heat and electricity demand of a housing district.
46
+
47
+ ## Installation
48
+
49
+ To get started first create a new conda env with:
50
+ conda create --name myenv python=3.10.13
51
+
52
+ Second, activate the environment and install the package:
53
+ conda activate myenv
54
+ pip install .
55
+
56
+ *(If you plan to modify the core models in the `src/` folder, install in editable mode instead using `pip install -e .`)*
57
+
58
+ After that you can run the simulation script from the project root with:
59
+ python main_sim.py
60
+
61
+ *Note: Configuration is pulled from data/inputs/input_params.json, and outputs are saved to data/outputs/.*
62
+
63
+ ### Installing dependencies
64
+ Install the recommended dependencies with:
65
+ ```
66
+ pip install . docs
67
+
68
+ ```
69
+ ## Documentation
70
+
71
+ The documentation for the individual models is available [here](docs/index.md)
72
+
73
+ ## Recommended vscode-extensions
74
+ - GitLens -Git supercharged: Nice graphical git support
75
+ - autopep8: Autoformatting in pep8. Install and press (strg+alt+F)
76
+ - Better Comments: Highlighting of comments syntax
77
+ - Code Spell Checker: Spelling checker
78
+ - Drawio.io Integration: UML-Diagrams, etc. in vs-code
79
+ - Edit csv: Editing csv files like tables in excel
80
+ - Rainbow CSV: Color highlighting in csv files
81
+ - autoDocstring: Python Docstring generator (Generates Docstrings in different styles (Google, sphinx, etc...))
82
+
83
+ ## Note:
84
+ **src** Folder:
85
+ - Do not rename it to "code". It will cause name clashes with the internal python module "code".
@@ -0,0 +1,22 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/DES_sim.egg-info/PKG-INFO
5
+ src/DES_sim.egg-info/SOURCES.txt
6
+ src/DES_sim.egg-info/dependency_links.txt
7
+ src/DES_sim.egg-info/requires.txt
8
+ src/DES_sim.egg-info/top_level.txt
9
+ src/des_sim/__init__.py
10
+ src/des_sim/models/3wayvalve.py
11
+ src/des_sim/models/EnTransformer.py
12
+ src/des_sim/models/__init__.py
13
+ src/des_sim/models/battery.py
14
+ src/des_sim/models/boiler_model_v2.py
15
+ src/des_sim/models/chp_model_v2.py
16
+ src/des_sim/models/collector.py
17
+ src/des_sim/models/controller.py
18
+ src/des_sim/models/controller_mosaik.py
19
+ src/des_sim/models/pvlib_model.py
20
+ src/des_sim/utils/__init__.py
21
+ src/des_sim/utils/helpers.py
22
+ src/des_sim/utils/visu_v2_prep.py
@@ -0,0 +1,29 @@
1
+ setuptools<81
2
+ mosaik==3.2.0
3
+ mosaik-api==3.0.3
4
+ mosaik-api-v3==3.0.9
5
+ mosaik-heatpump==1.0.1
6
+ mosaik-pv==1.2.1
7
+ mosaik-pvlib==1.0
8
+ mosaik-csv
9
+ pandas
10
+ numpy
11
+ matplotlib
12
+ plotly==5.24.1
13
+ nest_asyncio
14
+ nbformat==5.10.4
15
+
16
+ [dev]
17
+ pytest
18
+ flake8
19
+
20
+ [docs]
21
+ sphinx==7.4.5
22
+ sphinx-rtd-theme==2.0.0
23
+ m2r2==0.3.3.post2
24
+
25
+ [opti]
26
+ ipykernel
27
+ ipynbname
28
+ tqdm
29
+ pyDOE
@@ -0,0 +1,2 @@
1
+ des_sim
2
+ utils
@@ -0,0 +1 @@
1
+ # Marks the des_sim directory as an importable Python package.
@@ -0,0 +1,132 @@
1
+ import mosaik_api
2
+ from des_sim.utils import helpers
3
+
4
+ class ThreeWayValve():
5
+ '''
6
+ A class representing a three-way valve.
7
+ It takes an input flow and splits it into two output flows based on a defined share.
8
+ The temperature is assumed to be the same for all flows.
9
+ Attributes:
10
+ - flows: A dictionary containing the input and output flows.
11
+ - out1_share: The fraction of the input flow that goes to output 1. Could be preset in the params, or also dynamically assigned by another entity.
12
+ - out2_share(optional) : The fraction of the input flow that goes to output 2. If provided, out1_share is adjusted accordingly.
13
+
14
+ '''
15
+ def __init__(self, params={}):
16
+
17
+ self.flows = {
18
+ 'in' : 0,
19
+ 'out_1' : 0,
20
+ 'out_2' : 0,
21
+ 'temp' : 0
22
+ }
23
+ self.out1_share = params.get('out1_share', 0.5) # how much of the input flow goes to out_1
24
+ if 'out2_share' in params.keys():
25
+ self.out1_share = 1 - params.get('out2_share')
26
+
27
+
28
+ def step(self, time):
29
+
30
+ self.flows['out_1'] = self.flows['in'] * self.out1_share
31
+ self.flows['out_2'] = self.flows['in'] * (1 - self.out1_share)
32
+
33
+ def get_init_attrs(self):
34
+ '''
35
+ Simply returns a list of all user defined attributes in this class.
36
+ Useful to add to the attrs list in META.
37
+ '''
38
+ attr_list = helpers.flatten_attrs(self, list(vars(self).keys()))
39
+ return attr_list
40
+
41
+ #-------------------------Mosaik Back-end-------------------------------
42
+ META = {
43
+ 'type': 'time-based',
44
+ 'models': {
45
+ 'Valve': {
46
+ 'public': True,
47
+ 'params': ['params'],
48
+ 'attrs': ['status'],
49
+ },
50
+ },
51
+ }
52
+
53
+ class SimInterface(mosaik_api.Simulator):
54
+ def __init__(self):
55
+
56
+ super().__init__(META)
57
+ self.time_resolution = None
58
+ self.models = dict() # contains the model instances
59
+ self.sid = None
60
+ self.step_size = None
61
+ self.eid_prefix = None
62
+ self.time = 0
63
+
64
+
65
+ def init(self, sid, time_resolution, step_size, params, same_time_loop=False):
66
+ self.time_resolution = float(time_resolution)
67
+ if self.time_resolution != 1.0:
68
+ print('WARNING: %s got a time_resolution other than 1.0, which \
69
+ can not be handled by this simulator.', sid)
70
+ self.sid = sid # simulator id
71
+ self.step_size = step_size
72
+ if same_time_loop:
73
+ self.meta['type'] = 'event-based'
74
+
75
+ self.eid_prefix = params.get('eid_prefix')
76
+
77
+ self.dummy_object = ThreeWayValve(params)
78
+ self.meta['models']['Valve']['attrs'] = self.dummy_object.get_init_attrs()
79
+ # self.meta['models']['Transformer']['trigger'] = self.dummy_object.get_init_attrs()
80
+
81
+ return self.meta
82
+
83
+ def create(self, num, model, params):
84
+ entities = []
85
+
86
+ next_eid = len(self.models) #if create called a second time, eid will not repeat
87
+ for i in range(next_eid, next_eid + num):
88
+ eid = '%s%d' % (self.eid_prefix, i)
89
+ self.models[eid] = ThreeWayValve(params)
90
+ entities.append({'eid': eid, 'type': model})
91
+ return entities
92
+
93
+ def step(self, time, inputs, max_advance):
94
+ for eid, attrs in inputs.items():
95
+ if self.meta['type'] == 'event-based':
96
+ if time != self.time:
97
+ self.time = time
98
+ setattr(self.models[eid], 'step_executed', False)
99
+ for attr, src_ids in attrs.items():
100
+ if len(src_ids) > 1:
101
+ raise ValueError('Too many inputs for attribute %s' % attr)
102
+ for val in src_ids.values():
103
+ helpers.set_nested_attr(self.models[eid], attr, val)
104
+
105
+ self.models[eid].step_size = self.step_size
106
+
107
+ for eid, model in self.models.items():
108
+ model.step(time)
109
+
110
+ if self.meta['type'] == 'event-based':
111
+ return None
112
+ else:
113
+ return time + self.step_size
114
+
115
+ def get_data(self, outputs):
116
+ data = {}
117
+ for eid, attrs in outputs.items():
118
+ data[eid] = {}
119
+ for attr in attrs:
120
+ if attr not in self.meta['models']['Valve'][
121
+ 'attrs']:
122
+ raise ValueError('Unknown output attribute: %s' % attr)
123
+ data['time'] = self.time
124
+ data[eid][attr] = helpers.get_nested_attr(self.models[eid], attr)
125
+
126
+ return data
127
+
128
+ def main():
129
+ return mosaik_api.start_simulation(SimInterface())
130
+
131
+ if __name__ == '__main__':
132
+ main()