-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# :copyright (c) URBANopt, Alliance for Sustainable Energy, LLC, and other contributors. | ||
# See also https://github.com/urbanopt/geojson-modelica-translator/blob/develop/LICENSE.md | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from geojson_modelica_translator.geojson.urbanopt_geojson import UrbanOptGeoJson | ||
from geojson_modelica_translator.model_connectors.couplings.coupling import Coupling | ||
from geojson_modelica_translator.model_connectors.couplings.graph import CouplingGraph | ||
from geojson_modelica_translator.model_connectors.districts.district import District | ||
from geojson_modelica_translator.model_connectors.load_connectors.time_series import TimeSeries | ||
from geojson_modelica_translator.model_connectors.networks.ground_coupling import GroundCoupling | ||
from geojson_modelica_translator.model_connectors.networks.network_distribution_pump import NetworkDistributionPump | ||
from geojson_modelica_translator.model_connectors.plants.borefield import Borefield | ||
from geojson_modelica_translator.system_parameters.system_parameters import SystemParameters | ||
from tests.base_test_case import TestCaseBase | ||
|
||
|
||
class DistrictSystemTest(TestCaseBase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
project_name = "district_multi_ghe" | ||
self.data_dir, self.output_dir = self.set_up(Path(__file__).parent, project_name) | ||
|
||
# load in the example geojson with multiple buildings | ||
filename = Path.home() / "github" / "test_ghe" / "exportGeo.json" | ||
self.gj = UrbanOptGeoJson(filename) | ||
|
||
# load system parameter data | ||
filename = Path.home() / "github" / "test_ghe" / "sys_param.json" | ||
sys_params = SystemParameters(filename) | ||
|
||
# create ambient water stub | ||
ambient_water_stub = NetworkDistributionPump(sys_params) | ||
|
||
# create ground coupling | ||
ground_coupling = GroundCoupling(sys_params) | ||
|
||
# create the couplings and graph | ||
all_couplings = [] | ||
for geojson_load in self.gj.buildings: | ||
# create the building time series load | ||
time_series_load = TimeSeries(sys_params, geojson_load) | ||
# couple each time series load to the thermal loop | ||
all_couplings.append(Coupling(time_series_load, ambient_water_stub, district_type="5G")) | ||
for ghe in sys_params.get_param("$.district_system.fifth_generation.ghe_parameters.ghe_specific_params"): | ||
# create borefields | ||
borefield = Borefield(sys_params, ghe) | ||
# couple each borefield to the thermal loop | ||
all_couplings.append(Coupling(borefield, ambient_water_stub, district_type="5G")) | ||
all_couplings.append(Coupling(ambient_water_stub, ambient_water_stub, district_type="5G")) | ||
all_couplings.append(Coupling(ground_coupling, borefield, district_type="5G")) | ||
|
||
graph = CouplingGraph(all_couplings) | ||
|
||
self.district = District( | ||
root_dir=self.output_dir, | ||
project_name=project_name, | ||
system_parameters=sys_params, | ||
geojson_file=self.gj, | ||
coupling_graph=graph, | ||
) | ||
|
||
self.district.to_modelica() | ||
|
||
def test_build_district_system(self): | ||
root_path = Path(self.district._scaffold.districts_path.files_dir).resolve() | ||
assert (root_path / "DistrictEnergySystem.mo").exists() | ||
|
||
@pytest.mark.simulation() | ||
def test_simulate_district_system(self): | ||
self.run_and_assert_in_docker( | ||
f"{self.district._scaffold.project_name}.Districts.DistrictEnergySystem", | ||
run_path=self.district._scaffold.project_path, | ||
file_to_load=self.district._scaffold.package_path, | ||
) |