Exemplo n.º 1
0
def test_simulation_control_dict_methods():
    """Test the to/from dict methods."""
    shadow_calc = ShadowCalculation(calculation_frequency=20)

    shadow_dict = shadow_calc.to_dict()
    new_shadow_calc = ShadowCalculation.from_dict(shadow_dict)
    assert new_shadow_calc == shadow_calc
    assert shadow_dict == new_shadow_calc.to_dict()
Exemplo n.º 2
0
def test_simulation_control_init_from_idf():
    """Test the initialization of SimulationControl from_idf."""
    shadow_calc = ShadowCalculation(calculation_frequency=20)

    idf_str = shadow_calc.to_idf()
    rebuilt_shadow_calc = ShadowCalculation.from_idf(idf_str)
    assert shadow_calc == rebuilt_shadow_calc
    assert rebuilt_shadow_calc.to_idf() == idf_str
Exemplo n.º 3
0
def test_simulation_control_equality():
    """Test the equality of SimulationControl objects."""
    shadow_calc = ShadowCalculation()
    shadow_calc_dup = shadow_calc.duplicate()
    shadow_calc_alt = ShadowCalculation(solar_distribution='FullExteriorWithReflections')

    assert shadow_calc is shadow_calc
    assert shadow_calc is not shadow_calc_dup
    assert shadow_calc == shadow_calc_dup
    shadow_calc_dup.solar_distribution = 'FullExterior'
    assert shadow_calc != shadow_calc_dup
    assert shadow_calc != shadow_calc_alt
Exemplo n.º 4
0
def simulation_par_detailed(directory):
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    output.include_html = True
    output.reporting_frequency = 'Daily'
    output.add_summary_report('Annual Building Utility Performance Summary')
    output.add_summary_report('Climatic Data Summary')
    output.add_summary_report('Envelope Summary')
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    run_period.daylight_saving_time = DaylightSavingTime(Date(3, 12), Date(11, 5))
    run_period.start_day_of_week = 'Monday'
    run_period.holidays = [Date(1, 1), Date(3, 17), Date(7, 4)]
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(
        solar_distribution='FullInteriorAndExteriorWithReflections',
        calculation_method='PixelCounting', calculation_update_method='Timestep')
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(None, 1, 1)
    relative_path = './scripts/ddy/chicago.ddy'
    sizing_alt.add_from_ddy_996_004(relative_path)
    sim_par.sizing_parameter = sizing_alt

    dest_file = os.path.join(directory, 'simulation_par_detailed.json')
    with open(dest_file, 'w') as fp:
        json.dump(sim_par.to_dict(), fp, indent=4)
Exemplo n.º 5
0
def dict_to_simulation(sim_dict, raise_exception=True):
    """Get a Python object of any Simulation object from a dictionary.

    Args:
        sim_dict: A dictionary of any Honeybee energy simulation object. Note
            that this should be a non-abridged dictionary to be valid.
        raise_exception: Boolean to note whether an excpetion should be raised
            if the object is not identified as a simulation object. Default: True.

    Returns:
        A Python object derived from the input sim_dict.
    """
    try:  # get the type key from the dictionary
        sim_type = sim_dict['type']
    except KeyError:
        raise ValueError('Simulation dictionary lacks required "type" key.')

    if sim_type == 'SimulationControl':
        return SimulationControl.from_dict(sim_dict)
    elif sim_type == 'RunPeriod':
        return RunPeriod.from_dict(sim_dict)
    elif sim_type == 'DaylightSavingTime':
        return DaylightSavingTime.from_dict(sim_dict)
    elif sim_type == 'ShadowCalculation':
        return ShadowCalculation.from_dict(sim_dict)
    elif sim_type == 'SizingParameter':
        return SizingParameter.from_dict(sim_dict)
    elif sim_type == 'SimulationOutput':
        return SimulationOutput.from_dict(sim_dict)
    elif sim_type == 'SimulationParameter':
        return SimulationParameter.from_dict(sim_dict)
    elif raise_exception:
        raise ValueError(
            '{} is not a recognized energy Simulation type'.format(sim_type))
