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 5g to sysparams #469

Merged
merged 63 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
3f127c8
fix error in schema
nllong May 19, 2022
7ca979d
small refactor before 5G addition
nllong May 19, 2022
2b845b2
add choice for 4G and 5G systems
nllong May 19, 2022
4c99842
Merge branch 'develop' into add-5G-to-sysparams
vtnate May 25, 2022
8770bce
Merge branch 'develop' into add-5G-to-sysparams
nllong May 26, 2022
fe9dd94
Merge branch 'develop' into add-5G-to-sysparams
vtnate Jun 10, 2022
e1e8d53
Merge branch 'develop' into add-5G-to-sysparams
vtnate Jul 14, 2022
9642276
Merge branch 'develop' into add-5G-to-sysparams
vtnate Aug 11, 2022
8894409
fix oneOf condition in json schema
nllong Jul 18, 2022
e696eea
update sys-params.py to work with explicitly labeled 4gdhc systems
vtnate Aug 12, 2022
dc2a147
update some test sys param files to explicitly label 4gdhc systems
vtnate Aug 12, 2022
95ac632
remove "custom" title, require "ets_model" in building_def
vtnate Aug 16, 2022
5df5d42
remove default path elements in sys_param call
vtnate Aug 16, 2022
223d6de
update test sys param file
vtnate Aug 16, 2022
c212750
improve schema validation failure reporting
vtnate Aug 17, 2022
979add7
updating schema hierarchy and types in a few places
vtnate Aug 17, 2022
eedd53e
more updates to test sys-param file to work with choice of system gen…
vtnate Aug 17, 2022
a013a7f
json keys are not allowed to start with a number
vtnate Aug 17, 2022
a8bd46c
loop differently now that "buildings" object itself is a list
vtnate Aug 17, 2022
9bd7d70
change expanded_path test to work when called from anywhere
vtnate Aug 17, 2022
cedd631
fix another test now that "buildings" is a list
vtnate Aug 17, 2022
d6b854d
update another test sys-param file to work with new schema
vtnate Aug 17, 2022
452a431
WIP: fix most sys-param tests
vtnate Aug 17, 2022
a7f306f
Revert "improve schema validation failure reporting"
vtnate Aug 17, 2022
576ec6f
fix xpath path to parse lists correctly
vtnate Aug 17, 2022
0b47c90
fix xpath path in test so list gets parsed correctly
vtnate Aug 17, 2022
a9b9845
update test sys param files to work with 5g schema
vtnate Aug 17, 2022
ddddb9e
simplify get_param_by_building_id now that the param default section …
vtnate Aug 17, 2022
c6e9f06
remove duplicate spawn sys param file
vtnate Aug 17, 2022
ecc5589
update cooling plant xpath paths to district system in sys params file
vtnate Aug 17, 2022
495650a
remove newly unnecessary function parameter
vtnate Aug 17, 2022
47b44d7
remove unnecessary if-statement level
vtnate Aug 18, 2022
8982395
update jsonpath parsing now that "buildings" itself is an array
vtnate Aug 18, 2022
f8db90e
update jsonpath in model_base for new jsonpath in district_systems
vtnate Aug 18, 2022
d7801e4
update jsonpath in load_base for indirect params
vtnate Aug 18, 2022
06ff6a8
Revert "remove unnecessary if-statement level"
vtnate Aug 18, 2022
3a2ec33
update sys-param tests with new jsonpaths and new exception types
vtnate Aug 18, 2022
2fe84a8
Revert "change expanded_path test to work when called from anywhere"
vtnate Aug 18, 2022
0174024
change more jsonpaths away from "default"
vtnate Aug 18, 2022
1b1b57b
skip geojson validation for features with "detailed_model_filename"
vtnate Aug 18, 2022
e4a8835
remove another instace of "custom" in hardcoded jsonpath
vtnate Aug 18, 2022
59d65f1
change jsonpath key to indirect ets params in their py files
vtnate Aug 18, 2022
ee515a8
remove "custom" from jsonpath in load_base
vtnate Aug 18, 2022
d41d567
fix jsonpaths in teaser.py
vtnate Aug 18, 2022
a431a7c
update jsonpaths in chp.py to explicitly look at 4th gen
vtnate Aug 18, 2022
4a7656b
update jsonpaths, make filechecks more detailed in sysparams.py
vtnate Aug 18, 2022
432b528
remove default values in function call, and the test for those defaul…
vtnate Aug 18, 2022
dabdcfb
update dict indexing in test to get to correct value now that sys-par…
vtnate Aug 18, 2022
616d28d
Merge branch 'develop' into add-5G-to-sysparams
vtnate Aug 23, 2022
58af423
fix test json path that came in from microgrid PR
vtnate Aug 23, 2022
0227052
set model_base log level to info
vtnate Aug 23, 2022
e725519
autopep8
vtnate Aug 23, 2022
96e1c8b
change fourthGDHC to fourth_generation and same for fifth
vtnate Aug 29, 2022
a6ce163
remove test that only tested default sys-param values, which no longe…
vtnate Aug 29, 2022
f1bfad9
remove sys-param file from tests that was not being used
vtnate Aug 29, 2022
f5cf3bc
require ets params for each building
vtnate Aug 29, 2022
ec36396
implement ets requirement in each load_connector type
vtnate Aug 29, 2022
8ebeb1c
fix jsonpath for new schema hierarchy
vtnate Aug 29, 2022
979c149
Revert "require ets params for each building"
vtnate Aug 31, 2022
c97979b
Revert "implement ets requirement in each load_connector type"
vtnate Aug 31, 2022
552cbcb
remove unused variables from spawn building template
vtnate Sep 1, 2022
448c9bd
remove unused ets variable from teaser building template
vtnate Sep 1, 2022
fa65f16
remove ets sys-param code that is not needed, variables removed from …
vtnate Sep 1, 2022
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
19 changes: 12 additions & 7 deletions geojson_modelica_translator/geojson/urbanopt_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ def __init__(self, filename, building_ids=None):
self.buildings = []
for feature in self.data.features:
if feature["properties"]["type"] == "Building":
building = UrbanOptLoad(feature)
if not building_ids or building.id in building_ids:
errors = self.schemas.validate("building", building.feature.properties)
if errors:
building_errors[building.id] = errors
else:
self.buildings.append(building)
# Don't validate features with 'detailed_model_filename' in the building properties
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it's done in urbanopt sdk. 😆 😬 🤷

