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

Add GHE Properties to System Parameter File #570

Merged
merged 34 commits into from Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c528d4
add ghe to create system parameter function
tanushree04 Jul 6, 2023
051822f
Add design method for borehole
tanushree04 Jul 12, 2023
8e1abca
update create sys param and system_parameter.py
tanushree04 Jul 14, 2023
e3daa50
update tests
tanushree04 Jul 17, 2023
3332b83
update district system type property
tanushree04 Jul 19, 2023
8b3a564
reduce unnecessary indenting
vtnate Jul 19, 2023
82025ab
add negative sign to heat_flow to designate as cooling
vtnate Jul 19, 2023
53119ad
clean up test setup now that we have at least python 3.8
vtnate Jul 19, 2023
66b8a74
update district_system_type property in system_parameters.py
tanushree04 Jul 19, 2023
df37a30
Merge branch 'ghe_modify' of github.com:urbanopt/geojson-modelica-tra…
vtnate Jul 19, 2023
4ac499c
redo the un-indenting I accidentally committed
vtnate Jul 19, 2023
7c5fd69
update dependencies with poetry
vtnate Jul 20, 2023
1d61309
remove generated test sys-param file
vtnate Jul 20, 2023
836cca8
gitignore generated test sys-param file
vtnate Jul 20, 2023
3ca86b6
add sys param argument
tanushree04 Jul 26, 2023
d0d58e2
fix typo that prevented sys-param creation via cli
vtnate Jul 26, 2023
1662b82
remove nonsensical 5G district parameters
vtnate Jul 27, 2023
1616023
clean up uo_des test comments a bit, and add intermediate assertions
vtnate Jul 27, 2023
bf3f983
remove outdated spawn compilation instructions
vtnate Jul 27, 2023
f600deb
enable 5G models with the CLI
vtnate Jul 27, 2023
60a43ca
Merge branch 'gmt-with-5g' into ghe_modify
vtnate Jul 27, 2023
b743d6e
add borehole length to template
tanushree04 Jul 27, 2023
377241c
Merge branch 'ghe_modify' of github.com:urbanopt/geojson-modelica-tra…
vtnate Jul 27, 2023
5a3da8c
add gfunction csv file to cli test for ghe district tests
vtnate Jul 27, 2023
1b66d1b
more updates to gmt class to handle 5g districts from cli
vtnate Jul 27, 2023
ac85feb
choose generations more explicitly in district.py
vtnate Jul 27, 2023
1f6adbc
use correct sys-param parameter name in borefield.py
vtnate Jul 27, 2023
56fa91d
add start/stop/step times for model simulation to cli options
vtnate Jul 27, 2023
98701bd
add 5g cli integration test, update calls to simulate during the summer
vtnate Jul 27, 2023
2963d54
Quick fix to enlarge loop flow rate
JingWang-CUB Jul 27, 2023
6644106
change borehole length in test sys-param files to match schema
vtnate Jul 27, 2023
174b6b9
make pytest skip reason comment more explicit
vtnate Jul 27, 2023
217f045
don't skip distribution simulation test
vtnate Jul 27, 2023
0a11c46
clarify pytest skip reason comment
vtnate Jul 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions geojson_modelica_translator/system_parameters/schema.json
Expand Up @@ -1599,6 +1599,15 @@
"description": "Design parameters used for GHE sizing.",
"type": "object",
"properties": {
"method": {
"description": "Building load distribution method for Ground Heat Exchanger sizing",
"type": "string",
"enum": [
"AREAPROPORTIONAL",
"UPSTREAM"
],
"default": "AREAPROPORTIONAL"
},
"flow_rate": {
"description": "Nominal design mass flow rate. Depending on whether the flow_type attribute is set to 'borehole' or 'system', this will be the nominal flow rate for either each borehole or the entire ground heat exchanger.",
"type": "number",
Expand Down Expand Up @@ -1626,6 +1635,7 @@
}
},
"required": [
"method",
"flow_rate",
"flow_type",
"max_eft",
Expand Down
Expand Up @@ -3,6 +3,7 @@

import json
import logging
import math
import os
from copy import deepcopy
from pathlib import Path
Expand Down Expand Up @@ -674,11 +675,24 @@ def process_microgrid_inputs(self, scenario_dir: Path):
# Power Converters
# TODO: not handled in UO / OpenDSS

def calculate_dimensions(self, area, perimeter):

discriminant = perimeter ** 2 - 16 * area

if discriminant < 0:
raise ValueError("No valid rectangle dimensions exist for the given area and perimeter.")

length = (perimeter + math.sqrt(discriminant)) / 4
width = (perimeter - 2 * length) / 2

return length, width

def csv_to_sys_param(self,
model_type: str,
scenario_dir: Path,
feature_file: Path,
sys_param_filename: Path,
ghe=False,
overwrite=True,
microgrid=False) -> None:
"""
Expand All @@ -689,6 +703,7 @@ def csv_to_sys_param(self,
:param feature_file: Path, location/name of uo_sdk input file
:param sys_param_filename: Path, location/name of system parameter file to be created
:param overwrite: Boolean, whether to overwrite existing sys-param file
:param ghe: Boolean, flag to add Ground Heat Exchanger properties to System Parameter File
:param microgrid: Boolean, Optional. If set to true, also process microgrid fields
:return None, file created and saved to user-specified location
"""
Expand Down Expand Up @@ -731,7 +746,7 @@ def csv_to_sys_param(self,
measure_list.append(Path(item) / "modelica.mos") # space heating/cooling & water heating
measure_list.append(Path(item) / "building_loads.csv") # used for max electricity load

# Get each feature id from the SDK FeatureFile
# Get each building feature id from the SDK FeatureFile
building_ids = []
with open(feature_file) as json_file:
sdk_input = json.load(json_file)
Expand Down Expand Up @@ -825,6 +840,55 @@ def csv_to_sys_param(self,
raise SystemExit(f"\nError: No scenario_optimization.json file found in {scenario_dir}\n"
"Perhaps you haven't run REopt post-processing step in the UO sdk?")

# Update ground heat exchanger properties if true
if ghe:

ghe_ids = []
# add properties from the feature file
with open(feature_file) as json_file:
sdk_input = json.load(json_file)
for feature in sdk_input['features']:
if feature['properties']['type'] == 'District System':
try:
district_system_type = feature['properties']['districtSystemType']
except KeyError:
pass
if district_system_type == 'Ground Heat Exchanger':
length, width = self.calculate_dimensions(feature['properties']['footprint_area'], feature['properties']['footprint_perimeter'])
ghe_ids.append({'ghe_id': feature['properties']['id'],
'length_of_ghe': length,
'width_of_ghe': width})

ghe_sys_param = self.param_template['district_system']['fifth_generation']['ghe_parameters']
# Make sys_param template entries for GHE specific properties
ghe_list = []
for ghe in ghe_ids:
# update GHE specific properties
ghe_info = deepcopy(ghe_sys_param['ghe_specific_params'][0])
# Update GHE ID
ghe_info['ghe_id'] = str(ghe['ghe_id'])
# Add ghe geometric properties
ghe_info['ghe_geometric_params']['length_of_ghe'] = ghe['length_of_ghe']
ghe_info['ghe_geometric_params']['width_of_ghe'] = ghe['width_of_ghe']
ghe_list.append(ghe_info)

# Add all GHE specific properties to sys-param file
ghe_sys_param['ghe_specific_params'] = ghe_list

# Update ghe_dir
ghe_dir = scenario_dir / 'ghe_dir'
ghe_sys_param['ghe_dir'] = str(ghe_dir)

# remove fourth generation district system type
del self.param_template['district_system']['fourth_generation']

else:
# remove fifth generation district system type if it exists in template and ghe is not true
try:
del self.param_template['district_system']['fifth_generation']
except KeyError:
pass

# save the file to disk
self.save()

Expand Down
Expand Up @@ -75,6 +75,66 @@
"pressure_drop_hhw_valve_nominal": 6001,
"chp_installed": false
}
},
"fifth_generation": {
"ghe_parameters": {
"version": "1.0",
"ghe_dir": "tests/system_parameters/data",
"fluid": {
"fluid_name": "Water",
"concentration_percent": 0.0,
"temperature": 20
},
"grout": {
"conductivity": 1.0,
"rho_cp": 3901000
},
"soil": {
"conductivity": 2.0,
"rho_cp": 2343493,
"undisturbed_temp": 18.3
},
"pipe": {
"inner_diameter": 0.0216,
"outer_diameter": 0.0266,
"shank_spacing": 0.0323,
"roughness": 1e-06,
"conductivity": 0.4,
"rho_cp": 1542000,
"arrangement": "singleutube"
},
"simulation": {
"num_months": 240
},
"geometric_constraints": {
"b_min": 3.0,
"b_max": 10.0,
"max_height": 135.0,
"min_height": 60.0,
"method": "rectangle"
},
"design": {
"method": "AREAPROPORTIONAL",
"flow_rate": 0.2,
"flow_type": "borehole",
"max_eft": 35.0,
"min_eft": 5.0
},
"ghe_specific_params": [
{
"ghe_id": "c432cb11-4813-40df-8dd4-e88f5de40033",
"ghe_geometric_params": {
"length_of_ghe": 100,
"width_of_ghe": 100
},
"borehole": {
"buried_depth": 2.0,
"diameter": 0.15
},
"ground_loads": []
}
]
}
}
},
"weather": "../../data_shared/USA_CA_San.Francisco.Intl.AP.724940_TMY3.mos"
Expand Down
27 changes: 15 additions & 12 deletions management/uo_des.py
Expand Up @@ -23,10 +23,6 @@ def cli():


