Ejemplo n.º 1
0
def test_load_idf(config):
    """Will load an idf object"""

    files = [
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
        "5ZoneNightVent1.idf",
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" / "BasicsFiles" /
        "AdultEducationCenter.idf",
    ]

    obj = {os.path.basename(file): tr.load_idf(file) for file in files}
    assert isinstance(obj, dict)
Ejemplo n.º 2
0
def test_run_olderv(clean_config, ep_version):
    """Will run eplus on a file that needs to be upgraded with one that does
    not"""
    tr.settings.use_cache = False
    files = [
        "tests/input_data/problematic/nat_ventilation_SAMPLE0.idf",
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
        "5ZoneNightVent1.idf",
    ]
    wf = "tests/input_data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw"
    files = tr.copy_file(files)
    rundict = {
        file: dict(
            eplus_file=file,
            weather_file=wf,
            ep_version=ep_version,
            annual=True,
            prep_outputs=True,
            expandobjects=True,
            verbose="q",
            output_report="sql",
        )
        for file in files
    }
    result = {file: tr.run_eplus(**rundict[file]) for file in files}
Ejemplo n.º 3
0
def converttest(request):
    file = get_eplus_dirs(settings.ep_version) / "ExampleFiles" / request.param
    # file = request.param
    window_file = "W74-lib.dat"
    template_dir = os.path.join("trnslator", "ressources")
    window_filepath = os.path.join(template_dir, window_file)
    template_d18 = "tests/input_data/trnsys/NewFileTemplate.d18"
    trnsidf_exe = "docker/trnsidf/trnsidf.exe"  # 'docker/trnsidf/trnsidf.exe'

    # prepare args (key=value). Key is a unique id for the runs (here the
    # file basename is used). Value is a dict of the function arguments
    kwargs_dict = {
        "u_value": 2.5,
        "shgc": 0.6,
        "t_vis": 0.78,
        "tolerance": 0.05,
        "ordered": True,
    }
    idf = load_idf(file)

    weather_file = os.path.join("tests", "input_data",
                                "CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw")

    output_folder = os.path.relpath(settings.data_folder)

    yield idf, file, weather_file, window_filepath, trnsidf_exe, template_d18, output_folder, kwargs_dict

    del idf
Ejemplo n.º 4
0
def test_run_eplus_from_idf(clean_config):
    file = get_eplus_dirs(
        settings.ep_version) / "ExampleFiles" / "5ZoneNightVent1.idf"
    wf = "tests/input_data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw"

    idf = tr.load_idf(file, weather_file=wf)
    sql = idf.run_eplus(prep_outputs=True, output_report="sql")

    assert sql
Ejemplo n.º 5
0
def schedules_idf():
    config(cache_folder="tests/.temp/cache")
    idf = load_idf(
        idf_file,
        include=[
            get_eplus_dirs(settings.ep_version) / "DataSets" / "TDV" /
            "TDV_2008_kBtu_CTZ06.csv"
        ],
    )
    return idf
Ejemplo n.º 6
0
def test_load_old(config):
    files = [
        "tests/input_data/problematic/nat_ventilation_SAMPLE0.idf",
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
        "5ZoneNightVent1.idf",
    ]

    obj = {os.path.basename(file): tr.load_idf(file) for file in files}

    assert not any(isinstance(a, Exception) for a in obj.values())
Ejemplo n.º 7
0
def test_space_cooling_profile(config):
    from trnslator import load_idf

    file = (get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
            "BasicsFiles" / "AdultEducationCenter.idf")
    wf = "tests/input_data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw"

    idf = load_idf(file, None, weather_file=wf)

    assert not idf.space_cooling_profile().empty
Ejemplo n.º 8
0
def test_small_home_data(clean_config):
    file = (get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
            "BasicsFiles" / "AdultEducationCenter.idf")
    file = tr.copy_file(file)
    wf = "tests/input_data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw"
    return tr.run_eplus(file,
                        wf,
                        prep_outputs=True,
                        design_day=True,
                        expandobjects=True,
                        verbose="q")
Ejemplo n.º 9
0
def test_old_than_change_args(clean_config):
    """Should upgrade file only once even if run_eplus args are changed afterwards"""
    from trnslator import run_eplus

    file = (get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
            "RefBldgQuickServiceRestaurantNew2004_Chicago.idf")
    epw = "tests/input_data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw"

    idf = run_eplus(file, epw, prep_outputs=True, output_report="sql_file")

    idf = run_eplus(file, epw, prep_outputs=True, output_report="sql_file")

    idf = run_eplus(file, epw, prep_outputs=True, output_report="sql")
Ejemplo n.º 10
0
def run_schedules_idf(config):
    files = run_eplus(
        idf_file,
        weather_file="tests/input_data/CAN_PQ_Montreal.Intl.AP"
        ".716270_CWEC.epw",
        annual=True,
        readvars=True,
        include=[
            get_eplus_dirs(settings.ep_version) / "DataSets" / "TDV" /
            "TDV_2008_kBtu_CTZ06.csv"
        ],
        return_files=True,
    )
    cache_dir = files[1][0].dirname()
    csv = next(iter(cache_dir.glob("*out.csv")))
    yield csv
Ejemplo n.º 11
0
    def test_trnbuild_from_idf_parallel_darwin_or_linux(self, config):
        # Path to EnergyPlus example files
        file_upper_path = os.path.join(get_eplus_dirs(settings.ep_version),
                                       "ExampleFiles")

        # IDF file names
        files = [
            "RefBldgWarehouseNew2004_Chicago.idf",
            "ASHRAE9012016_Warehouse_Denver.idf",
            "ASHRAE9012016_ApartmentMidRise_Denver.idf",
            "5ZoneGeometryTransform.idf",
        ]

        # Path to weather file
        weather_file = os.path.join("tests", "input_data",
                                    "CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw")

        # prepare args (key=value). Key is a unique id for the runs (here the
        # file basename is used). Value is a dict of the function arguments
        in_dict = {
            os.path.basename(file): dict(
                idf_file=os.path.join(file_upper_path, file),
                weather_file=weather_file,
                template="tests/input_data/trnsys/NewFileTemplate.d18",
                trnsidf_exe="docker/trnsidf/trnsidf.exe",
            )
            for file in files
        }

        # Convert IDF files to BUI ones usinf parallel process
        result = parallel_process(in_dict,
                                  convert_idf_to_trnbuild,
                                  4,
                                  use_kwargs=True)

        # Print results
        [print(a) for a in result.values() if isinstance(a, Exception)]

        assert not any(isinstance(a, Exception) for a in result.values())
Ejemplo n.º 12
0
import trnslator as tr
import pandas as pd
import pytest

from path import Path

from trnslator import EnergySeries, get_eplus_dirs, settings

import numpy as np


@pytest.fixture(
    scope="module",
    params=[
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" /
        "5ZoneNightVent1.idf",
        get_eplus_dirs(settings.ep_version) / "ExampleFiles" / "BasicsFiles" /
        "AdultEducationCenter.idf",
    ],
)
def energy_series(config, request):
    from trnslator import ReportData

    outputs = {
        "ep_object": "Output:Variable".upper(),
        "kwargs": {
            "Key_Value": "OCCUPY-1",
            "Variable_Name": "Schedule Value",
            "Reporting_Frequency": "Hourly",
        },
Ejemplo n.º 13
0
def trnbuild_file(config, request):
    idf_file = get_eplus_dirs(
        settings.ep_version) / "ExampleFiles" / request.param
    idf_file = copy_file(idf_file, where=settings.cache_folder)

    yield idf_file