vtnate marked this conversation as resolved.
Show resolved Hide resolved
# Buildings defined by an osm don't have all keys in geojson, they'll always fail validation
if "detailed_model_filename" in feature["properties"]:
continue
else:
building = UrbanOptLoad(feature)
if not building_ids or building.id in building_ids:
errors = self.schemas.validate("building", building.feature.properties)
if errors:
building_errors[building.id] = errors
else:
self.buildings.append(building)

if building_errors:
formatted_errors = ''
Expand Down
2 changes: 1 addition & 1 deletion geojson_modelica_translator/geojson_modelica_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def __init__(
self._system_parameters = SystemParameters(sys_params_filepath)

geojson_ids = self._system_parameters.get_default(
'$.buildings.custom[*].geojson_id',
'$.buildings.[*].geojson_id',
vtnate marked this conversation as resolved.
Show resolved Hide resolved
[]
)
self._geojson = UrbanOptGeoJson(geojson_filepath, geojson_ids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
// TODO: This should not be here, it is entirely plant specific and should be moved elsewhere
// but since it requires a connect statement we must put it here for now...
Modelica.Blocks.Sources.RealExpression TDisSetHeaWat_{{ coupling.id }}(
each y=273.15+{{ sys_params.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw }})
each y=273.15+{{ sys_params.district_system.fourthGDHC.central_heating_plant_parameters.temp_setpoint_hhw }})
vtnate marked this conversation as resolved.
Show resolved Hide resolved
"District side heating water supply temperature set point."
annotation (Placement({{ diagram.transformation.t_dis_set_hea_wat.real_expression }}));
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"Secondary loop heated water flow rate."
annotation (Placement({{ diagram.transformation.sec_mas_flo_rat.real_expression }}));
Modelica.Blocks.Sources.RealExpression TDisSetHeaWat_{{ coupling.id }}(
each y=273.15+{{ sys_params.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw }})
each y=273.15+{{ sys_params.district_system.fourthGDHC.central_heating_plant_parameters.temp_setpoint_hhw }})
"District side heating water supply temperature set point."
annotation (Placement({{ diagram.transformation.t_dis_set_hea_wat.real_expression }}));
Modelica.Blocks.Sources.BooleanConstant mPum_flow_{{ coupling.id }}(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_modelica(self, scaffold):

ets_data = self.system_parameters.get_param_by_building_id(
self._geojson_load_id,
'ets_model_parameters.indirect'
'ets_indirect_parameters'
)

combined_template_data = {**ets_data, **self.district_template_data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_modelica(self, scaffold):

ets_data = self.system_parameters.get_param_by_building_id(
self._geojson_load_id,
"ets_model_parameters.indirect"
"ets_indirect_parameters"
)

combined_template_data = {**ets_data, **self.district_template_data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,58 +75,58 @@ def __init__(self, system_parameters, geojson_load):
# test_base.py and test_time_series.py test these cases
if system_parameters is not None:
if self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect") is not None:
self.building_id, "ets_indirect_parameters") is not None:
self.ets_template_data = {
"heat_flow_nominal": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heat_flow_nominal"
self.building_id, "ets_indirect_parameters.heat_flow_nominal"
),
"heat_exchanger_efficiency": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heat_exchanger_efficiency"
self.building_id, "ets_indirect_parameters.heat_exchanger_efficiency"
),
"nominal_mass_flow_district": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.nominal_mass_flow_district"
self.building_id, "ets_indirect_parameters.nominal_mass_flow_district"
),
"nominal_mass_flow_building": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.nominal_mass_flow_building"
self.building_id, "ets_indirect_parameters.nominal_mass_flow_building"
),
"valve_pressure_drop": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.valve_pressure_drop"
self.building_id, "ets_indirect_parameters.valve_pressure_drop"
),
"heat_exchanger_secondary_pressure_drop": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heat_exchanger_secondary_pressure_drop"
self.building_id, "ets_indirect_parameters.heat_exchanger_secondary_pressure_drop"
),
"heat_exchanger_primary_pressure_drop": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heat_exchanger_primary_pressure_drop"
self.building_id, "ets_indirect_parameters.heat_exchanger_primary_pressure_drop"
),
"cooling_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.cooling_supply_water_temperature_building"
self.building_id, "ets_indirect_parameters.cooling_supply_water_temperature_building"
)),
"heating_supply_water_temperature_building": convert_c_to_k(self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heating_supply_water_temperature_building"
self.building_id, "ets_indirect_parameters.heating_supply_water_temperature_building"
)),
"delta_temp_chw_building": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.delta_temp_chw_building"
self.building_id, "ets_indirect_parameters.delta_temp_chw_building"
),
"delta_temp_chw_district": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.delta_temp_chw_district"
self.building_id, "ets_indirect_parameters.delta_temp_chw_district"
),
"delta_temp_hw_building": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.delta_temp_hw_building"
self.building_id, "ets_indirect_parameters.delta_temp_hw_building"
),
"delta_temp_hw_district": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.delta_temp_hw_district"
self.building_id, "ets_indirect_parameters.delta_temp_hw_district"
),
"cooling_controller_y_max": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.cooling_controller_y_max"
self.building_id, "ets_indirect_parameters.cooling_controller_y_max"
),
"cooling_controller_y_min": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.cooling_controller_y_min"
self.building_id, "ets_indirect_parameters.cooling_controller_y_min"
),
"heating_controller_y_max": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heating_controller_y_max"
self.building_id, "ets_indirect_parameters.heating_controller_y_max"
),
"heating_controller_y_min": self.system_parameters.get_param_by_building_id(
self.building_id, "ets_model_parameters.indirect.heating_controller_y_min"
self.building_id, "ets_indirect_parameters.heating_controller_y_min"
)
}
else:
Expand All @@ -148,7 +148,7 @@ def add_building(self, urbanopt_building, mapper=None):
# TODO: Abstract out the GeoJSON functionality
if mapper is None:
if self.system_parameters:
for building in self.system_parameters.get_default('$.buildings.custom', []):
for building in self.system_parameters.get_default('$.buildings', []):
# Only look at buildings in the sys-param file, not necessarily the entire feature file
if urbanopt_building.feature.properties["id"] == building["geojson_id"]:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def to_modelica(self, scaffold, keep_original_models=False):

