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

fix(room): Ensure Internal Mass and Process Load are Re-serialized #783

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 4 additions & 6 deletions honeybee_energy/properties/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,20 +1190,18 @@ def apply_properties_from_dict(
abridged_data['window_vent_control'], schedules)
if 'process_loads' in abridged_data and \
abridged_data['process_loads'] is not None:
self.process_loads = []
for dat in abridged_data['process_loads']:
if dat['type'] == 'Process':
self.process_loads.append(Process.from_dict(dat))
self._process_loads.append(Process.from_dict(dat))
else:
self.process_loads.append(Process.from_dict_abridged(dat, schedules))
self._process_loads.append(Process.from_dict_abridged(dat, schedules))
if 'internal_masses' in abridged_data and \
abridged_data['internal_masses'] is not None:
self.internal_masses = []
for dat in abridged_data['internal_masses']:
if dat['type'] == 'InternalMass':
self.internal_masses.append(InternalMass.from_dict(dat))
self._internal_masses.append(InternalMass.from_dict(dat))
else:
self.internal_masses.append(
self._internal_masses.append(
InternalMass.from_dict_abridged(dat, constructions))

def to_dict(self, abridged=False):
Expand Down
14 changes: 14 additions & 0 deletions tests/model_extend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from honeybee_energy.construction.window import WindowConstruction
from honeybee_energy.construction.shade import ShadeConstruction
from honeybee_energy.construction.air import AirBoundaryConstruction
from honeybee_energy.internalmass import InternalMass
from honeybee_energy.load.process import Process
from honeybee_energy.material._base import _EnergyMaterialBase
from honeybee_energy.material.opaque import EnergyMaterial
from honeybee_energy.schedule.ruleset import ScheduleRuleset
Expand Down Expand Up @@ -377,6 +379,9 @@ def test_to_dict_single_zone():
table = Shade('Table', table_geo)
room.add_indoor_shade(table)

int_mass = InternalMass('Stone Fireplace', thermal_mass_constr, 8)
room.properties.energy.internal_masses = [int_mass]

model = Model('TinyHouse', [room], orphaned_shades=[tree_canopy])

model_dict = model.to_dict()
Expand Down Expand Up @@ -405,6 +410,9 @@ def test_to_dict_single_zone():
assert model_dict['rooms'][0]['properties']['energy']['hvac'] == \
room.properties.energy.hvac.identifier

assert model_dict['rooms'][0]['properties']['energy']['internal_masses'][0]['identifier'] == \
int_mass.identifier


def test_to_dict_single_zone_schedule_fixed_interval():
"""Test the Model to_dict method with a single zone model and fixed interval schedules."""
Expand Down Expand Up @@ -486,6 +494,10 @@ def test_to_dict_single_zone_detailed_loads():
room.properties.energy.infiltration = office_program.infiltration
room.properties.energy.ventilation = office_program.ventilation
room.properties.energy.setpoint = office_program.setpoint

fireplace = Process('Wood Burning Fireplace', 300,
office_program.people.occupancy_schedule, 'OtherFuel1')
room.properties.energy.process_loads = [fireplace]

room[0].boundary_condition = boundary_conditions.adiabatic
room[1].boundary_condition = boundary_conditions.adiabatic
Expand Down Expand Up @@ -515,6 +527,8 @@ def test_to_dict_single_zone_detailed_loads():
assert 'setpoint' in model_dict['rooms'][0]['properties']['energy']
assert model_dict['rooms'][0]['properties']['energy']['setpoint']['identifier'] == \
office_program.setpoint.identifier
assert model_dict['rooms'][0]['properties']['energy']['process_loads'][0]['identifier'] == \
fireplace.identifier


def test_to_dict_shoe_box():
Expand Down