Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed Oct 19, 2022
1 parent 29abd4a commit 014bb8a
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 38 deletions.
1 change: 1 addition & 0 deletions archetypal/template/building_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BuildingTemplate(UmiBase):
.. image:: ../images/template/buildingtemplate.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ZoneConditioning(UmiBase):
.. image:: ../images/template/zoninfo-conditioning.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/dhw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DomesticHotWaterSetting(UmiBase):
.. image:: ../images/template/zoneinfo-dhw.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ZoneLoad(UmiBase):
.. image:: ../images/template/zoneinfo-loads.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/materials/gas_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GasMaterial(MaterialBase):
.. image:: ../images/template/materials-gas.png
"""

_CREATED_OBJECTS = []

__slots__ = ("_type", "_conductivity", "_density")
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/materials/glazing_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GlazingMaterial(MaterialBase):
.. image:: ../images/template/materials-glazing.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
67 changes: 39 additions & 28 deletions archetypal/template/measures/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def Validator(self, validator):

@property
def Transformer(self):
"""Get or set a measure action transformer """
"""Get or set a measure action transformer"""

return self._transformer

Expand Down Expand Up @@ -402,7 +402,7 @@ def Value(self, value):

@property
def Validator(self):
"""Get or set a measure property validator """
"""Get or set a measure property validator"""
return self._validator

@Validator.setter
Expand Down Expand Up @@ -1120,7 +1120,7 @@ class SetFacadeThermalResistance(Measure):
_name = "Facade Upgrade"
_description = "Upgrade roof and facade insulation by specifying R-Values for entire assemblies."

def __init__(self, RoofRValue=1/2.37, FacadeRValue=1/1.66, **kwargs):
def __init__(self, RoofRValue=1 / 2.37, FacadeRValue=1 / 1.66, **kwargs):

super(SetFacadeThermalResistance, self).__init__(**kwargs)
roof_property = MeasureProperty(
Expand Down Expand Up @@ -1228,66 +1228,72 @@ class InstallDoublePaneWindowsWithFixedUValueAndCoating(Measure):
_description = "Upgrade windows to fixed double pane window"

def __init__(self, AirGapThickness=0.080, IsLowE=True, Gas="AIR", **kwargs):
super(InstallDoublePaneWindowsWithFixedUValueAndCoating, self).__init__(**kwargs)
super(InstallDoublePaneWindowsWithFixedUValueAndCoating, self).__init__(
**kwargs
)

def create_double_pane_window( AirGapThickness, IsLowE, Gas):
location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "boston_default_windows.json")
def create_double_pane_window(AirGapThickness, IsLowE, Gas):
location = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"boston_default_windows.json",
)
window_lib = UmiTemplateLibrary.open(location)
gasOffset = 0
if (Gas.lower() == "air"):
if Gas.lower() == "air":
pass
elif (Gas.lower() == "argon"):
elif Gas.lower() == "argon":
gasOffset = 2
else:
raise ValueError("Unsupported gas specified.")
lowEOffset = 0
if (not IsLowE):
if not IsLowE:
pass
elif (IsLowE):
elif IsLowE:
lowEOffset = 1

window = window_lib.WindowConstructions[gasOffset+lowEOffset]
window = window_lib.WindowConstructions[gasOffset + lowEOffset]

window.Layers[1].Thickness = AirGapThickness
return window



def WindowReplacer(original_value, proposed_transformer_value, *args, **kwargs):
return create_double_pane_window(self.AirGapThickness, self.IsLowE, self.Gas)
return create_double_pane_window(
self.AirGapThickness, self.IsLowE, self.Gas
)

window_replacement_action = MeasureAction(
Name="Replace Window",
Lookup=["Windows", "Construction"],
Transformer=WindowReplacer,
)

window_replacement_property = MeasureProperty(
Name="Window Replacer",
AttrName="WindowReplacer",
Description="Replaces the window construction",
Default=None,
Actions=[window_replacement_action]
Actions=[window_replacement_action],
)
window_gas_prop = MeasureProperty(
Name="Gas",
AttrName="Gas",
Description="Select the gas layer",
Default=Gas,
Actions=[]
Actions=[],
)
window_lowe_prop = MeasureProperty(
Name="Is LowE",
AttrName="IsLowE",
Description="Adds a low-e coating",
Default=IsLowE,
Actions=[]
Actions=[],
)
window_airgap_property = MeasureProperty(
Name="Air Gap Thickness",
AttrName="AirGapThickness",
Description="Change the airgap thickness",
Default=AirGapThickness,
Actions=[]
Actions=[],
)
self.add_property(window_replacement_property)
self.add_property(window_gas_prop)
Expand All @@ -1304,15 +1310,20 @@ def __init__(self, FacadeRValue=2, RoofRValue=2, **kwargs):
super(AddInsulationIfItDoesNotExistOrUpgrade, self).__init__(**kwargs)

def create_insulation_material():
location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "default_insulation.json")
location = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "default_insulation.json"
)
data = {}
with open(location) as f:
data = json.load(f)
insulation_material = OpaqueMaterial.from_dict(data)
return insulation_material

def AddInsulationLayerAndSetRValue(original_value, proposed_transformer_value, *args, **kwargs):
def AddInsulationLayerAndSetRValue(
original_value, proposed_transformer_value, *args, **kwargs
):
from archetypal.template.materials.material_layer import MaterialLayer

mat = create_insulation_material()
layer = MaterialLayer(mat, 0.060)
new = original_value.duplicate()
Expand All @@ -1325,13 +1336,13 @@ def AddInsulationLayerAndSetRValue(original_value, proposed_transformer_value, *
Lookup=["Perimeter", "Constructions", "Facade"],
Transformer=AddInsulationLayerAndSetRValue,
)
facade_insulation_creation_prop= MeasureProperty(

facade_insulation_creation_prop = MeasureProperty(
Name="Facade R-Value",
AttrName="FacadeRValue",
Description="Adds an insulation layer if none exists, then set r-value of entire assembly.",
Default=FacadeRValue,
Actions=[facade_insulation_addition]
Actions=[facade_insulation_addition],
)
self.add_property(facade_insulation_creation_prop)

Expand All @@ -1340,12 +1351,12 @@ def AddInsulationLayerAndSetRValue(original_value, proposed_transformer_value, *
Lookup=["Perimeter", "Constructions", "Roof"],
Transformer=AddInsulationLayerAndSetRValue,
)
roof_insulation_creation_prop= MeasureProperty(

roof_insulation_creation_prop = MeasureProperty(
Name="Roof R-Value",
AttrName="RoofRValue",
Description="Adds an insulation layer if none exists, then set r-value of entire assembly.",
Default=RoofRValue,
Actions=[roof_insulation_addition]
Actions=[roof_insulation_addition],
)
self.add_property(roof_insulation_creation_prop)
self.add_property(roof_insulation_creation_prop)
1 change: 1 addition & 0 deletions archetypal/template/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

class UmiSchedule(Schedule, UmiBase):
"""Class that handles Schedules."""

_CREATED_OBJECTS = []

__slots__ = ("_quantity",)
Expand Down
9 changes: 2 additions & 7 deletions archetypal/template/umi_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ def get_unique(self):
(
x
for x in self._CREATED_OBJECTS
if x == self
and x.Name == self.Name
if x == self and x.Name == self.Name
),
key=lambda x: x.unit_number,
)
Expand All @@ -424,11 +423,7 @@ def get_unique(self):
obj = next(
iter(
sorted(
(
x
for x in self._CREATED_OBJECTS
if x == self
),
(x for x in self._CREATED_OBJECTS if x == self),
key=lambda x: x.unit_number,
)
),
Expand Down
13 changes: 10 additions & 3 deletions archetypal/template/ventilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class VentilationSetting(UmiBase):
.. image:: ../images/template/zoneinfo-ventilation.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down Expand Up @@ -868,7 +869,9 @@ def to_epbunch(self, idf, zone_name, opening_area=0.0):
)
else:
infiltration_epbunch = None
log("No 'ZONEINFILTRATION:DESIGNFLOWRATE' created since IsInfiltrationOn == False.")
log(
"No 'ZONEINFILTRATION:DESIGNFLOWRATE' created since IsInfiltrationOn == False."
)

if self.IsScheduledVentilationOn:
ventilation_epbunch = idf.newidfobject(
Expand Down Expand Up @@ -904,7 +907,9 @@ def to_epbunch(self, idf, zone_name, opening_area=0.0):
)
else:
ventilation_epbunch = None
log("No 'ZONEVENTILATION:DESIGNFLOWRATE' created since IsScheduledVentilationOn == False.")
log(
"No 'ZONEVENTILATION:DESIGNFLOWRATE' created since IsScheduledVentilationOn == False."
)

if self.IsNatVentOn:
natural_epbunch = idf.newidfobject(
Expand All @@ -931,7 +936,9 @@ def to_epbunch(self, idf, zone_name, opening_area=0.0):
)
else:
natural_epbunch = None
log("No 'ZONEVENTILATION:WINDANDSTACKOPENAREA' created since IsNatVentOn == False.")
log(
"No 'ZONEVENTILATION:WINDANDSTACKOPENAREA' created since IsNatVentOn == False."
)

return infiltration_epbunch, ventilation_epbunch, natural_epbunch

Expand Down
1 change: 1 addition & 0 deletions archetypal/template/window_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class WindowSetting(UmiBase):
.. _eppy : https://eppy.readthedocs.io/en/latest/
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/zone_construction_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class ZoneConstructionSet(UmiBase):
"""ZoneConstructionSet class."""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down
1 change: 1 addition & 0 deletions archetypal/template/zonedefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ZoneDefinition(UmiBase):
.. image:: ../images/template/zoneinfo-zone.png
"""

_CREATED_OBJECTS = []

__slots__ = (
Expand Down

0 comments on commit 014bb8a

Please sign in to comment.