Пример #1
0
    def test_run_weather_name_only(self):
        """
        Test that running works with the name of a weather file that is
        in the Weather subdirectory of the EnergyPlus install directory.
        Fails if no results are produced.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        run(fname1, TEST_EPW, output_directory="test_results")
        assert len(os.listdir('test_results')) > 0
        for f in os.listdir('test_results'):
            assert os.path.isfile(os.path.join('test_results', f))
Пример #2
0
    def test_run_abs_paths(self):
        """
        Test that running works with absolute paths.
        Fails if no results are produced.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        epw = os.path.join(eplus_weather, TEST_EPW)
        run(fname1, epw, output_directory="test_results", ep_version=VERSION)
        assert len(os.listdir("test_results")) > 0
        for f in os.listdir("test_results"):
            assert os.path.isfile(os.path.join("test_results", f))
Пример #3
0
    def test_run_abs_paths(self):
        """
        Test that running works with absolute paths.
        Fails if no results are produced.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        epw = os.path.join(
            eplus_weather, TEST_EPW)
        run(fname1, epw, output_directory="test_results", ep_version=VERSION)
        assert len(os.listdir('test_results')) > 0
        for f in os.listdir('test_results'):
            assert os.path.isfile(os.path.join('test_results', f))
Пример #4
0
    def test_run_abs_paths(self):
        """
        Test that running works with absolute paths.
        Fails if no results are produced.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        epw = os.path.join(
            EPLUS_WEATHER, TEST_EPW)
        run(fname1, epw, output_directory="test_results")
        assert len(os.listdir('test_results')) > 0
        for f in os.listdir('test_results'):
            assert os.path.isfile(os.path.join('test_results', f))
Пример #5
0
    def test_run_missing_file_raises_error(self, capfd):
        """
        Test that a missing file produces the expected warning to std
        out.
        Fails if error message is not as expected.

        """
        fname1 = os.path.join(IDF_FILES, "XXXXXXX_fake_file.idf")
        with pytest.raises(EnergyPlusRunError):
            run(fname1, TEST_EPW,
                output_directory="test_results",
                ep_version=VERSION)
            out, _err = capfd.readouterr()
            assert "ERROR: Could not find input data file:" in out
