#====================================================================== # Imports #====================================================================== #====================================================================== # Functions #====================================================================== #Function to write a ep surface def write_ep_surface( idf_file, name, srf_type, const,zone,boundry,boundry_obj, sun_exp,wind_exp,view_fact, points): idf_file.write("! Building Surface\n") idf_file.write("BuildingSurface:Detailed,\n") idf_file.write(" "+name+",\n") idf_file.write(" "+srf_type+",\n") idf_file.write(" "+const+",\n") idf_file.write(" "+zone+",\n") idf_file.write(" "+boundry+",\n") idf_file.write(" "+boundry_obj+",\n") idf_file.write(" "+sun_exp+",\n") idf_file.write(" "+wind_exp+",\n") idf_file.write(" "+view_fact+",\n") idf_file.write(" "+str(len(points))+",\n") for counter in range(len(points)): point = points[counter] text_point = str(point[0])+","+str(point[1])+","+str(point[2]) if counter < len(points)-1: idf_file.write(" "+text_point+",\n" ) else: idf_file.write(" "+text_point+";\n\n" ) #====================================================================== # Main Script #====================================================================== # Create a simple box box = ( (0,0,0),(15,0,0),(15,15,0),(0,15,0), (0,0,10),(15,0,10),(15,15,10),(0,15,10), ) floor_points = (box[3], box[2], box[1], box[0]) wall1_points = (box[1], box[5], box[4], box[0]) wall2_points = (box[2], box[6], box[5], box[1]) wall3_points = (box[3], box[7], box[6], box[2]) wall4_points = (box[0], box[4], box[7], box[3]) roof_points = (box[4], box[5], box[6], box[7]) #Create the idf file idf_file_1 = open("D:/box.idf", "w") base_file = open("D:/base.idf", "r") base_stuff = base_file.read() idf_file_1.write(base_stuff) idf_file_1.write("!- ========================= \n\n\n") # Add the surfaces write_ep_surface(idf_file_1, "zn001:floor", "Floor", "FLOOR", "Main Zone", "Surface", "zn001:floor", "NoSun", "NoWind", "1.00", floor_points) write_ep_surface(idf_file_1, "zn001:wall1", "Wall", "R13WALL", "Main Zone", "Outdoors", "", "SunExposed", "WindExposed", "0.50", wall1_points) write_ep_surface(idf_file_1, "zn001:wall2", "Wall", "R13WALL", "Main Zone", "Outdoors", "", "SunExposed", "WindExposed", "0.50", wall2_points) write_ep_surface(idf_file_1, "zn001:wall3", "Wall", "R13WALL", "Main Zone", "Outdoors", "", "SunExposed", "WindExposed", "0.50", wall3_points) write_ep_surface(idf_file_1, "zn001:wall4", "Wall", "R13WALL", "Main Zone", "Outdoors", "", "SunExposed", "WindExposed", "0.50", wall4_points) write_ep_surface(idf_file_1, "zn001:roof", "Roof", "ROOF31", "Main Zone", "Outdoors", "", "SunExposed", "WindExposed", "0.00", roof_points) #Close the file idf_file_1.close() base_file.close()
Friday, January 8, 2010
Python and EnergyPlus
Here is the script from todays session. This script generates the IDF input file for EnergyPlus. Note that this script requires a base file, i.e. rather than generating the whole IDF file, the script only generates the surfaces and appends these to the base file. To run this script, you will have to make the base file - just open 1ZoneEvapCooler.idf, save it as base.idf, and delete all the BuildingSurface objects in this file.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment