def test_easyopen_withidd(): """py.test for easyopen""" ver = idd_helpers.latestidd() iddfile = easyopen.getiddfile(ver) txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1, idd=iddfile), eppy.openidf(fhandle2, idd=iddfile) for idf in [idf1, idf2]: versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = 'weatherfile.epw' idf1, idf2 = easyopen.easyopen(fhandle1, idd=iddfile, epw=epwname), eppy.openidf(fhandle2, idd=iddfile, epw=epwname) for idf in [idf1, idf2]: assert idf.epw == epwname
def test_easyopen_idfopen(): """py.test for easyopen""" ver = idd_helpers.latestidd() txt, result = (" Version,{};".format(ver), "{}".format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1), eppy.openidf(fhandle2) for idf in [idf1, idf2]: versions = idf.idfobjects["version"] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = "weatherfile.epw" idf1, idf2 = ( easyopen.easyopen(fhandle1, epw=epwname), eppy.openidf(fhandle2, epw=epwname), ) for idf in [idf1, idf2]: assert idf.epw == epwname
def zeppy_runandget(idftxt, wfiletxt, getdict): """writes idftxt and wfiletxt to a tempfile, runs and returns the getdict values """ with tempfile.TemporaryDirectory() as tmpdir: idf_temp_file = f"{tmpdir}/a.idf" open(idf_temp_file, "w").write(idftxt) wfile_temp_file = f"{tmpdir}/a.epw" open(wfile_temp_file, "w").write(wfiletxt) print("saved temp files") idf_temp = eppy.openidf(idf_temp_file, epw=wfile_temp_file) fullresult = runandget.anon_runandget(idf_temp, getdict) print(fullresult) return fullresult
def test_easyopen_idfopen(): """py.test for easyopen""" ver = idd_helpers.latestidd() txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) reload(eppy) reload(modeleditor) reload(easyopen) idf1, idf2 = easyopen.easyopen(fhandle1), eppy.openidf(fhandle2) for idf in [idf1, idf2]: versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle1 = StringIO(txt) fhandle2 = StringIO(txt) epwname = 'weatherfile.epw' idf1, idf2 = easyopen.easyopen(fhandle1, epw=epwname), eppy.openidf(fhandle2, epw=epwname) for idf in [idf1, idf2]: assert idf.epw == epwname
def runsomefiles(): fnames = [ # "./eplus_files/f1/Minimal.idf", "./eplus_files/f2/UnitHeaterGasElec.idf", "./eplus_files/f3/ZoneWSHP_wDOAS.idf", "./eplus_files/f4/ZoneWSHP_wDOAS_1.idf", ] wfile = ( "/Applications/EnergyPlus-9-1-0/WeatherData/USA_CO_Golden-NREL.724666_TMY3.epw" ) idfs = [eppy.openidf(fname, epw=wfile) for fname in fnames] idfs_options = [] for idf in idfs: options = make_options(idf) idfs_options.append([idf, options]) processors = 3 eppy.runner.run_functions.runIDFs(idfs_options, processors)
def runeverything(): # waitlist = [1, 2, 3, 2, 1] # # waitlist = [(1, ), (2, ), (3, ), (2, ), (1, )] # # waitlist = [(1, 0), (1, 1), (2, 1), (2, 0), (0, 1)] # # waitlist = [(1, 0, 1), (1, 1, 1), (2, 1, 1), (2, 0, 1), (0, 1, 1)] # waitlist = [(1, 0, 1), (1, 1, 1), (2, 1, 1), (2, 0, 1), (0, 1, 1)] # # waitlist = [(1, 0, 1), ] # # waitlist = [{'args':(1, ), 'kwargs':{'add':0, 'mult':1}}] # waitlist = [ # # {'args':1, 'kwargs':{'add':3}}, # {'args':(1,), 'kwargs':{'mult':3}}, # {'args':(1,), 'kwargs':{'add':2, 'mult':3}}, # {'args': (1, 2, 3)}, # ] # print(waitlist) # func = wait_add_mult # result = ipc_parallelpipe(func, waitlist, nworkers=None, verbose=True) # # print(result) # running eppy in zeppy import eppy fnames = [ # "./eplus_files/Minimal.idf", "./eplus_files/UnitHeaterGasElec.idf", "./eplus_files/ZoneWSHP_wDOAS.idf", "./eplus_files/ZoneWSHP_wDOAS_1.idf", ] wfile = ( "/Applications/EnergyPlus-9-1-0/WeatherData/USA_CO_Golden-NREL.724666_TMY3.epw" ) idfs = [eppy.openidf(fname, epw=wfile) for fname in fnames] waitlist = [[{"args": idf, "kwargs": make_options(idf)}] for idf in idfs] func = idf_multirun result = ipc_parallelpipe(func, waitlist, nworkers=None, verbose=True, sleeptime=1) # sleeptime=1 sec. This is a pause between sending the task out. Not sure if a single worker is grabbing all the tasks in E+. May need some testing to confirm. print(result)
def test_idf2idj_epj2idf(): """py.test for idf2idj and epj2idf""" # rearranged the order of so that it matches the order in the idd file. # So the tests can pass data = ( ( """ Version,9.1; Building, Bldg one, !- Name 30, !- North Axis {deg} City, !- Terrain 0.04, !- Loads Convergence Tolerance Value 0.4, !- Temperature Convergence Tolerance Value {deltaC} FullExterior, !- Solar Distribution 25, !- Maximum Number of Warmup Days 6; !- Minimum Number of Warmup Days Timestep,4; Zone, Main Zone, !- Name 0, !- Direction of Relative North {deg} 0, !- X Origin {m} 0, !- Y Origin {m} 0, !- Z Origin {m} 1, !- Type 1, !- Multiplier autocalculate, !- Ceiling Height {m} autocalculate; !- Volume {m3} Zone, Another Zone, !- Name 90, !- Direction of Relative North {deg} 11, !- X Origin {m} 22, !- Y Origin {m} 33, !- Z Origin {m} 1, !- Type 1, !- Multiplier autocalculate, !- Ceiling Height {m} autocalculate; !- Volume {m3} BuildingSurface:Detailed, WALL-1PF, !- Name WALL, !- Surface Type WALL-1, !- Construction Name PLENUM-1, !- Zone Name Outdoors, !- Outside Boundary Condition , !- Outside Boundary Condition Object SunExposed, !- Sun Exposure WindExposed, !- Wind Exposure 0.50000, !- View Factor to Ground 4, !- Number of Vertices 0,0,3, !- X,Y,Z ==> Vertex 1 {m} 0,0,2.4, !- X,Y,Z ==> Vertex 2 {m} 30.5,0,2.4, !- X,Y,Z ==> Vertex 3 {m} 30.5,0,3; !- X,Y,Z ==> Vertex 4 {m} ZoneHVAC:EquipmentList, SPACE1-1 Eq, !- Name SequentialLoad, !- Load Distribution Scheme ZoneHVAC:AirDistributionUnit, !- Zone Equipment 1 Object Type SPACE1-1 ATU, !- Zone Equipment 1 Name 1, !- Zone Equipment 1 Cooling Sequence 1; !- Zone Equipment 1 Heating or No-Load Sequence NodeList, SPACE1-1 In Nodes, !- Name SPACE1-1 In Node; !- Node 1 Name NodeList, Supply Air Temp Nodes 1, !- Name Main Cooling Coil 1 Inlet Node, !- Node 1 Name Heat Recovery Supply Outlet, !- Node 2 Name Main Heating Coil 1 Inlet Node, !- Node 3 Name Reheat Coil Air Inlet Node, !- Node 4 Name VAV Sys 1 Outlet Node; !- Node 5 Name OutdoorAir:NodeList, OutsideAirInletNodes; !- Node or NodeList Name 1 """, # noqa: E501 ), # idftxt ) for (idftxt,) in data: iddhandle = open(iddfile, "r") iddtxt = iddhandle.read() iddstringio = StringIO(iddtxt) # convert idf to epj, then epj to idf and lastly idf to epj # compare the first epj.json and last epj.json idfhandle = StringIO(idftxt) idf = eppy.openidf(idfhandle, idd=iddstringio) epsjsonschema = schemafortesting.schema # idf to epj epj1 = oldeppy.idf2epj(idf, epsjsonschema) # epj to idf idf1 = oldeppy.epj2idf(epj1, epsjsonschema, iddhandle=iddstringio) # idf to epj epj2 = oldeppy.idf2epj(idf1, epsjsonschema) # compare epj1 and epj2 assert epj1.jsonstr() == epj2.jsonstr()
# Change People # Zone_Floor_Area = [16,18,29,22,24] ##for i in [16,18,29,22,24]: ## idf = eppy.openidf(fname1, epw=epwfile) ## idf.idfobjects["People"][0].Zone_Floor_Area_per_Person = i## a = idf.idfobjects["People"][0].Zone_Floor_Area_per_Person ## print(a) ## ## idf.save() ## ## witheppy.runner.eplaunch_run(idf) ## fname = 'instanceTable.htm' # the html file you want to read ## filehandle = open(fname, 'r').read() # get a file handle to the html file ## htables = readhtml.titletable(filehandle) # reads the tables with their titles ## firstitem = htables[0] ## seconditem = htables[2] ## ## pp = pprint.PrettyPrinter() ## total_site_energy = firstitem[1][1][1] ## total_conditioned_area = seconditem[1][2][1] ## print(total_conditioned_area) ##idf.run(readvars=True) ##for i in range(5): filename = ["idf_instance_1.idf","idf_instance_2.idf","idf_instance_3.idf","idf_instance_4.idf","idf_instance_5.idf"] ## a = (filename[i]) ## print(a) idf = eppy.openidf(filename[4], epw=epwfile) witheppy.runner.eplaunch_run(idf)
def epj2idf(epj, epjsonhandle, iddhandle=None): """convert json to idf""" jsonhandle = epj.savecopy() idfstr = eppy3000.idfjsonconverter.json2idf(jsonhandle, epjsonhandle) return eppy.openidf(StringIO(idfstr), idd=iddhandle, epw=epj.epw)
# Copyright (c) 2020 Santosh Philip # ======================================================================= # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # ======================================================================= """convert an idf file into an epj file Quick script to be used during development. Remove this later """ import eppy import eppy3000.oldeppy as oldeppy inname = "./eppy3000/resources/snippets/V9_3/constructions.idf" outname = "./eppy3000/resources/snippets/V9_3/constructions.epJSON" epschema = "./eppy3000/resources/schema/V9_3/Energy+.schema.epJSON" idf = eppy.openidf(inname) epj = oldeppy.idf2epj(idf, open(epschema, "r")) epj.saveas(outname)
import sys import math # one home desktop pathnameto_blender = '/Users/santoshphilip/Documents/coolshadow/github/eppyjuice/eppyjuice' sys.path.append(pathnameto_blender) import eppy import eppy3000.oldeppy import eppy3000.experimental.listfields as listfields import poly fname = '/Users/santoshphilip/Documents/coolshadow/github/eppyjuice/eppyjuice/resources/V9_1/5Zone_IdealLoadsAirSystems_ReturnPlenum1.idf' idf = eppy.openidf(fname) epjson = '/Applications/EnergyPlus-9-1-0/Energy+.schema.epJSON' epj = eppy3000.oldeppy.idf2epj(idf, open(epjson, 'r')) surfs = epj.epobjects['BuildingSurface:Detailed'] surfaces_pts = [(surf.eppyname, listfields.surf2list(surf)) for surf in surfs] # surface_pts = surfaces_pts[0] for surface_pts in surfaces_pts: poly.create_apoly(surface_pts[0], surface_pts[1])