def run_sim_site(base_output_folder, main_config_path, fids=None): base_output_folder = __abs_path(base_output_folder) assert not os.path.exists( base_output_folder ), f"output folder {base_output_folder} already exists - please specify a non-existing folder for cesar-p outputs." sim_manager = SimulationManager(base_output_folder, main_config_path, cesarp.common.init_unit_registry(), fids_to_use=fids, load_from_disk=False) sim_manager.run_all_steps() zip_path = sim_manager.save_to_zip( main_script_path=__file__, save_folder_path=os.path.dirname(__file__), include_idfs=False, include_eplus_output=False, include_src_pck=True) print( f"Project has been saved to {zip_path}, including all input files so it can be transfered to another computer." ) # if you need different result parameters, you have to make sure that energy plus reports them. Do so by using the configuration parameters from eplus_adapter package, namely # "OUTPUR_METER" and "OUTPUT_VARS", see cesarp.eplus_adapter.default_config.yml. You can overwrite those parameters in your project config, in this example that would be main_config.yml. # Also make sure that the reporting frequency in the configuration and in the callect_results_in_parallel() call match. result_series_frame = sim_manager.collect_custom_results( result_keys=["DistrictHeating:HVAC", "DistrictHeating:Building"], results_frequency=ResultsFrequency.HOURLY) # you can postprocess the results as you like, e.g. save to a file result_series_frame.to_csv( __abs_path(base_output_folder) / Path("hourly_results.csv")) if sim_manager.failed_fids: logging.warning( f"Something went wrong for following FID's {sim_manager.failed_fids}" )
from cesarp.manager.SimulationManager import SimulationManager def __abs_path(path): return cesarp.common.abs_path(path, os.path.abspath(__file__)) if __name__ == "__main__": # note: expected to be run in simple_example folder - otherwise adapt the path specifications as needed logging.config.fileConfig( __abs_path("logging.conf") ) # this logging config is only for the main process, workers log to separate log files which go into a folder, configured in SimulationManager. main_config_path = __abs_path("simple_main_config.yml") output_dir = __abs_path("./results/example") shutil.rmtree(output_dir, ignore_errors=True) fids_to_use = [1, 2, 3] # set to None to simulate all buildings sim_manager = SimulationManager(output_dir, main_config_path, cesarp.common.init_unit_registry(), fids_to_use=fids_to_use) sim_manager.run_all_steps() zip_path = sim_manager.save_to_zip(main_script_path=__file__) print("\n=========PROCESS FINISHED ===========") print(f"You find the results in {output_dir}") print( f"Project has been saved to {zip_path}, including all input files so it can be transfered to another computer." )