prj.used_library_calc = "IBPSA"
prj.number_of_elements_calc = self.system_parameters.get_param_by_building_id(
self.building_id, "load_model_parameters.rc.order", default=2
self.building_id, "load_model_parameters.rc.order"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the default no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I removed the "default" parameter from this method. What if default values were pulled from the schema if they aren't explicitly called out in the sys-param file? Or at least hinted, if a param is missing? The get_param and get_default methods just above that one ought to be refactored/removed in a future PR, imho.

)
prj.merge_windows_calc = False

Expand Down Expand Up @@ -310,15 +310,15 @@ def post_process(self, scaffold, keep_original_models=False):
)

fraction_latent_person = self.system_parameters.get_param(
"buildings.default.load_model_parameters.rc.fraction_latent_person", default=1.25
"buildings.load_model_parameters.rc.fraction_latent_person", default=1.25
)

use_moisture_balance = self.system_parameters.get_param(
"buildings.default.load_model_parameters.rc.use_moisture_balance", default='false'
"buildings.load_model_parameters.rc.use_moisture_balance", default='false'
)

n_ports = self.system_parameters.get_param(
"buildings.default.load_model_parameters.rc.nPorts", default=0
"buildings.load_model_parameters.rc.nPorts", default=0
)

# create a new parameter for fraction latent person
Expand Down Expand Up @@ -372,7 +372,7 @@ def post_process(self, scaffold, keep_original_models=False):

