def test_rotate_xy(): """Test the Aperture rotate_xy method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) aperture = Aperture('RectangleWindow', Face3D(pts, plane)) origin_1 = Point3D(1, 1, 0) test_1 = aperture.duplicate() test_1.rotate_xy(180, origin_1) assert test_1.geometry[0].x == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].y == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].x == pytest.approx(0, rel=1e-3) assert test_1.geometry[2].y == pytest.approx(0, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3) test_2 = aperture.duplicate() test_2.rotate_xy(90, origin_1) assert test_2.geometry[0].x == pytest.approx(1, rel=1e-3) assert test_2.geometry[0].y == pytest.approx(1, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3) assert test_2.geometry[2].x == pytest.approx(0, rel=1e-3) assert test_2.geometry[2].y == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)
def test_rotate(): """Test the Aperture rotate method.""" pts = (Point3D(0, 0, 2), Point3D(2, 0, 2), Point3D(2, 2, 2), Point3D(0, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) aperture = Aperture('RectangleWindow', Face3D(pts, plane)) origin = Point3D(0, 0, 0) axis = Vector3D(1, 0, 0) test_1 = aperture.duplicate() test_1.rotate(axis, 180, origin) assert test_1.geometry[0].x == pytest.approx(0, rel=1e-3) assert test_1.geometry[0].y == pytest.approx(0, rel=1e-3) assert test_1.geometry[0].z == pytest.approx(-2, rel=1e-3) assert test_1.geometry[2].x == pytest.approx(2, rel=1e-3) assert test_1.geometry[2].y == pytest.approx(-2, rel=1e-3) assert test_1.geometry[2].z == pytest.approx(-2, rel=1e-3) assert aperture.area == test_1.area assert len(aperture.vertices) == len(test_1.vertices) test_2 = aperture.duplicate() test_2.rotate(axis, 90, origin) assert test_2.geometry[0].x == pytest.approx(0, rel=1e-3) assert test_2.geometry[0].y == pytest.approx(-2, rel=1e-3) assert test_2.geometry[0].z == pytest.approx(0, rel=1e-3) assert test_2.geometry[2].x == pytest.approx(2, rel=1e-3) assert test_2.geometry[2].y == pytest.approx(-2, rel=1e-3) assert test_2.geometry[2].z == pytest.approx(2, rel=1e-3) assert aperture.area == test_2.area assert len(aperture.vertices) == len(test_2.vertices)
def reflect_state_shades(): """Check to be sure that dynamic shades are reflected with their parent.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) ap = Aperture('TestWindow', Face3D(pts)) pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0)) shade = StateGeometry('RectangleShade', Face3D(pts_1)) tint1 = RadianceSubFaceState(shades=[shade]) ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1' ap.properties.radiance.states = [tint1] tint1.gen_geos_from_tmtx_thickness(0.05) new_ap = ap.duplicate() origin_1 = Point3D(1, 0, 2) normal_1 = Vector3D(1, 0, 0) plane_1 = Plane(normal_1, origin_1) new_ap.reflect(plane_1) new_shd = new_ap.properties.radiance.states[0].shades[0] assert new_shd.geometry[-1].x == pytest.approx(1, rel=1e-3) assert new_shd.geometry[-1].y == pytest.approx(1, rel=1e-3) assert new_shd.geometry[-1].z == pytest.approx(2, rel=1e-3) assert new_shd.geometry[1].x == pytest.approx(0, rel=1e-3) assert new_shd.geometry[1].y == pytest.approx(2, rel=1e-3) assert new_shd.geometry[1].z == pytest.approx(2, rel=1e-3)
def test_reflect(): """Test the Aperture reflect method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) aperture = Aperture('RectangleWindow', Face3D(pts, plane)) origin_1 = Point3D(1, 0, 2) origin_2 = Point3D(0, 0, 2) normal_1 = Vector3D(1, 0, 0) normal_2 = Vector3D(-1, -1, 0).normalize() plane_1 = Plane(normal_1, origin_1) plane_2 = Plane(normal_2, origin_2) plane_3 = Plane(normal_2, origin_1) test_1 = aperture.duplicate() test_1.reflect(plane_1) assert test_1.geometry[-1].x == pytest.approx(1, rel=1e-3) assert test_1.geometry[-1].y == pytest.approx(1, rel=1e-3) assert test_1.geometry[-1].z == pytest.approx(2, rel=1e-3) assert test_1.geometry[1].x == pytest.approx(0, rel=1e-3) assert test_1.geometry[1].y == pytest.approx(2, rel=1e-3) assert test_1.geometry[1].z == pytest.approx(2, rel=1e-3) test_1 = aperture.duplicate() test_1.reflect(plane_2) assert test_1.geometry[-1].x == pytest.approx(-1, rel=1e-3) assert test_1.geometry[-1].y == pytest.approx(-1, rel=1e-3) assert test_1.geometry[-1].z == pytest.approx(2, rel=1e-3) assert test_1.geometry[1].x == pytest.approx(-2, rel=1e-3) assert test_1.geometry[1].y == pytest.approx(-2, rel=1e-3) assert test_1.geometry[1].z == pytest.approx(2, rel=1e-3) test_2 = aperture.duplicate() test_2.reflect(plane_3) assert test_2.geometry[-1].x == pytest.approx(0, rel=1e-3) assert test_2.geometry[-1].y == pytest.approx(0, rel=1e-3) assert test_2.geometry[-1].z == pytest.approx(2, rel=1e-3) assert test_2.geometry[1].x == pytest.approx(-1, rel=1e-3) assert test_2.geometry[1].y == pytest.approx(-1, rel=1e-3) assert test_2.geometry[1].z == pytest.approx(2, rel=1e-3)
def test_set_states(): """Test the setting of states on an Aperture.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0)) ap = Aperture('TestWindow', Face3D(pts)) shd1 = StateGeometry.from_vertices( 'wall_overhang1', [[0, 0, 10], [10, 0, 10], [10, 2, 10], [0, 2, 10]]) shd2 = StateGeometry.from_vertices( 'wall_overhang2', [[0, 0, 5], [10, 0, 5], [10, 2, 5], [0, 2, 5]]) ecglass1 = Glass.from_single_transmittance('ElectrochromicState1', 0.4) ecglass2 = Glass.from_single_transmittance('ElectrochromicState2', 0.27) ecglass3 = Glass.from_single_transmittance('ElectrochromicState3', 0.14) ecglass4 = Glass.from_single_transmittance('ElectrochromicState4', 0.01) tint1 = RadianceSubFaceState(ecglass1) tint2 = RadianceSubFaceState(ecglass2) tint3 = RadianceSubFaceState(ecglass3) tint4 = RadianceSubFaceState(ecglass4) states = (tint1, tint2, tint3, tint4) tint3.add_shade(shd1) with pytest.raises(AssertionError): tint4.add_shades([shd1, shd2]) tint4.add_shades([shd1.duplicate(), shd2]) with pytest.raises(AssertionError): tint1.gen_geos_from_tmtx_thickness(0.05) with pytest.raises(AssertionError): tint1.gen_geo_from_vmtx_offset(0.1) with pytest.raises(AssertionError): tint1.gen_geo_from_dmtx_offset(0.1) with pytest.raises(AssertionError): ap.properties.radiance.states = states ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1' ap.properties.radiance.states = states for state in ap.properties.radiance.states: assert state.parent.identifier == 'TestWindow' new_ap = ap.duplicate() assert ap.properties.radiance.dynamic_group_identifier == \ new_ap.properties.radiance.dynamic_group_identifier == 'ElectrochromicWindow1' assert len(new_ap.properties.radiance.states) == 4 for i, state in enumerate(new_ap.properties.radiance.states): assert state.modifier.identifier == 'ElectrochromicState{}'.format(i + 1) assert len(new_ap.properties.radiance.states[2].shades) == 1 assert len(new_ap.properties.radiance.states[3].shades) == 2
def test_aperture_duplicate(): """Test the duplication of Aperture objects.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) ap_1 = Aperture('Test Window', Face3D(pts)) ap_2 = ap_1.duplicate() assert ap_1 is not ap_2 for i, pt in enumerate(ap_1.vertices): assert pt == ap_2.vertices[i] assert ap_1.name == ap_2.name ap_2.move(Vector3D(0, 1, 0)) for i, pt in enumerate(ap_1.vertices): assert pt != ap_2.vertices[i]
def test_scale(): """Test the Aperture scale method.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2)) aperture = Aperture('Rectangle Window', Face3D(pts, plane)) new_ap = aperture.duplicate() new_ap.scale(2) assert new_ap.geometry[0] == Point3D(2, 2, 4) assert new_ap.geometry[1] == Point3D(4, 2, 4) assert new_ap.geometry[2] == Point3D(4, 4, 4) assert new_ap.geometry[3] == Point3D(2, 4, 4) assert new_ap.area == aperture.area * 2 ** 2 assert new_ap.perimeter == aperture.perimeter * 2 assert new_ap.normal == aperture.normal
def test_face_duplicate(): """Test the duplication of Face objects.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(5, 0, 3), Point3D(5, 0, 0)) face_1 = Aperture('Test Face', Face3D(pts)) face_2 = face_1.duplicate() assert face_1 is not face_2 for i, pt in enumerate(face_1.vertices): assert pt == face_2.vertices[i] assert face_1.name == face_2.name face_2.move(Vector3D(0, 1, 0)) for i, pt in enumerate(face_1.vertices): assert pt != face_2.vertices[i]
def test_move(): """Test the Aperture move method.""" pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0)) plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0)) aperture = Aperture('Rectangle Window', Face3D(pts_1, plane_1)) vec_1 = Vector3D(2, 2, 2) new_ap = aperture.duplicate() new_ap.move(vec_1) assert new_ap.geometry[0] == Point3D(2, 2, 2) assert new_ap.geometry[1] == Point3D(4, 2, 2) assert new_ap.geometry[2] == Point3D(4, 4, 2) assert new_ap.geometry[3] == Point3D(2, 4, 2) assert new_ap.normal == aperture.normal assert aperture.area == new_ap.area assert aperture.perimeter == new_ap.perimeter
def scale_state_shades(): """Check to be sure that dynamic shades are scaled with their parent.""" pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2)) ap = Aperture('TestWindow', Face3D(pts)) pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0)) shade = StateGeometry('RectangleShade', Face3D(pts_1)) tint1 = RadianceSubFaceState(shades=[shade]) ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1' ap.properties.radiance.states = [tint1] tint1.gen_geo_from_vmtx_offset(0.05) tint1.gen_geo_from_dmtx_offset(0.1) new_ap = ap.duplicate() new_ap.scale(2) new_shd = new_ap.properties.radiance.states[0].shades[0] assert new_shd.geometry[0] == Point3D(2, 2, 4) assert new_shd.geometry[1] == Point3D(4, 2, 4) assert new_shd.geometry[2] == Point3D(4, 4, 4) assert new_shd.geometry[3] == Point3D(2, 4, 4)
def move_state_shades(): """Check to be sure that dynamic shades are moved with their parent.""" pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0)) ap = Aperture('TestWindow', Face3D(pts)) pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0)) shade = StateGeometry('RectangleShade', Face3D(pts_1)) tint1 = RadianceSubFaceState(shades=[shade]) ap.properties.radiance.dynamic_group_identifier = 'ElectrochromicWindow1' ap.properties.radiance.states = [tint1] tint1.gen_geos_from_tmtx_thickness(0.05) vec_1 = Vector3D(2, 2, 2) new_ap = ap.duplicate() new_ap.move(vec_1) new_shd = new_ap.properties.radiance.states[0].shades[0] assert new_shd.geometry[0] == Point3D(2, 2, 2) assert new_shd.geometry[1] == Point3D(4, 2, 2) assert new_shd.geometry[2] == Point3D(4, 4, 2) assert new_shd.geometry[3] == Point3D(2, 4, 2)
def test_duplicate(): """Test what happens to energy properties when duplicating an Aperture.""" verts = [ Point3D(0, 0, 0), Point3D(10, 0, 0), Point3D(10, 0, 10), Point3D(0, 0, 10) ] clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) triple_pane = WindowConstruction( 'Triple Pane', [clear_glass, gap, clear_glass, gap, clear_glass]) aperture_original = Aperture('wall window', Face3D(verts)) aperture_dup_1 = aperture_original.duplicate() assert aperture_original.properties.energy.host is aperture_original assert aperture_dup_1.properties.energy.host is aperture_dup_1 assert aperture_original.properties.energy.host is not \ aperture_dup_1.properties.energy.host assert aperture_original.properties.energy.construction == \ aperture_dup_1.properties.energy.construction aperture_dup_1.properties.energy.construction = triple_pane assert aperture_original.properties.energy.construction != \ aperture_dup_1.properties.energy.construction aperture_dup_2 = aperture_dup_1.duplicate() assert aperture_dup_1.properties.energy.construction == \ aperture_dup_2.properties.energy.construction aperture_dup_2.properties.energy.construction = None assert aperture_dup_1.properties.energy.construction != \ aperture_dup_2.properties.energy.construction