def eval_daylight(wall_list, flr_list, roof_list, win_list, bldg_shade_list,
                  win_srfmat_parm, dae_filepath):
    current_path = os.path.dirname(__file__)
    parent_path = os.path.abspath(
        os.path.join(current_path, os.pardir, os.pardir))

    rad_base_filepath = os.path.join(parent_path, "example_files", "rad",
                                     "base.rad")
    rad_folderpath = os.path.join(parent_path, "example_files", "rad",
                                  "rad_data")
    daysim_folderpath = os.path.join(parent_path, "example_files", "rad",
                                     "daysim_data")
    epwweatherfile = os.path.join(parent_path, "example_files", "weatherfile",
                                  "SGP_Singapore.486980_IWEC.epw")

    rad = py2radiance.Rad(rad_base_filepath, rad_folderpath)
    opaque_srfmat = "light_painted_concrete"
    if win_srfmat_parm == 0:
        win_srfmat = "single_clr_6mm_uvalue_5.25_sc0.9_glass"
    if win_srfmat_parm == 1:
        win_srfmat = "bca_dblglz_uncoated_glass"
    if win_srfmat_parm == 2:
        win_srfmat = "bca_dblglz_reflective_lowe_glass"

    total_sensor_srf_list = []
    total_sensor_pt_list = []
    total_sensor_dir_list = []

    mid_level = int(len(flr_list) / 2)
    chosen_flr = flr_list[mid_level]
    reversed_flr = py3dmodel.modify.reverse_face(chosen_flr)
    flr_midpt = py3dmodel.calculate.face_midpt(reversed_flr)
    loc_pt = py3dmodel.modify.move_pt(flr_midpt, (0, 0, 1), 0.8)
    moved_flr = py3dmodel.fetch.topo2topotype(
        py3dmodel.modify.move(flr_midpt, loc_pt, reversed_flr))
    #offset_flr = py3dmodel.construct.make_offset(moved_flr, 0.5)
    sensor_surfaces, sensor_pts, sensor_dirs = urbangeom.generate_sensor_surfaces(
        moved_flr, 2, 2)
    total_sensor_srf_list.extend(sensor_surfaces)
    total_sensor_pt_list.extend(sensor_pts)
    total_sensor_dir_list.extend(sensor_dirs)
    rad.set_sensor_points(total_sensor_pt_list, total_sensor_dir_list)
    rad.create_sensor_input_file()

    #triangulate the roof and floor
    rf_list = flr_list + roof_list
    tri_rf_list = []
    for rf in rf_list:
        tri_face = triangulate_face(rf)
        tri_rf_list.extend(tri_face)

    #create the scene for radiance
    opaque_srf_list = wall_list + bldg_shade_list + tri_rf_list
    srf_cnt = 0
    for opaque_srf in opaque_srf_list:
        pypolygon = py3dmodel.fetch.points_frm_occface(opaque_srf)
        srfname = "opaque" + str(srf_cnt)
        py2radiance.RadSurface(srfname, pypolygon, opaque_srfmat, rad)
        #reverse the opaque srf
        reversed_opaque = py3dmodel.modify.reverse_face(opaque_srf)
        r_pypolygon = py3dmodel.fetch.points_frm_occface(reversed_opaque)
        r_srfname = "opaque_reverse" + str(srf_cnt)
        py2radiance.RadSurface(r_srfname, r_pypolygon, opaque_srfmat, rad)
        srf_cnt += 1

    win_cnt = 0
    for win in win_list:
        pypolygon = py3dmodel.fetch.points_frm_occface(win)
        srfname = "win" + str(win_cnt)
        py2radiance.RadSurface(srfname, pypolygon, win_srfmat, rad)
        #reverse the opaque srf
        reversed_win = py3dmodel.modify.reverse_face(win)
        r_pypolygon = py3dmodel.fetch.points_frm_occface(reversed_win)
        r_srfname = "win_reverse" + str(win_cnt)
        py2radiance.RadSurface(r_srfname, r_pypolygon, win_srfmat, rad)
        win_cnt += 1
    rad.create_rad_input_file()

    #execute radiance
    time_range = str(0) + " " + str(24)
    date = str(1) + " " + str(1) + " " + str(12) + " " + str(31)
    rad.execute_cumulative_oconv(time_range,
                                 date,
                                 epwweatherfile,
                                 output="illuminance")
    #execute cumulative_rtrace
    rad.execute_cumulative_rtrace(str(2))  #EXECUTE!!
    #retrieve the results
    illum_ress = rad.eval_cumulative_rad(output="illuminance")
    rad.initialise_daysim(daysim_folderpath)
    #a 60min weatherfile is generated
    rad.execute_epw2wea(epwweatherfile)
    sunuphrs = rad.sunuphrs
    #ge the mean_illum_ress
    mean_illum_ress = []
    useful_ill_list = []
    for illum in illum_ress:
        mean_illum = illum / float(sunuphrs)
        if 2000 > mean_illum >= 300:
            useful_ill_list.append(mean_illum)
        mean_illum_ress.append(mean_illum)

    cmpd = py3dmodel.construct.make_compound(opaque_srf_list + win_list)
    edges = py3dmodel.fetch.topo_explorer(cmpd, "edge")
    daylight_level = float(len(useful_ill_list)) / float(len(mean_illum_ress))
    d_str = "% of floor area > 300lx: " + str(daylight_level)
    py3dmodel.export_collada.write_2_collada_falsecolour(
        total_sensor_srf_list,
        mean_illum_ress,
        "lx",
        dae_filepath,
        description_str=d_str,
        minval=87.5,
        maxval=2212.5,
        other_occedge_list=edges)

    return daylight_level
Esempio n. 2
0
def create_radiance_srf(occface, srfname, srfmat, rad):
    bface_pts = fetch.points_frm_occface(occface)
    py2radiance.RadSurface(srfname, bface_pts, srfmat, rad)
occfaces = py3dmodel.fetch.faces_frm_solid(box)
cmpd = py3dmodel.construct.make_compound(occfaces)
edges = py3dmodel.fetch.topo_explorer(cmpd, "edge")
displaylist = []
displaylist.append(box)
#display2dlist.append(displaylist)

sensor_pts = []
sensor_dirs = []
face_cnt = 0
displaylist2 = []
for occface in occfaces:
    radsrfname = "srf" + str(face_cnt)
    rad_polygon = py3dmodel.fetch.points_frm_occface(occface)
    srfmat = "RAL9010_pur_white_paint"
    py2radiance.RadSurface(radsrfname, rad_polygon, srfmat, rad)

    #get the surface that is pointing upwards, the roof
    normal = py3dmodel.calculate.face_normal(occface)
    if normal == (0, 0, 1):
        #generate the sensor points
        grid_occfaces = py3dmodel.construct.grid_face(occface, 3, 3)
        display2dlist.extend(grid_occfaces)
        #calculate the midpt of each surface
        for grid_occface in grid_occfaces:
            midpt = py3dmodel.calculate.face_midpt(grid_occface)
            midpt = py3dmodel.modify.move_pt(midpt, normal, 0.8)
            sensor_pts.append(midpt)
            sensor_dirs.append(normal)
    face_cnt += 1