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']
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)
def test_sizing_parameter_dict_methods(): """Test the to/from dict methods.""" sizing = SizingParameter(None, 1) relative_path = './tests/ddy/chicago.ddy' sizing.add_from_ddy_996_004(relative_path) sizing_dict = sizing.to_dict() new_sizing = SizingParameter.from_dict(sizing_dict) new_sizing.apply_location(sizing[0].location) assert new_sizing == sizing assert sizing_dict == new_sizing.to_dict()
def test_sizing_parameter_init_from_idf(): """Test the initialization of SimulationControl from_idf.""" sizing = SizingParameter(None, 1) relative_path = './tests/ddy/chicago.ddy' sizing.add_from_ddy_996_004(relative_path) des_days, idf_str = sizing.to_idf() rebuilt_sizing = SizingParameter.from_idf(des_days, idf_str) rebuilt_sizing.apply_location(sizing[0].location) assert sizing == rebuilt_sizing assert rebuilt_sizing.to_idf()[1] == idf_str for dday1, dday2 in zip(des_days, rebuilt_sizing.to_idf()[0]): assert dday1 == dday2
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
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()
""" ghenv.Component.Name = 'HB Sizing Parameter' ghenv.Component.NickName = 'SizingPar' ghenv.Component.Message = '1.2.0' ghenv.Component.Category = 'HB-Energy' ghenv.Component.SubCategory = '5 :: Simulate' ghenv.Component.AdditionalHelpFromDocStrings = '3' try: from honeybee_energy.simulation.sizing import SizingParameter except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) # set default sizing factors heating_fac = 1.25 if _heating_fac_ is None else _heating_fac_ cooling_fac = 1.15 if _cooling_fac_ is None else _cooling_fac_ # create the object sizing = SizingParameter(None, heating_fac, cooling_fac) # apply design days from ddy if ddy_file_ is not None: if filter_ddays_ == 1: sizing.add_from_ddy_996_004(ddy_file_) elif filter_ddays_ == 2: sizing.add_from_ddy_990_010(ddy_file_) else: sizing.add_from_ddy(ddy_file_)