Пример #6
0
    def test_run_weather_name_only(self):
        """
        Test that running works with the name of a weather file that is
        in the Weather subdirectory of the EnergyPlus install directory.
        Fails if no results are produced.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        run(fname1, TEST_EPW,
            output_directory="test_results",
            ep_version=VERSION)
        assert len(os.listdir('test_results')) > 0
        for f in os.listdir('test_results'):
            assert os.path.isfile(os.path.join('test_results', f))
Пример #7
0
    def test_run_missing_file_raises_error(self, capfd):
        """
        Test that a missing file produces the expected warning to std
        out.
        Fails if error message is not as expected.

        """
        fname1 = os.path.join(IDF_FILES, "XXXXXXX_fake_file.idf")
        try:
            run(fname1, TEST_EPW, output_directory="test_results")
            assert False  # missed the error
        except CalledProcessError:
            out, _err = capfd.readouterr()
            assert "ERROR: Could not find input data file:" in out
Пример #8
0
    def test_run_missing_file_raises_error(self, capfd):
        """
        Test that a missing file produces the expected warning to std
        out.
        Fails if error message is not as expected.

        """
        fname1 = os.path.join(IDF_FILES, "XXXXXXX_fake_file.idf")
        with pytest.raises(EnergyPlusRunError):
            run(fname1,
                TEST_EPW,
                output_directory="test_results",
                ep_version=VERSION)
            out, _err = capfd.readouterr()
            assert "ERROR: Could not find input data file:" in out
Пример #9
0
    def run(self, **kwargs):
        """
        Run an IDF file with a given EnergyPlus weather file. This is a
        wrapper for the EnergyPlus command line interface.

        Parameters
        ----------
        **kwargs
            See eppy.runner.functions.run()

        """
        # write the IDF to the current directory
        self.saveas('in.idf')
        # run EnergyPlus
        run('in.idf', self.epw, **kwargs)
        # remove in.idf
        os.remove('in.idf')
Пример #10
0
def ep_runner(idfname, epwfile, outfolder):
    pst = time()
    # Delete output folder if exists

    # if output_dir exists then delete it
    if os.path.isdir(outfolder):
        shutil.rmtree(outfolder)

    filename = os.path.splitext(os.path.basename(idfname))[0]
    print(strftime('%H:%M:%S', localtime()),
          '- {} simulation started'.format(filename))
    sys.stdout.flush()

    run(idf=idfname, weather=epwfile, output_directory=outfolder, idd=iddfile,
        expandobjects=True, readvars=True, verbose='q', ep_version=8.9)

    pt('{} simulation completed in:'.format(filename), pst)
    return
Пример #11
0
    def run(self, **kwargs):
        """Run an IDF file with a given EnergyPlus weather file. This is a
        wrapper for the EnergyPlus command line interface.

        Parameters
        ----------
        kwargs :
            See eppy.runner.functions.run()

        """
        # write the IDF to the current directory
        self.saveas("in.idf")
        # if `idd` is not passed explicitly, use the IDF.iddname
        idd = kwargs.pop("idd", self.iddname)
        epw = kwargs.pop("weather", self.epw)
        try:
            run(self, weather=epw, idd=idd, **kwargs)
        finally:
            os.remove("in.idf")
Пример #12
0
    def test_sequential_run(self):
        """
        Test that we can run a sequence of runs using the signature:
            run([idf_path, epw], kwargs)
        Fails if expected output files are not in the expected output
        directories.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        runs = []
        for i in range(2):
            kwargs = {'output_directory': 'results_%s' % i}
            runs.append([[fname1, TEST_EPW], kwargs])
        for r in runs:
            run(*r[0], **r[1])
        for results_dir in glob('results_*'):
            assert not has_severe_errors(results_dir)
            files = os.listdir(results_dir)
            assert set(files) == set(self.expected_files)
Пример #13
0
    def test_sequential_run(self):
        """
        Test that we can run a sequence of runs using the signature:
            run([idf_path, epw], kwargs)
        Fails if expected output files are not in the expected output
        directories.

        """
        fname1 = os.path.join(IDF_FILES, TEST_IDF)
        runs = []
        for i in range(2):
            kwargs = {'output_directory': 'results_%s' % i,
                      'ep_version': VERSION}
            runs.append([[fname1, TEST_EPW], kwargs])
        for r in runs:
            run(*r[0], **r[1])
        for results_dir in glob('results_*'):
            assert not has_severe_errors(results_dir)
            files = os.listdir(results_dir)
            assert set(files) == set(self.expected_files)
Пример #14
0
    def run(self, **kwargs):
        """
        Run an IDF file with a given EnergyPlus weather file. This is a
        wrapper for the EnergyPlus command line interface.

        Parameters
        ----------
        **kwargs
            See eppy.runner.functions.run()

        """
        # write the IDF to the current directory
        self.saveas('in.idf')
        # if `idd` is not passed explicitly, use the IDF.iddname
        idd = kwargs.pop('idd', self.iddname)
        epw = kwargs.pop('weather', self.epw)
        try:
            run(self, weather=epw, idd=idd, **kwargs)
        finally:
            os.remove('in.idf')
Пример #15
0
    def run(self, **kwargs):
        """
        Run an IDF file with a given EnergyPlus weather file. This is a
        wrapper for the EnergyPlus command line interface.

        Parameters
        ----------
        **kwargs
            See eppy.runner.functions.run()

        """
        # write the IDF to the current directory
        self.saveas('in.idf')
        # if `idd` is not passed explicitly, use the IDF.iddname
        idd = kwargs.pop('idd', self.iddname)
        epw = kwargs.pop('weather', self.epw)
        # run EnergyPlus
        run(self, weather=epw, idd=idd, **kwargs)
        # remove in.idf
        os.remove('in.idf')