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'
def custom_sim_par(ddy_file, output_names, run_period, north, filter_des_days, output_file): """Get a SimulationParameter JSON with an option for custom outputs. \b Args: ddy_file: Full path to a DDY file that will be used to specify design days within the simulation parameter. output_names: Any number of EnergyPlus output names as strings (eg. 'Surface Window System Solar Transmittance'. These outputs will be requested from the simulation. """ try: sim_par = SimulationParameter() for output_name in output_names: sim_par.output.add_output(output_name) _apply_run_period(run_period, sim_par) sim_par.north_angle = north _apply_design_days(ddy_file, filter_des_days, sim_par) output_file.write(json.dumps(sim_par.to_dict())) except Exception as e: _logger.exception( 'Failed to generate simulation parameter.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def sizing_sim_par(ddy_file, load_type, north, filter_des_days, output_file): """Get a SimulationParameter JSON with outputs and run period for HVAC sizing. \b Args: ddy_file: Full path to a DDY file that will be used to specify design days within the simulation parameter. """ try: sim_par = SimulationParameter() sim_par.output.add_zone_energy_use(load_type) gl_load_type = load_type if load_type != 'All' else 'Total' sim_par.output.add_gains_and_losses(gl_load_type) sim_par.output.add_surface_energy_flow() sim_par.simulation_control = SimulationControl(True, True, True, True, False) sim_par.north_angle = north _apply_design_days(ddy_file, filter_des_days, sim_par) output_file.write(json.dumps(sim_par.to_dict())) except Exception as e: _logger.exception( 'Failed to generate simulation parameter.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def orientation_sim_pars(ddy_file, north_angles, output_name, run_period, start_north, filter_des_days, folder, log_file): """Get SimulationParameter JSONs with different north angles for orientation studies. \b Args: ddy_file: Full path to a DDY file that will be used to specify design days within the simulation parameter. north_angles: Any number of values between -360 and 360 for the counterclockwise difference between the North and the positive Y-axis in degrees. 90 is West and 270 is East. """ try: # get a default folder if none was specified if folder is None: folder = os.path.join(folders.default_simulation_folder, 'orientation_study') preparedir(folder, remove_content=False) # create a base set of simulation parameters to be edited parametrically sim_par = SimulationParameter() for out_name in output_name: sim_par.output.add_output(out_name) _apply_run_period(run_period, sim_par) _apply_design_days(ddy_file, filter_des_days, sim_par) # shift all of the north angles by the start_north if specified if start_north != 0: north_angles = [angle + start_north for angle in north_angles] for i, angle in enumerate(north_angles): angle = angle - 360 if angle > 360 else angle angle = angle + 360 if angle < -360 else angle north_angles[i] = angle # loop through the north angles and write a simulation parameter for each json_files = [] for angle in north_angles: sim_par.north_angle = angle base_name = 'sim_par_north_{}'.format(int(angle)) file_name = '{}.json'.format(base_name) file_path = os.path.join(folder, file_name) with open(file_path, 'w') as fp: json.dump(sim_par.to_dict(), fp) sp_info = { 'id': base_name, 'path': file_name, 'full_path': os.path.abspath(file_path) } json_files.append(sp_info) log_file.write(json.dumps(json_files)) except Exception as e: _logger.exception( 'Failed to generate simulation parameters.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def default_sim_par(ddy_file, run_period, north, filter_des_days, output_file): """Get a SimulationParameter JSON with default outputs for energy use only. \b Args: ddy_file: Full path to a DDY file that will be used to specify design days within the simulation parameter. """ try: sim_par = SimulationParameter() sim_par.output.add_zone_energy_use() sim_par.output.add_hvac_energy_use() _apply_run_period(run_period, sim_par) sim_par.north_angle = north _apply_design_days(ddy_file, filter_des_days, sim_par) output_file.write(json.dumps(sim_par.to_dict())) except Exception as e: _logger.exception( 'Failed to generate simulation parameter.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
def comfort_sim_par(ddy_file, run_period, north, filter_des_days, output_file): """Get a SimulationParameter JSON with outputs for thermal comfort mapping. \b Args: ddy_file: Full path to a DDY file that will be used to specify design days within the simulation parameter. """ try: sim_par = SimulationParameter() sim_par.output.add_comfort_metrics() sim_par.output.add_surface_temperature() _apply_run_period(run_period, sim_par) sim_par.north_angle = north _apply_design_days(ddy_file, filter_des_days, sim_par) output_file.write(json.dumps(sim_par.to_dict())) except Exception as e: _logger.exception( 'Failed to generate simulation parameter.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)
_sim_par_.shadow_calculation.solar_distribution = 'FullExterior' _sim_par_.output.add_zone_energy_use() _sim_par_.output.reporting_frequency = 'Monthly' if run_bal_: _sim_par_.output.add_output(gl_el_equip_out) _sim_par_.output.add_output(gl_gas_equip_out) _sim_par_.output.add_output(gl1_shw_out) _sim_par_.output.add_output(gl2_shw_out) _sim_par_.output.add_gains_and_losses('Total') _sim_par_.output.add_surface_energy_flow() # set the north if it is not defaulted if _north_ is not None: try: _sim_par_.north_vector = to_vector2d(_north_) except AttributeError: # north angle instead of vector _sim_par_.north_angle = float(_north_) # check the rooms for inaccurate cases if _sim_par_.timestep < 4: check_window_vent(_rooms) # assign design days from the EPW msg = None folder, epw_file_name = os.path.split(_epw_file) ddy_file = os.path.join(folder, epw_file_name.replace('.epw', '.ddy')) if os.path.isfile(ddy_file): try: _sim_par_.sizing_parameter.add_from_ddy_996_004(ddy_file) except AssertionError: msg = 'No design days were found in the .ddy file next to the _epw_file.' else: