Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
def runandget(idf, runoptions, getdict, json_it=False, compress_it=False):
    """run the idf and return the results"""
    # idf.run(**runoptions)
    # idf.run() does not allow simultaeous runs. -> using runIDFs
    idfversion = idf.idfobjects["version"][0].Version_Identifier.split(".")
    idfversion.extend([0] * (3 - len(idfversion)))
    idfversionstr = "-".join([str(item) for item in idfversion])
    runoptions["ep_version"] = idfversionstr
    #
    runs = []
    runs.append([idf, runoptions])
    num_CPUs = 1
    runIDFs(runs, num_CPUs)
    return getrun(runoptions, getdict, json_it, compress_it)
Ejemplo n.º 4
0
    def run_models(self, processors):
        if self.idf is None:
            raise TypeError('idf not set')
        util = EppyUtilIdf()
        idf_lst = []
        file_dir = os.path.dirname(__file__)
        output_folder = os.path.join(file_dir, 'sensitivity_results')
        try:
            shutil.rmtree(output_folder)
        except FileNotFoundError as e:
            print(e)
        os.mkdir(output_folder)

        for i, values in enumerate(self.X):
            idf_temp = util.copy(self.idf)
            for j, value in enumerate(values):
                for obj in self.objects[j]:
                    obj_id, obj_name, field = obj.split(',')
                    util.mod(idf_temp, obj_id, obj_name, field, value)
            idf_temp.idfname = os.path.join(output_folder,
                                            'run-{}.idf'.format(i))
            idf_temp.save()

            sim_settings = {
                'ep_version': '8-7-0',
                'verbose': 'q',
                'output_directory': output_folder,
                'readvars': True,
                'output_prefix': "run-{}-".format(i)
            }
            idf_lst.append([idf_temp, sim_settings])

        run_functions.runIDFs(idf_lst, processors=processors)
        # retrieve E+ outputs after simulations are run
        num_samples = self.X.shape[0]
        self.y = np.zeros(num_samples)

        for k in range(num_samples):
            result_file = os.path.join(output_folder,
                                       'run-{}-tbl.htm'.format(k))
            with open(result_file, "r", encoding="ISO-8859-1") as f:
                results_table = readhtml.titletable(f.read())

            total_site_energy = util.get_output(
                results_table, ['Site and Source Energy', 'Total Site Energy'])
            total_site_energy_per_area = total_site_energy[1]
            self.y[k] = total_site_energy_per_area
Ejemplo n.º 5
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)
       IDF.setiddname(open(iddfile, 'r'), testing=True)
       runs = []
       for i in range(4):
           runs.append([IDF(open(fname1, 'r'), TEST_EPW),
                        {'output_directory': 'results_%i' % i}])
       num_CPUs = 2
       runIDFs(runs, num_CPUs)
 
       num_CPUs = -1
       runIDFs(runs, num_CPUs)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
	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;
'''
for idf in lista_idfs_VN:
	nome = idf.replace('.idf','')
	saida = os.getcwd() + "\%s" % nome
	idf_run = IDF(idf, epw)
	idf_run.run(output_directory=saida,expandobjects=True)

for idf in lista_idfs_AC:
	nome = idf.replace('.idf','')
	saida = os.getcwd() + "\%s" % nome