Esempio n. 1
0
def test_to_dict():
    """Test the Shade to_dict method with energy properties."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))

    shade_dict = shade.to_dict()
    assert 'properties' in shade_dict
    assert shade_dict['properties']['type'] == 'ShadeProperties'
    assert 'energy' in shade_dict['properties']
    assert shade_dict['properties']['energy'][
        'type'] == 'ShadeEnergyProperties'

    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    shade_dict = shade.to_dict()
    assert 'construction' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy']['construction'][
        'solar_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction'][
        'visible_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction']['is_specular']

    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans
    shade_dict = shade.to_dict()
    assert 'transmittance_schedule' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy'][
        'transmittance_schedule'] is not None
Esempio n. 2
0
def test_to_from_dict_with_states():
    """Test the Shade from_dict method with radiance properties."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0,
                                                       3), Point3D(1, 0, 0))
    shd = Shade('TreeTrunk', Face3D(pts))
    shd1 = StateGeometry.from_vertices(
        'tree_foliage1', [[0, 0, 5], [2, 0, 5], [2, 2, 5], [0, 2, 5]])
    shd2 = StateGeometry.from_vertices(
        'tree_foliage2', [[0, 0, 5], [-2, 0, 5], [-2, 2, 5], [0, 2, 5]])

    trans1 = Glass.from_single_transmittance('TreeTrans1', 0.5)
    trans2 = Glass.from_single_transmittance('TreeTrans2', 0.27)
    trans3 = Glass.from_single_transmittance('TreeTrans3', 0.14)
    trans4 = Glass.from_single_transmittance('TreeTrans4', 0.01)

    tr1 = RadianceShadeState(trans1)
    tr2 = RadianceShadeState(trans2)
    tr3 = RadianceShadeState(trans3, [shd1])
    tr4 = RadianceShadeState(trans4, [shd1.duplicate(), shd2])
    states = (tr1, tr2, tr3, tr4)

    shd.properties.radiance.dynamic_group_identifier = 'DeciduousTrees'
    shd.properties.radiance.states = states

    ad = shd.to_dict()
    new_shade = Shade.from_dict(ad)
    assert new_shade.properties.radiance.dynamic_group_identifier == \
        shd.properties.radiance.dynamic_group_identifier
    state_ids1 = [state.modifier for state in states]
    state_ids2 = [
        state.modifier for state in new_shade.properties.radiance.states
    ]
    assert state_ids1 == state_ids2
    assert new_shade.to_dict() == ad
Esempio n. 3
0
def test_from_dict():
    """Test the Shade from_dict method with energy properties."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))
    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans

    shade_dict = shade.to_dict()
    new_shade = Shade.from_dict(shade_dict)
    assert new_shade.properties.energy.construction == light_shelf
    assert shade.properties.energy.construction.solar_reflectance == 0.5
    assert shade.properties.energy.construction.visible_reflectance == 0.5
    assert shade.properties.energy.construction.is_specular
    assert new_shade.properties.energy.transmittance_schedule == fritted_glass_trans
    assert new_shade.to_dict() == shade_dict