buildyn 1.0.0__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.
- buildyn-1.0.0/LICENSE +21 -0
- buildyn-1.0.0/PKG-INFO +105 -0
- buildyn-1.0.0/README.md +82 -0
- buildyn-1.0.0/buildyn/__init__.py +2 -0
- buildyn-1.0.0/buildyn/buildyn.py +129 -0
- buildyn-1.0.0/buildyn/converter/__init__.py +2 -0
- buildyn-1.0.0/buildyn/converter/converter.py +35 -0
- buildyn-1.0.0/buildyn/converter/converter_function.py +12 -0
- buildyn-1.0.0/buildyn/distributions/__init__.py +1 -0
- buildyn-1.0.0/buildyn/distributions/continuous/__init__.py +2 -0
- buildyn-1.0.0/buildyn/distributions/continuous/continuous_distribution.py +5 -0
- buildyn-1.0.0/buildyn/distributions/continuous/gauss_distribution.py +35 -0
- buildyn-1.0.0/buildyn/distributions/discrete/__init__.py +2 -0
- buildyn-1.0.0/buildyn/distributions/discrete/discrete_distribution.py +10 -0
- buildyn-1.0.0/buildyn/distributions/discrete/random_choice.py +21 -0
- buildyn-1.0.0/buildyn/distributions/distribution.py +13 -0
- buildyn-1.0.0/buildyn/examples/builda/builda_fmu.py +104 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Component_configurator.py +119 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Component_properties_calculator.py +167 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Link_resolver.py +28 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Miscellaneous_handler.py +21 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Model_compatibility_layer.py +42 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/NaiveConverterFunction.py +30 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Nominal_cooling_power_calculator.py +597 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Nominal_heating_power_calculator.py +54 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/RC_Distribution_Configurator.py +80 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/Zone_dimensions_calculator.py +66 -0
- buildyn-1.0.0/buildyn/examples/builda/converter_functions/__init__.py +10 -0
- buildyn-1.0.0/buildyn/fmu.py +345 -0
- buildyn-1.0.0/buildyn/walker/__init__.py +2 -0
- buildyn-1.0.0/buildyn/walker/fixed/__init__.py +2 -0
- buildyn-1.0.0/buildyn/walker/fixed/constant_walker.py +16 -0
- buildyn-1.0.0/buildyn/walker/fixed/poisson_walker.py +57 -0
- buildyn-1.0.0/buildyn/walker/interval_walker.py +32 -0
- buildyn-1.0.0/buildyn/walker/random/__init__.py +2 -0
- buildyn-1.0.0/buildyn/walker/random/ramp_walker.py +31 -0
- buildyn-1.0.0/buildyn/walker/random/random_walker.py +24 -0
- buildyn-1.0.0/buildyn/walker/random/sinusoidal_walker.py +54 -0
- buildyn-1.0.0/buildyn/walker/walker.py +8 -0
- buildyn-1.0.0/buildyn.egg-info/PKG-INFO +105 -0
- buildyn-1.0.0/buildyn.egg-info/SOURCES.txt +46 -0
- buildyn-1.0.0/buildyn.egg-info/dependency_links.txt +1 -0
- buildyn-1.0.0/buildyn.egg-info/requires.txt +14 -0
- buildyn-1.0.0/buildyn.egg-info/top_level.txt +4 -0
- buildyn-1.0.0/notebooks/builda_fmu.py +104 -0
- buildyn-1.0.0/pyproject.toml +35 -0
- buildyn-1.0.0/setup.cfg +4 -0
- buildyn-1.0.0/setup.py +8 -0
buildyn-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Felix Koch, Thomas Krug, Benjamin Tischler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
buildyn-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: buildyn
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Author-email: Felix Koch <felix.koch@th-rosenheim.de>, Thomas Krug <thomas.krug@th-rosenheim.de>
|
|
5
|
+
Requires-Python: ==3.13.*
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: more-itertools==10.6.0
|
|
9
|
+
Requires-Dist: json-five==1.1.2
|
|
10
|
+
Requires-Dist: fmpy==0.3.22
|
|
11
|
+
Requires-Dist: matplotlib==3.10.1
|
|
12
|
+
Requires-Dist: numpy==2.2.4
|
|
13
|
+
Requires-Dist: pandas==2.2.3
|
|
14
|
+
Requires-Dist: plotly==6.0.0
|
|
15
|
+
Requires-Dist: regex==2024.11.6
|
|
16
|
+
Requires-Dist: scipy==1.15.2
|
|
17
|
+
Requires-Dist: ruff==0.1.10
|
|
18
|
+
Requires-Dist: tqdm==4.67.1
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: ruff; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
|
|
24
|
+
[](https://www.python.org/downloads/release/python-3100/)
|
|
25
|
+
[](https://github.com/felixmkoch/buildyn/blob/main/LICENSE)
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
BuilDyn is an open-source free-to-use PyPI package to help simulating Functional Mockup Units (FMU) for buildings. Its primarily use is probing buildings thermal dynamics, randomizing building parameters, and demand-driven building simulation. As this is an open-source project, we encourage users and researchers to contribute with new ideas and directions to follow for future releases!
|
|
30
|
+
|
|
31
|
+
## Setup
|
|
32
|
+
|
|
33
|
+
The only hard requirement for this package is python == 3.13.
|
|
34
|
+
Aside from that, there are two ways to build this package in your environment:
|
|
35
|
+
|
|
36
|
+
### Installation via Pip
|
|
37
|
+
|
|
38
|
+
We distribute the newest version of this package over PyPI.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install buildyn
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Installation from source code
|
|
45
|
+
|
|
46
|
+
Aside from the pip installation, you can also build the newest version of this package from scratch. First, clone this repository.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
git clone https://github.com/felixmkoch/buildyn.git
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
After that, you can pip install this package into your python environemnt using
|
|
53
|
+
```
|
|
54
|
+
pip install .
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Strcture
|
|
58
|
+
|
|
59
|
+
The package has two main classes to consider: FMU and BuilDyn. FMU is a modified and extended wrapper around the FmuSlave from FmPy. BuilDyn enables users full control over variations, walker distributions, and demand-dirven simulation. Multiple functionalities are inspired by [BuilDa](https://github.com/fabianraisch/BuilDa). For further information about the structure we refer to our paper.
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
One general use-case would be the following:
|
|
64
|
+
```python
|
|
65
|
+
from buildyn import FMU
|
|
66
|
+
from buildyn.buildyn import BuilDyn
|
|
67
|
+
from buildyn.walker.random.random_walker import RandomWalker
|
|
68
|
+
from buildyn.walker.interval_walker import IntervalWalker
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
fmu_path = "model1.fmu"
|
|
72
|
+
|
|
73
|
+
start_variables = {
|
|
74
|
+
"weaDat.filNam": "resources/Munich.mos",
|
|
75
|
+
"internalGain.fileName": "resources/NoActivity.txt"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fmu = FMU(fmu_path, init_values=start_variables)
|
|
79
|
+
|
|
80
|
+
observables = ["thermalZone.TAir", "heatingPower"]
|
|
81
|
+
|
|
82
|
+
rw = RandomWalker(min=10, max=500, is_discrete=True)
|
|
83
|
+
iw = IntervalWalker(rw, 900) # 900 is the step size of the walker.
|
|
84
|
+
|
|
85
|
+
buildyn = BuilDyn(fmu, observables=observables)
|
|
86
|
+
|
|
87
|
+
buildyn.add_walker_distribution("heatingPower", iw)
|
|
88
|
+
|
|
89
|
+
print(buildyn.sample_one())
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
To explore all features of BuilDyn, we refer to our notebooks; each of them thematizes one key part.
|
|
93
|
+
|
|
94
|
+
## Citation
|
|
95
|
+
If you are using BuilDyn, consider citing the corresponding paper.
|
|
96
|
+
```
|
|
97
|
+
@inproceedings{
|
|
98
|
+
koch26buildyn,
|
|
99
|
+
title={BuilDyn: Excitation-Driven Data Generation for Building Thermal Dynamics Modeling and Control},
|
|
100
|
+
author={Koch, Felix and Krug, Thomas and Raisch, Fabian and Schäfer, Benjamin and Tischler, Benjamin},
|
|
101
|
+
booktitle={Proceedings of the 17th ACM International Conference on Future and Sustainable Energy Systems}
|
|
102
|
+
year={2026}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
buildyn-1.0.0/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[](https://www.python.org/downloads/release/python-3100/)
|
|
2
|
+
[](https://github.com/felixmkoch/buildyn/blob/main/LICENSE)
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
BuilDyn is an open-source free-to-use PyPI package to help simulating Functional Mockup Units (FMU) for buildings. Its primarily use is probing buildings thermal dynamics, randomizing building parameters, and demand-driven building simulation. As this is an open-source project, we encourage users and researchers to contribute with new ideas and directions to follow for future releases!
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
The only hard requirement for this package is python == 3.13.
|
|
11
|
+
Aside from that, there are two ways to build this package in your environment:
|
|
12
|
+
|
|
13
|
+
### Installation via Pip
|
|
14
|
+
|
|
15
|
+
We distribute the newest version of this package over PyPI.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install buildyn
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Installation from source code
|
|
22
|
+
|
|
23
|
+
Aside from the pip installation, you can also build the newest version of this package from scratch. First, clone this repository.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
git clone https://github.com/felixmkoch/buildyn.git
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
After that, you can pip install this package into your python environemnt using
|
|
30
|
+
```
|
|
31
|
+
pip install .
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Strcture
|
|
35
|
+
|
|
36
|
+
The package has two main classes to consider: FMU and BuilDyn. FMU is a modified and extended wrapper around the FmuSlave from FmPy. BuilDyn enables users full control over variations, walker distributions, and demand-dirven simulation. Multiple functionalities are inspired by [BuilDa](https://github.com/fabianraisch/BuilDa). For further information about the structure we refer to our paper.
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
One general use-case would be the following:
|
|
41
|
+
```python
|
|
42
|
+
from buildyn import FMU
|
|
43
|
+
from buildyn.buildyn import BuilDyn
|
|
44
|
+
from buildyn.walker.random.random_walker import RandomWalker
|
|
45
|
+
from buildyn.walker.interval_walker import IntervalWalker
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
fmu_path = "model1.fmu"
|
|
49
|
+
|
|
50
|
+
start_variables = {
|
|
51
|
+
"weaDat.filNam": "resources/Munich.mos",
|
|
52
|
+
"internalGain.fileName": "resources/NoActivity.txt"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fmu = FMU(fmu_path, init_values=start_variables)
|
|
56
|
+
|
|
57
|
+
observables = ["thermalZone.TAir", "heatingPower"]
|
|
58
|
+
|
|
59
|
+
rw = RandomWalker(min=10, max=500, is_discrete=True)
|
|
60
|
+
iw = IntervalWalker(rw, 900) # 900 is the step size of the walker.
|
|
61
|
+
|
|
62
|
+
buildyn = BuilDyn(fmu, observables=observables)
|
|
63
|
+
|
|
64
|
+
buildyn.add_walker_distribution("heatingPower", iw)
|
|
65
|
+
|
|
66
|
+
print(buildyn.sample_one())
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To explore all features of BuilDyn, we refer to our notebooks; each of them thematizes one key part.
|
|
70
|
+
|
|
71
|
+
## Citation
|
|
72
|
+
If you are using BuilDyn, consider citing the corresponding paper.
|
|
73
|
+
```
|
|
74
|
+
@inproceedings{
|
|
75
|
+
koch26buildyn,
|
|
76
|
+
title={BuilDyn: Excitation-Driven Data Generation for Building Thermal Dynamics Modeling and Control},
|
|
77
|
+
author={Koch, Felix and Krug, Thomas and Raisch, Fabian and Schäfer, Benjamin and Tischler, Benjamin},
|
|
78
|
+
booktitle={Proceedings of the 17th ACM International Conference on Future and Sustainable Energy Systems}
|
|
79
|
+
year={2026}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from buildyn.fmu import FMU
|
|
2
|
+
from typing import Dict
|
|
3
|
+
from buildyn.walker.walker import Walker
|
|
4
|
+
from buildyn.walker.interval_walker import IntervalWalker
|
|
5
|
+
from buildyn.distributions.distribution import Distribution
|
|
6
|
+
from buildyn.distributions.discrete.discrete_distribution import DiscreteDistribution
|
|
7
|
+
|
|
8
|
+
from copy import copy
|
|
9
|
+
import itertools
|
|
10
|
+
|
|
11
|
+
class BuilDyn:
|
|
12
|
+
|
|
13
|
+
def __init__(self,
|
|
14
|
+
fmu: FMU,
|
|
15
|
+
observables: list = []
|
|
16
|
+
):
|
|
17
|
+
|
|
18
|
+
self.variation_distributions: Dict[str, Distribution] = dict()
|
|
19
|
+
|
|
20
|
+
self.walker_distributions: Dict[str, IntervalWalker | DiscreteDistribution] = dict()
|
|
21
|
+
|
|
22
|
+
self.fmu: FMU = fmu
|
|
23
|
+
|
|
24
|
+
self.observables = observables
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_variation_distribution(self, variable: str, distribution: Distribution):
|
|
28
|
+
|
|
29
|
+
self.variation_distributions[variable] = distribution
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def add_walker_distribution(self, variable: str, distribution: IntervalWalker | DiscreteDistribution):
|
|
33
|
+
|
|
34
|
+
self.walker_distributions[variable] = distribution
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def sample_one(self,
|
|
38
|
+
start_time: int = 0,
|
|
39
|
+
stop_time: int = 86_400,
|
|
40
|
+
step_size: int = 900):
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Sample one fmu with random variation
|
|
44
|
+
fmu = self.sample_one_fmu()
|
|
45
|
+
|
|
46
|
+
# Sample the walker from the correpnding walker distributions
|
|
47
|
+
walker: Dict[str, Walker] = dict()
|
|
48
|
+
|
|
49
|
+
for param, walker_dist in self.walker_distributions.items():
|
|
50
|
+
|
|
51
|
+
if isinstance(walker_dist, IntervalWalker):
|
|
52
|
+
|
|
53
|
+
walker[param] = walker_dist
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
walker[param] = walker_dist.sample_one()
|
|
57
|
+
|
|
58
|
+
res = fmu.simulate(
|
|
59
|
+
start_time=start_time,
|
|
60
|
+
stop_time=stop_time,
|
|
61
|
+
step_size=step_size,
|
|
62
|
+
observables=self.observables,
|
|
63
|
+
walker=walker
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return res
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def sample_one_fmu(self):
|
|
70
|
+
|
|
71
|
+
fmu = self.fmu.__copy__()
|
|
72
|
+
|
|
73
|
+
fmu_initial_variables = dict()
|
|
74
|
+
|
|
75
|
+
# Sample the variations from the corresponding distributions
|
|
76
|
+
for param, distirbution in self.variation_distributions.items():
|
|
77
|
+
|
|
78
|
+
variable_value = distirbution.sample_one()
|
|
79
|
+
|
|
80
|
+
fmu_initial_variables[param] = variable_value
|
|
81
|
+
|
|
82
|
+
fmu.set_initial_variables(variables=fmu_initial_variables)
|
|
83
|
+
|
|
84
|
+
return fmu
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sample_all_fmus(self):
|
|
88
|
+
|
|
89
|
+
all_fmus = []
|
|
90
|
+
all_samples = {}
|
|
91
|
+
|
|
92
|
+
# Check if all distributions in this class are Discrete, else it would not be possible to really sample all.
|
|
93
|
+
|
|
94
|
+
for variable, distribution in self.variation_distributions.items():
|
|
95
|
+
|
|
96
|
+
if not isinstance(distribution, DiscreteDistribution):
|
|
97
|
+
|
|
98
|
+
return TypeError(f"Sampling all FMUs in not possible because {distribution.__class__.__name__} is not a discrete distribution.")
|
|
99
|
+
|
|
100
|
+
all_samples[variable] = distribution.sample_all()
|
|
101
|
+
|
|
102
|
+
keys = list(all_samples.keys())
|
|
103
|
+
values = list(all_samples.values())
|
|
104
|
+
|
|
105
|
+
# Making the cartesian product of the sample_all
|
|
106
|
+
for combination in itertools.product(*values):
|
|
107
|
+
|
|
108
|
+
variation_dict = dict(zip(keys, combination))
|
|
109
|
+
|
|
110
|
+
fmu = copy(self.fmu)
|
|
111
|
+
fmu.set_initial_variables(variation_dict)
|
|
112
|
+
|
|
113
|
+
all_fmus.append(fmu)
|
|
114
|
+
|
|
115
|
+
return all_fmus
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from buildyn.converter.converter_function import ConverterFunction
|
|
2
|
+
|
|
3
|
+
class Converter:
|
|
4
|
+
|
|
5
|
+
def __init__(self):
|
|
6
|
+
|
|
7
|
+
self.converter_functions: set[ConverterFunction] = []
|
|
8
|
+
|
|
9
|
+
# For variables that should be used in the variation step of an fmu.
|
|
10
|
+
self.converter_variables: dict[str, str | bool | float | int] = {}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def add_converter_function(self, converter_function: ConverterFunction = None):
|
|
14
|
+
|
|
15
|
+
if not converter_function:
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
self.converter_functions.append(converter_function)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_converter_functions(self) -> list[ConverterFunction]:
|
|
22
|
+
|
|
23
|
+
return self.converter_functions
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def update_converter_variables(self, d: dict[str, str | bool | float | int]):
|
|
27
|
+
|
|
28
|
+
self.converter_variables.update(d)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_converter_variables(self) -> dict[str, str | bool | float | int]:
|
|
32
|
+
|
|
33
|
+
return self.converter_variables
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
|
|
3
|
+
class ConverterFunction(ABC):
|
|
4
|
+
|
|
5
|
+
def __init__(self):
|
|
6
|
+
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def convert(self, var_dict: dict):
|
|
11
|
+
|
|
12
|
+
return NotImplementedError("Function convert not implemented in this ConverterFunction. Please override this method first.")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .distribution import Distribution
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from buildyn.distributions.continuous.continuous_distribution import ContinuousDistribution
|
|
2
|
+
import random
|
|
3
|
+
|
|
4
|
+
class GaussDistribution(ContinuousDistribution):
|
|
5
|
+
|
|
6
|
+
def __init__(self, mu, sigma, min: float = None, max: float = None):
|
|
7
|
+
|
|
8
|
+
super().__init__()
|
|
9
|
+
|
|
10
|
+
self.mu = mu
|
|
11
|
+
self.sigma = sigma
|
|
12
|
+
self.min = min
|
|
13
|
+
self.max = max
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def sample_one(self):
|
|
17
|
+
|
|
18
|
+
# No bounds → return normally
|
|
19
|
+
if self.min is None and self.max is None:
|
|
20
|
+
return random.gauss(self.mu, self.sigma)
|
|
21
|
+
|
|
22
|
+
# Otherwise, keep sampling until value is within bounds
|
|
23
|
+
for _ in range(999):
|
|
24
|
+
value = random.gauss(self.mu, self.sigma)
|
|
25
|
+
|
|
26
|
+
if self.min is not None and value < self.min:
|
|
27
|
+
continue
|
|
28
|
+
if self.max is not None and value > self.max:
|
|
29
|
+
continue
|
|
30
|
+
|
|
31
|
+
return value
|
|
32
|
+
|
|
33
|
+
# We assume that the min-max is near-impossible to hit.
|
|
34
|
+
raise Exception(f"Gauss distribution: Not realistic with min {self.min} and max {self.max}")
|
|
35
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from buildyn.distributions.discrete.discrete_distribution import DiscreteDistribution
|
|
2
|
+
import random
|
|
3
|
+
|
|
4
|
+
class RandomChoiceDistribution(DiscreteDistribution):
|
|
5
|
+
|
|
6
|
+
def __init__(self, choices: list | set):
|
|
7
|
+
|
|
8
|
+
super().__init__()
|
|
9
|
+
|
|
10
|
+
self.choices = choices
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def sample_one(self):
|
|
14
|
+
|
|
15
|
+
return random.choice(self.choices)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def sample_all(self):
|
|
19
|
+
|
|
20
|
+
return self.choices
|
|
21
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from buildyn.converter import Converter
|
|
2
|
+
from buildyn.examples.builda.converter_functions.Component_configurator import Component_configurator
|
|
3
|
+
from buildyn.examples.builda.converter_functions.Link_resolver import Link_resolver
|
|
4
|
+
from buildyn.examples.builda.converter_functions.Miscellaneous_handler import Miscellaneous_handler
|
|
5
|
+
from buildyn.examples.builda.converter_functions.Model_compatibility_layer import Model_compatibility_layer
|
|
6
|
+
from buildyn.examples.builda.converter_functions.Nominal_cooling_power_calculator import Nominal_cooling_power_calculator
|
|
7
|
+
from buildyn.examples.builda.converter_functions.Nominal_heating_power_calculator import Nominal_heating_power_calculator
|
|
8
|
+
from buildyn.examples.builda.converter_functions.RC_Distribution_Configurator import RC_Distribution_Configurator
|
|
9
|
+
from buildyn.examples.builda.converter_functions.Zone_dimensions_calculator import Zone_dimensions_calculator
|
|
10
|
+
from buildyn.examples.builda.converter_functions.Component_properties_calculator import Component_properties_calculator
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Helper function to retrieve the pre-configured BuilDa FMU with all converter functions and default values set.
|
|
14
|
+
def get_configured_builda_fmu(internal_controller: bool = False):
|
|
15
|
+
|
|
16
|
+
converter = Converter()
|
|
17
|
+
|
|
18
|
+
# All the converter functiosn from BuilDa 2.0
|
|
19
|
+
converter_functions = [Link_resolver, Miscellaneous_handler, Model_compatibility_layer, Zone_dimensions_calculator, Component_configurator, RC_Distribution_Configurator, Component_properties_calculator, Nominal_heating_power_calculator, Nominal_cooling_power_calculator]
|
|
20
|
+
|
|
21
|
+
for cf in converter_functions:
|
|
22
|
+
converter.add_converter_function(cf())
|
|
23
|
+
|
|
24
|
+
converter_variables = {
|
|
25
|
+
"zone_length": 9.4125,
|
|
26
|
+
"zone_width": 8,
|
|
27
|
+
"floor_height": 3.04,
|
|
28
|
+
"n_floors": 2,
|
|
29
|
+
"fAWin_south": 0.14056,
|
|
30
|
+
"fAWin_west": 0.14056,
|
|
31
|
+
"fAWin_north": 0.14056,
|
|
32
|
+
"fAWin_east": 0.14056,
|
|
33
|
+
"fATransToAWindow": 0.9,
|
|
34
|
+
"fARoofToAFloor": 1.63612217795485,
|
|
35
|
+
"fAInt": 1.238235294117647,
|
|
36
|
+
"heatCapacity_furniture_per_m2": 2230,
|
|
37
|
+
"UExt": 0.665,
|
|
38
|
+
"heatCapacity_wall": 192000,
|
|
39
|
+
"UFloor": 0.514,
|
|
40
|
+
"heatCapacity_floor": 483840,
|
|
41
|
+
"UInt": 1,
|
|
42
|
+
"heatCapacity_internalWall": 145154,
|
|
43
|
+
"URoof": 0.402,
|
|
44
|
+
"heatCapacity_roof": 81240,
|
|
45
|
+
"UWin": 3.2,
|
|
46
|
+
"thermalZone.gWin": 0.7,
|
|
47
|
+
"heatRecoveryRate": 0,
|
|
48
|
+
"airChangeRate": 0.3,
|
|
49
|
+
"heatingCurve_steepness": 1,
|
|
50
|
+
"relative_heatPump_efficiency": 0.8,
|
|
51
|
+
"internalGainsConvectiveFraction": 0.4,
|
|
52
|
+
"heatingConvectiveFraction": 1,
|
|
53
|
+
"weaDat.fileName": "resources/Munich.mos",
|
|
54
|
+
"internalGain.fileName": "resources/NoActivity.txt",
|
|
55
|
+
"hygienicalWindowOpening.fileName": "resources/no_opening.txt",
|
|
56
|
+
"roomTempLowerSetpoint": 18,
|
|
57
|
+
"roomTempUpperSetpoint": 22,
|
|
58
|
+
#"UseInternalController": 0,
|
|
59
|
+
"extWall_C_distribution": "monolythic",
|
|
60
|
+
"floor_C_distribution": [478800, 5040, 0.001],
|
|
61
|
+
"roof_C_distribution": [22440, 58800, 0.001],
|
|
62
|
+
"extWall_R_distribution": "monolythic",
|
|
63
|
+
"floor_R_distribution": [0.0525, 0.0525, 0.1579, 0.0001],
|
|
64
|
+
"roof_R_distribution": [1.1085, 1.1085, 0.1, 0.0001],
|
|
65
|
+
"intWall_R_distribution": "monolythic",
|
|
66
|
+
"intWall_C_distribution": "monolythic",
|
|
67
|
+
"Rsi_extWall": 0.13333333333333333,
|
|
68
|
+
"Rsi_intWall": 0.13333333333333333,
|
|
69
|
+
"Rsi_floor": 0.17543859649122806,
|
|
70
|
+
"Rsi_roof": 0.1,
|
|
71
|
+
"Rse_extWall": 0.04,
|
|
72
|
+
"Rse_roof": 0.04,
|
|
73
|
+
"Rsi_window": 0.13333333333333333,
|
|
74
|
+
"Rse_window": 0.05,
|
|
75
|
+
"ta_min": None,
|
|
76
|
+
"ti_set": None
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Set the converter variables in the converter. This also updates previously set variables.
|
|
80
|
+
converter.update_converter_variables(converter_variables)
|
|
81
|
+
|
|
82
|
+
from buildyn import FMU
|
|
83
|
+
import json
|
|
84
|
+
|
|
85
|
+
# Example FMU from BuilDa 2.0
|
|
86
|
+
fmu_path = "resources/building.fmu"
|
|
87
|
+
|
|
88
|
+
# Initial variables from the BuilDa 2.0 FMU -> Needs extra variables here because the BuilDa FMU is weird. For other use-cases you don't have to do this.
|
|
89
|
+
with open("resources/fmu_state_dict.json", "r") as f:
|
|
90
|
+
start_variables = json.load(f)
|
|
91
|
+
|
|
92
|
+
start_variables.update({
|
|
93
|
+
"weaDat.filNam": "resources/Munich.mos",
|
|
94
|
+
"internalGain.fileName": "resources/NoActivity.txt",
|
|
95
|
+
"hygienicalWindowOpening.fileName": "resources/no_opening.txt",
|
|
96
|
+
"UseInternalController.k": 1 if internal_controller else 0
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
# FMU object from the buil_dyn package
|
|
100
|
+
fmu = FMU(fmu_file=fmu_path, init_values=start_variables)
|
|
101
|
+
|
|
102
|
+
fmu.set_converter(converter=converter)
|
|
103
|
+
|
|
104
|
+
return fmu
|