Exemplo n.º 6
0
def test_simulation_parameter_setability():
    """Test the setting of properties of SimulationParameter."""
    sim_par = SimulationParameter()

    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    assert sim_par.output == output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    assert sim_par.run_period == run_period
    sim_par.timestep = 4
    assert sim_par.timestep == 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    assert sim_par.simulation_control == sim_control_alt
    shadow_calc_alt = ShadowCalculation('FullExteriorWithReflections')
    sim_par.shadow_calculation = shadow_calc_alt
    assert sim_par.shadow_calculation == shadow_calc_alt
    sizing_alt = SizingParameter(None, 1, 1)
    relative_path = './tests/ddy/chicago_monthly.ddy'
    sizing_alt.add_from_ddy(relative_path)
    sim_par.sizing_parameter = sizing_alt
    assert sim_par.sizing_parameter == sizing_alt
    sim_par.north_angle = 20
    assert sim_par.north_angle == 20
    sim_par.terrain_type = 'Ocean'
    assert sim_par.terrain_type == 'Ocean'
Exemplo n.º 7
0
def test_simulation_parameter_to_dict_detailed():
    """Test the to_dict method with a detailed SimulationParameter."""
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    output.include_html = True
    output.reporting_frequency = 'Daily'
    output.add_summary_report('Annual Building Utility Performance Summary')
    output.add_summary_report('Climatic Data Summary')
    output.add_summary_report('Envelope Summary')
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    run_period.daylight_saving_time = DaylightSavingTime(
        Date(3, 12), Date(11, 5))
    run_period.start_day_of_week = 'Monday'
    run_period.holidays = [Date(1, 1), Date(3, 17), Date(7, 4)]
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(calculation_frequency=20)
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(None, 1, 1)
    relative_path = './tests/ddy/chicago.ddy'
    sizing_alt.add_from_ddy_996_004(relative_path)
    sim_par.sizing_parameter = sizing_alt

    sim_par_dict = sim_par.to_dict()

    assert 'outputs' in sim_par_dict['output']
    assert 'holidays' in sim_par_dict['run_period']
    assert 'daylight_saving_time' in sim_par_dict['run_period']
    assert 'design_days' in sim_par_dict['sizing_parameter']
Exemplo n.º 8
0
def test_shadow_calculation_init():
    """Test the initialization of ShadowCalculation and basic properties."""
    shadow_calc = ShadowCalculation()
    str(shadow_calc)  # test the string representation

    assert shadow_calc.solar_distribution == 'FullInteriorAndExteriorWithReflections'
    assert shadow_calc.calculation_method == 'AverageOverDaysInFrequency'
    assert shadow_calc.calculation_frequency == 30
    assert shadow_calc.maximum_figures == 15000
Exemplo n.º 9
0
def test_shadow_calculation_init():
    """Test the initialization of ShadowCalculation and basic properties."""
    shadow_calc = ShadowCalculation()
    str(shadow_calc)  # test the string representation

    assert shadow_calc.solar_distribution == 'FullExteriorWithReflections'
    assert shadow_calc.calculation_method == 'PolygonClipping'
    assert shadow_calc.calculation_update_method == 'Periodic'
    assert shadow_calc.calculation_frequency == 30
    assert shadow_calc.maximum_figures == 15000
Exemplo n.º 10
0
def test_simulation_parameter_init():
    """Test the initialization of SimulationParameter and basic properties."""
    sim_par = SimulationParameter()
    str(sim_par)  # test the string representation

    assert sim_par.output == SimulationOutput()
    assert sim_par.run_period == RunPeriod()
    assert sim_par.timestep == 6
    assert sim_par.simulation_control == SimulationControl()
    assert sim_par.shadow_calculation == ShadowCalculation()
    assert sim_par.sizing_parameter == SizingParameter()
Exemplo n.º 11
0
def test_shadow_calculation_setability():
    """Test the setting of properties of ShadowCalculation."""
    shadow_calc = ShadowCalculation()

    shadow_calc.solar_distribution = 'fullexterior'
    assert shadow_calc.solar_distribution == 'FullExterior'
    shadow_calc.calculation_method = 'pixelcounting'
    assert shadow_calc.calculation_method == 'PixelCounting'
    shadow_calc.calculation_update_method = 'timestep'
    assert shadow_calc.calculation_update_method == 'Timestep'
    shadow_calc.calculation_frequency = 20
    assert shadow_calc.calculation_frequency == 20
    shadow_calc.maximum_figures = 5000
    assert shadow_calc.maximum_figures == 5000
Exemplo n.º 12
0
def test_simulation_parameter_dict_methods():
    """Test the to/from dict methods."""
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(calculation_frequency=20)
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(1, 1)
    sim_par.sizing_parameter = sizing_alt

    sim_par_dict = sim_par.to_dict()
    new_sim_par = SimulationParameter.from_dict(sim_par_dict)
    assert new_sim_par == sim_par
    assert sim_par_dict == new_sim_par.to_dict()
