Пример #1
0
def test_import_ddy():
    """Test import standard ddy."""
    relative_path = './tests/fixtures/ddy/chicago.ddy'
    abs_path = os.path.abspath(relative_path)

    ddy_rel = DDY.from_ddy_file(relative_path)
    ddy = DDY.from_ddy_file(abs_path)

    # Test imports don't break
    assert ddy.file_path == abs_path
    assert ddy_rel.file_path == os.path.normpath(relative_path)
Пример #2
0
def test_ddy_from_design_day():
    """Test ddy from design day method."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    new_ddy = DDY.from_design_day(ddy.design_days[0])
    assert ddy.location == new_ddy.location
    assert ddy.design_days[0] == new_ddy.design_days[0]
Пример #3
0
def test_sizing_parameter_to_ddy():
    """Test the setting of properties of SizingParameter."""
    sizing = SizingParameter()
    relative_path = './tests/ddy/chicago_monthly.ddy'
    sizing.add_from_ddy(relative_path)
    ddy_obj = DDY.from_ddy_file(relative_path)

    assert sizing.to_ddy() == ddy_obj
Пример #4
0
    def add_from_ddy(self, ddy_file):
        """Add all design days within a .ddy file to this object.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            self._design_days.append(dday)
Пример #5
0
def test_dict_methods():
    """Test dict methods for the DDY object."""
    relative_path = './tests/fixtures/ddy/chicago.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    ddy_dict = ddy.to_dict()
    reconstructed_ddy = DDY.from_dict(ddy_dict)
    assert ddy_dict == reconstructed_ddy.to_dict()
    for dday1, dday2 in zip(ddy.design_days, reconstructed_ddy.design_days):
        assert dday1 == dday2
Пример #6
0
def test_duplicate():
    """Test duplicate method for the DDY object."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    ddy_dup = ddy.duplicate()

    assert ddy is ddy
    assert ddy is not ddy_dup
    assert ddy == ddy_dup
    ddy_dup[0].dry_bulb_condition.dry_bulb_max = 40
    assert ddy != ddy_dup
Пример #7
0
    def add_from_ddy_keyword(self, ddy_file, keyword):
        """Add DesignDays from a .ddy file using a keyword in the DesignDay name.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
            keyword: String for a keyword, which will be used to select DesignDays
                from the .ddy file to add to this object.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            if keyword in dday.name:
                self._design_days.append(dday)
Пример #8
0
def test_duplicate_design_day():
    """Test duplicate method for the DesignDay object."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    des_day = ddy[0]
    des_day_dup = des_day.duplicate()

    assert des_day is des_day
    assert des_day is not des_day_dup
    assert des_day == des_day_dup
    des_day_dup.dry_bulb_condition.dry_bulb_max = 40
    assert des_day != des_day_dup
Пример #9
0
    def add_from_ddy_990_010(self, ddy_file):
        """Add the 99.0% and 1.0% design days within a .ddy file to this object.

        99.0% means that this percent of the hours of the year have outside heating
        conditions warmer than this design day. 1.0% means that this percent of the
        hours of the year have outside cooling conditions cooler than this design day.

        Args:
            ddy_file: The full path to a .ddy file on this machine.
        """
        ddy_obj = DDY.from_ddy_file(ddy_file)
        for dday in ddy_obj:
            if '99%' in dday.name or '1%' in dday.name:
                self._design_days.append(dday)
Пример #10
0
def test_monthly_ddy_properties():
    """Test properties of a monthly ddy."""
    relative_path = './tests/fixtures/ddy/chicago_monthly.ddy'
    ddy = DDY.from_ddy_file(relative_path)

    # Test accuracy of import
    assert ddy.location.city == 'Chicago Ohare Intl Ap'
    assert ddy.location.latitude == approx(41.96, rel=1e-1)
    assert ddy.location.longitude == approx(-87.92, rel=1e-1)
    assert ddy.location.time_zone == -6
    assert ddy.location.elevation == 201

    assert len(ddy.design_days) == 12
    for des_day in ddy.design_days:
        assert isinstance(des_day, DesignDay)
        assert des_day.day_type == 'SummerDesignDay'
Пример #11
0
def test_standard_ddy_properties():
    """Test properties of a standard ddy."""
    relative_path = './tests/fixtures/ddy/tokyo.ddy'

    ddy = DDY.from_ddy_file(relative_path)

    # Test accuracy of import
    assert ddy.location.city == 'TOKYO HYAKURI_JPN Design_Conditions'
    assert ddy.location.latitude == approx(36.18, rel=1e-1)
    assert ddy.location.longitude == approx(140.42, rel=1e-1)
    assert ddy.location.time_zone == 9
    assert ddy.location.elevation == 35

    assert len(ddy.design_days) == 18
    for des_day in ddy.design_days:
        assert isinstance(des_day, DesignDay)
    assert len(ddy.filter_by_keyword('.4%')) == 4
    assert len(ddy.filter_by_keyword('99.6%')) == 3
    _sim_par_.output.reporting_frequency = 'Timestep'
    _sim_par_.simulation_control.run_for_sizing_periods = True
    _sim_par_.simulation_control.run_for_run_periods = False
    if run_bal_:
        _sim_par_.output.add_zone_energy_use('Sensible')
        _sim_par_.output.add_gains_and_losses('Sensible')
        _sim_par_.output.add_surface_energy_flow()

    # load design days to the simulation parameters
    if _ddy_file.lower().endswith('.epw'):  # load design days from EPW
        epw_obj = EPW(_ddy_file)
        des_days = epw_obj.best_available_design_days()
        _sim_par_.sizing_parameter.design_days = des_days
        location = epw_obj.location
    else:  # load design days from DDY
        ddy_obj = DDY.from_ddy_file(_ddy_file)
        w_days = [
            day for day in ddy_obj.design_days
            if day.day_type == 'WinterDesignDay'
        ]
        s_days = [
            day for day in ddy_obj.design_days
            if day.day_type == 'SummerDesignDay'
        ]
        check_and_filter_des_days(_sim_par_, w_days, 'WinterDesignDay')
        check_and_filter_des_days(_sim_par_, s_days, 'SummerDesignDay')
        location = ddy_obj.location

    # get the dates of the heating and cooling design days
    h_dt = _sim_par_.sizing_parameter.design_days[0].sky_condition.date
    c_dt = _sim_par_.sizing_parameter.design_days[1].sky_condition.date
Пример #13
0
def test_write_ddy():
    """Test write ddy."""
    relative_path = './tests/fixtures/ddy/chicago.ddy'
    ddy = DDY.from_ddy_file(relative_path)
    new_file_path = './tests/fixtures/ddy/chicago_edited.ddy'
    ddy.save(new_file_path)