示例#1
0
    def test_multiprocess_run_IDF(self):
        """
        Test that we can run a sequence of runs using the signature:
            runIDFs([[IDF, kwargs],...], num_CPUs)
        Fails if expected output files are not in the expected output
        directories.

        """
        iddfile = os.path.join(IDD_FILES, TEST_IDD)
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        modeleditor.IDF.setiddname(open(iddfile, 'r'), testing=True)
        ep_version = '-'.join(str(x) for x in modeleditor.IDF.idd_version[:3])
        assert ep_version == VERSION
        runs = []
        for i in range(4):
            runs.append([
                modeleditor.IDF(open(fname1, 'r'), TEST_EPW), {
                    'output_directory': 'results_%i' % i,
                    'ep_version': ep_version
                }
            ])
        num_CPUs = 2
        runIDFs(runs, num_CPUs)

        num_CPUs = -1
        runIDFs(runs, num_CPUs)
示例#2
0
    def test_multiprocess_run_IDF_from_generator(self):
        """
        Test that we can run a sequence passed as a generator of runs using
        the signature:
            runIDFs(([IDF, kwargs],...), num_CPUs)
        Fails if expected output files are not in the expected output
        directories.

        """
        iddfile = os.path.join(IDD_FILES, TEST_IDD)
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        modeleditor.IDF.setiddname(open(iddfile, "r"), testing=True)
        ep_version = "-".join(str(x) for x in modeleditor.IDF.idd_version[:3])
        assert ep_version == VERSION
        runs = ((
            modeleditor.IDF(open(fname1, "r"), TEST_EPW),
            {
                "output_directory": "results_%i" % i,
                "ep_version": ep_version
            },
        ) for i in range(4))
        num_CPUs = 2
        runIDFs(runs, num_CPUs)

        num_CPUs = -1
        runIDFs(runs, num_CPUs)
示例#3
0
    def setup(self):
        """Tidy up anything left from previous runs. Get an IDF object to run.
        """
        outdir = os.path.join(THIS_DIR, 'run_outputs')
        if os.path.isdir(outdir):
            shutil.rmtree(outdir)
        iddfile = os.path.join(IDD_FILES, TEST_IDD)
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        modeleditor.IDF.setiddname(iddfile, testing=True)
        self.idf = modeleditor.IDF(fname1, TEST_EPW)
        try:
            ep_version = self.idf.idd_version
            assert ep_version == versiontuple(VERSION)
        except AttributeError:
            raise

        self.expected_files = [
            u'eplusout.audit', u'eplusout.bnd', u'eplusout.eio',
            u'eplusout.end', u'eplusout.err', u'eplusout.eso',
            u'eplusout.mdd', u'eplusout.mtd', u'eplusout.rdd',
            u'eplusout.shd', u'eplustbl.htm', u'sqlite.err', ]
        self.expected_files_suffix_C = [
            u'eplus.audit', u'eplus.mdd', u'eplus.err',
            u'eplusSqlite.err', u'eplus.eio', u'eplusTable.htm', u'eplus.shd',
            u'eplus.mtd', u'eplus.bnd', u'eplus.eso', u'eplus.rdd',
            u'eplus.end']
        self.expected_files_suffix_D = [
            u'eplus.audit', u'eplus.mdd', u'eplus-sqlite.err',
            u'eplus-table.htm', u'eplus.err', u'eplus.eio', u'eplus.bnd',
            u'eplus.shd', u'eplus.mtd', u'eplus.end', u'eplus.eso',
            u'eplus.rdd']
