Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing borefield test breaks due to schema changes #550

Merged
merged 61 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
72e354f
Add redeclaration of allowFlowReverseSer=true
JingWang-CUB Mar 15, 2023
8e62c40
Inital implementation of district system template with single GHE
JingWang-CUB Mar 15, 2023
dc09f1c
Add modified GroundTemperatureResponse class to overwrite MBL
JingWang-CUB Mar 15, 2023
af80dd7
Initial implementation of OneUTube and PartialBorefield templates
JingWang-CUB Mar 15, 2023
2ef633c
Fix bug of inconsistent template name and Modelica class name of Buil…
JingWang-CUB Mar 15, 2023
7bfb5b0
Update system template, removed temperature sensors
JingWang-CUB Mar 15, 2023
2c65be7
District energy test file that has multiple buildings
JingWang-CUB Mar 15, 2023
adf2ad6
Add comment and test version control with VSCode
JingWang-CUB Mar 22, 2023
243ca2d
Add declaration of borefield data parameters
JingWang-CUB Mar 22, 2023
78d5a57
Add template for TwoUTubes borefield
JingWang-CUB Mar 22, 2023
82366c6
Remove unneeded mo files
JingWang-CUB Mar 22, 2023
7883d79
Modify input field names based on schema
JingWang-CUB Mar 22, 2023
da955ce
Change within statement
JingWang-CUB Mar 22, 2023
a714748
Initial implementation of borefield.py
JingWang-CUB Mar 22, 2023
da3ce53
Conversion of shank spacing
JingWang-CUB Mar 23, 2023
9c4dd19
Merge branch 'develop' of https://github.com/urbanopt/geojson-modelic…
JingWang-CUB Mar 29, 2023
028214e
Modify shank spacing conversion
JingWang-CUB Mar 29, 2023
37ad838
Remove unneeded mo file
JingWang-CUB Mar 29, 2023
56ceae8
Minor changes to model_name
JingWang-CUB Mar 29, 2023
6b67802
Add system template for testing borefield template
JingWang-CUB Mar 29, 2023
4643d02
Initial implementation of borefield test
JingWang-CUB Mar 29, 2023
9eca55b
Move ghe system parameter files to right location
JingWang-CUB Mar 29, 2023
d12a267
Take out SingleGHE system template for now
JingWang-CUB Mar 29, 2023
d9d2ddb
Change within statement
JingWang-CUB Mar 29, 2023
83afc6a
Initial implementation of borefield coupling
JingWang-CUB Mar 29, 2023
d1b68e2
Add code to point to BorefieldSystem.mot
JingWang-CUB Mar 29, 2023
803b120
Remove duplicated test script
JingWang-CUB Mar 29, 2023
2e37b66
Rename package
JingWang-CUB Apr 5, 2023
fe04859
Add {%endraw%} at the end
JingWang-CUB Apr 5, 2023
5e9eb26
Add input fields needed for the test
JingWang-CUB Apr 5, 2023
4a067da
Debugging changes
JingWang-CUB Apr 5, 2023
cee7a57
Add borefield_instance.mopt
JingWang-CUB Apr 11, 2023
573800d
Changes for debugging, now the test passes
JingWang-CUB Apr 11, 2023
155c160
Add borehole_length to example system params file
JingWang-CUB Apr 12, 2023
1b1dacf
Debug PartialBorefield.mot, it passes check
JingWang-CUB Apr 12, 2023
62ae2c5
Change coupling definitions
JingWang-CUB Apr 12, 2023
6522be0
Minor changes
JingWang-CUB Apr 12, 2023
e3561ae
Remove partial template models
JingWang-CUB Apr 12, 2023
416bbcd
Add sample g-function and path
JingWang-CUB Apr 12, 2023
396767a
Merge branch 'develop' into issue511_ghe_templates
JingWang-CUB Apr 19, 2023
7116fac
Reverting 3 system params files
JingWang-CUB Apr 19, 2023
867addd
Merge branch 'issue511_ghe_templates' of https://github.com/urbanopt/…
JingWang-CUB Apr 19, 2023
21b27bb
pre-commit now with more modelica-fmt
vtnate Apr 19, 2023
8751cb1
Apply uniform 5G district system template
JingWang-CUB Apr 26, 2023
fdd4c17
Remove unused GHE district template
JingWang-CUB Apr 26, 2023
c86c137
Fix for non-ghe 5G districts
JingWang-CUB Apr 26, 2023
f5174b6
Resolved merge conflicts with develop branch
JingWang-CUB May 17, 2023
c1c97b4
Delete sys_param files not needed
JingWang-CUB May 17, 2023
c670076
Replace Gfunction input with csv file
JingWang-CUB May 24, 2023
4ec2e13
Point to the right sys_param file
JingWang-CUB May 24, 2023
bff713e
Updated template to reflect schema changes
JingWang-CUB May 24, 2023
01a60c4
Changes for the test to run
JingWang-CUB May 24, 2023
b2c8b22
Fix backslashes
JingWang-CUB May 24, 2023
13019c1
Change to adapt to recent commits
JingWang-CUB May 24, 2023
e513754
Temporary fixes to make the test pass
JingWang-CUB May 24, 2023
9816f52
Change ghe_dir to relative path
JingWang-CUB May 30, 2023
dcada95
Use pathlib to handle ghe_dir
JingWang-CUB May 30, 2023
cbde3f7
Add if statement to avoid breaking other 5G tests
JingWang-CUB May 31, 2023
88a9188
Change due to schema change
JingWang-CUB May 31, 2023
f9963be
Pre-commit changes
JingWang-CUB May 31, 2023
f80d740
Fix bug
JingWang-CUB May 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Borefield ambient coupling connections
connect(supHeaWat.ports[1], {{ coupling.plant.id }}.port_a)
connect(supHeaWat_{{ sys_params.num_buildings }}.ports[1], {{ coupling.plant.id }}.port_a)
{% raw %}annotation (Line(points={{-70,10},{-10,10}}, color={0,127,255}));
{% endraw %}connect({{ coupling.plant.id }}.port_b, sinHeaWat.ports[1])
{% raw %}annotation (Line(points={{10,10},{60,10}}, color={0,127,255}));
Expand Down
4 changes: 2 additions & 2 deletions geojson_modelica_translator/model_connectors/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, system_parameters, template_dir):
district_params = self.system_parameters.get_param("district_system")
if 'fifth_generation' in district_params:
self.district_template_data = {
"temp_setpoint_hhw": district_params['fifth_generation']['central_heating_plant_parameters']['temp_setpoint_hhw'],
"temp_setpoint_chw": district_params['fifth_generation']['central_cooling_plant_parameters']['temp_setpoint_chw'],
# "temp_setpoint_hhw": district_params['fifth_generation']['central_heating_plant_parameters']['temp_setpoint_hhw'],
# "temp_setpoint_chw": district_params['fifth_generation']['central_cooling_plant_parameters']['temp_setpoint_chw'],
}
elif 'fourth_generation' in district_params:
self.district_template_data = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
redeclare package Medium={{ globals.medium_w }},
use_m_flow_in=true,
use_T_in=false,
{% if sys_params.district_system['fifth_generation']['ghe_parameters'] %}
JingWang-CUB marked this conversation as resolved.
Show resolved Hide resolved
T={{ sys_params.district_system.fifth_generation.ghe_parameters.soil.undisturbed_temp}}+273.15,
JingWang-CUB marked this conversation as resolved.
Show resolved Hide resolved
{% else %}
T={{ sys_params.district_system.fifth_generation.central_heating_plant_parameters.temp_setpoint_hhw }}+273.15,
{% endif %}
nPorts=1)
"Heating water supply temperature (district side)."
annotation (Placement({{ diagram.transformation.sup_hea_wat.boundary_pt }}));
Expand Down
63 changes: 41 additions & 22 deletions geojson_modelica_translator/model_connectors/plants/borefield.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

import os
from pathlib import Path
import pandas as pd
import scipy.io as sio
import math

from geojson_modelica_translator.model_connectors.plants.plant_base import (
PlantBase
Expand Down Expand Up @@ -30,71 +33,87 @@ def to_modelica(self, scaffold):

template_data = {
"gfunction": {
"gfunction_file_path": self.system_parameters.get_param(
"$.ghe_parameters.placeholder.gfunction_file_path"
),
"gfunction_file_rows": self.system_parameters.get_param(
"$.ghe_parameters.placeholder.gfunction_file_rows"
),
"input_path": self.system_parameters.get_param(
"$.district_system.fifth_generation.ghe_parameters.ghe_dir"
)
},
"soil": {
"initial_ground_temperature": self.system_parameters.get_param(
"$.ghe_parameters.soil.undisturbed_temp"
"$.district_system.fifth_generation.ghe_parameters.soil.undisturbed_temp"
),
"conductivity": self.system_parameters.get_param(
"$.ghe_parameters.soil.conductivity"
"$.district_system.fifth_generation.ghe_parameters.soil.conductivity"
),
"volumetric_heat_capacity": self.system_parameters.get_param(
"$.ghe_parameters.soil.rho_cp"
"$.district_system.fifth_generation.ghe_parameters.soil.rho_cp"
),
},
"fill": {
"conductivity": self.system_parameters.get_param(
"$.ghe_parameters.grout.conductivity"
"$.district_system.fifth_generation.ghe_parameters.grout.conductivity"
),
"volumetric_heat_capacity": self.system_parameters.get_param(
"$.ghe_parameters.grout.rho_cp"
"$.district_system.fifth_generation.ghe_parameters.grout.rho_cp"
),
},
"configuration": {
"borehole_configuration": self.system_parameters.get_param(
"$.ghe_parameters.pipe.arrangement"
"$.district_system.fifth_generation.ghe_parameters.pipe.arrangement"
),
"nominal_mass_flow_per_borehole": self.system_parameters.get_param(
"$.ghe_parameters.design.flow_rate"
"$.district_system.fifth_generation.ghe_parameters.design.flow_rate"
),
"flow_type": self.system_parameters.get_param(
"$.ghe_parameters.design.flow_type"
"$.district_system.fifth_generation.ghe_parameters.design.flow_type"
),
"borehole_height": self.system_parameters.get_param(
"$.ghe_parameters.borehole.length"
"$.district_system.fifth_generation.ghe_parameters.borehole.length"
),
"borehole_diameter": self.system_parameters.get_param(
"$.ghe_parameters.borehole.diameter"
"$.district_system.fifth_generation.ghe_parameters.borehole.diameter"
),
"borehole_buried_depth": self.system_parameters.get_param(
"$.ghe_parameters.borehole.buried_depth"
"$.district_system.fifth_generation.ghe_parameters.borehole.buried_depth"
),
"number_of_boreholes": self.system_parameters.get_param(
"$.ghe_parameters.design.number_of_boreholes"
"$.district_system.fifth_generation.ghe_parameters.borehole.number_of_boreholes"
),
},
"tube": {
"outer_diameter": self.system_parameters.get_param(
"$.ghe_parameters.pipe.outer_diameter"
"$.district_system.fifth_generation.ghe_parameters.pipe.outer_diameter"
),
"inner_diameter": self.system_parameters.get_param(
"$.ghe_parameters.pipe.inner_diameter"
"$.district_system.fifth_generation.ghe_parameters.pipe.inner_diameter"
),
"conductivity": self.system_parameters.get_param(
"$.ghe_parameters.pipe.conductivity"
"$.district_system.fifth_generation.ghe_parameters.pipe.conductivity"
),
"shank_spacing": self.system_parameters.get_param(
"$.ghe_parameters.pipe.shank_spacing"
"$.district_system.fifth_generation.ghe_parameters.pipe.shank_spacing"
),
},
}

# process g-function file
gfunction = pd.read_csv((Path(template_data["gfunction"]["input_path"]) / "Gfunction.csv").resolve(), header=0)
template_data["gfunction"]["gfunction_file_rows"] = gfunction.shape[0]+1

# convert the values to match Modelica gfunctions
for i in range(len(gfunction)):
gfunction[gfunction.columns[0]].iloc[i] = math.exp(gfunction[gfunction.columns[0]].iloc[i])*template_data["configuration"]["borehole_height"]**2/(9*template_data["soil"]["conductivity"]/template_data["soil"]["volumetric_heat_capacity"])
gfunction[gfunction.columns[1]].iloc[i] = gfunction[gfunction.columns[1]].iloc[i]/(template_data["configuration"]["number_of_boreholes"]*2*math.pi*template_data["configuration"]["borehole_height"]*template_data["soil"]["conductivity"])

# add zeros to the first row
new_row = pd.Series({gfunction.columns[0]: 0, gfunction.columns[1]: 0})
gfunction = pd.concat([gfunction.iloc[:0], pd.DataFrame([new_row]), gfunction.iloc[0:]]).reset_index(drop=True)

# add to dict and save MAT file to the borefield's resources folder
data_dict = {'TStep': gfunction.values}
gfunction_path = os.path.join(scaffold.plants_path.resources_dir,'Gfunction.mat')
sio.savemat(gfunction_path, data_dict)
template_data["gfunction"]["gfunction_file_path"] = gfunction_path.replace('\\', '/')

# process nominal mass flow rate
if template_data["configuration"]["flow_type"] == "system":
template_data["configuration"]["nominal_mass_flow_per_borehole"] = template_data["configuration"]["nominal_mass_flow_per_borehole"] / template_data["configuration"]["number_of_boreholes"]
Expand Down
58 changes: 58 additions & 0 deletions tests/model_connectors/data/Gfunction.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
ln(t/ts),H:91.93
-48.91979309319371,-1.822663364108207
-47.5294629144498,-1.8162256957364589
-46.13913273570589,-1.809788027364711
-44.748802556961984,-1.8033503589929627
-43.358472378218075,-1.7969126906212147
-41.968142199474165,-1.7904750222494665
-40.577812020730256,-1.7840373538777183
-39.18748184198635,-1.7775996855059704
-37.79715166324244,-1.7711620171342222
-36.40682148449853,-1.764724348762474
-35.01649130575462,-1.758286680390726
-33.62616112701071,-1.7518490120189778
-32.23583094826681,-1.7454113436472298
-30.845500769522896,-1.7389736752754816
-29.455170590778987,-1.7325360069037334
-28.06484041203508,-1.7260983385319855
-26.67451023329117,-1.7196606701602373
-25.28418005454726,-1.7132230017884893
-23.89384987580335,-1.706785333416741
-22.503519697059442,-1.700347665044993
-21.113189518315533,-1.693909996673245
-19.722859339571624,-1.6874723283014967
-18.332529160827715,-1.6810346599297485
-16.942198982083806,-1.6745969915580006
-15.5518688033399,-1.4885153990472844
-14.161538624595991,-0.9616800791950322
-12.771208445852082,-0.1373890752849003
-11.380878267108173,0.7309045226911854
-9.990548088364264,1.4989474930073818
-8.600217909620355,2.21722778837189
-8.5,2.333668799654772
-7.8,2.680028116277204
-7.2,2.976579525355174
-6.5,3.3214979060006318
-5.9,3.6183780569291937
-5.2,3.985646165293046
-4.5,4.412741731362534
-3.963,4.78967983323376
-3.27,5.31964109001558
-2.864,5.639933817910789
-2.577,5.865880520772372
-2.171,6.179506729029434
-1.884,6.394511116374665
-1.191,6.876431928932908
-0.497,7.287549994326967
-0.274,7.400576450933945
-0.051,7.5026878612451275
0.196,7.602592987479888
0.419,7.680573087757184
0.642,7.747331143270593
0.873,7.8050691854404395
1.112,7.85358553376416
1.335,7.889798403899954
1.679,7.931270827487374
2.028,7.9595647196376795
2.275,7.973416909236491
3.003,7.995749059734852
Binary file removed tests/model_connectors/data/SampleGFunction.mat
Binary file not shown.
6 changes: 4 additions & 2 deletions tests/model_connectors/data/system_params_ghe.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fifth_generation": {
"ghe_parameters": {
"version": "1.0",
"ghe_dir": "C:/urbanopt-ghe/baseline_scenario/ghe",
"ghe_dir": "tests/model_connectors/data",
"fluid": {
"fluid_name": "Water",
"concentration_percent": 0.0,
Expand All @@ -68,7 +68,9 @@
},
"borehole": {
"buried_depth": 2.0,
"diameter": 0.15
"diameter": 0.15,
"length": 150,
"number_of_boreholes": 4
},
"simulation": {
"num_months": 240
Expand Down
Loading