move assumptions into configuration.ini
This commit is contained in:
parent
d073f0265e
commit
d7b24eba41
|
@ -1,7 +1,7 @@
|
||||||
from city_model_structure.thermal_opening import ThermalOpening
|
from city_model_structure.thermal_opening import ThermalOpening
|
||||||
from city_model_structure.surface import Surface
|
from city_model_structure.surface import Surface
|
||||||
from city_model_structure.layer import Layer
|
from city_model_structure.layer import Layer
|
||||||
import helpers.assumptions as assumptions
|
from helpers.configuration import Configuration
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ class ThermalBoundary:
|
||||||
@property
|
@property
|
||||||
def u_value(self):
|
def u_value(self):
|
||||||
if self._u_value is None:
|
if self._u_value is None:
|
||||||
h_i = assumptions.h_i
|
h_i = Configuration().h_i
|
||||||
h_e = assumptions.h_e
|
h_e = Configuration().h_e
|
||||||
r_value = 1.0/h_i + 1.0/h_e
|
r_value = 1.0/h_i + 1.0/h_e
|
||||||
try:
|
try:
|
||||||
for layer in self.layers:
|
for layer in self.layers:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import helpers.assumptions as assumptions
|
from helpers.configuration import Configuration
|
||||||
|
|
||||||
|
|
||||||
class ThermalOpening:
|
class ThermalOpening:
|
||||||
|
@ -6,7 +6,7 @@ class ThermalOpening:
|
||||||
self._area = None
|
self._area = None
|
||||||
self._openable_ratio = None
|
self._openable_ratio = None
|
||||||
self._conductivity_w_mk = None
|
self._conductivity_w_mk = None
|
||||||
self._frame_ratio = assumptions.frame_ratio
|
self._frame_ratio = Configuration().frame_ratio
|
||||||
self._g_value = None
|
self._g_value = None
|
||||||
self._thickness_m = None
|
self._thickness_m = None
|
||||||
self._inside_reflectance = None
|
self._inside_reflectance = None
|
||||||
|
@ -81,8 +81,8 @@ class ThermalOpening:
|
||||||
def u_value(self):
|
def u_value(self):
|
||||||
if self._u_value is None:
|
if self._u_value is None:
|
||||||
try:
|
try:
|
||||||
h_i = assumptions.h_i
|
h_i = Configuration().h_i
|
||||||
h_e = assumptions.h_e
|
h_e = Configuration().h_e
|
||||||
r_value = 1 / h_i + 1 / h_e + float(self.conductivity_w_mk) / float(self.thickness_m)
|
r_value = 1 / h_i + 1 / h_e + float(self.conductivity_w_mk) / float(self.thickness_m)
|
||||||
self._u_value = 1 / r_value
|
self._u_value = 1 / r_value
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
|
7
config/configuration.ini
Normal file
7
config/configuration.ini
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# These values are intended as configurable assumptions
|
||||||
|
[convective_fluxes]
|
||||||
|
h_i = 10 # W/m2K
|
||||||
|
h_e = 25 # W/m2K
|
||||||
|
|
||||||
|
[windows]
|
||||||
|
frame_ratio = 0
|
|
@ -1,9 +0,0 @@
|
||||||
# These values are intended as configurable assumptions
|
|
||||||
# ToDo: these values need to be changed into configurable parameters
|
|
||||||
|
|
||||||
# convective fluxes
|
|
||||||
h_i = 10 # W/m2K
|
|
||||||
h_e = 25 # W/m2K
|
|
||||||
|
|
||||||
# windows' default values
|
|
||||||
frame_ratio = 0
|
|
22
helpers/configuration.py
Normal file
22
helpers/configuration.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import configparser
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration:
|
||||||
|
def __init__(self):
|
||||||
|
base_path = Path().resolve().parent
|
||||||
|
config_file = Path(base_path / 'config/configuration.ini').resolve()
|
||||||
|
self._config = configparser.ConfigParser()
|
||||||
|
self._config.read(config_file)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def h_i(self):
|
||||||
|
return self._config.getfloat('convective_fluxes', 'h_i')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def h_e(self):
|
||||||
|
return self._config.getfloat('convective_fluxes', 'h_e')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def frame_ratio(self):
|
||||||
|
return self._config.getint('windows', 'frame_ratio')
|
|
@ -25,3 +25,20 @@ class TestPhysicsFactory(TestCase):
|
||||||
|
|
||||||
def test_city_with_physics(self):
|
def test_city_with_physics(self):
|
||||||
city = self.get_city_with_physics()
|
city = self.get_city_with_physics()
|
||||||
|
for city_object in city.city_objects:
|
||||||
|
self.assertIsNotNone(city_object.average_storey_height, 'average_storey_height is none')
|
||||||
|
self.assertIsNotNone(city_object.storeys_above_ground, 'storeys_above_ground is none')
|
||||||
|
for thermal_zone in city_object.thermal_zones:
|
||||||
|
self.assertIsNotNone(thermal_zone.effective_thermal_capacity, 'effective_thermal_capacity is none')
|
||||||
|
self.assertIsNotNone(thermal_zone.additional_thermal_bridge_u_value,
|
||||||
|
'additional_thermal_bridge_u_value is none')
|
||||||
|
self.assertIsNotNone(thermal_zone.indirectly_heated_area_ratio, 'indirectly_heated_area_ratio is none')
|
||||||
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_on, 'infiltration_rate_system_on is none')
|
||||||
|
self.assertIsNotNone(thermal_zone.infiltration_rate_system_off, 'infiltration_rate_system_off is none')
|
||||||
|
self.assertIsNotNone(thermal_zone.bounded, 'bounded is none')
|
||||||
|
for thermal_boundary in thermal_zone.bounded:
|
||||||
|
self.assertIsNotNone(thermal_boundary.outside_solar_absorptance, 'outside_solar_absorptance is none')
|
||||||
|
self.assertIsNotNone(thermal_boundary.outside_thermal_absorptance, 'outside_thermal_absorptance is none')
|
||||||
|
self.assertIsNotNone(thermal_boundary.outside_visible_absorptance, 'outside_visible_absorptance is none')
|
||||||
|
self.assertIsNotNone(thermal_boundary.window_ratio, 'window_ratio is none')
|
||||||
|
self.assertIsNotNone(thermal_boundary.layers, 'layers is none')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user