@cli.command(short_help="Create sys-param file")
@click.argument(
'sys_param_filename',
type=click.Path(file_okay=True, dir_okay=False),
)
tanushree04 marked this conversation as resolved.
Show resolved Hide resolved
@click.argument(
"scenario_file",
type=click.Path(exists=True, file_okay=True, dir_okay=False),
Expand All @@ -53,12 +49,17 @@ def cli():
help="If specified, microgrid inputs will be added to system parameters file",
default=False
)
def build_sys_param(model_type: str, sys_param_filename: Path, scenario_file: Path, feature_file: Path, overwrite: bool, microgrid: bool):
@click.option(
'-g',
'--ghe',
is_flag=True,
help="If specified, Ground Heat Exchanger properties will be added to System Parameters File. HELLO",
default=False
)
def build_sys_param(model_type: str, scenario_file: Path, feature_file: Path, ghe: bool, overwrite: bool, microgrid: bool):
"""
Create system parameters file using uo_sdk output

SYS_PARAM_FILENAME: Path/name to sys-param file be created. Be sure to include the ".json" suffix.

SCENARIO_FILE: Path to sdk scenario file.

FEATURE_FILE: Path to sdk json feature file with data about the buildings.
Expand All @@ -69,7 +70,7 @@ def build_sys_param(model_type: str, sys_param_filename: Path, scenario_file: Pa

\f
:param model_type: string, selection of which model type to use in the GMT
:param sys_param_filename: Path, location & name of json output file to save
:param ghe: Boolean, flag to add Ground Heat Exchanger properties to System Parameter File
:param scenario_file: Path, location of SDK scenario_file
:param feature_file: Path, location of SDK feature_file
:param overwrite: Boolean, flag to overwrite an existing file of the same name/location
Expand All @@ -78,21 +79,23 @@ def build_sys_param(model_type: str, sys_param_filename: Path, scenario_file: Pa
# Use scenario_file to be consistent with sdk
scenario_name = Path(scenario_file).stem
scenario_dir = Path(scenario_file).parent / 'run' / scenario_name
sys_param_filepath = Path(scenario_dir / 'system_parameter.json')

sp = SystemParameters()
sp.csv_to_sys_param(
model_type=model_type,
sys_param_filename=Path(sys_param_filename),
sys_param_filename=Path(sys_param_filepath),
scenario_dir=Path(scenario_dir),
feature_file=Path(feature_file),
ghe=ghe,
overwrite=overwrite,
microgrid=microgrid
)

if Path(sys_param_filename).exists():
print(f"\nSystem parameters file {sys_param_filename} successfully created.")
if Path(sys_param_filepath).exists():
print(f"\nSystem parameters file {sys_param_filepath} successfully created.")
else:
raise SystemExit(f"{sys_param_filename} failed. Please check your inputs and try again.")
raise SystemExit(f"{sys_param_filepath} failed. Please check your inputs and try again.")


@cli.command(short_help="Create Modelica model")
Expand Down