示例#4
0
 def setup(self):
     runfolder = "runfolder"
     self.runpath = os.path.join(THIS_DIR, runfolder)
     if os.path.exists(self.runpath):
         shutil.rmtree(self.runpath)
     os.mkdir(self.runpath)
     runidffile = os.path.join(self.runpath, TEST_IDF_NAME)
     shutil.copy(fname1, runidffile)
     self.idf = modeleditor.IDF(runidffile, TEST_EPW)
     expected_files = [
         "{}.audit",
         "{}.eso",
         "{}.shd",
         "{}.bnd",
         "{}.idf",
         "{}Sqlite.err",
         "{}.eio",
         "{}.mdd",
         "{}Table.htm",
         "{}.end",
         "{}.mtd",
         "{}.err",
         "{}.rdd",
     ]
     idf_noext = TEST_IDF_NAME.split(".")[0]
     self.expected_files = [
         expected_file.format(idf_noext) for expected_file in expected_files
     ]
示例#5
0
def test_idf_from_template():
    template_path = os.path.join('testing', 'test_template.idf')
    template = modeleditor.IDF(template_path)
    idf = citysimtoenergyplus.idf_from_template(template)
    assert idf.idfstr() == template.idfstr()
    building = idf.idfobjects['BUILDING'][0]
    building.Name = 'Some other name'
    assert idf.idfstr() != template.idfstr()
示例#6
0
def test_idf():
    idd_file = os.path.join(IDD_FILES, TEST_IDD)
    idf_file = os.path.join(IDF_FILES, TEST_IDF)
    modeleditor.IDF.setiddname(idd_file, testing=True)
    idf = modeleditor.IDF(idf_file, TEST_EPW)
    try:
        ep_version = idf.idd_version
        assert ep_version == versiontuple(VERSION)
    except AttributeError:
        raise
    return idf
示例#7
0
def idf_from_template(template):
    '''
    cloning a whole IDF file is not as easy as I thought it
    would be. But we can copy each object...
    '''
    from eppy import modeleditor
    idf = modeleditor.IDF()
    idf.initnew()
    for key in template.idfobjects.keys():
        for value in template.idfobjects[key]:
            idf.copyidfobject(value)
    return idf
示例#8
0
def test_version_reader():
    """Test that get the expected idd_version when reading an IDF/IDD."""
    # We need to reload modeleditor since the IDF class may have had an IDD
    # which causes problems.
    # https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module
    reload(modeleditor)
    iddfile = os.path.join(IDD_FILES, TEST_IDD)
    fname1 = os.path.join(IDF_FILES, TEST_IDF)
    modeleditor.IDF.setiddname(iddfile, testing=True)
    idf = modeleditor.IDF(fname1, TEST_EPW)
    ep_version = idf.idd_version
    assert ep_version == versiontuple(VERSION)
    ep_version = modeleditor.IDF.idd_version
    assert ep_version == versiontuple(VERSION)
示例#9
0
def makeidf():
    """return an idf"""
    reload(modeleditor)  # to make sure you have the right IDD
    iddfile = os.path.join(IDD_FILES, TEST_IDD)
    fname1 = os.path.join(IDF_FILES, TEST_IDF)
    modeleditor.IDF.setiddname(iddfile, testing=True)
    idf = modeleditor.IDF(fname1, TEST_EPW)
    # put a expidf object in.
    idf.newidfobject(
        "HVACTEMPLATE:THERMOSTAT",
        Name="TestThermostat",
        Cooling_Setpoint_Schedule_Name="",
        Heating_Setpoint_Schedule_Name="",
        Constant_Cooling_Setpoint=25,
        Constant_Heating_Setpoint=21,
    )
    # put and sql output
    idf.newidfobject(
        "Output:SQlite",
        Option_Type="simple",
    )
    return idf
示例#10
0
PATH_TO_IDD = r"C:\EnergyPlusV8-2-0\Energy+.idd"
PATH_TO_EPW = r"C:\EnergyPlusV8-2-0\WeatherData\USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw"  # noqa

import eppy.modeleditor as modeleditor
import subprocess
import sys
import os
import tempfile
import datetime

# load the original idf file
try:
    modeleditor.IDF.setiddname(PATH_TO_IDD)
except modeleditor.IDDAlreadySetError:
    pass
idf = modeleditor.IDF(PATH_TO_IDF)