# add new port connections
rc_order = self.system_parameters.get_param_by_building_id(
self.building_id, "load_model_parameters.rc.order", default=2
self.building_id, "load_model_parameters.rc.order"
)
thermal_zone_name = None
thermal_zone_type = None
Expand Down Expand Up @@ -643,7 +643,7 @@ def post_process(self, scaffold, keep_original_models=False):
)
else:
raise Exception(
f"Missing MOS weather file for Spawn: {building_template_data['mos_weather']['mos_weather_filename']}")
f"Missing MOS weather file for Teaser: {building_template_data['mos_weather']['mos_weather_filename']}")
# end of what AA added 9/24

# remaining clean up tasks across the entire exported project
Expand Down
6 changes: 3 additions & 3 deletions geojson_modelica_translator/model_connectors/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.DEBUG,
level=logging.INFO,
vtnate marked this conversation as resolved.
Show resolved Hide resolved
format='%(asctime)s - %(levelname)s: %(message)s',
datefmt='%d-%b-%y %H:%M:%S',
)
Expand Down Expand Up @@ -90,10 +90,10 @@ def __init__(self, system_parameters, template_dir):
if system_parameters is not None:
self.district_template_data = {
"temp_setpoint_hhw": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw"
"$.district_system.fourthGDHC.central_heating_plant_parameters.temp_setpoint_hhw"
),
"temp_setpoint_chw": self.system_parameters.get_param(
"$.district_system.default.central_cooling_plant_parameters.temp_setpoint_chw"
"$.district_system.fourthGDHC.central_cooling_plant_parameters.temp_setpoint_chw"
),
}

Expand Down
18 changes: 9 additions & 9 deletions geojson_modelica_translator/model_connectors/plants/chp.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, system_parameters):
super().__init__(system_parameters)
self.id = 'chpPla_' + simple_uuid()
self.chp_installed = self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.chp_installed"
"$.district_system.fourthGDHC.central_heating_plant_parameters.chp_installed"
)
if not self.chp_installed:
self.required_mo_files.append(Path(self.template_dir) / 'CentralHeatingPlant.mo')
Expand All @@ -75,30 +75,30 @@ def to_modelica(self, scaffold):
template_data = {
"nominal_values": {
"heat_flow_nominal": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.heat_flow_nominal"
"$.district_system.fourthGDHC.central_heating_plant_parameters.heat_flow_nominal"
),
"mass_hhw_flow_nominal": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.mass_hhw_flow_nominal"
"$.district_system.fourthGDHC.central_heating_plant_parameters.mass_hhw_flow_nominal"
),
"boiler_water_flow_minimum": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.boiler_water_flow_minimum"
"$.district_system.fourthGDHC.central_heating_plant_parameters.boiler_water_flow_minimum"
),
"pressure_drop_hhw_nominal": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.pressure_drop_hhw_nominal"
"$.district_system.fourthGDHC.central_heating_plant_parameters.pressure_drop_hhw_nominal"
),
"pressure_drop_setpoint": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.pressure_drop_setpoint"
"$.district_system.fourthGDHC.central_heating_plant_parameters.pressure_drop_setpoint"
),
"temp_setpoint_hhw": convert_c_to_k(self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.temp_setpoint_hhw"
"$.district_system.fourthGDHC.central_heating_plant_parameters.temp_setpoint_hhw"
)),
"pressure_drop_hhw_valve_nominal": self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.pressure_drop_hhw_valve_nominal"
"$.district_system.fourthGDHC.central_heating_plant_parameters.pressure_drop_hhw_valve_nominal"
),
},
"signals": {
"thermal_following": str(self.system_parameters.get_param(
"$.district_system.default.central_heating_plant_parameters.chp_thermal_following"
"$.district_system.fourthGDHC.central_heating_plant_parameters.chp_thermal_following"
)).lower(), # Booleans in Python start with a capital letter. Modelica wants it lowercase, hence this.
},
}
Expand Down
Loading