Skip to content

Commit

Permalink
Ensures compatibility with archetypal
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed May 24, 2021
1 parent 322ff16 commit bcdd40b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
11 changes: 7 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MassRatio,
StructureInformation,
WindowSetting,
GasLayer,
)


Expand Down Expand Up @@ -172,7 +173,7 @@ def airlayer(air):
Args:
air:
"""
return MaterialLayer(Material=air, Thickness=0.01)
return GasLayer(Material=air, Thickness=0.01)


@pytest.fixture()
Expand All @@ -183,7 +184,9 @@ def windowconstruction(windowlayer, airlayer):
airlayer:
"""
return WindowConstruction(
Name="A Window Construction", Layers=[windowlayer, airlayer, windowlayer]
Name="A Window Construction",
Layers=[windowlayer, airlayer, windowlayer],
Category="double",
).save()


Expand Down Expand Up @@ -217,8 +220,8 @@ def conset(construction):


@pytest.fixture()
def intmass():
return OpaqueConstruction(Name="OpaqueConstruction").save()
def intmass(materiallayer):
return OpaqueConstruction(Name="InternalMass", Layers=[materiallayer]).save()


@pytest.fixture()
Expand Down
10 changes: 6 additions & 4 deletions umitemplatedb/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from enum import Enum

from archetypal.umi_template import traverse
from mongoengine import EmbeddedDocument
from tqdm import tqdm

Expand Down Expand Up @@ -37,7 +38,7 @@ def recursive(umibase, **metaattributes):
if isinstance(
value,
(
archetypal.template.UmiBase,
archetypal.template.umi_base.UmiBase,
archetypal.template.schedule.YearSchedulePart,
),
):
Expand All @@ -48,10 +49,11 @@ def recursive(umibase, **metaattributes):
if isinstance(
value,
(
archetypal.template.UmiBase,
archetypal.template.umi_base.UmiBase,
archetypal.template.schedule.YearSchedulePart,
archetypal.template.MaterialLayer,
archetypal.template.MassRatio,
archetypal.template.materials.material_layer.MaterialLayer,
archetypal.template.materials.gas_layer.GasLayer,
archetypal.template.structure.MassRatio,
),
):
instance_attr[key].append(recursive(value))
Expand Down
41 changes: 36 additions & 5 deletions umitemplatedb/mongodb_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def failed(self, event):
"microseconds".format(event)
)


# Uncomment next line to register the logger
# monitoring.register(CommandLogger())

Expand Down Expand Up @@ -121,7 +122,7 @@ class GlazingMaterial(Material):


class OpaqueMaterial(Material):
SpecificHeat = FloatField(default=0)
SpecificHeat = FloatField(default=100, min_value=100)
SolarAbsorptance = FloatField(default=0.7)
ThermalEmittance = FloatField(default=0.9)
VisibleAbsorptance = FloatField(default=0.7)
Expand All @@ -139,13 +140,28 @@ class OpaqueMaterial(Material):
)


class MaterialLayer(EmbeddedDocument):
class _Layer(EmbeddedDocument):
"""Parent class of MaterialLayer & GasLayer to use in EmbeddedDocumentListField."""

pass

meta = {"allow_inheritance": True}


class MaterialLayer(_Layer):
Material = ReferenceField(Material, required=True)
Thickness = FloatField(required=True)

meta = {"allow_inheritance": True, "strict": False}


class GasLayer(_Layer):
Material = ReferenceField(GasMaterial, required=True)
Thickness = FloatField(required=True)

meta = {"allow_inheritance": True, "strict": False}


class ConstructionBase(UmiBase):
# Type = IntField(choices=range(0, 5))

Expand All @@ -157,13 +173,13 @@ class ConstructionBase(UmiBase):


class OpaqueConstruction(ConstructionBase):
Layers = EmbeddedDocumentListField(MaterialLayer)
Layers = EmbeddedDocumentListField(_Layer)

meta = {"allow_inheritance": True}


class WindowConstruction(ConstructionBase):
Layers = EmbeddedDocumentListField(MaterialLayer)
Layers = EmbeddedDocumentListField(_Layer)


class MassRatio(EmbeddedDocument):
Expand Down Expand Up @@ -302,6 +318,15 @@ class ZoneDefinition(UmiBase):
Loads = ReferenceField(ZoneLoad, required=True)
Ventilation = ReferenceField(VentilationSetting, required=True)

zone_surfaces = ListField()
is_part_of_conditioned_floor_area = BooleanField(default=True)
volume = FloatField()
multiplier = IntField(min_value=1)
occupants = FloatField()
is_part_of_total_floor_area = BooleanField(default=True)
area = FloatField()
is_core = BooleanField()


class WindowSetting(UmiBase):
AfnDischargeC = FloatField(default=0.65, min_value=0, max_value=1)
Expand Down Expand Up @@ -393,7 +418,13 @@ def recursive(document, idf, bar):
for value in document[key]:
if isinstance(
value,
(UmiBase, YearSchedulePart, MaterialLayer, MassRatio,),
(
UmiBase,
YearSchedulePart,
MaterialLayer,
GasLayer,
MassRatio,
),
):
instance_attr[key].append(recursive(value, idf, bar))
else:
Expand Down

0 comments on commit bcdd40b

Please sign in to comment.