# add a number of variables to the output interface
num_variables = int(sys.argv[1])
idf.newidfobject('RUNPERIOD',
                 Begin_Month=1,
                 Begin_Day_of_Month=1,
                 End_Month=12,
                 End_Day_of_Month=31)
idf.idfobjects['TIMESTEP'][0].Number_of_Timesteps_per_Hour = 1
idf.idfobjects['SIMULATIONCONTROL'][
    0].Run_Simulation_for_Weather_File_Run_Periods = 'YES'  # noqa
idf.newidfobject('EXTERNALINTERFACE',
                 Name_of_External_Interface='FunctionalMockupUnitExport')
gvars = idf.newidfobject('ENERGYMANAGEMENTSYSTEM:GLOBALVARIABLE')
示例#11
0
    VERSION = os.environ["ENERGYPLUS_INSTALL_VERSION"]  # used in CI files
except KeyError:
    VERSION = '9-0-1'  # current default for integration tests on local system
TEST_IDF_NAME = 'smallfile.idf'
TEST_IDF = "V{}/{}".format(VERSION[:3].replace('-', '_'), TEST_IDF_NAME)
TEST_EPW = 'USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw'
TEST_IDD = "Energy+V{}.idd".format(VERSION.replace('-', '_'))
TEST_OLD_IDD = 'Energy+V7_2_0.idd'
(eplus_exe, eplus_weather) = install_paths(VERSION,
                                           os.path.join(IDD_FILES, TEST_IDD))

reload(modeleditor)
iddfile = os.path.join(IDD_FILES, TEST_IDD)
fname1 = os.path.join(IDF_FILES, TEST_IDF)
modeleditor.IDF.setiddname(iddfile, testing=True)
idf = modeleditor.IDF(fname1, TEST_EPW)

# IDF.setiddname(iddfile)
# idf = IDF(idfname, epw=wname)


class TestEPLaunch_Run(object):
    """tests for eplaunch_run"""
    def setup(self):
        runfolder = "runfolder"
        self.runpath = os.path.join(THIS_DIR, runfolder)
        if os.path.exists(self.runpath):
            shutil.rmtree(self.runpath)
        os.mkdir(self.runpath)
        runidffile = os.path.join(self.runpath, TEST_IDF_NAME)
        shutil.copy(fname1, runidffile)
示例#12
0
def get_idf(idf_file):
    """Returns the idf file as a eppy class"""
    modeleditor.IDF.setiddname(settings.ep_idd)
    return modeleditor.IDF(idf_file)
示例#13
0
	idf_VN.idfobjects["MATERIAL"][0].Density = new_density_floor
	idf_AC.idfobjects["MATERIAL"][0].Density = new_density_floor

	file.write("U piso: " + str(floor_random)+ " " + "\n")


	nome_VN = "C"+"%d" % i + ' VN' +'.idf'
	nome_AC = "C"+"%d" % i + ' AC' +'.idf'

	idf_VN.saveas('%s' % nome_VN)
	lista_idfs_VN.append(nome_VN)
	idf_AC.saveas('%s' % nome_AC)
	lista_idfs_AC.append(nome_AC)

	if(lista_tam < 100):
		runs_AC.append([modeleditor.IDF(open(nome_AC, 'r'), epw),
	                         {'output_directory': 'C%i AC' % i,'ep_version': version,'expandobjects':True}])
		runs_VN.append([modeleditor.IDF(open(nome_VN, 'r'), epw),
							 {'output_directory': 'C%i VN' % i,'ep_version': version,'expandobjects':True}])

	if(lista_tam == 100):
		paradas += 1
		lista_tam = 0
		print (paradas)
		runIDFs(runs_AC, int(multiprocessing.cpu_count()))
		runIDFs(runs_VN, int(multiprocessing.cpu_count()))
		runs_AC.clear()
		runs_VN.clear()

# RUNIDF sem uso de paralelismo;
'''
示例#14
0
def construct_empty_idf():
    from StringIO import StringIO
    idf = modeleditor.IDF(StringIO(''))
    return idf