Exemplo n.º 13
0
def test_simulation_parameter_init_from_idf():
    """Test the initialization of SimulationParameter from_idf."""
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(calculation_frequency=20)
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(1, 1)
    sim_par.sizing_parameter = sizing_alt

    idf_str = sim_par.to_idf()
    rebuilt_sim_par = SimulationParameter.from_idf(idf_str)
    assert sim_par == rebuilt_sim_par
    assert rebuilt_sim_par.to_idf() == idf_str
Exemplo n.º 14
0
def test_simulation_parameter_setability():
    """Test the setting of properties of SimulationParameter."""
    sim_par = SimulationParameter()

    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    assert sim_par.output == output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    assert sim_par.run_period == run_period
    sim_par.timestep = 4
    assert sim_par.timestep == 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    assert sim_par.simulation_control == sim_control_alt
    shadow_calc_alt = ShadowCalculation('FullExteriorWithReflections')
    sim_par.shadow_calculation = shadow_calc_alt
    assert sim_par.shadow_calculation == shadow_calc_alt
    sizing_alt = SizingParameter(1, 1)
    sim_par.sizing_parameter = sizing_alt
    assert sim_par.sizing_parameter == sizing_alt
Exemplo n.º 15
0
def test_simulation_parameter_init_from_idf():
    """Test the initialization of SimulationParameter from_idf."""
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(calculation_frequency=20)
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(None, 1, 1)
    relative_path = './tests/ddy/chicago.ddy'
    sizing_alt.add_from_ddy_996_004(relative_path)
    sim_par.sizing_parameter = sizing_alt

    idf_str = sim_par.to_idf()
    rebuilt_sim_par = SimulationParameter.from_idf(idf_str)
    rebuilt_sim_par.sizing_parameter.apply_location(sizing_alt[0].location)
    assert sim_par == rebuilt_sim_par
    assert rebuilt_sim_par.to_idf() == idf_str
Exemplo n.º 16
0
def test_simulation_parameter_dict_methods():
    """Test the to/from dict methods."""
    sim_par = SimulationParameter()
    output = SimulationOutput()
    output.add_zone_energy_use()
    sim_par.output = output
    run_period = RunPeriod(Date(1, 1), Date(6, 21))
    sim_par.run_period = run_period
    sim_par.timestep = 4
    sim_control_alt = SimulationControl(run_for_sizing_periods=True,
                                        run_for_run_periods=False)
    sim_par.simulation_control = sim_control_alt
    shadow_calc_alt = ShadowCalculation(calculation_frequency=20)
    sim_par.shadow_calculation = shadow_calc_alt
    sizing_alt = SizingParameter(None, 1, 1)
    relative_path = './tests/ddy/chicago.ddy'
    sizing_alt.add_from_ddy_996_004(relative_path)
    sim_par.sizing_parameter = sizing_alt

    sim_par_dict = sim_par.to_dict()
    new_sim_par = SimulationParameter.from_dict(sim_par_dict)
    new_sim_par.sizing_parameter.apply_location(sizing_alt[0].location)
    assert new_sim_par == sim_par
    assert sim_par_dict == new_sim_par.to_dict()
    'MinimalShadowing':
    'MinimalShadowing',
    'FullExterior':
    'FullExterior',
    'FullInteriorAndExterior':
    'FullInteriorAndExterior',
    'FullExteriorWithReflections':
    'FullExteriorWithReflections',
    'FullInteriorAndExteriorWithReflections':
    'FullInteriorAndExteriorWithReflections'
}

# process the solar distribution
try:
    _solar_dist_ = SOLAR_DISTRIBUTIONS[_solar_dist_] if _solar_dist_ is not None \
        else 'FullExteriorWithReflections'
except KeyError:
    raise ValueError(' Input _solar_dist_ "{}" is not valid.\nChoose from the '
                     'following:\n{}'.format(_solar_dist_,
                                             SOLAR_DISTRIBUTIONS.keys()))

# set other default values
_calc_method_ = _calc_method_ if _calc_method_ is not None else 'PolygonClipping'
_update_method_ = _update_method_ if _update_method_ is not None else 'Periodic'
_frequency_ = _frequency_ if _frequency_ is not None else 30
_max_figures_ = _max_figures_ if _max_figures_ is not None else 15000

# create the object
shadow_calc = ShadowCalculation(_solar_dist_, _calc_method_, _update_method_,
                                _frequency_, _max_figures_)