def multiply( cpu_count, ill, numWin, numSensor, workDir_path, bsdfVis_path, conIndex, month, day, hour, irrdirn, irrdiffh, lat, lon, tzone, ): # illuminance calculation head = 9 ioRoutines.shell( "gendaylit %i %i %f -a %1.2f -o %1.2f -m %1.2f -W %1.2f %1.2f | genskyvec -m 4 -c 1 1 1 > %stempVis.skv" % (month, day, hour, lat, lon, tzone, irrdirn, irrdiffh, workDir_path)) tasks = [ "dctimestep %sill_0.vmx %s %swin_0.dmx %stempVis.skv | rcalc -e '$1=179*($1*0.265+$2*0.670+$3*0.065)'" % (workDir_path, bsdfVis_path[conIndex[i]], workDir_path, workDir_path) for i in range(numWin) ] with multiprocessing.Pool(cpu_count) as pool: outRaws = pool.map(ioRoutines.shell_output, tasks) for outRaw in outRaws: out = outRaw.split("\n") for j in range(numSensor): ill[j] = ill[j] + float(out[j + head]) return ill
def do_work( nCore, illVert, dgp, illVertVmx, tmxv, conIndex, dmx, skyVis, numWin, mm, dd, hh, currenthh, irrdirn, irrdiffh, lat, lon, tzone, illuVertPts, numSensorVert, winRad_path, workDir, inputDir, ): # geometry.winRad(numWin,workDir,conIndex) shell( "gendaylit %i %i %1.1f -W %1.1f %1.1f -a %f -o %f -m %f -w > %sgendaylit_%i.sky" % (mm, dd, hh, irrdirn, irrdiffh, lat, lon, tzone, inputDir, currenthh)) genRtraceOct = "oconv %sroom.mat %sroom.rad " % (workDir, workDir) for i in range(numWin): genRtraceOct = genRtraceOct + " %s %swindowRad_%i.rad " % ( winRad_path[conIndex[i]], inputDir, i, ) genRtraceOct = (genRtraceOct + " %sgendaylit_%i.sky %ssky_prev.rad > %srtrace_%i.oct" % (inputDir, currenthh, workDir, inputDir, currenthh)) shell(genRtraceOct) for k in range(numSensorVert): output = shell( "rpict -x 800 -y 800 -ab 0 -dj 0 -dr 2 -lr 4 -lw 0.000001 -st 0.15 -ps 0 -pj 0 -vta -vv 180 -vh 180 -vu 0 0 1 -vs 0 -vl 0 -vp %1.3f %1.3f %1.3f -vd %1.3f %1.3f %1.3f %srtrace_%i.oct | evalglare -b 8000 -i %1.3f -D -y -1" % ( illuVertPts[k, 0], illuVertPts[k, 1], illuVertPts[k, 2], illuVertPts[k, 3], illuVertPts[k, 4], illuVertPts[k, 5], inputDir, currenthh, illVert[k], ), True, ) # --------------------------- dgp[k] = float(output[0]) return dgp
def sky(cpu_count, weather_file_path, lat, lon, tzone, grndAlb, bipv=False): ioRoutines.shell("epw2wea %s %s" % (weather_file_path, weather_sky_path(weather_file_path))) # ioRoutines.shell("gendaymtx -m 4 -O1 -d -h %s%s.wea > %s%sSun.smx" % (path,name,path,name)) genday_tasks = [ "gendaymtx -m 4 -O1 -h -g %1.2f %1.2f %1.2f %s > %s" % ( grndAlb, grndAlb, grndAlb, weather_sky_path(weather_file_path), sol_sky_path(weather_file_path), ), "gendaymtx -m 4 -h -g %1.2f %1.2f %1.2f %s > %s" % ( grndAlb, grndAlb, grndAlb, weather_sky_path(weather_file_path), vis_sky_path(weather_file_path), ), ] if bipv: genday_tasks.extend([ "gendaymtx -m 4 -O1 -d -h -g %1.2f %1.2f %1.2f %s > %s" % ( grndAlb, grndAlb, grndAlb, weather_sky_path(weather_file_path), sun_sky_path(weather_file_path), ), "gendaymtx -m 4 -O1 -s -h -g %1.2f %1.2f %1.2f %s > %s" % ( grndAlb, grndAlb, grndAlb, weather_sky_path(weather_file_path), dif_sky_path(weather_file_path), ), ]) # For an explanation on the differences between `map*` and `imap*` see # https://stackoverflow.com/questions/26520781/multiprocessing-pool-whats-the-difference-between-map-async-and-imap/26521507#26521507 with multiprocessing.Pool(cpu_count) as pool: pool.map(ioRoutines.shell, genday_tasks) nobis = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] gensky_tasks = [ "gensky %i %i %1.1f -a %f -o %f -m %f" % (mm + 1, dd + 1, hh + 0.5, lat, lon, tzone) for mm in range(12) for dd in range(nobis[mm]) for hh in range(24) ] with multiprocessing.Pool(cpu_count) as pool: coordsun_temps = pool.map(ioRoutines.shell_output, gensky_tasks) with open(sun_ang_sky_path(weather_file_path), "w") as fw: fw.write("%s, %s\n" % ("Sun Altitude (deg)", "Sun Azimuth (deg)")) for coordsun_temp in coordsun_temps: fw.write("%s, %s\n" % (coordsun_temp.split()[21], coordsun_temp.split()[22]))
def ext(nCore, numSurf, numFrame, bc, workDir): for i in range(numSurf): if bc[i]: # exterior boundary conditions ioRoutines.shell( "rfluxmtx -n %i -o %sirrSurfExt_%i.dmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %ssky.rad -w %sroom.mat %sroom.rad %soutside.rad < %sextSurfSensor_%i.pts" % (nCore, workDir, i, workDir, workDir, workDir, workDir, workDir, i)) # ioRoutines.shell("rfluxmtx -n %i -I+ -ab 12 -ad 50000 -lw 2e-5 < radiance/extSurfSensor_%i.pts - radiance/sky.rad radiance/room.mat radiance/room.rad > mtx/irrExt_%i.dmx" % (nCore,i,i), True) for i in range(numFrame): ioRoutines.shell( "rfluxmtx -n %i -o %sirrFrameExt_%i.dmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %ssky.rad -w %sroom.mat %sroom.rad %soutside.rad < %sextFrameSensor_%i.pts" % (nCore, workDir, i, workDir, workDir, workDir, workDir, workDir, i))
def df(ill, illExtDmx, illVmx, tmxv, conIndex, dmx, numWin, lat, lon, tzone, workDir): # Generate CIE sky vector shell("gensky 6 21 12 -a %f -o %f -m %f -c | genskyvec > %scie.skv" % (lat, lon, tzone, workDir)) skyCie = atleast_2d( genfromtxt("%scie.skv" % workDir, usecols=0, skip_header=7, delimiter="\t")) # interior horizontal illuminance illInt = illum(ill, illVmx, tmxv, conIndex, dmx, transpose(skyCie), numWin) # exterior horizontal illuminace illExt = illExtDmx.dot(transpose(skyCie)) * 179 # daylight factor df = illInt / illExt * 100 # df = illInt # -------------------------------------------------------- return df
def cie(mm, dd, hh, lat, lon, tzone, irrdirn, irrdiffh, sunAltitude, workDir): # Generate CIE sky vector shell( "gensky %i %i %1.1f -a %f -o %f -m %f +s -g 0.2 -B %f -R %f | genskyvec > %scie.skv" % ( mm, dd, hh, lat, lon, tzone, irrdiffh, max(irrdirn * sin(sunAltitude * pi / 180), 0), workDir, )) skyCie = atleast_2d( genfromtxt("%scie.skv" % workDir, usecols=0, skip_header=7, delimiter="\t")) return skyCie
def run(ep_path, meteo_path): weatherFile = os.path.join(os.getcwd(), meteo_path) with tempfile.TemporaryDirectory() as temp_directory_path: ioRoutines.shell( "cp -rf %s %s" % (os.path.join(ep_path, "*"), temp_directory_path) ) ioRoutines.shell( "cp -f %s %s" % (weatherFile, os.path.join(temp_directory_path, "weather.epw")) ) ioRoutines.shell( "runenergyplus %s %s" % ( os.path.join(temp_directory_path, "webport.idf"), os.path.join(temp_directory_path, "weather.epw"), ) ) ioRoutines.shell( "cp -rf %s %s" % (os.path.join(temp_directory_path, "Output"), ep_path) ) with open("%sOutput/webport.err" % ep_path) as f: for line in f: print(line)
def classicBsdf( month, day, hour, irrdirn, irrdiffh, cores, ab, ad, ar, ass, aa, conIndex, numWin, lat, lon, tzone, workDir_path, output_path, bsdfVis_path, ): geometry.winRadBsdf(numWin, workDir_path, bsdfVis_path, conIndex) ioRoutines.shell( "gendaylit %i %i %f -a %1.2f -o %1.2f -m %1.2f -W %1.2f %1.2f > %sgendaylit.rad" % (month, day, hour, lat, lon, tzone, irrdirn, irrdiffh, workDir_path)) radWin = "" for i in range(numWin): radWin = radWin + "%swindowBSDF_%i.rad " % (workDir_path, i) ioRoutines.shell( "oconv -f %sgendaylit.rad %ssky_prev.rad %sroom.mat %sroom.rad %s > %sclassicBsdf.oct" % (workDir_path, workDir_path, workDir_path, workDir_path, radWin, workDir_path)) ioRoutines.shell( "cat %silluSensor.pts | rtrace -h -I -n %i -ab %i -ad %i -ar %i -as %i -aa %1.2f %sclassicBsdf.oct | rcalc -e '$1=47.4*$1+120*$2+11.6*$3' > %sillRadBsdf_%1.1f.dat" % (workDir_path, cores, ab, ad, ar, ass, aa, workDir_path, output_path, hour))
def irrView(nCore, numWin, numFrame, numSurf, workDir): for i in range(numWin): ioRoutines.shell( "rfluxmtx -n %i -o %sirrWinFront_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintWinFrontSensor_%i.pts" % (nCore, workDir, i, workDir, i, workDir, workDir, workDir, i)) ioRoutines.shell( "rfluxmtx -n %i -o %sirrWinBack_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintWinBackSensor_%i.pts" % (nCore, workDir, i, workDir, i, workDir, workDir, workDir, i)) for j in range(numSurf): ioRoutines.shell( "rfluxmtx -n %i -o %sirrSurfFront_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintSurfFrontSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j)) ioRoutines.shell( "rfluxmtx -n %i -o %sirrSurfBack_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintSurfBackSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j)) for j in range(numFrame): ioRoutines.shell( "rfluxmtx -n %i -o %sirrFrameFront_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintFrameFrontSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j)) ioRoutines.shell( "rfluxmtx -n %i -o %sirrFrameBack_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintFrameBackSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j)) ioRoutines.shell( "rfluxmtx -n %i -o %sirrRevFront_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintRevFrontSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j)) ioRoutines.shell( "rfluxmtx -n %i -o %sirrRevBack_%i_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintRevBackSensor_%i.pts" % (nCore, workDir, i, j, workDir, i, workDir, workDir, workDir, j))
def irrWinBackView(nCore, numWin, workDir): for i in range(numWin): ioRoutines.shell( "rfluxmtx -n %i -o %sirrWinBack_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %sintWinBackSensor_%i.pts" % (nCore, workDir, i, workDir, i, workDir, workDir, workDir, i))
def glareView(nCore, numWin, workDir): for i in range(numWin): ioRoutines.shell( "rfluxmtx -n %i -o %sillVert_%i.vmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %swindow_%i.rad %sroom.mat %sroom.rad < %silluVertSensor.pts" % (nCore, workDir, i, workDir, i, workDir, workDir, workDir))
def comp_vf(nCores, sender, receiver, workDir): return ioRoutines.shell( """rfluxmtx -n %i -c 20000 -h "!xform -I %s" %s -w %sroom.mat""" % (nCores, sender, receiver, workDir), outputFlag=True, )
def dayH(nCore, numWin, workDir): for i in range(numWin): ioRoutines.shell( "rfluxmtx -n %i -c 20000 %swindow_%i.rad %ssky.rad -w %sroom.mat %sroom.rad %soutside.rad> %swin_%i.dmx" % (nCore, workDir, i, workDir, workDir, workDir, workDir, workDir, i))
def glareFull( nCore, dgp, conIndex, numWin, mm, dd, hh, irrdirn, irrdiffh, lat, lon, tzone, illuVertPts, numSensorVert, winRad_path, workDir, inputDir, ): # glare calculation # vertical illuminance start_time = time.time() octFlag = True # calculation of lowlight correction for k in range(numSensorVert): if octFlag: geometry.winRad(numWin, workDir, inputDir, conIndex) # generate an octree shell( "gendaylit %i %i %1.1f -W %1.1f %1.1f -a %f -o %f -m %f -w > %sgendaylit.sky" % (mm, dd, hh, irrdirn, irrdiffh, lat, lon, tzone, inputDir)) genRtraceOct = "oconv %sroom.mat %sroom.rad" % (workDir, workDir) for i in range(numWin): genRtraceOct = genRtraceOct + " %s %swindowRad_%i.rad" % ( winRad_path[conIndex[i]], inputDir, i, ) genRtraceOct = (genRtraceOct + " %sgendaylit.sky %ssky_prev.rad > %srtrace.oct" % (inputDir, workDir, inputDir)) shell(genRtraceOct) octFlag = False # evalglare # --------------------------- output = shell( "vwrays -ff -vf %sview.vf -x 800 -y 800 | rtrace -n %i -ab 5 -ad 512 -ar 128 -as 256 -aa 0.15 -dc 1 -ffc `vwrays -vf %sview.vf -x 800 -y 800 -d` %srtrace.oct | evalglare -vta -vh 180 -vv 180 -vd %1.3f %1.3f %1.3f -vu 0 0 1" % ( workDir, nCore, inputDir, inputDir, illuVertPts[k, 3], illuVertPts[k, 4], illuVertPts[k, 5], ), True, ) # --------------------------- dgp[k] = float(output[0].split(" ")[1]) if dgp[k] > 1.0: dgp[k] = 1.0 # -------------------------------------------------------- print("Time span (s): ", time.time() - start_time) # -------------------------------------------------------- return dgp
def gen( ep_path, rotAng, volume, floorArea, iniMonth, iniDay, endMonth, endDay, iniDayWeek, airExch, powerLight, radFracLight, powerEquip, radFracEquip, powerPeople, radFracPeople, output_path, infSch_path, lightSch_path, equipSch_path, occSch_path, coolSpSch_path, heatSpSch_path, matOpaq, conOpaq, matGlz, matGas, matBSDF, conWinVect, conWin, bsdfSys_path, length, width, height, thickSouth, thickEast, thickNorth, thickWest, thickCeiling, thickFloor, albWall, albCeiling, albFloor, bcSouth, bcEast, bcNorth, bcWest, bcCeiling, bcFloor, conSouth, conEast, conNorth, conWest, conCeiling, conFloor, numWin, win, numFrame, frame, frameWidth, ): # ---------------------------------------------------- ioRoutines.shell("cp -f %s %sinfiltration.dat" % (infSch_path, ep_path)) ioRoutines.shell("cp -f %s %sequipment.dat" % (equipSch_path, ep_path)) ioRoutines.shell("cp -f %s %soccupation.dat" % (occSch_path, ep_path)) ioRoutines.shell("cp -f %s %scoolSetpoint.dat" % (coolSpSch_path, ep_path)) ioRoutines.shell("cp -f %s %sheatSetpoint.dat" % (heatSpSch_path, ep_path)) ioRoutines.shell("cp -f %slights.dat %slights.dat" % (output_path, ep_path)) # ---------------------------------------------------- # module creation by substitution with open("%swebport.idf" % ep_path, "w") as o: with open("template.idf") as template_file: for line in template_file: line = line.replace("@ORIENT", str(-rotAng)) line = line.replace("@HEIGHT", str(volume / floorArea)) line = line.replace("@VOL", str(volume)) line = line.replace("@FLOORAREA", str(floorArea)) line = line.replace("@ACH", str(airExch)) line = line.replace("@BEGMONTH", str(iniMonth)) line = line.replace("@BEGDAY", str(iniDay)) line = line.replace("@ENDMONTH", str(endMonth)) line = line.replace("@ENDDAY", str(endDay)) line = line.replace("@LIGHTLEVEL", str(powerLight)) line = line.replace("@LIGHTRAD", str(radFracLight)) line = line.replace("@EQUIPLEVEL", str(powerEquip)) line = line.replace("@EQUIPRAD", str(radFracEquip)) line = line.replace("@NUMPEOPLE", str(powerPeople / 0.531 / 120.0)) line = line.replace("@PEOPLERAD", str(radFracPeople)) line = line.replace("@MASSAREA", str(0.0)) o.write(line) # ---------------------------------------------------- # module creation by object inception with open("%swebport.idf" % ep_path, "a") as fw: # Opaque surfaces fw.write("\n") fw.write("!================================\n") fw.write("! Opaque Surfaces \n") fw.write("!================================\n") fw.write("\n") southSurface( fw, "SouthWall", bcSouth, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conSouth, ) eastSurface( fw, "EastWall", bcEast, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conEast, ) northSurface( fw, "NorthWall", bcNorth, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conNorth, ) westSurface( fw, "WestWall", bcWest, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conWest, ) ceilingSurface( fw, "Ceiling", bcCeiling, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conCeiling, ) floorSurface( fw, "Floor", bcFloor, length - thickWest - thickEast, width - thickNorth - thickSouth, height - thickCeiling - thickFloor, conFloor, ) # Windows fw.write("\n") fw.write("!================================\n") fw.write("! Windows \n") fw.write("!================================\n") fw.write("\n") for i in range(numWin): for j in range(numFrame): if win[i].frame == j and frame[j].surf == 1: southWindow( fw, "SouthWindow_%i" % i, win[i], frame[j], thickFloor, thickWest, ) addFrame(fw, "SouthWindow_%i" % i, frame[j], frameWidth, thickSouth) if win[i].frame == j and frame[j].surf == 2: eastWindow( fw, "EastWindow_%i" % i, win[i], frame[j], length - thickWest - thickEast, thickFloor, thickSouth, ) addFrame(fw, "SouthWindow_%i" % i, frame[j], frameWidth, thickEast) if win[i].frame == j and frame[j].surf == 3: northWindow( fw, "NorthWindow_%i" % i, win[i], frame[j], width - thickNorth - thickSouth, thickFloor, length - thickWest - win[i].xOffset - win[i].length, ) addFrame(fw, "SouthWindow_%i" % i, frame[j], frameWidth, thickNorth) if win[i].frame == j and frame[j].surf == 4: westWindow( fw, "WestWindow_%i" % i, win[i], frame[j], thickFloor, width - thickSouth - win[i].xOffset - win[i].length, ) addFrame(fw, "SouthWindow_%i" % i, frame[j], frameWidth, thickWest) if win[i].frame == j and frame[j].surf == 5: ceilingWindow( fw, "CeilingWindow_%i" % i, win[i], frame[j], height - thickCeiling - thickFloor, thickWest, thickSouth, ) addFrame( fw, "SouthWindow_%i" % i, frame[j], frameWidth, thickCeiling ) # Materials fw.write("\n") fw.write("!================================\n") fw.write("! Materials \n") fw.write("!================================\n") fw.write("\n") for i in range(matOpaq.shape[0]): material(fw, "mat_%i" % i, matOpaq[i, :]) # Glazing material for i in range(matGlz.shape[0]): materialGlz(fw, "matGlz_%i" % i, matGlz[i, :]) # Gap material for i in range(matGas.shape[0]): materialGas(fw, "matGas_%i" % i, matGas[i, :]) # BSDF material for i in range(matBSDF.shape[0]): materialBSDF(fw, "matBSDF_%i" % i, matBSDF[i, :]) # Opaque constructions fw.write("\n") fw.write("!================================\n") fw.write("! Constructions \n") fw.write("!================================\n") fw.write("\n") for i in range(conOpaq.shape[0]): construction(fw, "conOpaq_%i" % i, conOpaq[i, :]) # Window construction for i in range(conWinVect.shape[0]): constructionWin(fw, "conWin_%i" % i, conWinVect[i, :]) TransMtxV = ioRoutines.xml(bsdfSys_path[i], "Visible", "Transmission Front") TransMtxS = ioRoutines.xml(bsdfSys_path[i], "Solar", "Transmission Front") ReflBackMtxS = ioRoutines.xml(bsdfSys_path[i], "Solar", "Reflection Back") matrix2D(fw, "Tfsol_conWin_%i" % i, TransMtxS, 145, 145) matrix2D(fw, "Rbsol_conWin_%i" % i, ReflBackMtxS, 145, 145) matrix2D(fw, "Tfvis_conWin_%i" % i, TransMtxV, 145, 145) matrix2D(fw, "Tbvis_conWin_%i" % i, TransMtxV, 145, 145) for k in range(conWin[i].numPane): matrix2D( fw, "fAbs_conWin_%i_Lay_%i" % (i, k), conWin[i].absFront[k, :, :], 1, 145, ) matrix2D( fw, "bAbs_conWin_%i_Lay_%i" % (i, k), conWin[i].absBack[k, :, :], 1, 145, )
def bipv(nCore, workDir): ioRoutines.shell( "rfluxmtx -n %i -o %sbipv.dmx -I+ -ab 12 -ad 50000 -lw 2e-5 -h - %ssky.rad -w %sroom.mat %sroom.rad %soutside.rad < %sbipvSensor.pts" % (nCore, workDir, workDir, workDir, workDir, workDir, workDir))
def dc(opts): ioRoutines.shell( "rfluxmtx -n %i -I+ -ab 12 -ad 10000 -lw 1e-4 < points.txt - skies/sky.rad materials/testroom.mat objects/testroom.rad > dc.dmx" % (opts.c))
def glare( nCore, illVert, dgp, illVertVmx, tmxv, conIndex, dmx, skyVis, numWin, mm, dd, hh, irrdirn, irrdiffh, lat, lon, tzone, illuVertPts, numSensorVert, winRad_path, workDir, inputDir, ): # glare calculation # vertical illuminance start_time = time.time() for i in range(numWin): illVert = illVert + illVertVmx[i, :, :].dot( tmxv[conIndex[i], :, :].dot(dmx[i, :, :].dot(skyVis))) illVert = illVert * 179 octFlag = True # calculation of lowlight correction lowlight = zeros(numSensorVert) for k in range(numSensorVert): if illVert[k] < 1000: lowlight[k] = (1.0 * exp(0.024 * illVert[k] - 4) / (1 + exp(0.024 * illVert[k] - 4))) else: lowlight[k] = 1.0 if illVert[k] > 14310.0: dgp[k] = 1.0 else: if irrdirn > 25: if octFlag: geometry.winRad(numWin, workDir, inputDir, conIndex) # generate an octree shell( "gendaylit %i %i %1.1f -W %1.1f %1.1f -a %f -o %f -m %f -w > %sgendaylit.sky" % (mm, dd, hh, irrdirn, irrdiffh, lat, lon, tzone, inputDir)) genRtraceOct = "oconv %sroom.mat %sroom.rad" % (workDir, workDir) for i in range(numWin): genRtraceOct = genRtraceOct + " %s %swindowRad_%i.rad" % ( winRad_path[conIndex[i]], inputDir, i, ) genRtraceOct = ( genRtraceOct + " %sgendaylit.sky %ssky_prev.rad > %srtrace.oct" % (inputDir, workDir, inputDir)) shell(genRtraceOct) octFlag = False # evalglare # --------------------------- # output = shell("vwrays -ff -vf %sview.vf -x 800 -y 800 | rtrace -n %i -ab 0 -dj 0 -dr 2 -lr 4 -lw 0.000001 -st 0.15 -ffc `vwrays -vf %sview.vf -x 800 -y 800 -d` %srtrace.oct | evalglare -i %.3f -1 -vta -vh 180 -vv 180 -vd %1.3f %1.3f %1.3f -vu 0 0 1" % (workDir,nCore,workDir,workDir,illVert[k],illuVertPts[k,3],illuVertPts[k,4],illuVertPts[k,5]),True) # --------------------------- # shell("vwrays -ff -vf %sview.vf -x 800 -y 800 | rtrace -n %i -ab 0 -dj 0 -dr 2 -lr 4 -lw 0.000001 -st 0.15 -ffc `vwrays -vf %sview.vf -x 800 -y 800 -d` %srtrace.oct > %srtrace.hdr" % (workDir,nCore,workDir,workDir,workDir)) # output = shell("evalglare -i %.3f -1 -vta -vh 180 -vv 180 -vd %1.3f %1.3f %1.3f -vu 0 0 1 %srtrace.hdr" % (mean(illVert),illuVertPts[k,3],illuVertPts[k,4],illuVertPts[k,5],workDir),True) # --------------------------- # ~ output = shell("rpict -x 800 -y 800 -ab 1 -dj 0 -dr 2 -lr 4 -lw 0.000001 -st 0.15 -ps 0 -pj 0 -vta -vv 180 -vh 180 -vu 0 0 1 -vs 0 -vl 0 -vp %1.3f %1.3f %1.3f -vd %1.3f %1.3f %1.3f %srtrace.oct | evalglare -b 8000 -i %1.3f -D -y -1" % (illuVertPts[k,0],illuVertPts[k,1],illuVertPts[k,2],illuVertPts[k,3],illuVertPts[k,4],illuVertPts[k,5],inputDir,illVert[k]),True) # ~ #--------------------------- output = shell( "rpict -x 800 -y 800 -ab 0 -dj 0 -dr 2 -lr 4 -lw 0.000001 -st 0.15 -ps 0 -pj 0 -vta -vv 180 -vh 180 -vu 0 0 1 -vs 0 -vl 0 -vp %1.3f %1.3f %1.3f -vd %1.3f %1.3f %1.3f %srtrace.oct | evalglare -b 8000 -i %1.3f -D -y -1" % ( illuVertPts[k, 0], illuVertPts[k, 1], illuVertPts[k, 2], illuVertPts[k, 3], illuVertPts[k, 4], illuVertPts[k, 5], inputDir, illVert[k], ), True, ) # --------------------------- dgp[k] = float(output) else: dgp[k] = lowlight[k] * (6.22e-5 * illVert[k] + 0.184) if dgp[k] > 1.0: dgp[k] = 1.0 # -------------------------------------------------------- print("Time span (s): ", time.time() - start_time) # -------------------------------------------------------- return illVert, dgp