Commit 5ad61563 authored by Bognár, Á.'s avatar Bognár, Á.
Browse files

Initial commit

parent f72d624a
Pipeline #3754 canceled with stages
# Daypym
Daypym is a project to preprocess and run DAYSIM solar irradiance simulations with Python. It uses EnergyPlus IDF files, as geometry input.
# Features
## Geometry preprocessing
* Translating [EnergyPlus](https://energyplus.net/) IDF geometry to .rad file for [DAYSIM](http://daysim.ning.com/) simulation (utilizing [Eppy](https://github.com/santoshphilip/eppy) and [GeomEppy](https://github.com/jamiebull1/geomeppy))
* Generating sensor points over selected surfaces (utilizing GeomEppy)
## Running DAYSIM simulations
* Creating folder structure for the simulations
* Writing .hea file for DAYSIM
* Running DAYSIM simulations
## Postprocessing
* Visualizing irradiance simulation results
# "Installation"
* Install DAYSIM
* Install Eppy
* Install GeomEppy
* Then:
```python
import sys
sys.path.append(r'Path/Of/Folder/Containing/Daypym.py')
from daypym import *
```
# Tutorial
See example_workflow.ipynb jupyter notebook in the example_workflow folder.
To start it:
1) clone or copy this repository to your computer
2) Open a terminal window and navigate to the example_workflow folder in the cloned repository
3) type: jupyter notebook example_workflow.ipynb
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import pandas as pd
from matplotlib import pyplot as plt
from geomeppy import IDF
from geomeppy import view_geometry
import os
import sys
sys.path.append(os.path.dirname(os.getcwd()) + r'\\daypym')
from daypym import *
from geomeppy.geom.polygons import (break_polygons, Polygon2D, Polygon3D, Vector2D, Vector3D)
from geomeppy.geom.transformations import align_face, invert_align_face
## navigate to the working folder and run
cwd = os.getcwd()
for f in os.listdir():
if f.endswith('.idf'):
project_name = f[:-4]
## create folders if they don't exist yet
for folder in ['res', 'tmp', 'wea', 'geo', 'pts', 'res\\vis']: # res: final results from Daysim with .ill and .dc files, tmp: Daysim poops temp files here, wea: converted wea file, geo: obj rad and pts files. Inputs, such as the idf and sketchup files are in the working directory
pathlib.Path(folder).mkdir(exist_ok=True)
## read the IDF (geomeppy)
source_idf_name = r'{}.idf'.format(project_name)
iddfile = r'c:\EnergyPlusV8-9-0\Energy+.idd'
IDF.setiddname(iddfile)
source_idf = IDF(source_idf_name)
source_idf.to_obj(fname=cwd + r'\geo\\'+ project_name +'.obj', mtllib=None)
## create sensor points using the IDF geomtry
# find the active surfaces (eppy)
surfaces = surface=source_idf.idfobjects['BUILDINGSURFACE:DETAILED']
act_surf_id = 'PV_Construction' # 'BIPV_Construction' this is the active surface identifier. Surfaces with construction names like this will get a sensor point mesh over them
act_surfs = [surface for surface in surfaces if surface.Construction_Name == act_surf_id]
# loop trough the surfaces and make a list of sensor-point data dicts which will be used to make the pts and kts files
n_row=10
n_col=6
sps = []
for surface in act_surfs: # consider making this for a function already. The only external input we need here is the IDF surface, n and the sp_offset
poly = IDFsurf_to_poly(surface=surface) # make poly from idf (daypym)
poly_trans = align_face(poly).order_points('upperleftcorner') # translate poly to the x-y plane (geomeppy)
poly_trans_2d = poly_trans.project_to_2D() # make the poly 2D (geomeppy)
poly_trans_bbox_2d = poly_trans.bounding_box.project_to_2D() # make a 2d bbox of the translated surface on the xy pane (geomeppy)
test_grid = grid_2d_pvmodule(n_row=n_row, n_col=n_col, bbox_2d=poly_trans_bbox_2d) # makes an offset grid over the cells (daypym)
#test_grid = grid_2d(bbox_2d=poly_trans_bbox_2d, d=10) # make a 2D test grid on the x-y plane (daypym)
pip = gridpoints_in_poly_2d(grid_2d=test_grid, poly_2d=poly_trans_2d) # makes a list of points, that are inside the 2D poly (daypym)
ri, ci = pos_in_module(n_row=10, n_col=6, test_grid_transp=test_grid)
sp = create_sensor_points(surf_name=surface['Name'], points_in_poly_2d=pip, row_index=ri, col_index=ci, original_poly=poly, sp_offset=0.01, sp_pos_round=3) # sensor point data dict (daypym)
sps.append(sp)
output = open(r'{}.pkl'.format(project_name), 'wb') # dumping the sps structure to a picke, because we need it later for posprocess
pickle.dump(sps, output)
output.close()
# use the sensor-point data dicts to make .pts and .kts files (daypym)
translate_to_ds_pts(surf_sensor_points=sps, p_name=project_name)
## great.. but now it would be nice to visualize if the sps are in the right place:
view_idf_and_sps(p_name=project_name, idf_name=source_idf_name, sps=sps) # plot the sensorpoints and the idf together (daypym-geomeppy)
## this is the running Daysim part
# make wea file from epw
wea_data = ds_epw2wea('NLD_Amsterdam.062400_IWEC.epw', project_name) # maybe check for negative altitude!
# make a rad file form obj (this is a Radiance program. Put this one to the Daysim bin folder)
rad_obj2rad(input_obj=project_name + r'.obj', output_rad=project_name)
# we make the site info dict. This is all the input we need, the rest is automated
site_info = {
'ground_eflectance':0,
'first_weekday':1,
'time_step':5, # if this is not 60, we need to run the ds_ds_shortterm
'wea_data_file':cwd + '/wea//' + project_name + '.wea', # this needs full abs path
'weather_data_file_units':1,
'wea_data_short_file':'/wea//' + project_name + '_short.wea', # this is an output and an input in this case
'wea_data_short_file_units':1,
'lower_direct_threshold':2,
'lower_diffuse_threshold':2
}
# add wea file data to the site info
site_info.update(wea_data)
# write hea
write_ds_hea(p_name=project_name, p_dir=cwd, bin_dir=r'c:\DAYSIM4\bin\\', uni_mat_file=r'c:\TUe\PhD\Simulations\Daysim\materials\daysim_all_mat.rad', site_info=site_info, model_info=None, radiance_params=None)
#run conversion, dc and ill
ds_radfiles2daysim(p_name=project_name, hea_file_name=None)
ds_ds_shortterm(project_name, hea_file_name=None)
ds_gen_dc(p_name=project_name, hea_file_name=None)
ds_ds_illum(p_name=project_name, hea_file_name=None)
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment