From 4233322fba9c2f32486fac9ea0423c501107e18b Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 25 Jan 2017 17:43:11 +0100 Subject: [PATCH 01/20] add citygml sample file --- teaser/examples/e5_load.py | 18 +- .../examples/examplefiles/CityGMLSample.gml | 622 ++++++++++++++++++ 2 files changed, 636 insertions(+), 4 deletions(-) create mode 100644 teaser/examples/examplefiles/CityGMLSample.gml diff --git a/teaser/examples/e5_load.py b/teaser/examples/e5_load.py index 771d618ae..ad03550af 100644 --- a/teaser/examples/e5_load.py +++ b/teaser/examples/e5_load.py @@ -25,12 +25,12 @@ def example_save(): prj = Project() - load_xml = pickle_file = os.path.join( + load_xml = os.path.join( utilities.get_default_path(), 'ArchetypeExample.teaserXML') - prj.load_project( - path=load_xml) + #prj.load_project( + # path=load_xml) # To reload data from a pickle file, we do not need to instantiate an # API, as pickle will automatically instantiate all classes as they have @@ -38,12 +38,22 @@ def example_save(): import pickle - load_pickle = pickle_file = os.path.join( + load_pickle = os.path.join( utilities.get_default_path(), 'teaser_pickle.p') pickle_prj = pickle.load(open(load_pickle, "rb")) + prj_gml = Project() + + load_gml = utilities.get_full_path(os.path.join( + 'examples', + 'examplefiles', + 'CityGMLSample.gml')) + + prj_gml.load_citygml(path=load_gml) + + if __name__ == '__main__': example_save() diff --git a/teaser/examples/examplefiles/CityGMLSample.gml b/teaser/examples/examplefiles/CityGMLSample.gml new file mode 100644 index 000000000..88fcb2bd3 --- /dev/null +++ b/teaser/examples/examplefiles/CityGMLSample.gml @@ -0,0 +1,622 @@ + + + Simple 3D city model LOD2 without Appearance + + + 458868.0 5438343.0 112.0 + 458892.0 5438362.0 117.0 + + + + + BSO_Office_lod20 + 1120 + 1985 + 24.0 + 6 + 4.0 + + + + + + + + + + + + + + + + + + + + + + + 291473.5 5630136.0 172.0 291473.5 5630181.0 172.0 291613.5 5630181.0 172.0 291613.5 5630136.0 172.0 291473.5 5630136.0 172.0 + + + + + + + + + + + + + + + + + 291473.5 5630136.0 196.0 291613.5 5630136.0 196.0 291613.5 5630181.0 196.0 291473.5 5630181.0 196.0 291473.5 5630136.0 196.0 + + + + + + + + + + + + + + + + + 291473.5 5630181.0 172.0 291473.5 5630181.0 196.0 291613.5 5630181.0 196.0 291613.5 5630181.0 172.0 291473.5 5630181.0 172.0 + + + + + + + + + + + + + + + + + 291473.5 5630136.0 172.0 291613.5 5630136.0 172.0 291613.5 5630136.0 196.0 291473.5 5630136.0 196.0 291473.5 5630136.0 172.0 + + + + + + + + + + + + + + + + + 291613.5 5630136.0 172.0 291613.5 5630181.0 172.0 291613.5 5630181.0 196.0 291613.5 5630136.0 196.0 291613.5 5630136.0 172.0 + + + + + + + + + + + + + + + + + 291473.5 5630136.0 172.0 291473.5 5630136.0 196.0 291473.5 5630181.0 196.0 291473.5 5630181.0 172.0 291473.5 5630136.0 172.0 + + + + + + + + + + + + + BSO_Office_lod21 + 1120 + 1985 + 24.0 + 6 + 4.0 + + + + + + + + + + + + + + + + + + + + + + + 291496.0 5630193.5 172.0 291496.0 5630228.5 172.0 291566.0 5630228.5 172.0 291566.0 5630193.5 172.0 291496.0 5630193.5 172.0 + + + + + + + + + + + + + + + + + 291496.0 5630193.5 196.0 291566.0 5630193.5 196.0 291566.0 5630228.5 196.0 291496.0 5630228.5 196.0 291496.0 5630193.5 196.0 + + + + + + + + + + + + + + + + + 291496.0 5630228.5 172.0 291496.0 5630228.5 196.0 291566.0 5630228.5 196.0 291566.0 5630228.5 172.0 291496.0 5630228.5 172.0 + + + + + + + + + + + + + + + + + 291496.0 5630193.5 172.0 291566.0 5630193.5 172.0 291566.0 5630193.5 196.0 291496.0 5630193.5 196.0 291496.0 5630193.5 172.0 + + + + + + + + + + + + + + + + + 291566.0 5630193.5 172.0 291566.0 5630228.5 172.0 291566.0 5630228.5 196.0 291566.0 5630193.5 196.0 291566.0 5630193.5 172.0 + + + + + + + + + + + + + + + + + 291496.0 5630193.5 172.0 291496.0 5630193.5 196.0 291496.0 5630228.5 196.0 291496.0 5630228.5 172.0 291496.0 5630193.5 172.0 + + + + + + + + + + + + + BSO_Office_lod10 + 1120 + 1985 + 36.0 + 9 + 4.0 + + + + + + + + + 291496.0 5630240.5 172.0 291496.0 5630285.5 172.0 291566.0 5630285.5 172.0 291566.0 5630240.5 172.0 291496.0 5630240.5 172.0 + + + + + + + + + 291496.0 5630240.5 208.0 291566.0 5630240.5 208.0 291566.0 5630285.5 208.0 291496.0 5630285.5 208.0 291496.0 5630240.5 208.0 + + + + + + + + + 291496.0 5630285.5 172.0 291496.0 5630285.5 208.0 291566.0 5630285.5 208.0 291566.0 5630285.5 172.0 291496.0 5630285.5 172.0 + + + + + + + + + 291496.0 5630240.5 172.0 291566.0 5630240.5 172.0 291566.0 5630240.5 208.0 291496.0 5630240.5 208.0 291496.0 5630240.5 172.0 + + + + + + + + + 291566.0 5630240.5 172.0 291566.0 5630285.5 172.0 291566.0 5630285.5 208.0 291566.0 5630240.5 208.0 291566.0 5630240.5 172.0 + + + + + + + + + 291496.0 5630240.5 172.0 291496.0 5630240.5 208.0 291496.0 5630285.5 208.0 291496.0 5630285.5 172.0 291496.0 5630240.5 172.0 + + + + + + + + + + + + + BSO_Office_lod11 + 1120 + 1985 + 32.0 + 8 + 4.0 + + + + + + + + + 291581.0 5630202.5 172.0 291581.0 5630272.5 172.0 291616.0 5630272.5 172.0 291616.0 5630202.5 172.0 291581.0 5630202.5 172.0 + + + + + + + + + 291581.0 5630202.5 204.0 291616.0 5630202.5 204.0 291616.0 5630272.5 204.0 291581.0 5630272.5 204.0 291581.0 5630202.5 204.0 + + + + + + + + + 291581.0 5630272.5 172.0 291581.0 5630272.5 204.0 291616.0 5630272.5 204.0 291616.0 5630272.5 172.0 291581.0 5630272.5 172.0 + + + + + + + + + 291581.0 5630202.5 172.0 291616.0 5630202.5 172.0 291616.0 5630202.5 204.0 291581.0 5630202.5 204.0 291581.0 5630202.5 172.0 + + + + + + + + + 291616.0 5630202.5 172.0 291616.0 5630272.5 172.0 291616.0 5630272.5 204.0 291616.0 5630202.5 204.0 291616.0 5630202.5 172.0 + + + + + + + + + 291581.0 5630202.5 172.0 291581.0 5630202.5 204.0 291581.0 5630272.5 204.0 291581.0 5630272.5 172.0 291581.0 5630202.5 172.0 + + + + + + + + + + + + + BSO_Residential_lod20 + 1000 + 1950 + 12.0 + 2 + 4.0 + + + + + + + + + + + + + + + + + + + + + + + + 291659.4951905284 5630160.4198729815 172.0 291646.5048094716 5630152.9198729815 172.0 291641.5048094716 5630161.5801270185 172.0 291654.4951905284 5630169.0801270185 172.0 291659.4951905284 5630160.4198729815 172.0 + + + + + + + + + + + + + + + + + 291654.4951905284 5630169.0801270185 179.0 291641.5048094716 5630161.5801270185 179.0 291644.0048094716 5630157.25 184.0 291656.9951905284 5630164.75 184.0 291654.4951905284 5630169.0801270185 179.0 + + + + + + + + + + + + + + + + + 291659.4951905284 5630160.4198729815 179.0 291656.9951905284 5630164.75 184.0 291644.0048094716 5630157.25 184.0 291646.5048094716 5630152.9198729815 179.0 291659.4951905284 5630160.4198729815 179.0 + + + + + + + + + + + + + + + + + 291646.5048094716 5630152.9198729815 172.0 291646.5048094716 5630152.9198729815 179.0 291644.0048094716 5630157.25 184.0 291641.5048094716 5630161.5801270185 179.0 291641.5048094716 5630161.5801270185 172.0 291646.5048094716 5630152.9198729815 172.0 + + + + + + + + + + + + + + + + + 291659.4951905284 5630160.4198729815 172.0 291654.4951905284 5630169.0801270185 172.0 291654.4951905284 5630169.0801270185 179.0 291656.9951905284 5630164.75 184.0 291659.4951905284 5630160.4198729815 179.0 291659.4951905284 5630160.4198729815 172.0 + + + + + + + + + + + + + + + + + 291654.4951905284 5630169.0801270185 172.0 291641.5048094716 5630161.5801270185 172.0 291641.5048094716 5630161.5801270185 179.0 291654.4951905284 5630169.0801270185 179.0 291654.4951905284 5630169.0801270185 172.0 + + + + + + + + + + + + + + + + + 291659.4951905284 5630160.4198729815 172.0 291659.4951905284 5630160.4198729815 179.0 291646.5048094716 5630152.9198729815 179.0 291646.5048094716 5630152.9198729815 172.0 291659.4951905284 5630160.4198729815 172.0 + + + + + + + + + + + + + BSO_Residential_lod10 + 1000 + 1950 + 12.0 + 2 + 4.0 + + + + + + + + + 291645.5 5630243.5 172.0 291645.5 5630258.5 172.0 291655.5 5630258.5 172.0 291655.5 5630243.5 172.0 291645.5 5630243.5 172.0 + + + + + + + + + 291645.5 5630243.5 184.0 291655.5 5630243.5 184.0 291655.5 5630258.5 184.0 291645.5 5630258.5 184.0 291645.5 5630243.5 184.0 + + + + + + + + + 291645.5 5630258.5 172.0 291645.5 5630258.5 184.0 291655.5 5630258.5 184.0 291655.5 5630258.5 172.0 291645.5 5630258.5 172.0 + + + + + + + + + 291645.5 5630243.5 172.0 291655.5 5630243.5 172.0 291655.5 5630243.5 184.0 291645.5 5630243.5 184.0 291645.5 5630243.5 172.0 + + + + + + + + + 291655.5 5630243.5 172.0 291655.5 5630258.5 172.0 291655.5 5630258.5 184.0 291655.5 5630243.5 184.0 291655.5 5630243.5 172.0 + + + + + + + + + 291645.5 5630243.5 172.0 291645.5 5630243.5 184.0 291645.5 5630258.5 184.0 291645.5 5630258.5 172.0 291645.5 5630243.5 172.0 + + + + + + + + + + + From 42eaeb28dc3df0663f57c2618897865a790d284a Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 26 Jan 2017 09:20:10 +0100 Subject: [PATCH 02/20] hopefully fix bindings and load example --- teaser/data/bindings/v_0_4/project_bind.py | 42 +++++++++++----------- teaser/data/bindings/v_0_5/project_bind.py | 42 +++++++++++----------- teaser/examples/e5_load.py | 14 ++++++-- 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/teaser/data/bindings/v_0_4/project_bind.py b/teaser/data/bindings/v_0_4/project_bind.py index 60d159e6f..cc9a91560 100644 --- a/teaser/data/bindings/v_0_4/project_bind.py +++ b/teaser/data/bindings/v_0_4/project_bind.py @@ -33,7 +33,7 @@ # NOTE: All namespace declarations are reserved within the binding Namespace = pyxb.namespace.NamespaceForURI('http://teaser.project', create_if_missing=True) -Namespace.configureCategories(['typeBinding', 'elementBinding']) +Namespace.configureCategories(['typeBinding_04', 'elementBinding_04']) def CreateFromDocument (xml_text, default_namespace=None, location_base=None): """Parse the given XML and use the document element to create a @@ -103,7 +103,7 @@ class UseConditionType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.UseConditionType = UseConditionType -Namespace.addCategoryObject('typeBinding', 'UseConditionType', UseConditionType) +Namespace.addCategoryObject('typeBinding_04', 'UseConditionType', UseConditionType) # Complex type {http://teaser.project}MaterialType with content type ELEMENT_ONLY @@ -171,7 +171,7 @@ class MaterialType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.MaterialType = MaterialType -Namespace.addCategoryObject('typeBinding', 'MaterialType', MaterialType) +Namespace.addCategoryObject('typeBinding_04', 'MaterialType', MaterialType) # Complex type {http://teaser.project}LayerType with content type ELEMENT_ONLY @@ -215,7 +215,7 @@ class LayerType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.LayerType = LayerType -Namespace.addCategoryObject('typeBinding', 'LayerType', LayerType) +Namespace.addCategoryObject('typeBinding_04', 'LayerType', LayerType) # Complex type {http://teaser.project}OuterWallType with content type ELEMENT_ONLY @@ -331,7 +331,7 @@ class OuterWallType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.OuterWallType = OuterWallType -Namespace.addCategoryObject('typeBinding', 'OuterWallType', OuterWallType) +Namespace.addCategoryObject('typeBinding_04', 'OuterWallType', OuterWallType) # Complex type {http://teaser.project}RooftopType with content type ELEMENT_ONLY @@ -447,7 +447,7 @@ class RooftopType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.RooftopType = RooftopType -Namespace.addCategoryObject('typeBinding', 'RooftopType', RooftopType) +Namespace.addCategoryObject('typeBinding_04', 'RooftopType', RooftopType) # Complex type {http://teaser.project}InnerWallType with content type ELEMENT_ONLY @@ -547,7 +547,7 @@ class InnerWallType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.InnerWallType = InnerWallType -Namespace.addCategoryObject('typeBinding', 'InnerWallType', InnerWallType) +Namespace.addCategoryObject('typeBinding_04', 'InnerWallType', InnerWallType) # Complex type {http://teaser.project}CeilingType with content type ELEMENT_ONLY @@ -647,7 +647,7 @@ class CeilingType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.CeilingType = CeilingType -Namespace.addCategoryObject('typeBinding', 'CeilingType', CeilingType) +Namespace.addCategoryObject('typeBinding_04', 'CeilingType', CeilingType) # Complex type {http://teaser.project}FloorType with content type ELEMENT_ONLY @@ -747,7 +747,7 @@ class FloorType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.FloorType = FloorType -Namespace.addCategoryObject('typeBinding', 'FloorType', FloorType) +Namespace.addCategoryObject('typeBinding_04', 'FloorType', FloorType) # Complex type {http://teaser.project}GroundFloorType with content type ELEMENT_ONLY @@ -847,7 +847,7 @@ class GroundFloorType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.GroundFloorType = GroundFloorType -Namespace.addCategoryObject('typeBinding', 'GroundFloorType', GroundFloorType) +Namespace.addCategoryObject('typeBinding_04', 'GroundFloorType', GroundFloorType) # Complex type {http://teaser.project}WindowType with content type ELEMENT_ONLY @@ -995,7 +995,7 @@ class WindowType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.WindowType = WindowType -Namespace.addCategoryObject('typeBinding', 'WindowType', WindowType) +Namespace.addCategoryObject('typeBinding_04', 'WindowType', WindowType) # Complex type {http://teaser.project}ThermalZoneType with content type ELEMENT_ONLY @@ -1127,7 +1127,7 @@ class ThermalZoneType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.ThermalZoneType = ThermalZoneType -Namespace.addCategoryObject('typeBinding', 'ThermalZoneType', ThermalZoneType) +Namespace.addCategoryObject('typeBinding_04', 'ThermalZoneType', ThermalZoneType) # Complex type {http://teaser.project}BuildingAHUType with content type ELEMENT_ONLY @@ -1243,7 +1243,7 @@ class BuildingAHUType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.BuildingAHUType = BuildingAHUType -Namespace.addCategoryObject('typeBinding', 'BuildingAHUType', BuildingAHUType) +Namespace.addCategoryObject('typeBinding_04', 'BuildingAHUType', BuildingAHUType) # Complex type {http://teaser.project}BuildingType with content type ELEMENT_ONLY @@ -1367,7 +1367,7 @@ class BuildingType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.BuildingType = BuildingType -Namespace.addCategoryObject('typeBinding', 'BuildingType', BuildingType) +Namespace.addCategoryObject('typeBinding_04', 'BuildingType', BuildingType) # Complex type {http://teaser.project}OfficeType with content type ELEMENT_ONLY @@ -1491,7 +1491,7 @@ class OfficeType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.OfficeType = OfficeType -Namespace.addCategoryObject('typeBinding', 'OfficeType', OfficeType) +Namespace.addCategoryObject('typeBinding_04', 'OfficeType', OfficeType) # Complex type {http://teaser.project}ResidentialType with content type ELEMENT_ONLY @@ -1615,7 +1615,7 @@ class ResidentialType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.ResidentialType = ResidentialType -Namespace.addCategoryObject('typeBinding', 'ResidentialType', ResidentialType) +Namespace.addCategoryObject('typeBinding_04', 'ResidentialType', ResidentialType) # Complex type {http://teaser.project}InstituteType with content type ELEMENT_ONLY @@ -1739,7 +1739,7 @@ class InstituteType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.InstituteType = InstituteType -Namespace.addCategoryObject('typeBinding', 'InstituteType', InstituteType) +Namespace.addCategoryObject('typeBinding_04', 'InstituteType', InstituteType) # Complex type {http://teaser.project}Institute4Type with content type ELEMENT_ONLY @@ -1863,7 +1863,7 @@ class Institute4Type (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.Institute4Type = Institute4Type -Namespace.addCategoryObject('typeBinding', 'Institute4Type', Institute4Type) +Namespace.addCategoryObject('typeBinding_04', 'Institute4Type', Institute4Type) # Complex type {http://teaser.project}Institute8Type with content type ELEMENT_ONLY @@ -1987,7 +1987,7 @@ class Institute8Type (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.Institute8Type = Institute8Type -Namespace.addCategoryObject('typeBinding', 'Institute8Type', Institute8Type) +Namespace.addCategoryObject('typeBinding_04', 'Institute8Type', Institute8Type) # Complex type {http://teaser.project}ProjectType with content type ELEMENT_ONLY @@ -2063,11 +2063,11 @@ class ProjectType (pyxb.binding.basis.complexTypeDefinition): __version.name() : __version }) _module_typeBindings.ProjectType = ProjectType -Namespace.addCategoryObject('typeBinding', 'ProjectType', ProjectType) +Namespace.addCategoryObject('typeBinding_04', 'ProjectType', ProjectType) Project = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'Project'), ProjectType, location=pyxb.utils.utility.Location('D:\\GIT\\TEASER\\teaser\\data\\bindings\\schemas\\Project.xsd', 6, 2)) -Namespace.addCategoryObject('elementBinding', Project.name().localName(), Project) +Namespace.addCategoryObject('elementBinding_04', Project.name().localName(), Project) diff --git a/teaser/data/bindings/v_0_5/project_bind.py b/teaser/data/bindings/v_0_5/project_bind.py index dab997379..822ab71e6 100644 --- a/teaser/data/bindings/v_0_5/project_bind.py +++ b/teaser/data/bindings/v_0_5/project_bind.py @@ -33,7 +33,7 @@ # NOTE: All namespace declarations are reserved within the binding Namespace = pyxb.namespace.NamespaceForURI('http://teaser.project', create_if_missing=True) -Namespace.configureCategories(['typeBinding_05', 'elementBinding_05']) +Namespace.configureCategories(['typeBinding', 'elementBinding']) def CreateFromDocument (xml_text, default_namespace=None, location_base=None): """Parse the given XML and use the document element to create a @@ -103,7 +103,7 @@ class UseConditionType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.UseConditionType = UseConditionType -Namespace.addCategoryObject('typeBinding_05', 'UseConditionType', UseConditionType) +Namespace.addCategoryObject('typeBinding', 'UseConditionType', UseConditionType) # Complex type {http://teaser.project}MaterialType with content type ELEMENT_ONLY @@ -171,7 +171,7 @@ class MaterialType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.MaterialType = MaterialType -Namespace.addCategoryObject('typeBinding_05', 'MaterialType', MaterialType) +Namespace.addCategoryObject('typeBinding', 'MaterialType', MaterialType) # Complex type {http://teaser.project}LayerType with content type ELEMENT_ONLY @@ -215,7 +215,7 @@ class LayerType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.LayerType = LayerType -Namespace.addCategoryObject('typeBinding_05', 'LayerType', LayerType) +Namespace.addCategoryObject('typeBinding', 'LayerType', LayerType) # Complex type {http://teaser.project}OuterWallType with content type ELEMENT_ONLY @@ -331,7 +331,7 @@ class OuterWallType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.OuterWallType = OuterWallType -Namespace.addCategoryObject('typeBinding_05', 'OuterWallType', OuterWallType) +Namespace.addCategoryObject('typeBinding', 'OuterWallType', OuterWallType) # Complex type {http://teaser.project}RooftopType with content type ELEMENT_ONLY @@ -447,7 +447,7 @@ class RooftopType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.RooftopType = RooftopType -Namespace.addCategoryObject('typeBinding_05', 'RooftopType', RooftopType) +Namespace.addCategoryObject('typeBinding', 'RooftopType', RooftopType) # Complex type {http://teaser.project}InnerWallType with content type ELEMENT_ONLY @@ -547,7 +547,7 @@ class InnerWallType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.InnerWallType = InnerWallType -Namespace.addCategoryObject('typeBinding_05', 'InnerWallType', InnerWallType) +Namespace.addCategoryObject('typeBinding', 'InnerWallType', InnerWallType) # Complex type {http://teaser.project}CeilingType with content type ELEMENT_ONLY @@ -647,7 +647,7 @@ class CeilingType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.CeilingType = CeilingType -Namespace.addCategoryObject('typeBinding_05', 'CeilingType', CeilingType) +Namespace.addCategoryObject('typeBinding', 'CeilingType', CeilingType) # Complex type {http://teaser.project}FloorType with content type ELEMENT_ONLY @@ -747,7 +747,7 @@ class FloorType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.FloorType = FloorType -Namespace.addCategoryObject('typeBinding_05', 'FloorType', FloorType) +Namespace.addCategoryObject('typeBinding', 'FloorType', FloorType) # Complex type {http://teaser.project}GroundFloorType with content type ELEMENT_ONLY @@ -847,7 +847,7 @@ class GroundFloorType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.GroundFloorType = GroundFloorType -Namespace.addCategoryObject('typeBinding_05', 'GroundFloorType', GroundFloorType) +Namespace.addCategoryObject('typeBinding', 'GroundFloorType', GroundFloorType) # Complex type {http://teaser.project}WindowType with content type ELEMENT_ONLY @@ -995,7 +995,7 @@ class WindowType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.WindowType = WindowType -Namespace.addCategoryObject('typeBinding_05', 'WindowType', WindowType) +Namespace.addCategoryObject('typeBinding', 'WindowType', WindowType) # Complex type {http://teaser.project}ThermalZoneType with content type ELEMENT_ONLY @@ -1127,7 +1127,7 @@ class ThermalZoneType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.ThermalZoneType = ThermalZoneType -Namespace.addCategoryObject('typeBinding_05', 'ThermalZoneType', ThermalZoneType) +Namespace.addCategoryObject('typeBinding', 'ThermalZoneType', ThermalZoneType) # Complex type {http://teaser.project}BuildingAHUType with content type ELEMENT_ONLY @@ -1243,7 +1243,7 @@ class BuildingAHUType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.BuildingAHUType = BuildingAHUType -Namespace.addCategoryObject('typeBinding_05', 'BuildingAHUType', BuildingAHUType) +Namespace.addCategoryObject('typeBinding', 'BuildingAHUType', BuildingAHUType) # Complex type {http://teaser.project}BuildingType with content type ELEMENT_ONLY @@ -1367,7 +1367,7 @@ class BuildingType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.BuildingType = BuildingType -Namespace.addCategoryObject('typeBinding_05', 'BuildingType', BuildingType) +Namespace.addCategoryObject('typeBinding', 'BuildingType', BuildingType) # Complex type {http://teaser.project}OfficeType with content type ELEMENT_ONLY @@ -1491,7 +1491,7 @@ class OfficeType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.OfficeType = OfficeType -Namespace.addCategoryObject('typeBinding_05', 'OfficeType', OfficeType) +Namespace.addCategoryObject('typeBinding', 'OfficeType', OfficeType) # Complex type {http://teaser.project}ResidentialType with content type ELEMENT_ONLY @@ -1615,7 +1615,7 @@ class ResidentialType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.ResidentialType = ResidentialType -Namespace.addCategoryObject('typeBinding_05', 'ResidentialType', ResidentialType) +Namespace.addCategoryObject('typeBinding', 'ResidentialType', ResidentialType) # Complex type {http://teaser.project}InstituteType with content type ELEMENT_ONLY @@ -1739,7 +1739,7 @@ class InstituteType (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.InstituteType = InstituteType -Namespace.addCategoryObject('typeBinding_05', 'InstituteType', InstituteType) +Namespace.addCategoryObject('typeBinding', 'InstituteType', InstituteType) # Complex type {http://teaser.project}Institute4Type with content type ELEMENT_ONLY @@ -1863,7 +1863,7 @@ class Institute4Type (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.Institute4Type = Institute4Type -Namespace.addCategoryObject('typeBinding_05', 'Institute4Type', Institute4Type) +Namespace.addCategoryObject('typeBinding', 'Institute4Type', Institute4Type) # Complex type {http://teaser.project}Institute8Type with content type ELEMENT_ONLY @@ -1987,7 +1987,7 @@ class Institute8Type (pyxb.binding.basis.complexTypeDefinition): }) _module_typeBindings.Institute8Type = Institute8Type -Namespace.addCategoryObject('typeBinding_05', 'Institute8Type', Institute8Type) +Namespace.addCategoryObject('typeBinding', 'Institute8Type', Institute8Type) # Complex type {http://teaser.project}ProjectType with content type ELEMENT_ONLY @@ -2063,11 +2063,11 @@ class ProjectType (pyxb.binding.basis.complexTypeDefinition): __version.name() : __version }) _module_typeBindings.ProjectType = ProjectType -Namespace.addCategoryObject('typeBinding_05', 'ProjectType', ProjectType) +Namespace.addCategoryObject('typeBinding', 'ProjectType', ProjectType) Project = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'Project'), ProjectType, location=pyxb.utils.utility.Location('D:\\GIT\\TEASER\\teaser\\data\\bindings\\schemas\\Project.xsd', 6, 2)) -Namespace.addCategoryObject('elementBinding_05', Project.name().localName(), Project) +Namespace.addCategoryObject('elementBinding', Project.name().localName(), Project) diff --git a/teaser/examples/e5_load.py b/teaser/examples/e5_load.py index ad03550af..62dee0384 100644 --- a/teaser/examples/e5_load.py +++ b/teaser/examples/e5_load.py @@ -19,7 +19,8 @@ def example_save(): # To load data from *.teaserXML we can use a simple API function. So # first we need to instantiate our API (similar to example # e1_generate_archetype). The XML file is called - # `ArchetypeExample.teaserXML` and saved in the default path. + # `ArchetypeExample.teaserXML` and saved in the default path. You need to + # run e4 first before you can load this example file. from teaser.project import Project @@ -29,8 +30,8 @@ def example_save(): utilities.get_default_path(), 'ArchetypeExample.teaserXML') - #prj.load_project( - # path=load_xml) + prj.load_project( + path=load_xml) # To reload data from a pickle file, we do not need to instantiate an # API, as pickle will automatically instantiate all classes as they have @@ -44,6 +45,10 @@ def example_save(): pickle_prj = pickle.load(open(load_pickle, "rb")) + # The last option to import data into TEASER is using a CityGML file. The + # import of CityGML underlies some limitations e.g. concerning data + # given in the file and the way the buildings are modeled. + prj_gml = Project() load_gml = utilities.get_full_path(os.path.join( @@ -53,6 +58,9 @@ def example_save(): prj_gml.load_citygml(path=load_gml) + # After you imported your teaser project one or another way into you + # python environment you can access variables and functions. + if __name__ == '__main__': example_save() From ef28c0ed29e096f929192a3b54193ab322d81d17 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 26 Jan 2017 09:28:40 +0100 Subject: [PATCH 03/20] fix output and update example files --- teaser/data/output/teaserxml_output.py | 32 ++++++++++++------- teaser/examples/e5_load.py | 16 ++++++++++ .../examplefiles/VDI6007_Room1.teaserXML | 2 +- .../examplefiles/VDI6007_Room10.teaserXML | 2 +- .../examplefiles/VDI6007_Room3.teaserXML | 2 +- .../examplefiles/VDI6007_Room8.teaserXML | 2 +- 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/teaser/data/output/teaserxml_output.py b/teaser/data/output/teaserxml_output.py index 6277179c2..ca45f212d 100644 --- a/teaser/data/output/teaserxml_output.py +++ b/teaser/data/output/teaserxml_output.py @@ -222,21 +222,25 @@ def save_teaser_xml(path, project): pyxb_zone.OuterWall.append(pyxb_wall) - if type(out_wall).__name__ == "Rooftop": + for roof in zone.rooftops: + + if type(roof).__name__ == "Rooftop": pyxb_wall = pb.RooftopType() - set_basic_data_pyxb(pyxb_wall, out_wall) - set_layer_data_pyxb(pyxb_wall, out_wall) + set_basic_data_pyxb(pyxb_wall, roof) + set_layer_data_pyxb(pyxb_wall, roof) pyxb_zone.Rooftop.append(pyxb_wall) - if type(out_wall).__name__ == "GroundFloor": + for ground in zone.ground_floors: + + if type(ground).__name__ == "GroundFloor": pyxb_wall = pb.GroundFloorType() - set_basic_data_pyxb(pyxb_wall, out_wall) - set_layer_data_pyxb(pyxb_wall, out_wall) + set_basic_data_pyxb(pyxb_wall, ground) + set_layer_data_pyxb(pyxb_wall, ground) pyxb_zone.GroundFloor.append(pyxb_wall) @@ -251,21 +255,25 @@ def save_teaser_xml(path, project): pyxb_zone.InnerWall.append(pyxb_wall) - if type(in_wall).__name__ == "Ceiling": + for ceil in zone.ceilings: + + if type(ceil).__name__ == "Ceiling": pyxb_wall = pb.CeilingType() - set_basic_data_pyxb(pyxb_wall, in_wall) - set_layer_data_pyxb(pyxb_wall, in_wall) + set_basic_data_pyxb(pyxb_wall, ceil) + set_layer_data_pyxb(pyxb_wall, ceil) pyxb_zone.Ceiling.append(pyxb_wall) - if type(in_wall).__name__ == "Floor": + for floor in zone.floors: + + if type(floor).__name__ == "Floor": pyxb_wall = pb.FloorType() - set_basic_data_pyxb(pyxb_wall, in_wall) - set_layer_data_pyxb(pyxb_wall, in_wall) + set_basic_data_pyxb(pyxb_wall, floor) + set_layer_data_pyxb(pyxb_wall, floor) pyxb_zone.Floor.append(pyxb_wall) diff --git a/teaser/examples/e5_load.py b/teaser/examples/e5_load.py index 62dee0384..8cdb676fc 100644 --- a/teaser/examples/e5_load.py +++ b/teaser/examples/e5_load.py @@ -32,6 +32,22 @@ def example_save(): prj.load_project( path=load_xml) + prj = Project() + prj.load_project(utilities.get_full_path( + "examples/examplefiles/VDI6007_Room1.teaserXML")) + prj.save_project(file_name="VDI6007_Room1", path=None) + prj = Project() + prj.load_project(utilities.get_full_path( + "examples/examplefiles/VDI6007_Room3.teaserXML")) + prj.save_project(file_name="VDI6007_Room3", path=None) + prj = Project() + prj.load_project(utilities.get_full_path( + "examples/examplefiles/VDI6007_Room8.teaserXML")) + prj.save_project(file_name="VDI6007_Room8", path=None) + prj = Project() + prj.load_project(utilities.get_full_path( + "examples/examplefiles/VDI6007_Room10.teaserXML")) + prj.save_project(file_name="VDI6007_Room10", path=None) # To reload data from a pickle file, we do not need to instantiate an # API, as pickle will automatically instantiate all classes as they have diff --git a/teaser/examples/examplefiles/VDI6007_Room1.teaserXML b/teaser/examples/examplefiles/VDI6007_Room1.teaserXML index d21078885..b4ad542bf 100644 --- a/teaser/examples/examplefiles/VDI6007_Room1.teaserXML +++ b/teaser/examples/examplefiles/VDI6007_Room1.teaserXML @@ -1,5 +1,5 @@ - + VDI6007_1_TEASER_Matlab none diff --git a/teaser/examples/examplefiles/VDI6007_Room10.teaserXML b/teaser/examples/examplefiles/VDI6007_Room10.teaserXML index 2400d7e2e..f31d9e13f 100644 --- a/teaser/examples/examplefiles/VDI6007_Room10.teaserXML +++ b/teaser/examples/examplefiles/VDI6007_Room10.teaserXML @@ -1,5 +1,5 @@ - + VDI6007_10_TEASER_Matlab none diff --git a/teaser/examples/examplefiles/VDI6007_Room3.teaserXML b/teaser/examples/examplefiles/VDI6007_Room3.teaserXML index 14f0cbe5c..2d5060f48 100644 --- a/teaser/examples/examplefiles/VDI6007_Room3.teaserXML +++ b/teaser/examples/examplefiles/VDI6007_Room3.teaserXML @@ -1,5 +1,5 @@ - + VDI6007_2_TEASER_Matlab none diff --git a/teaser/examples/examplefiles/VDI6007_Room8.teaserXML b/teaser/examples/examplefiles/VDI6007_Room8.teaserXML index 0af6f0636..3cba1b9d1 100644 --- a/teaser/examples/examplefiles/VDI6007_Room8.teaserXML +++ b/teaser/examples/examplefiles/VDI6007_Room8.teaserXML @@ -1,5 +1,5 @@ - + VDI6007_3_TEASER_Matlab none From 75c53a2c45dac898efeb5e33f3087f987058d5c6 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 26 Jan 2017 09:29:35 +0100 Subject: [PATCH 04/20] update last example file --- teaser/examples/e5_load.py | 17 +++-------------- teaser/examples/examplefiles/new.teaserXML | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/teaser/examples/e5_load.py b/teaser/examples/e5_load.py index 8cdb676fc..86f5a5687 100644 --- a/teaser/examples/e5_load.py +++ b/teaser/examples/e5_load.py @@ -34,20 +34,9 @@ def example_save(): path=load_xml) prj = Project() prj.load_project(utilities.get_full_path( - "examples/examplefiles/VDI6007_Room1.teaserXML")) - prj.save_project(file_name="VDI6007_Room1", path=None) - prj = Project() - prj.load_project(utilities.get_full_path( - "examples/examplefiles/VDI6007_Room3.teaserXML")) - prj.save_project(file_name="VDI6007_Room3", path=None) - prj = Project() - prj.load_project(utilities.get_full_path( - "examples/examplefiles/VDI6007_Room8.teaserXML")) - prj.save_project(file_name="VDI6007_Room8", path=None) - prj = Project() - prj.load_project(utilities.get_full_path( - "examples/examplefiles/VDI6007_Room10.teaserXML")) - prj.save_project(file_name="VDI6007_Room10", path=None) + "examples/examplefiles/new.teaserXML")) + prj.save_project(file_name="new", path=None) + # To reload data from a pickle file, we do not need to instantiate an # API, as pickle will automatically instantiate all classes as they have diff --git a/teaser/examples/examplefiles/new.teaserXML b/teaser/examples/examplefiles/new.teaserXML index 03160a89e..5321c7863 100644 --- a/teaser/examples/examplefiles/new.teaserXML +++ b/teaser/examples/examplefiles/new.teaserXML @@ -1,5 +1,5 @@ - + B1988 Templergraben 55 From 26272cc64d4da9e54eb9e125d4ee9ce095b4be18 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 26 Jan 2017 09:33:42 +0100 Subject: [PATCH 05/20] add citygml laod unit test --- tests/test_data.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_data.py b/tests/test_data.py index a7e91ce1f..b96024430 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -568,13 +568,18 @@ def test_load_save_project(self): prj.save_project("unitTest") prj.set_default() - # commented until we find solution for opengis PyXB bindings def test_save_citygml(self): '''test of save_gml''' helptest.building_test2(prj) prj.save_citygml("unitTest") prj.set_default() + def test_load_citygml(self): + '''test of load_gml''' + prj.set_default() + prj.load_citygml(utilities.get_full_path( + "examples/examplefiles/CityGMLSample.gml")) + def test_calc_all_buildings(self): '''test of calc_all_buildings, no calculation verification''' From 3ed1b2430c6ef3854855493f7b2e14ce33c7f08c Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 14:25:40 +0200 Subject: [PATCH 06/20] add old est project functions --- tests/test_data.py | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/test_data.py b/tests/test_data.py index 4f80dccc3..db11c9ad9 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -853,7 +853,18 @@ def test_type_bldg_residential(self): construction_type="heavy") def test_est_bldgs(self): - '''test of type_bldg_residential, no calculation verification''' + '''test of type_bldg_est, no calculation verification''' + + prj.type_bldg_est1a( + name="TestBuilding", + year_of_construction=1988, + number_of_floors=7, + height_of_floors=1, + net_leased_area=1988, + with_ahu=False, + neighbour_buildings=None, + construction_type=None) + prj.add_residential( method='urbanrenet', @@ -872,6 +883,17 @@ def test_est_bldgs(self): construction_type="heavy", number_of_apartments=1) + prj.type_bldg_est1b( + name="TestBuilding", + year_of_construction=1988, + number_of_floors=7, + height_of_floors=1, + net_leased_area=1988, + with_ahu=False, + neighbour_buildings=None, + construction_type=None, + number_of_apartments=2) + prj.add_residential( method='urbanrenet', usage='est1b', @@ -940,6 +962,17 @@ def test_est_bldgs(self): construction_type="heavy", number_of_apartments=1) + prj.type_bldg_est4b( + name="TestBuilding", + year_of_construction=1988, + number_of_floors=7, + height_of_floors=1, + net_leased_area=1988, + with_ahu=False, + neighbour_buildings=None, + construction_type=None, + number_of_apartments=2) + prj.add_residential( method='urbanrenet', usage='est4b', @@ -991,6 +1024,17 @@ def test_est_bldgs(self): construction_type="heavy", number_of_apartments=1) + prj.type_bldg_est7( + name="TestBuilding", + year_of_construction=1988, + number_of_floors=7, + height_of_floors=1, + net_leased_area=1988, + with_ahu=False, + neighbour_buildings=None, + construction_type=None, + number_of_apartments=2) + prj.add_residential( method='urbanrenet', usage='est7', From b72db581647aab45d32087ab231e3c7dbe8a7b1f Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 14:38:59 +0200 Subject: [PATCH 07/20] #373 add test for material_output --- teaser/data/dataclass.py | 2 +- tests/test_data.py | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/teaser/data/dataclass.py b/teaser/data/dataclass.py index 6fbaacf51..9d7f32b7b 100644 --- a/teaser/data/dataclass.py +++ b/teaser/data/dataclass.py @@ -123,7 +123,7 @@ def load_mat_binding(self): """ try: __xml_file_mat = open(self.path_mat, 'r+') - version_parse = et.parse(self.path_tb) + version_parse = et.parse(self.path_mat) except: __xml_file_mat = open(self.path_mat, 'w') version_parse = False diff --git a/tests/test_data.py b/tests/test_data.py index db11c9ad9..fe7f2b1be 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -7,7 +7,7 @@ from teaser.logic import utilities from teaser.project import Project import math - +import os import helptest prj = Project(True) @@ -1586,3 +1586,27 @@ def test_change_infiltration_rate(self): therm_zone.use_conditions.base_ach = 0.5 assert therm_zone.infiltration_rate == 0.5 + + def test_load_save_material(self): + '''test of load_material_template and save_material_template, + no parameter checking''' + + from teaser.logic.buildingobjects.buildingphysics.material import \ + Material + + path = os.path.join(utilities.get_default_path(), + 'MatUT.xml') + + mat = Material(parent=None) + mat.load_material_template(mat_name='Tiledroof', + data_class=prj.data) + + from teaser.data.dataclass import DataClass + + dat = DataClass() + dat.path_mat = path + dat.load_mat_binding() + + mat.save_material_template(data_class=dat) + + From 478f3ae75568aa0597c4388af32d12a9d5a06013 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 15:05:11 +0200 Subject: [PATCH 08/20] some missing parts of project.py --- tests/test_data.py | 177 ++++++++++++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 67 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index fe7f2b1be..9adb5a955 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1,8 +1,8 @@ -''' +""" Created July 2015 @author: TEASER 4 Development Team -''' +""" from teaser.logic import utilities from teaser.project import Project @@ -18,7 +18,7 @@ class Test_teaser(object): global prj def test_calc_vdi_room1(self): - '''Parameter Verification for rouvel room1''' + """Parameter Verification for rouvel room1""" import teaser.examples.verification.verification_room1 as room1 room1_prj = room1.parameter_room1() @@ -43,7 +43,7 @@ def test_calc_vdi_room1(self): assert round(zone_attr.alpha_comb_outer_ow, 1) == 25.0 def test_calc_vdi_room3(self): - '''Parameter Verification for room 3''' + """Parameter Verification for room 3""" import teaser.examples.verification.verification_room3 as room3 room3_prj = room3.parameter_room3() @@ -68,7 +68,7 @@ def test_calc_vdi_room3(self): assert round(zone_attr.alpha_comb_outer_ow, 1) == 25.0 def test_calc_vdi_room8(self): - '''Parameter Verification for room 8''' + """Parameter Verification for room 8""" import teaser.examples.verification.verification_room8 as room8 room8_prj = room8.parameter_room8() @@ -93,10 +93,10 @@ def test_calc_vdi_room8(self): # EBC Calculation Verification, with parameters from TEASER3 def test_calc_ebc(self): - ''' + """ Parameter Verification for ebc calculation method. Values are compared with TEASER3 values. - ''' + """ prj.set_default() prj.load_project(utilities.get_full_path("examples/examplefiles" "/new.teaserXML")) @@ -129,10 +129,10 @@ def test_calc_ebc(self): assert round(zone_attr.weightfactor_ground, 5) == 0.54398 def test_type_bldg_office_with_calc(self): - ''' + """ Verification of the type building generation of an office building. Values are compared with TEASER3 values. - ''' + """ from teaser.logic.archetypebuildings.bmvbs.office import Office prj.set_default() @@ -257,10 +257,10 @@ def test_type_bldg_office_with_calc(self): assert round(test_office.get_window_area(270), 0) == 315 def test_type_bldg_institute4_with_calc(self): - ''' + """ Verification of the type building generation of an office building. Values are compared with TEASER3 values. - ''' + """ from teaser.logic.archetypebuildings.bmvbs.custom.institute4 import \ Institute4 @@ -313,10 +313,10 @@ def test_type_bldg_institute4_with_calc(self): assert round(test_institute4.get_window_area(270), 0) == 28 def test_type_bldg_institute8_with_calc(self): - ''' + """ Verification of the type building generation of an office building. Values are compared with TEASER3 values. - ''' + """ from teaser.logic.archetypebuildings.bmvbs.custom.institute8 import \ Institute8 @@ -369,10 +369,10 @@ def test_type_bldg_institute8_with_calc(self): assert round(test_institute8.get_window_area(270), 0) == 28 def test_type_bldg_institute_with_calc(self): - ''' + """ Verification of the type building generation of an office building. Values are compared with TEASER3 values. - ''' + """ from teaser.logic.archetypebuildings.bmvbs.custom.institute import \ Institute @@ -425,10 +425,10 @@ def test_type_bldg_institute_with_calc(self): assert round(test_institute.get_window_area(270), 0) == 28 def test_type_bldg_residential_with_calc(self): - ''' + """ Verification of the type building generation of an office building. Values are compared with TEASER3 values. - ''' + """ from teaser.logic.archetypebuildings.bmvbs.singlefamilydwelling \ import SingleFamilyDwelling @@ -556,7 +556,7 @@ def test_type_bldg_residential_with_calc(self): # not if it produces reliable results. def test_load_save_project(self): - '''test of load_project and save_project''' + """test of load_project and save_project""" prj.load_project(utilities.get_full_path(("examples/examplefiles" "/new.teaserXML"))) @@ -565,42 +565,44 @@ def test_load_save_project(self): tz_area = sum([tz.area for tz in prj.buildings[ -1].thermal_zones]) assert prj.buildings[-1].net_leased_area == tz_area - prj.save_project("unitTest") + prj.save_project(file_name="unitTest", path=None) + prj.save_project(file_name=None, path=utilities.get_default_path()) prj.set_default() def test_save_citygml(self): - '''test of save_gml''' + """test of save_gml""" helptest.building_test2(prj) - prj.save_citygml("unitTest") + prj.save_citygml(file_name="unitTest", path=None) + prj.save_citygml(file_name=None, path=utilities.get_default_path()) prj.set_default() def test_load_citygml(self): - '''test of load_gml''' + """test of load_gml""" prj.set_default() prj.load_citygml(utilities.get_full_path( "examples/examplefiles/CityGMLSample.gml")) def test_calc_all_buildings(self): - '''test of calc_all_buildings, no calculation verification''' + """test of calc_all_buildings, no calculation verification""" helptest.building_test2(prj) helptest.building_test2(prj) prj.number_of_elements_calc = 2 - prj.merge_windows_calc = True + prj.merge_windows_calc = False prj.used_library_calc = 'AixLib' prj.calc_all_buildings() prj.number_of_elements_calc = 2 prj.merge_windows_calc = False prj.used_library_calc = 'AixLib' - prj.calc_all_buildings() + prj.calc_all_buildings(raise_errors=True) def test_retrofit_all_buildings(self): - '''test of retrofit_all_buildings, no calculation verification''' + """test of retrofit_all_buildings, no calculation verification""" prj.retrofit_all_buildings(2015) def test_export_aixlib(self): - '''test of export_aixlib, no calculation verification''' + """test of export_aixlib, no calculation verification""" prj.number_of_elements_calc = 1 prj.merge_windows_calc = False @@ -626,8 +628,28 @@ def test_export_aixlib(self): prj.calc_all_buildings() prj.export_aixlib() + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'AixLib' + prj.calc_all_buildings() + prj.export_aixlib(building_model="Test", + zone_model="Test", + corG="Test") + + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'AixLib' + prj.calc_all_buildings() + prj.export_aixlib(internal_id=prj.buildings[-1].internal_id) + + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'AixLib' + prj.calc_all_buildings() + prj.export_aixlib(path=utilities.get_default_path()) + def test_export_annex(self): - '''test of export_annex, no calculation verification''' + """test of export_annex, no calculation verification""" prj.number_of_elements_calc = 1 prj.merge_windows_calc = True @@ -669,10 +691,20 @@ def test_export_annex(self): prj.used_library_calc = 'Annex60' prj.calc_all_buildings() prj.export_annex() + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'Annex60' + prj.calc_all_buildings() + prj.export_annex(internal_id=prj.buildings[-1].internal_id) + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'Annex60' + prj.calc_all_buildings() + prj.export_annex(path=utilities.get_default_path()) prj.set_default() def test_export_parameters_txt(self): - '''test of the export of the readable parameter output''' + """test of the export of the readable parameter output""" prj.number_of_elements_calc = 1 prj.merge_windows_calc = True prj.used_library_calc = 'AixLib' @@ -713,16 +745,21 @@ def test_export_parameters_txt(self): prj.used_library_calc = 'AixLib' prj.calc_all_buildings() prj.export_parameters_txt() + prj.number_of_elements_calc = 4 + prj.merge_windows_calc = False + prj.used_library_calc = 'AixLib' + prj.calc_all_buildings() + prj.export_parameters_txt(path=utilities.get_default_path()) prj.set_default() def test_instantiate_data_class(self): - '''test of instantiate_data_class''' + """test of instantiate_data_class""" prj.instantiate_data_class() def test_type_bldg_office(self): - '''test of type_bldg_office, no calculation verification - ''' + """test of type_bldg_office, no calculation verification + """ prj.type_bldg_office(name="TestBuilding", year_of_construction=1988, @@ -747,7 +784,7 @@ def test_type_bldg_office(self): construction_type="heavy") def test_type_bldg_institute(self): - '''test of type_bldg_institute, no calculation verification''' + """test of type_bldg_institute, no calculation verification""" prj.type_bldg_institute(name="TestBuilding", year_of_construction=1988, @@ -772,7 +809,7 @@ def test_type_bldg_institute(self): construction_type="heavy") def test_type_bldg_institute4(self): - '''test of type_bldg_institute4, no calculation verification''' + """test of type_bldg_institute4, no calculation verification""" prj.type_bldg_institute4(name="TestBuilding", year_of_construction=1988, @@ -797,7 +834,7 @@ def test_type_bldg_institute4(self): construction_type="heavy") def test_type_bldg_institute8(self): - '''test of type_bldg_institute8, no calculation verification''' + """test of type_bldg_institute8, no calculation verification""" prj.type_bldg_institute8(name="TestBuilding", year_of_construction=1988, @@ -822,7 +859,7 @@ def test_type_bldg_institute8(self): construction_type="heavy") def test_type_bldg_residential(self): - '''test of type_bldg_residential, no calculation verification''' + """test of type_bldg_residential, no calculation verification""" prj.type_bldg_residential(name="TestBuilding", year_of_construction=1988, @@ -853,7 +890,7 @@ def test_type_bldg_residential(self): construction_type="heavy") def test_est_bldgs(self): - '''test of type_bldg_est, no calculation verification''' + """test of type_bldg_est, no calculation verification""" prj.type_bldg_est1a( name="TestBuilding", @@ -1089,14 +1126,14 @@ def test_est_bldgs(self): # methods in Building def test_get_inner_wall_area(self): - '''test of get_inner_wall_area''' + """test of get_inner_wall_area""" prj.set_default() helptest.building_test2(prj) sum_area = prj.buildings[-1].get_inner_wall_area() assert round(sum_area, 1) == 34.0 def test_set_outer_wall_area(self): - '''test of set_outer_wall_area''' + """test of set_outer_wall_area""" print(prj.buildings[-1].thermal_zones[-1].outer_walls[1].area) prj.buildings[-1].set_outer_wall_area(2.0, 0.0) @@ -1106,26 +1143,26 @@ def test_set_outer_wall_area(self): assert round(therm_zone.outer_walls[1].area, 3) == 14.0 def test_get_outer_wall_area(self): - '''test of get_outer_wall_area''' + """test of get_outer_wall_area""" prj.buildings[-1].get_outer_wall_area(0.0) therm_zone = prj.buildings[-1].thermal_zones[-1] assert round(therm_zone.outer_walls[0].area, 3) == 2.0 assert round(therm_zone.outer_walls[1].area, 3) == 14.0 def test_set_window_area(self): - '''test of set_window_area''' + """test of set_window_area""" prj.buildings[-1].set_window_area(1.0, 90.0) therm_zone = prj.buildings[-1].thermal_zones[-1] assert round(therm_zone.windows[0].area, 3) == 1.0 def test_get_window_area(self): - '''test of get_window_area''' + """test of get_window_area""" prj.buildings[-1].get_window_area(90.0) therm_zone = prj.buildings[-1].thermal_zones[-1] assert round(therm_zone.windows[0].area, 3) == 1.0 def test_fill_outer_wall_area_dict(self): - '''test of fill_outer_wall_area_dict''' + """test of fill_outer_wall_area_dict""" prj.buildings[-1].fill_outer_area_dict() outwall_dict_round = {key: round(value, 2) for key, value in @@ -1138,14 +1175,14 @@ def test_fill_outer_wall_area_dict(self): 270.0: 14.0} def test_fill_window_area_dict(self): - '''test of fill_window_area_dict''' + """test of fill_window_area_dict""" prj.buildings[-1].fill_window_area_dict() assert prj.buildings[-1].window_area == {90.0: 1.0, 180.0: 8.0, 270.0: 5.0} def test_calc_building_parameter(self): - '''test of calc_building_parameter''' + """test of calc_building_parameter""" prj.set_default() helptest.building_test2(prj) @@ -1160,7 +1197,7 @@ def test_calc_building_parameter(self): # methods in therm_zone def test_calc_zone_parameters(self): - '''test of calc zone parameter, no calculation verification''' + """test of calc zone parameter, no calculation verification""" prj.buildings[-1].thermal_zones[-1].calc_zone_parameters( number_of_elements=2, merge_windows=False) @@ -1168,7 +1205,7 @@ def test_calc_zone_parameters(self): number_of_elements=2, merge_windows=True) def test_heat_load(self): - '''test of heating_load''' + """test of heating_load""" prj.set_default() helptest.building_test2(prj) prj.buildings[-1].thermal_zones[-1].infiltration_rate = 0.5 @@ -1181,7 +1218,7 @@ def test_heat_load(self): 4) == 6659.6256 def test_sum_building_elements(self): - '''test of combine_building_elements''' + """test of combine_building_elements""" prj.set_default() helptest.building_test2(prj) @@ -1274,7 +1311,7 @@ def test_sum_building_elements(self): assert round(calc_attr.weighted_g_value, 3) == 0.789 def test_calc_chain_matrix(self): - '''test of calc_chain_matrix''' + """test of calc_chain_matrix""" from teaser.logic.buildingobjects.calculation.two_element import\ TwoElement @@ -1303,7 +1340,7 @@ def test_calc_chain_matrix(self): assert round(c1_iw, 6) == 319983.518743 def test_calc_weightfactor(self): - '''test of calc_weightfactor''' + """test of calc_weightfactor""" prj.set_default() helptest.building_test2(prj) prj.buildings[-1].calc_building_parameter(number_of_elements=2, @@ -1358,7 +1395,7 @@ def test_calc_weightfactor(self): weightfactors_test_list.sort() def test_calc_two_element(self): - '''test of calc_two_element''' + """test of calc_two_element""" prj.set_default() helptest.building_test2(prj) @@ -1426,13 +1463,13 @@ def test_calc_two_element(self): assert round(zone_attr.r_rest_ow, 15) == 0.005852240613452 def test_volume_zone(self): - '''test of volume_zone''' + """test of volume_zone""" prj.buildings[-1].thermal_zones[-1].set_volume_zone() assert prj.buildings[-1].thermal_zones[-1].volume == 490.0 def test_set_inner_wall_area(self): - '''test of set_inner_wall_area''' + """test of set_inner_wall_area""" prj.buildings[-1].thermal_zones[-1].set_inner_wall_area() for wall in prj.buildings[-1].thermal_zones[-1].inner_walls: @@ -1441,13 +1478,13 @@ def test_set_inner_wall_area(self): # methods in UseConditions18599() def test_load_use_conditions(self): - '''test of load_use_conditions, no parameter checking''' + """test of load_use_conditions, no parameter checking""" use_cond = prj.buildings[-1].thermal_zones[-1].use_conditions use_cond.load_use_conditions("Living", data_class=prj.data) def test_save_use_conditions(self): - '''test of save_use_conditions, no parameter checking''' + """test of save_use_conditions, no parameter checking""" import os path = os.path.join(utilities.get_default_path(), @@ -1460,7 +1497,7 @@ def test_save_use_conditions(self): # methods in BuildingElement def test_ua_value(self): - '''test of ua_value''' + """test of ua_value""" prj.set_default() helptest.building_test2(prj) @@ -1472,7 +1509,7 @@ def test_ua_value(self): 15) == 4.132453174475393 def test_gather_element_properties(self): - '''test of gather_element_properties''' + """test of gather_element_properties""" outerWalls = prj.buildings[-1].thermal_zones[-1].outer_walls[0] number_of_layer, density, thermal_conduc, heat_capac, thickness = \ outerWalls.gather_element_properties() @@ -1483,7 +1520,7 @@ def test_gather_element_properties(self): assert (thickness == [5., 2.]).all() def test_load_type_element(self): - '''test of load_type_element, no parameter checking''' + """test of load_type_element, no parameter checking""" # test load function therm_zone = prj.buildings[-1].thermal_zones[-1] @@ -1495,7 +1532,7 @@ def test_load_type_element(self): prj.data) def test_save_type_element(self): - '''test of save_type_element, no parameter checking''' + """test of save_type_element, no parameter checking""" import os # test load function therm_zone = prj.buildings[-1].thermal_zones[-1] @@ -1510,7 +1547,7 @@ def test_save_type_element(self): # methods in Wall def test_calc_equivalent_res_wall(self): - '''test of calc_equivalent_res, wall''' + """test of calc_equivalent_res, wall""" prj.set_default() helptest.building_test2(prj) therm_zone = prj.buildings[-1].thermal_zones[-1] @@ -1527,13 +1564,13 @@ def test_calc_equivalent_res_wall(self): assert round(therm_zone.outer_walls[0].c1_korr, 6) == 111237.213205 def test_insulate_wall(self): - '''test of insulate_wall''' + """test of insulate_wall""" therm_zone = prj.buildings[-1].thermal_zones[-1] therm_zone.outer_walls[0].insulate_wall("EPS035", 0.04) assert round(therm_zone.outer_walls[0].ua_value, 6) == 2.806838 def test_retrofit_wall(self): - '''test of retrofit_wall''' + """test of retrofit_wall""" prj.set_default() helptest.building_test2(prj) therm_zone = prj.buildings[-1].thermal_zones[-1] @@ -1566,7 +1603,7 @@ def test_retrofit_wall(self): assert round(therm_zone.outer_walls[0].ua_value, 2) == 4.13 def test_calc_equivalent_res_win(self): - '''test of calc_equivalent_res, win''' + """test of calc_equivalent_res, win""" prj.set_default() helptest.building_test2(prj) therm_zone = prj.buildings[-1].thermal_zones[-1] @@ -1575,8 +1612,8 @@ def test_calc_equivalent_res_win(self): assert round(therm_zone.windows[0].r1, 3) == 0.072 def test_change_infiltration_rate(self): - '''test for change of infiltration_rate''' - prj.set_default() + """test for change of infiltration_rate""" + prj.set_default(load_data=True) helptest.building_test2(prj) therm_zone = prj.buildings[-1].thermal_zones[-1] assert therm_zone.infiltration_rate == 0.2 @@ -1588,8 +1625,8 @@ def test_change_infiltration_rate(self): assert therm_zone.infiltration_rate == 0.5 def test_load_save_material(self): - '''test of load_material_template and save_material_template, - no parameter checking''' + """test of load_material_template and save_material_template, + no parameter checking""" from teaser.logic.buildingobjects.buildingphysics.material import \ Material @@ -1609,4 +1646,10 @@ def test_load_save_material(self): mat.save_material_template(data_class=dat) + def test_properties_project(self): + """Tests properties of project class""" + prj.number_of_elements_calc + prj.merge_windows_calc + prj.used_library_calc + prj.name = 123 From 92f51118070a3d9a6239c9bb18dd39308a015443 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 15:26:01 +0200 Subject: [PATCH 09/20] more missed project.py --- tests/test_data.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/test_data.py b/tests/test_data.py index 9adb5a955..c77f119fd 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -640,7 +640,7 @@ def test_export_aixlib(self): prj.merge_windows_calc = False prj.used_library_calc = 'AixLib' prj.calc_all_buildings() - prj.export_aixlib(internal_id=prj.buildings[-1].internal_id) + prj.buildings.append(prj.buildings[-1]) prj.number_of_elements_calc = 4 prj.merge_windows_calc = False @@ -1652,4 +1652,30 @@ def test_properties_project(self): prj.merge_windows_calc prj.used_library_calc prj.name = 123 + prj.name = prj.data + + def test_warnings_prj(self): + """Tests misc parts in project.py""" + + from teaser.logic.buildingobjects.building import Building + # warnings for not calculated buidlings + bld = Building(parent=prj) + prj.calc_all_buildings() + prj.set_default() + # warning if iwu and number_of_apartments is used + prj.add_residential(method='iwu', + usage="single_family_dwelling", + name="test", + year_of_construction=1988, + number_of_floors=1, + height_of_floors=7, + net_leased_area=1988, + number_of_apartments=1) + # not all buildings if internal id is passed over + + prj.calc_all_buildings() + prj.export_aixlib(internal_id=prj.buildings[-1]) + prj.export_annex(internal_id=prj.buildings[-1]) + + prj.set_default(load_data="Test") From 9081688f83309ad4ec31857979a6a743dfaa1739 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 16:25:55 +0200 Subject: [PATCH 10/20] more project stuff --- teaser/project.py | 23 +++++++---------------- tests/test_data.py | 13 ++++++++++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/teaser/project.py b/teaser/project.py index 24372148d..3de69784f 100644 --- a/teaser/project.py +++ b/teaser/project.py @@ -33,12 +33,8 @@ from teaser.logic.archetypebuildings.bmvbs.singlefamilydwelling import \ SingleFamilyDwelling from teaser.logic.simulation.modelicainfo import ModelicaInfo - -try: - import teaser.data.output.citygml_output as citygml_out - import teaser.data.input.citygml_input as citygml_in -except UserWarning: - warnings.warn("No CityGML module found, no CityGML import/export") +import teaser.data.output.citygml_output as citygml_out +import teaser.data.input.citygml_input as citygml_in class Project(object): @@ -153,13 +149,12 @@ def calc_all_buildings(self, raise_errors=False): number_of_elements=self._number_of_elements_calc, merge_windows=self._merge_windows_calc, used_library=self._used_library_calc) - except UserWarning: + except ZeroDivisionError: warnings.warn( "Following building can't be calculated and is " "removed from buildings list. Use raise_errors=True " "to get python errors and stop TEASER from deleting " - "this building:", - bldg, bldg.name) + "this building:" + bldg.name) def retrofit_all_buildings( self, @@ -1379,10 +1374,6 @@ def name(self, value): regex = re.compile('[^a-zA-z0-9]') self._name = regex.sub('', value) else: - try: - value = str(value) - regex = re.compile('[^a-zA-z0-9]') - self._name = regex.sub('', value) - - except ValueError: - print("Can't convert name to string") + value = str(value) + regex = re.compile('[^a-zA-z0-9]') + self._name = regex.sub('', value) diff --git a/tests/test_data.py b/tests/test_data.py index c77f119fd..b8d7cebcf 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1652,14 +1652,15 @@ def test_properties_project(self): prj.merge_windows_calc prj.used_library_calc prj.name = 123 - prj.name = prj.data def test_warnings_prj(self): """Tests misc parts in project.py""" from teaser.logic.buildingobjects.building import Building + from teaser.logic.buildingobjects.thermalzone import ThermalZone # warnings for not calculated buidlings bld = Building(parent=prj) + tz = ThermalZone(parent=bld) prj.calc_all_buildings() prj.set_default() # warning if iwu and number_of_apartments is used @@ -1672,10 +1673,16 @@ def test_warnings_prj(self): net_leased_area=1988, number_of_apartments=1) # not all buildings if internal id is passed over - + prj.add_residential(method='iwu', + usage="single_family_dwelling", + name="test1", + year_of_construction=1988, + number_of_floors=1, + height_of_floors=7, + net_leased_area=1988, + number_of_apartments=1) prj.calc_all_buildings() prj.export_aixlib(internal_id=prj.buildings[-1]) prj.export_annex(internal_id=prj.buildings[-1]) prj.set_default(load_data="Test") - From ee70a96dbfed5dbd9005e5874e76702911600e63 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 17:14:46 +0200 Subject: [PATCH 11/20] add coverage to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d2f0d1029..f44985816 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ ##################### .cache/ __pycache__/ +.coverage #pip install # ##################### @@ -48,4 +49,4 @@ dist #ignore docs# ##################### -doc/_build \ No newline at end of file +doc/_build From b807e11fc5bbcd3fd1a5d2ae772b4da228e84b41 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Wed, 29 Mar 2017 17:37:37 +0200 Subject: [PATCH 12/20] 100% coverage of API --- teaser/project.py | 6 ++---- tests/test_data.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/teaser/project.py b/teaser/project.py index 3de69784f..85445c52f 100644 --- a/teaser/project.py +++ b/teaser/project.py @@ -1195,8 +1195,7 @@ def export_aixlib( buildings=[bldg], prj=self, path=path) - else: - pass + def export_annex( self, @@ -1240,8 +1239,7 @@ def export_annex( buildings=[bldg], prj=self, path=path) - else: - pass + def export_parameters_txt(self, path=None): """Exports parameters of all buildings in a readable text file diff --git a/tests/test_data.py b/tests/test_data.py index b8d7cebcf..6a7300569 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1677,12 +1677,15 @@ def test_warnings_prj(self): usage="single_family_dwelling", name="test1", year_of_construction=1988, - number_of_floors=1, - height_of_floors=7, - net_leased_area=1988, - number_of_apartments=1) + number_of_floors=15, + height_of_floors=6, + net_leased_area=1988) prj.calc_all_buildings() - prj.export_aixlib(internal_id=prj.buildings[-1]) - prj.export_annex(internal_id=prj.buildings[-1]) + prj.export_aixlib(internal_id=prj.buildings[-1].internal_id) + prj.number_of_elements_calc = 1 + prj.merge_windows_calc = True + prj.used_library_calc = 'Annex60' + prj.calc_all_buildings() + prj.export_annex(internal_id=prj.buildings[-1].internal_id) prj.set_default(load_data="Test") From d67902dae8af5533698a4f81d521236fbc763643 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 30 Mar 2017 10:54:47 +0200 Subject: [PATCH 13/20] add sum building elements for all four calc --- tests/test_data.py | 196 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 195 insertions(+), 1 deletion(-) diff --git a/tests/test_data.py b/tests/test_data.py index 6a7300569..5cb748efc 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1217,7 +1217,201 @@ def test_heat_load(self): prj.buildings[-1].thermal_zones[-1].model_attr.heat_load, 4) == 6659.6256 - def test_sum_building_elements(self): + def test_sum_building_elements_one(self): + """test of combine_building_elements""" + prj.set_default() + helptest.building_test2(prj) + + from teaser.logic.buildingobjects.calculation.one_element import\ + OneElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = OneElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.ground_floors + therm_zone.inner_walls +\ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + calc_attr._sum_outer_wall_elements() + calc_attr._sum_window_elements() + + # outerwall + assert round(calc_attr.ua_value_ow, 16) == 135.5818558809656 + assert round(calc_attr.area_ow, 1) == 328.0 + assert round(calc_attr.r_conv_inner_ow, 19) == 0.0016512549537648611 + assert round(calc_attr.r_rad_inner_ow, 18) == 0.000609756097560976 + assert round(calc_attr.r_comb_inner_ow, 20) == 0.00044531528322052017 + assert round(calc_attr.r_conv_outer_ow, 20) == 0.00026595744680851064 + assert round(calc_attr.r_rad_outer_ow, 18) == 0.001063829787234043 + assert round(calc_attr.r_comb_outer_ow, 20) == 0.0002127659574468085 + assert round(calc_attr.alpha_conv_inner_ow, 5) == 1.84634 + assert round(calc_attr.alpha_rad_inner_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_inner_ow, 5) == 6.84634 + assert round(calc_attr.alpha_conv_outer_ow, 1) == 20.0 + assert round(calc_attr.alpha_rad_outer_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_outer_ow, 1) == 25.0 + + # window + assert round(calc_attr.ua_value_win, 16) == 32.87895310796074 + assert round(calc_attr.area_win, 1) == 18.0 + assert round(calc_attr.r_conv_inner_win, 19) == 0.032679738562091505 + assert round(calc_attr.r_rad_inner_win, 4) == 0.0111 + assert round(calc_attr.r_comb_inner_win, 19) == 0.008291873963515755 + assert round(calc_attr.r_conv_outer_win, 5) == 0.00278 + assert round(calc_attr.r_rad_outer_win, 4) == 0.0111 + assert round(calc_attr.r_comb_outer_win, 4) == 0.0022 + assert round(calc_attr.alpha_conv_inner_win, 1) == 1.7 + assert round(calc_attr.alpha_comb_outer_win, 1) == 25.0 + assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 + assert round(calc_attr.weighted_g_value, 3) == 0.789 + + def test_sum_building_elements_two(self): + """test of combine_building_elements""" + prj.set_default() + helptest.building_test2(prj) + + from teaser.logic.buildingobjects.calculation.two_element import\ + TwoElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = TwoElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.ground_floors + therm_zone.inner_walls +\ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + calc_attr._sum_outer_wall_elements() + calc_attr._sum_inner_wall_elements() + calc_attr._sum_window_elements() + + # innerwall + + assert round(calc_attr.ua_value_iw, 16) == 14.286493860845841 + assert round(calc_attr.area_iw, 1) == 34.0 + assert round(calc_attr.r_conv_inner_iw, 18) == 0.010893246187363833 + assert round(calc_attr.r_rad_inner_iw, 19) == 0.0058823529411764705 + assert round(calc_attr.r_comb_inner_iw, 19) == 0.003819709702062643 + assert round(calc_attr.alpha_conv_inner_iw, 1) == 2.7 + assert round(calc_attr.alpha_rad_inner_iw, 1) == 5.0 + assert round(calc_attr.alpha_comb_inner_iw, 1) == 7.7 + + # outerwall + assert round(calc_attr.ua_value_ow, 16) == 135.5818558809656 + assert round(calc_attr.area_ow, 1) == 328.0 + assert round(calc_attr.r_conv_inner_ow, 19) == 0.0016512549537648611 + assert round(calc_attr.r_rad_inner_ow, 18) == 0.000609756097560976 + assert round(calc_attr.r_comb_inner_ow, 20) == 0.00044531528322052017 + assert round(calc_attr.r_conv_outer_ow, 20) == 0.00026595744680851064 + assert round(calc_attr.r_rad_outer_ow, 18) == 0.001063829787234043 + assert round(calc_attr.r_comb_outer_ow, 20) == 0.0002127659574468085 + assert round(calc_attr.alpha_conv_inner_ow, 5) == 1.84634 + assert round(calc_attr.alpha_rad_inner_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_inner_ow, 5) == 6.84634 + assert round(calc_attr.alpha_conv_outer_ow, 1) == 20.0 + assert round(calc_attr.alpha_rad_outer_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_outer_ow, 1) == 25.0 + + # window + assert round(calc_attr.ua_value_win, 16) == 32.87895310796074 + assert round(calc_attr.area_win, 1) == 18.0 + assert round(calc_attr.r_conv_inner_win, 19) == 0.032679738562091505 + assert round(calc_attr.r_rad_inner_win, 4) == 0.0111 + assert round(calc_attr.r_comb_inner_win, 19) == 0.008291873963515755 + assert round(calc_attr.r_conv_outer_win, 5) == 0.00278 + assert round(calc_attr.r_rad_outer_win, 4) == 0.0111 + assert round(calc_attr.r_comb_outer_win, 4) == 0.0022 + assert round(calc_attr.alpha_conv_inner_win, 1) == 1.7 + assert round(calc_attr.alpha_comb_outer_win, 1) == 25.0 + assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 + assert round(calc_attr.weighted_g_value, 3) == 0.789 + + def test_sum_building_elements_three(self): + """test of combine_building_elements""" + prj.set_default() + helptest.building_test2(prj) + + from teaser.logic.buildingobjects.calculation.three_element import\ + ThreeElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = ThreeElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.ground_floors + therm_zone.inner_walls +\ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + calc_attr._sum_outer_wall_elements() + calc_attr._sum_ground_floor_elements() + calc_attr._sum_inner_wall_elements() + calc_attr._sum_window_elements() + + # innerwall + + assert round(calc_attr.ua_value_iw, 16) == 14.286493860845841 + assert round(calc_attr.area_iw, 1) == 34.0 + assert round(calc_attr.r_conv_inner_iw, 18) == 0.010893246187363833 + assert round(calc_attr.r_rad_inner_iw, 19) == 0.0058823529411764705 + assert round(calc_attr.r_comb_inner_iw, 19) == 0.003819709702062643 + assert round(calc_attr.alpha_conv_inner_iw, 1) == 2.7 + assert round(calc_attr.alpha_rad_inner_iw, 1) == 5.0 + assert round(calc_attr.alpha_comb_inner_iw, 1) == 7.7 + + # outerwall + assert round(calc_attr.ua_value_ow, 16) == 77.23037843150993 + assert round(calc_attr.area_ow, 1) == 188.0 + assert round(calc_attr.r_conv_inner_ow, 19) == 0.0027203482045701846 + assert round(calc_attr.r_rad_inner_ow, 18) == 0.001063829787234043 + assert round(calc_attr.r_comb_inner_ow, 20) == 0.0007647598654022638 + assert round(calc_attr.r_conv_outer_ow, 20) == 0.00026595744680851064 + assert round(calc_attr.r_rad_outer_ow, 18) == 0.001063829787234043 + assert round(calc_attr.r_comb_outer_ow, 20) == 0.0002127659574468085 + assert round(calc_attr.alpha_conv_inner_ow, 5) == 1.95532 + assert round(calc_attr.alpha_rad_inner_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_inner_ow, 5) == 6.95532 + assert round(calc_attr.alpha_conv_outer_ow, 1) == 20.0 + assert round(calc_attr.alpha_rad_outer_ow, 5) == 5.0 + assert round(calc_attr.alpha_comb_outer_ow, 1) == 25.0 + + # groundfloor + assert round(calc_attr.ua_value_gf, 16) == 58.351477449455686 + assert round(calc_attr.area_gf, 1) == 140.0 + assert round(calc_attr.r_conv_inner_gf, 19) == 0.004201680672268907 + assert round(calc_attr.r_rad_inner_gf, 18) == 0.001428571428571429 + assert round(calc_attr.r_comb_inner_gf, 20) == 0.0010660980810234541 + assert round(calc_attr.alpha_conv_inner_gf, 5) == 1.7 + assert round(calc_attr.alpha_rad_inner_gf, 5) == 5.0 + assert round(calc_attr.alpha_comb_inner_gf, 5) == 6.7 + + # window + assert round(calc_attr.ua_value_win, 16) == 32.87895310796074 + assert round(calc_attr.area_win, 1) == 18.0 + assert round(calc_attr.r_conv_inner_win, 19) == 0.032679738562091505 + assert round(calc_attr.r_rad_inner_win, 4) == 0.0111 + assert round(calc_attr.r_comb_inner_win, 19) == 0.008291873963515755 + assert round(calc_attr.r_conv_outer_win, 5) == 0.00278 + assert round(calc_attr.r_rad_outer_win, 4) == 0.0111 + assert round(calc_attr.r_comb_outer_win, 4) == 0.0022 + assert round(calc_attr.alpha_conv_inner_win, 1) == 1.7 + assert round(calc_attr.alpha_comb_outer_win, 1) == 25.0 + assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 + assert round(calc_attr.weighted_g_value, 3) == 0.789 + + def test_sum_building_elements_four(self): """test of combine_building_elements""" prj.set_default() helptest.building_test2(prj) From b47bac03fd5e2591b0d2c9d8420b6a4fa0d8a7dc Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 30 Mar 2017 11:21:33 +0200 Subject: [PATCH 14/20] add chain matrix for all calc --- tests/test_data.py | 130 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 121 insertions(+), 9 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index 5cb748efc..29b49690f 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1270,6 +1270,35 @@ def test_sum_building_elements_one(self): assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 assert round(calc_attr.weighted_g_value, 3) == 0.789 + def test_calc_chain_matrix_one(self): + """test of calc_chain_matrix""" + + from teaser.logic.buildingobjects.calculation.one_element import \ + OneElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = OneElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops + \ + therm_zone.ground_floors + therm_zone.inner_walls + \ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + omega = (2 * math.pi / 86400 / 5) + + helplist_outer_walls = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.ground_floors + therm_zone.windows + + r1_ow, c1_ow = calc_attr._calc_parallel_connection( + element_list=helplist_outer_walls, + omega=omega) + assert round(r1_ow, 14) == 0.00100751548411 + assert round(c1_ow, 5) == 3648580.59312 + def test_sum_building_elements_two(self): """test of combine_building_elements""" prj.set_default() @@ -1335,6 +1364,45 @@ def test_sum_building_elements_two(self): assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 assert round(calc_attr.weighted_g_value, 3) == 0.789 + def test_calc_chain_matrix_two(self): + """test of calc_chain_matrix""" + from teaser.logic.buildingobjects.calculation.two_element import \ + TwoElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = TwoElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops + \ + therm_zone.ground_floors + therm_zone.inner_walls + \ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + omega = (2 * math.pi / 86400 / 5) + + calc_attr = TwoElement(therm_zone, merge_windows=True, t_bt=5) + + helplist_outer_walls = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.ground_floors + therm_zone.windows + + r1_ow, c1_ow = calc_attr._calc_parallel_connection( + element_list=helplist_outer_walls, + omega=omega) + assert round(r1_ow, 14) == 0.00100751548411 + assert round(c1_ow, 5) == 3648580.59312 + + helplist_inner_walls = therm_zone.inner_walls +\ + therm_zone.ceilings + therm_zone.floors + + r1_iw, c1_iw = calc_attr._calc_parallel_connection( + element_list=helplist_inner_walls, + omega=omega) + assert round(r1_iw, 13) == 0.0097195611408 + assert round(c1_iw, 6) == 319983.518743 + def test_sum_building_elements_three(self): """test of combine_building_elements""" prj.set_default() @@ -1411,6 +1479,43 @@ def test_sum_building_elements_three(self): assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 assert round(calc_attr.weighted_g_value, 3) == 0.789 + def test_calc_chain_matrix_three(self): + """test of calc_chain_matrix""" + from teaser.logic.buildingobjects.calculation.three_element import \ + ThreeElement + + therm_zone = prj.buildings[-1].thermal_zones[-1] + + calc_attr = ThreeElement(therm_zone, merge_windows=False, t_bt=5) + + helplist = therm_zone.outer_walls + therm_zone.rooftops + \ + therm_zone.ground_floors + therm_zone.inner_walls + \ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows + + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + omega = (2 * math.pi / 86400 / 5) + + helplist_outer_walls = therm_zone.outer_walls + therm_zone.rooftops +\ + therm_zone.windows + + r1_ow, c1_ow = calc_attr._calc_parallel_connection( + element_list=helplist_outer_walls, + omega=omega) + assert round(r1_ow, 14) == 0.00175779297228 + assert round(c1_ow, 5) == 2091259.60825 + + helplist_inner_walls = therm_zone.inner_walls +\ + therm_zone.ceilings + therm_zone.floors + + r1_iw, c1_iw = calc_attr._calc_parallel_connection( + element_list=helplist_inner_walls, + omega=omega) + assert round(r1_iw, 13) == 0.0097195611408 + assert round(c1_iw, 6) == 319983.518743 + def test_sum_building_elements_four(self): """test of combine_building_elements""" prj.set_default() @@ -1504,25 +1609,32 @@ def test_sum_building_elements_four(self): assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 assert round(calc_attr.weighted_g_value, 3) == 0.789 - def test_calc_chain_matrix(self): + def test_calc_chain_matrix_three(self): """test of calc_chain_matrix""" - from teaser.logic.buildingobjects.calculation.two_element import\ - TwoElement + from teaser.logic.buildingobjects.calculation.four_element import \ + FourElement therm_zone = prj.buildings[-1].thermal_zones[-1] - omega = (2 * math.pi / 86400 / 5) + calc_attr = FourElement(therm_zone, merge_windows=False, t_bt=5) - calc_attr = TwoElement(therm_zone, merge_windows=True, t_bt=5) + helplist = therm_zone.outer_walls + therm_zone.rooftops + \ + therm_zone.ground_floors + therm_zone.inner_walls + \ + therm_zone.ceilings + therm_zone.floors + therm_zone.windows - helplist_outer_walls = therm_zone.outer_walls + therm_zone.rooftops +\ - therm_zone.ground_floors + therm_zone.windows + for element in helplist: + element.calc_equivalent_res() + element.calc_ua_value() + + omega = (2 * math.pi / 86400 / 5) + + helplist_outer_walls = therm_zone.outer_walls + therm_zone.windows r1_ow, c1_ow = calc_attr._calc_parallel_connection( element_list=helplist_outer_walls, omega=omega) - assert round(r1_ow, 14) == 0.00100751548411 - assert round(c1_ow, 5) == 3648580.59312 + assert round(r1_ow, 14) == 0.00688468914141 + assert round(c1_ow, 5) == 533938.62338 helplist_inner_walls = therm_zone.inner_walls +\ therm_zone.ceilings + therm_zone.floors From c2d07d5e8bf7937355e3ca11eabb0b50d68270dd Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 30 Mar 2017 13:58:46 +0200 Subject: [PATCH 15/20] weightfactors for all calc --- tests/test_data.py | 243 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 230 insertions(+), 13 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index 29b49690f..14c8f6a81 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1609,7 +1609,7 @@ def test_sum_building_elements_four(self): assert round(calc_attr.alpha_conv_outer_win, 1) == 20.0 assert round(calc_attr.weighted_g_value, 3) == 0.789 - def test_calc_chain_matrix_three(self): + def test_calc_chain_matrix_four(self): """test of calc_chain_matrix""" from teaser.logic.buildingobjects.calculation.four_element import \ FourElement @@ -1645,33 +1645,117 @@ def test_calc_chain_matrix_three(self): assert round(r1_iw, 13) == 0.0097195611408 assert round(c1_iw, 6) == 319983.518743 - def test_calc_weightfactor(self): + def test_calc_weightfactor_one(self): """test of calc_weightfactor""" prj.set_default() helptest.building_test2(prj) - prj.buildings[-1].calc_building_parameter(number_of_elements=2, + prj.buildings[-1].calc_building_parameter(number_of_elements=1, merge_windows=True, - used_library='AixLib') + used_library='Annex60') calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr - print(calc_attr.weightfactor_ow) + weightfactors_test_list = [ + 0, 0.024530650180761254, 0.03434291025306576, 0.024530650180761254, 0.03434291025306576, 0.3407000330729792] - assert calc_attr.weightfactor_ow.sort() == \ + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow == \ + weightfactors_test_list + + weightfactors_test_list = [ + 0.08674342795625017, + 0.0, + 0.0, + 0.0, + 0.054214642472656345, + 0.054214642472656345] + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0.34638013315780397 + + prj.buildings[-1].thermal_zones[-1].weightfactor_ow = [] + prj.buildings[-1].thermal_zones[-1].weightfactor_win = [] + + prj.buildings[-1].calc_building_parameter(number_of_elements=1, + merge_windows=False, + used_library='AixLib') + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + + weightfactors_test_list = [ + 0.03047939672771178, + 0.423320678280269, + 0.03047939672771178, + 0.0, + 0.04267115541879649, + 0.04267115541879649] + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow ==\ + weightfactors_test_list + + + weightfactors_test_list = [ + 0.44444444444444453, + 0.0, + 0.0, + 0.0, + 0.2777777777777778, + 0.2777777777777778] + + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win.sort() ==\ weightfactors_test_list.sort() + assert calc_attr.weightfactor_ground == \ + 0.4303782174267145 + + def test_calc_weightfactor_two(self): + """test of calc_weightfactor""" + prj.set_default() + helptest.building_test2(prj) + prj.buildings[-1].calc_building_parameter(number_of_elements=2, + merge_windows=True, + used_library='Annex60') + + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + + weightfactors_test_list = [ + 0.0, + 0.024530650180761254, + 0.03434291025306576, + 0.024530650180761254, + 0.03434291025306576, + 0.3407000330729792] + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow == \ + weightfactors_test_list weightfactors_test_list = [ + 0.0, 0.0, 0.054214642472656345, 0.08674342795625017, 0.054214642472656345, 0.0] - assert calc_attr.weightfactor_win.sort() ==\ - weightfactors_test_list.sort() + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0.34638013315780397 prj.buildings[-1].thermal_zones[-1].weightfactor_ow = [] prj.buildings[-1].thermal_zones[-1].weightfactor_win = [] @@ -1682,23 +1766,156 @@ def test_calc_weightfactor(self): calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr weightfactors_test_list = [ + 0.0, 0.03047939672771178, 0.04267115541879649, 0.03047939672771178, 0.04267115541879649, 0.423320678280269] - - assert calc_attr.weightfactor_ow.sort() ==\ - weightfactors_test_list.sort() + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_ow ==\ + weightfactors_test_list weightfactors_test_list = [ + 0.0, 0.0, 0.27777777777777778, 0.44444444444444453, 0.27777777777777778, 0.0] - assert calc_attr.weightfactor_win.sort() ==\ - weightfactors_test_list.sort() + + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0.4303782174267145 + + def test_calc_weightfactor_three(self): + """test of calc_weightfactor""" + prj.set_default() + helptest.building_test2(prj) + prj.buildings[-1].calc_building_parameter(number_of_elements=3, + merge_windows=True, + used_library='Annex60') + + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + weightfactors_test_list = [ + 0.03753045374718346, + 0.5212510365068732, + 0.05254263524605685, + 0.03753045374718346, + 0.05254263524605685] + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow == \ + weightfactors_test_list + weightfactors_test_list = [ + 0.13271234911406493, + 0.0, + 0.08294521819629057, + 0.0, + 0.08294521819629057] + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0 + + prj.buildings[-1].thermal_zones[-1].weightfactor_ow = [] + prj.buildings[-1].thermal_zones[-1].weightfactor_win = [] + + prj.buildings[-1].calc_building_parameter(number_of_elements=3, + merge_windows=False, + used_library='AixLib') + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + + weightfactors_test_list = [ + 0.05350813058801943, + 0.7431609731775066, + 0.07491138282322722, + 0.05350813058801943, + 0.07491138282322722] + + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow ==\ + weightfactors_test_list + + weightfactors_test_list = [ + 0.44444444444444453, + 0.0, + 0.2777777777777778, + 0.0, + 0.2777777777777778] + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0 + + def test_calc_weightfactor_four(self): + """test of calc_weightfactor""" + prj.set_default() + helptest.building_test2(prj) + prj.buildings[-1].calc_building_parameter(number_of_elements=4, + merge_windows=True, + used_library='Annex60') + + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + + weightfactors_test_list = [ + 0.07839276240589141, 0.10974986736824797, 0.07839276240589141, + 0.10974986736824797] + + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + + assert calc_attr.weightfactor_ow == \ + weightfactors_test_list + weightfactors_test_list = [ + 0.27720655131187616, 0.17325409456992255, 0.0, 0.17325409456992255] + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0 + assert calc_attr.weightfactor_rt == \ + [1] + + prj.buildings[-1].thermal_zones[-1].weightfactor_ow = [] + prj.buildings[-1].thermal_zones[-1].weightfactor_win = [] + + prj.buildings[-1].calc_building_parameter(number_of_elements=4, + merge_windows=False, + used_library='AixLib') + calc_attr = prj.buildings[-1].thermal_zones[-1].model_attr + + weightfactors_test_list = [ + 0.20833333333333331, 0.29166666666666663, 0.20833333333333331, + 0.29166666666666663] + calc_attr.weightfactor_ow.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_ow ==\ + weightfactors_test_list + + weightfactors_test_list = [ + 0.44444444444444453, 0.2777777777777778, 0.0, 0.2777777777777778] + + calc_attr.weightfactor_win.sort() + weightfactors_test_list.sort() + assert calc_attr.weightfactor_win ==\ + weightfactors_test_list + assert calc_attr.weightfactor_ground == \ + 0 + assert calc_attr.weightfactor_rt == \ + [1] def test_calc_two_element(self): """test of calc_two_element""" From 0a26baed4fa515203cb03269cc7df5a31b05ede9 Mon Sep 17 00:00:00 2001 From: PRemmen Date: Thu, 30 Mar 2017 16:24:16 +0200 Subject: [PATCH 16/20] unittest for lumped parameters all calc --- tests/test_data.py | 231 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 198 insertions(+), 33 deletions(-) diff --git a/tests/test_data.py b/tests/test_data.py index 14c8f6a81..2cdb0806b 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1917,6 +1917,48 @@ def test_calc_weightfactor_four(self): assert calc_attr.weightfactor_rt == \ [1] + def test_calc_one_element(self): + """test of calc_two_element""" + prj.set_default() + helptest.building_test2(prj) + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=1, + merge_windows=True) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 328.0 + assert round(zone_attr.ua_value_ow, 16) == 135.5818558809656 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.0016512549537649 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.000609756097561 + + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.84634 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_ow, 15) == 0.000772773294534 + assert round(zone_attr.c1_ow, 5) == 3648580.59312 + assert round(zone_attr.r_rest_ow, 14) == 0.00461875570532 + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=1, + merge_windows=False) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 328.0 + assert round(zone_attr.ua_value_ow, 16) == 135.5818558809656 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.0016512549537649 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.000609756097561 + + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.84634 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_win, 13) == 0.0199004975124 + assert round(zone_attr.r1_ow, 15) == 0.001007515484109 + assert round(zone_attr.c1_ow, 5) == 3648580.59312 + assert round(zone_attr.r_rest_ow, 14) == 0.00585224061345 + def test_calc_two_element(self): """test of calc_two_element""" prj.set_default() @@ -1932,23 +1974,15 @@ def test_calc_two_element(self): assert round(zone_attr.ua_value_ow, 16) == 135.5818558809656 assert round(zone_attr.r_conv_inner_ow, 16) == 0.0016512549537649 assert round(zone_attr.r_rad_inner_ow, 16) == 0.000609756097561 - outer_conv_roof_temp = sum( - 1 / roof.r_outer_conv for roof in therm_zone.rooftops) - # old calc was only ow, in the new core we calc outer walls plus - # rooftops, therefore we need to subtract it. - r_outer_conv_ow_temp = 1 / ( - (1 / zone_attr.r_conv_outer_ow) - outer_conv_roof_temp) - assert round(r_outer_conv_ow_temp, 9) == 0.001041667 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.84634 assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 - assert round(zone_attr.r1_win, 15) == 0.003316749585406 assert round(zone_attr.r1_ow, 15) == 0.000772773294534 + assert round(zone_attr.c1_ow, 5) == 3648580.59312 assert round(zone_attr.r1_iw, 15) == 0.009719561140816 - # old calc core was without inner window radiation and without - # combined alpha - r_rest = zone_attr.r_rest_ow + 1 / (zone_attr.alpha_comb_outer_ow * - zone_attr.area_ow) - assert round(r_rest, 15) == 0.004740706924836 + assert round(zone_attr.c1_iw, 5) == 319983.51874 + + assert round(zone_attr.r_rest_ow, 14) == 0.00461875570532 therm_zone = prj.buildings[-1].thermal_zones[-1] therm_zone.calc_zone_parameters( @@ -1960,30 +1994,161 @@ def test_calc_two_element(self): assert round(zone_attr.ua_value_ow, 16) == 135.5818558809656 assert round(zone_attr.r_conv_inner_ow, 16) == 0.0016512549537649 assert round(zone_attr.r_rad_inner_ow, 16) == 0.000609756097561 - outer_conv_roof_temp = sum( - 1 / roof.r_outer_conv for roof in therm_zone.rooftops) - # old calc was only ow, in the new core we calc outer walls plus - # rooftops, therefore we need to subtract it. - r_outer_conv_ow_temp = 1 / ( - (1 / zone_attr.r_conv_outer_ow) - outer_conv_roof_temp) - assert round(r_outer_conv_ow_temp, 9) == 0.001041667 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.84634 assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 - # old r1_win - sum_r1_win = 0 - for win_count in therm_zone.windows: - sum_r1_win += 1 / (win_count.r1 + win_count.r_outer_comb) - r1_win_temp = 1 / sum_r1_win - # new r1_win - assert round(r1_win_temp, 15) == 0.02212271973466 - assert round(zone_attr.r1_win, 15) == 0.019900497512438001 + assert round(zone_attr.r1_win, 13) == 0.0199004975124 assert round(zone_attr.r1_ow, 15) == 0.001007515484109 + assert round(zone_attr.c1_ow, 5) == 3648580.59312 + assert round(zone_attr.r1_iw, 15) == 0.009719561140816 + assert round(zone_attr.r_rest_ow, 14) == 0.00585224061345 + + def test_calc_three_element(self): + """test of calc_two_element""" + prj.set_default() + helptest.building_test2(prj) + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=3, + merge_windows=True) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 188.0 + assert round(zone_attr.ua_value_ow, 16) == 77.23037843150993 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.0027203482045702 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.001063829787234 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.95532 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_ow, 14) == 0.00114890338306 + assert round(zone_attr.c1_ow, 5) == 2091259.60825 + assert round(zone_attr.r1_iw, 15) == 0.009719561140816 + assert round(zone_attr.c1_iw, 5) == 319983.51874 + assert round(zone_attr.r_rest_ow, 11) == 0.00702003101 + assert round(zone_attr.area_gf, 1) == 140.0 + assert round(zone_attr.ua_value_gf, 16) == 58.351477449455686 + assert round(zone_attr.r_conv_inner_gf, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_gf, 16) == 0.0014285714285714 + assert round(zone_attr.alpha_conv_inner_gf, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_gf, 1) == 5.0 + assert round(zone_attr.r1_gf, 14) == 0.00236046484848 + assert round(zone_attr.c1_gf, 5) == 1557320.98487 + assert round(zone_attr.r_rest_gf, 13) == 0.0137109637229 + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=3, + merge_windows=False) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 188.0 + assert round(zone_attr.ua_value_ow, 16) == 77.23037843150993 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.0027203482045702 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.001063829787234 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.000265957 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 1.95532 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_win, 13) == 0.0199004975124 + assert round(zone_attr.r1_ow, 13) == 0.0017577929723 + assert round(zone_attr.c1_ow, 5) == 2091259.60825 assert round(zone_attr.r1_iw, 15) == 0.009719561140816 - # old r_rest - r_rest_ow = zone_attr.r_total_ow - zone_attr.r1_ow -\ - 1 / (1 / zone_attr.r_conv_inner_ow + 1 / zone_attr.r_rad_inner_ow) - assert round(r_rest_ow, 15) == 0.005922787404456 - assert round(zone_attr.r_rest_ow, 15) == 0.005852240613452 + assert round(zone_attr.c1_iw, 5) == 319983.51874 + assert round(zone_attr.r_rest_ow, 13) == 0.0102102921341 + assert round(zone_attr.area_gf, 1) == 140.0 + assert round(zone_attr.ua_value_gf, 16) == 58.351477449455686 + assert round(zone_attr.r_conv_inner_gf, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_gf, 16) == 0.0014285714285714 + assert round(zone_attr.alpha_conv_inner_gf, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_gf, 1) == 5.0 + assert round(zone_attr.r1_gf, 14) == 0.00236046484848 + assert round(zone_attr.c1_gf, 5) == 1557320.98487 + assert round(zone_attr.r_rest_gf, 13) == 0.0137109637229 + + def test_calc_four_element(self): + """test of calc_two_element""" + prj.set_default() + helptest.building_test2(prj) + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=4, + merge_windows=True) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 48.0 + assert round(zone_attr.ua_value_ow, 16) == 19.83577523748189 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.007716049382716 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.0041666666666667 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.001041667 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 2.7 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_ow, 14) == 0.00223838915931 + assert round(zone_attr.c1_ow, 5) == 533938.62338 + assert round(zone_attr.r1_iw, 14) == 0.00971956114082 + assert round(zone_attr.c1_iw, 5) == 319983.51874 + assert round(zone_attr.r_rest_ow, 13) == 0.0138583242416 + assert round(zone_attr.area_gf, 1) == 140.0 + assert round(zone_attr.ua_value_gf, 16) == 58.351477449455686 + assert round(zone_attr.r_conv_inner_gf, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_gf, 16) == 0.0014285714285714 + assert round(zone_attr.alpha_conv_inner_gf, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_gf, 1) == 5.0 + assert round(zone_attr.r1_gf, 14) == 0.00236046484848 + assert round(zone_attr.c1_gf, 5) == 1557320.98487 + assert round(zone_attr.r_rest_gf, 13) == 0.0137109637229 + + assert round(zone_attr.area_rt, 1) == 140.0 + assert round(zone_attr.ua_value_rt, 16) == 57.394603194028036 + assert round(zone_attr.r_conv_inner_rt, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_rt, 16) == 0.0014285714285714 + assert round(zone_attr.r_conv_outer_rt, 9) == 0.000357143 + assert round(zone_attr.alpha_conv_inner_rt, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_rt, 1) == 5.0 + assert round(zone_attr.r1_rt, 14) == 0.00236046484848 + assert round(zone_attr.c1_rt, 5) == 1557320.98487 + assert round(zone_attr.r_rest_rt, 13) == 0.0137109637229 + + therm_zone = prj.buildings[-1].thermal_zones[-1] + therm_zone.calc_zone_parameters( + number_of_elements=4, + merge_windows=False) + + zone_attr = therm_zone.model_attr + assert round(zone_attr.area_ow, 1) == 48.0 + assert round(zone_attr.ua_value_ow, 16) == 19.83577523748189 + assert round(zone_attr.r_conv_inner_ow, 16) == 0.007716049382716 + assert round(zone_attr.r_rad_inner_ow, 16) == 0.0041666666666667 + assert round(zone_attr.r_conv_outer_ow, 9) == 0.001041667 + assert round(zone_attr.alpha_conv_inner_ow, 5) == 2.7 + assert round(zone_attr.alpha_rad_inner_ow, 1) == 5.0 + assert round(zone_attr.r1_win, 13) == 0.0199004975124 + assert round(zone_attr.r1_ow, 14) == 0.00688468914141 + assert round(zone_attr.c1_ow, 5) == 533938.62338 + assert round(zone_attr.r1_iw, 14) == 0.00971956114082 + assert round(zone_attr.c1_iw, 5) == 319983.51874 + assert round(zone_attr.r_rest_ow, 13) == 0.0399903108586 + + assert round(zone_attr.area_gf, 1) == 140.0 + assert round(zone_attr.ua_value_gf, 16) == 58.351477449455686 + assert round(zone_attr.r_conv_inner_gf, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_gf, 16) == 0.0014285714285714 + assert round(zone_attr.alpha_conv_inner_gf, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_gf, 1) == 5.0 + assert round(zone_attr.r1_gf, 14) == 0.00236046484848 + assert round(zone_attr.c1_gf, 5) == 1557320.98487 + assert round(zone_attr.r_rest_gf, 13) == 0.0137109637229 + + assert round(zone_attr.area_rt, 1) == 140.0 + assert round(zone_attr.ua_value_rt, 16) == 57.394603194028036 + assert round(zone_attr.r_conv_inner_rt, 16) == 0.0042016806722689 + assert round(zone_attr.r_rad_inner_rt, 16) == 0.0014285714285714 + assert round(zone_attr.r_conv_outer_rt, 9) == 0.000357143 + assert round(zone_attr.alpha_conv_inner_rt, 5) == 1.7 + assert round(zone_attr.alpha_rad_inner_rt, 1) == 5.0 + assert round(zone_attr.r1_rt, 14) == 0.00236046484848 + assert round(zone_attr.c1_rt, 5) == 1557320.98487 + assert round(zone_attr.r_rest_rt, 13) == 0.0137109637229 def test_volume_zone(self): """test of volume_zone""" From 54954ff827c93b2cbfe5bb3a64105ea68dab7b63 Mon Sep 17 00:00:00 2001 From: MichaMans Date: Thu, 30 Mar 2017 17:33:35 +0200 Subject: [PATCH 17/20] #373 added project bindings v4 test --- tests/test_data.py | 9 + tests/testfiles/teaser_v4.teaserXML | 606 ++++++++++++++++++++++++++++ 2 files changed, 615 insertions(+) create mode 100644 tests/testfiles/teaser_v4.teaserXML diff --git a/tests/test_data.py b/tests/test_data.py index 2cdb0806b..0b0314bfa 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -2377,3 +2377,12 @@ def test_warnings_prj(self): prj.export_annex(internal_id=prj.buildings[-1].internal_id) prj.set_default(load_data="Test") + + def test_v4_bindings(self): + """ + Tests the old v4 project bindings + """ + prj.set_default() + prj.load_project( + os.path.join(os.path.dirname(__file__), 'testfiles', + 'teaser_v4.teaserXML')) diff --git a/tests/testfiles/teaser_v4.teaserXML b/tests/testfiles/teaser_v4.teaserXML new file mode 100644 index 000000000..03160a89e --- /dev/null +++ b/tests/testfiles/teaser_v4.teaserXML @@ -0,0 +1,606 @@ + + + + B1988 + Templergraben 55 + 52062 Aachen + Wohngebaeude + 5 + None + 5 + 4.0 + 2000.0 + + Wohngebaeude + 2000.0 + 8000.0 + 0.5 + 123.0 + 123.0 + + + Living + + 7 18 + 11 + 250 + 2543 + 207 + 13 + 250 + 250 + 250 + 13 + + + 500.0 + 0.8 + 0.84 + 0.3 + 0.9 + 0.7 + 0.5 + + + 21.0 + 24.0 + 4.0 + 20.0 + 26.0 + 45.0 + 5 18 + 5 18 + 0.5 + 0.3 + 1.0 + + + 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.4 0.6 0.8 0.8 0.4 0.6 0.8 0.8 0.4 0.2 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 + 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.2 0.4 0.6 0.8 0.8 0.4 0.6 0.8 0.8 0.4 0.2 0.1 0.1 0.1 0.1 0.1 0.1 + 11.1 + 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 + + + 0.0 + 0.5 + false + false + 0.2 + 1.0 + 3.0 2.0 + 1.0 283.15 290.15 + 0.2 273.15 283.15 + + + + + None + 1988 + massiv + 40.0 + 90.0 + 0.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + WetterschaleausBeton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 20.0 + 90.0 + 90.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + WetterschaleausBeton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 40.0 + 90.0 + 180.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + WetterschaleausBeton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 20.0 + 90.0 + 270.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + WetterschaleausBeton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 400.0 + 0.0 + -1.0 + 1.7000000000000002 + 5.0 + 20.0 + 5.0 + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.09 + + Schaumglas + 120.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.03 + + Kiesschuettung + 1800.0 + 0.7 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 400.0 + 0.0 + -2.0 + 1.7000000000000002 + 5.0 + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.05 + + PSDaemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 6666.66666667 + 2.7 + 5.0 + + 0 + 0.01 + + Kalkputz + 1600.0 + 0.8 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + LeichtHochlochziegel + 800.0 + 0.25 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.01 + + Kalkputz + 1600.0 + 0.8 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 1600.0 + 1.7000000000000002 + 5.0 + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.02 + + PSDaemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + massiv + 1600.0 + 1.7000000000000002 + 5.0 + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.02 + + PSDaemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + + None + 1988 + 9 + 20.0 + 90.0 + 0.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + None + 1988 + 9 + 10.0 + 90.0 + 90.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + None + 1988 + 9 + 20.0 + 90.0 + 180.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + None + 1988 + 9 + 10.0 + 90.0 + 270.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + + From 7844bdf1dbdebfcec11b528a9f95b8cb83ba9d90 Mon Sep 17 00:00:00 2001 From: MichaMans Date: Thu, 30 Mar 2017 18:01:38 +0200 Subject: [PATCH 18/20] #373 added try and except for older binding versions and added 039 binding test --- teaser/data/input/teaserxml_input.py | 24 +- tests/test_data.py | 16 +- tests/testfiles/teaser_v39.teaserXML | 593 +++++++++++++++++++++++++++ 3 files changed, 623 insertions(+), 10 deletions(-) create mode 100644 tests/testfiles/teaser_v39.teaserXML diff --git a/teaser/data/input/teaserxml_input.py b/teaser/data/input/teaserxml_input.py index 367618b05..95ad70b32 100644 --- a/teaser/data/input/teaserxml_input.py +++ b/teaser/data/input/teaserxml_input.py @@ -135,10 +135,14 @@ def _load_building(prj, pyxb_bld, type, project_bind): pyxb_ahu.by_pass_dehumidification bldg.central_ahu.efficiency_recovery = pyxb_ahu.efficiency_recovery - if float(project_bind.version) >= 0.5: - bldg.central_ahu.efficiency_recovery_false = \ - pyxb_ahu.efficiency_recovery_false - else: + try: + if float(project_bind.version) >= 0.5: + bldg.central_ahu.efficiency_recovery_false = \ + pyxb_ahu.efficiency_recovery_false + else: + bldg.central_ahu.efficiency_recovery_false = \ + pyxb_ahu.efficiency_revocery_false + except AttributeError: bldg.central_ahu.efficiency_recovery_false = \ pyxb_ahu.efficiency_revocery_false @@ -191,10 +195,14 @@ def _load_building(prj, pyxb_bld, type, project_bind): zone.use_conditions.daily_operation_heating = \ pyxb_use.UsageOperationTime.daily_operation_heating - if float(project_bind.version) >= 0.4: - zone.use_conditions.maintained_illuminance = \ - pyxb_use.Lighting.maintained_illuminance - else: + try: + if float(project_bind.version) >= 0.4: + zone.use_conditions.maintained_illuminance = \ + pyxb_use.Lighting.maintained_illuminance + else: + zone.use_conditions.maintained_illuminance = \ + pyxb_use.Lighting.maintained_illuminace + except AttributeError: zone.use_conditions.maintained_illuminance = \ pyxb_use.Lighting.maintained_illuminace diff --git a/tests/test_data.py b/tests/test_data.py index 0b0314bfa..e14a09ed8 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -902,7 +902,6 @@ def test_est_bldgs(self): neighbour_buildings=None, construction_type=None) - prj.add_residential( method='urbanrenet', usage='est1a', @@ -2384,5 +2383,18 @@ def test_v4_bindings(self): """ prj.set_default() prj.load_project( - os.path.join(os.path.dirname(__file__), 'testfiles', + os.path.join( + os.path.dirname(__file__), + 'testfiles', 'teaser_v4.teaserXML')) + + def test_v4_bindings(self): + """ + Tests the old v39 project bindings + """ + prj.set_default() + prj.load_project( + os.path.join( + os.path.dirname(__file__), + 'testfiles', + 'teaser_v39.teaserXML')) diff --git a/tests/testfiles/teaser_v39.teaserXML b/tests/testfiles/teaser_v39.teaserXML new file mode 100644 index 000000000..c8f2f9c51 --- /dev/null +++ b/tests/testfiles/teaser_v39.teaserXML @@ -0,0 +1,593 @@ + + + + 1988 + Templergraben 55 + 52062 Aachen + Wohngebaeude + 5 + None + 5 + 4.0 + 2000.0 + + Wohngebaeude + 2000.0 + 8000.0 + 0.5 + 123.0 + 123.0 + + + Living + + 7 18 + 11 + 250 + 2543 + 207 + 13 + 250 + 250 + 250 + 13 + + + 500.0 + 0.8 + 0.84 + 0.3 + 0.9 + 0.7 + 0.5 + + + 21.0 + 24.0 + 4.0 + 20.0 + 26.0 + 45.0 + 5 18 + 5 18 + 0.5 + 0.3 + 1.0 + + + 0.0 + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.4 0.6 0.8 0.8 0.4 0.6 0.8 0.8 0.4 0.2 0.0 0.0 0.0 0.0 0.0 0.0 + 0.0 + 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.2 0.4 0.6 0.8 0.8 0.4 0.6 0.8 0.8 0.4 0.2 0.1 0.1 0.1 0.1 0.1 0.1 + 11.1 + 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 + + + 0.0 + 0.5 + false + false + 0.2 + 1.0 + 3.0 2.0 + 1.0 283.15 290.15 + 0.2 273.15 283.15 + + + + + 1988 + massiv + 40.0 + 90.0 + 0.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Wetterschale aus Beton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 20.0 + 90.0 + 90.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Wetterschale aus Beton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 40.0 + 90.0 + 180.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Wetterschale aus Beton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 20.0 + 90.0 + 270.0 + 2.7 + 5.0 + 20.0 + 5.0 + + 0 + 0.175 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.06 + + Polystyrol + 20.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Wetterschale aus Beton + 2200.0 + 1.65 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 400.0 + 0.0 + -1.0 + 1.7000000000000002 + 5.0 + 20.0 + 5.0 + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.09 + + Schaumglas + 120.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.03 + + Kiesschuettung + 1800.0 + 0.7 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 400.0 + 0.0 + -2.0 + 1.7000000000000002 + 5.0 + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.05 + + PS-Daemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 6666.66666667 + 2.7 + 5.0 + + 0 + 0.01 + + Kalkputz + 1600.0 + 0.8 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + Leicht-Hochlochziegel + 800.0 + 0.25 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.01 + + Kalkputz + 1600.0 + 0.8 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 1600.0 + 1.7000000000000002 + 5.0 + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.02 + + PS-Daemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + + 1988 + massiv + 1600.0 + 1.7000000000000002 + 5.0 + + 0 + 0.04 + + Estrich + 2000.0 + 1.4 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.02 + + PS-Daemmung + 30.0 + 0.04 + 1.0 + 0.0 + 0.0 + + + + 0 + 0.15 + + Stahlbeton + 2400.0 + 2.5 + 1.0 + 0.0 + 0.0 + + + + + 1988 + 9 + 20.0 + 90.0 + 0.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + 1988 + 9 + 10.0 + 90.0 + 90.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + 1988 + 9 + 20.0 + 90.0 + 180.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + 1988 + 9 + 10.0 + 90.0 + 270.0 + 2.7 + 5.0 + 20.0 + 5.0 + 0.03 + 0.0 + 0.0 + + 0 + 0.024 + + glass + 0.0 + 0.147 + 0.0 + 0.0 + 0.0 + + + + + + From 332eceee46bfb327f96795223f925128280b99f8 Mon Sep 17 00:00:00 2001 From: MichaMans Date: Thu, 30 Mar 2017 18:08:54 +0200 Subject: [PATCH 19/20] #373 typo in pytests --- tests/test_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_data.py b/tests/test_data.py index e14a09ed8..8c7616413 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -2388,7 +2388,7 @@ def test_v4_bindings(self): 'testfiles', 'teaser_v4.teaserXML')) - def test_v4_bindings(self): + def test_v39_bindings(self): """ Tests the old v39 project bindings """ From 14584616f0c6e78575047c6d75d4b47ad300bf2c Mon Sep 17 00:00:00 2001 From: MichaMans Date: Mon, 3 Apr 2017 09:52:40 +0200 Subject: [PATCH 20/20] #373 added a delete type element test --- tests/helptest.py | 26 +++++++++++++------------- tests/test_data.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/helptest.py b/tests/helptest.py index 4c50a5042..ae840b98e 100644 --- a/tests/helptest.py +++ b/tests/helptest.py @@ -15,7 +15,7 @@ def building_test2(prj): """ building which is hardcoded for testing """ - bldg = Building(parent = prj) + bldg = Building(parent=prj) '''Set some building parameters''' @@ -29,7 +29,7 @@ def building_test2(prj): '''Instantiate a ThermalZone class, with building as parent and set some parameters of the thermal zone''' - tz = ThermalZone(parent = bldg) + tz = ThermalZone(parent=bldg) tz.name = "Living Room" tz.area = 140.0 tz.volume = tz.area * bldg.number_of_floors * bldg.height_of_floors @@ -37,13 +37,13 @@ def building_test2(prj): tz.use_conditions = BoundaryConditions(tz) tz.use_conditions.usage = "Living" - tz.use_conditions.cooling_time = [5,18] - tz.use_conditions.heating_time = [5,18] + tz.use_conditions.cooling_time = [5, 18] + tz.use_conditions.heating_time = [5, 18] tz.use_conditions.set_temp_heat = 288.15 tz.use_conditions.set_temp_cool = 298.15 - tz.use_conditions.temp_set_back= 4.0 - tz.use_conditions.min_air_exchange= 0.0 - tz.use_conditions.min_ahu= 0.0 + tz.use_conditions.temp_set_back = 4.0 + tz.use_conditions.min_air_exchange = 0.0 + tz.use_conditions.min_ahu = 0.0 tz.use_conditions.max_ahu = 2.6 tz.use_conditions.with_ahu = True tz.use_conditions.persons = 3 @@ -82,7 +82,7 @@ def building_test2(prj): #out_wall_dict = collections.OrderedDict(sorted(out_wall_dict.items(), key=lambda t: t[0])) for value in out_wall_dict: '''instantiate OuterWall class''' - out_wall = OuterWall(parent = tz) + out_wall = OuterWall(parent=tz) out_wall.name = value[0] out_wall.year_of_construction = value[1][0] out_wall.construction_type = value[1][1] @@ -121,7 +121,7 @@ def building_test2(prj): for value in in_wall_dict: '''instantiate OuterWall class''' - in_wall = InnerWall(parent = tz) + in_wall = InnerWall(parent=tz) in_wall.name = value[0] in_wall.year_of_construction = value[1][0] in_wall.construction_type = value[1][1] @@ -156,7 +156,7 @@ def building_test2(prj): 5.0, 90.0, 270.0]]] for value in win_dict: - win = Window(parent = tz) + win = Window(parent=tz) win.construction_type = "Window" win.name = value[0] win.area = value[1][1] @@ -172,7 +172,7 @@ def building_test2(prj): win.a_conv = 0.03 win.shading_g_total = 1.0 win.shading_max_irr = 180.0 - win_layer = Layer(parent = win) + win_layer = Layer(parent=win) win_layer.id = 1 win_layer.thickness = 0.024 @@ -181,7 +181,7 @@ def building_test2(prj): win_material.thermal_conduc = 0.067 win_material.transmittance = 0.9 - roof = Rooftop(parent = tz) + roof = Rooftop(parent=tz) roof.name = "Roof" roof.year_of_construction = bldg.year_of_construction roof.construction_type = "heavy" @@ -205,7 +205,7 @@ def building_test2(prj): roof_material.thermal_conduc = 2.0 roof_material.heat_capac = 0.84 - ground = GroundFloor(parent = tz) + ground = GroundFloor(parent=tz) ground.name = "ground" ground.year_of_construction = bldg.year_of_construction ground.construction_type = "heavy" diff --git a/tests/test_data.py b/tests/test_data.py index 8c7616413..3c59d89e3 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -705,6 +705,7 @@ def test_export_annex(self): def test_export_parameters_txt(self): """test of the export of the readable parameter output""" + helptest.building_test2(prj) prj.number_of_elements_calc = 1 prj.merge_windows_calc = True prj.used_library_calc = 'AixLib' @@ -2231,6 +2232,19 @@ def test_save_type_element(self): therm_zone.inner_walls[0].save_type_element(data_class=prj.data) therm_zone.windows[0].save_type_element(data_class=prj.data) + def test_delete_type_element(self): + """test of save_type_element, no parameter checking""" + import os + # test load function + therm_zone = prj.buildings[-1].thermal_zones[-1] + path = os.path.join(utilities.get_default_path(), + 'unitTestTB.xml') + prj.data.path_tb = path + prj.data.load_tb_binding() + therm_zone.outer_walls[0].delete_type_element(data_class=prj.data) + therm_zone.inner_walls[0].delete_type_element(data_class=prj.data) + therm_zone.windows[0].delete_type_element(data_class=prj.data) + # methods in Wall def test_calc_equivalent_res_wall(self):