oplus/simulation.py
def run_eplus(epm_or_idf_path, weather_data_or_epw_path, simulation_dir_path, stdout=None, stderr=None, beat_freq=None):
    """
    Parameters
    ----------
    epm_or_idf_path:
    weather_data_or_epw_path
    simulation_dir_path
    stdout: default sys.stdout
    stderr: default sys.stderr
    beat_freq: if not none, stdout will be used at least every beat_freq (in seconds)
    """
    # work with absolute paths
    simulation_dir_path = os.path.abspath(simulation_dir_path)

    # check dir path
    if not os.path.isdir(simulation_dir_path):
        raise NotADirectoryError("Simulation directory does not exist: '%s'." % simulation_dir_path)

    # epm
    if not isinstance(epm_or_idf_path, Epm):
        # we don't copy file directly because we want to manage it's external files
        # could be optimized (use _copy_without_read_only)
        epm = Epm.from_idf(epm_or_idf_path)
    else:
        epm = epm_or_idf_path

    # create idf
    simulation_idf_path = os.path.join(simulation_dir_path, CONF.default_model_name + ".idf")
    epm.to_idf(simulation_idf_path)

    # weather data
    simulation_epw_path = os.path.join(simulation_dir_path, CONF.default_model_name + ".epw")
    if isinstance(weather_data_or_epw_path, WeatherData):
        weather_data_or_epw_path.to_epw(simulation_epw_path)
    else:
        # no need to load: we copy directly
        _copy_without_read_only(weather_data_or_epw_path, simulation_epw_path)

    # copy epw if needed (depends on os/eplus version)
    temp_epw_path = get_simulated_epw_path()
    if temp_epw_path is not None:
        _copy_without_read_only(simulation_epw_path, temp_epw_path)

    # prepare command
    eplus_relative_cmd = get_simulation_base_command()
    eplus_cmd = os.path.join(CONF.eplus_base_dir_path, eplus_relative_cmd)

    # idf
    idf_command_style = get_simulation_input_command_style("idf")
    if idf_command_style == SIMULATION_INPUT_COMMAND_STYLES.simu_dir:
        idf_file_cmd = os.path.join(simulation_dir_path, CONF.default_model_name)
    elif idf_command_style == SIMULATION_INPUT_COMMAND_STYLES.file_path:
        idf_file_cmd = simulation_idf_path
    else:
        raise AssertionError("should not be here")

    # epw
    epw_command_style = get_simulation_input_command_style("epw")
    if epw_command_style == SIMULATION_INPUT_COMMAND_STYLES.simu_dir:
        epw_file_cmd = os.path.join(simulation_dir_path, CONF.default_model_name)
    elif epw_command_style == SIMULATION_INPUT_COMMAND_STYLES.file_path:
        epw_file_cmd = simulation_epw_path
    else:
        raise AssertionError("should not be here")

    # command list
    simulation_command_style = get_simulation_command_style()
    if simulation_command_style == SIMULATION_COMMAND_STYLES.args:
        cmd_l = [eplus_cmd, idf_file_cmd, epw_file_cmd]
    elif simulation_command_style == SIMULATION_COMMAND_STYLES.kwargs:
        cmd_l = [eplus_cmd, "-w", epw_file_cmd, "-r", idf_file_cmd]
    else:
        raise RuntimeError("should not be here")

    # launch calculation
    run_subprocess(
        cmd_l,
        cwd=simulation_dir_path,
        stdout=stdout,
        stderr=stderr,
        beat_freq=beat_freq
    )

    # if needed, we delete temp weather data (only on Windows, see above)
    if (temp_epw_path is not None) and os.path.isfile(temp_epw_path):
        os.remove(os.path.join(temp_epw_path))
def run_eplus(epm_or_idf_path, weather_data_or_epw_path, simulation_dir_path, stdout=None, stderr=None, beat_freq=None):
    """
    Parameters
    ----------
    epm_or_idf_path:
    weather_data_or_epw_path
    simulation_dir_path
    stdout: default sys.stdout
    stderr: default sys.stderr
    beat_freq: if not none, stdout will be used at least every beat_freq (in seconds)
    """
    # work with absolute paths
    simulation_dir_path = os.path.abspath(simulation_dir_path)

    # check dir path
    if not os.path.isdir(simulation_dir_path):
        raise NotADirectoryError("Simulation directory does not exist: '%s'." % simulation_dir_path)

    # epm
    if not isinstance(epm_or_idf_path, Epm):
        # we don't copy file directly because we want to manage it's external files
        # could be optimized (use _copy_without_read_only)
        epm = Epm.from_idf(epm_or_idf_path)
    else:
        epm = epm_or_idf_path

    # create idf
    simulation_idf_path = os.path.join(simulation_dir_path, CONF.default_model_name + ".idf")
    epm.to_idf(simulation_idf_path)

    # weather data
    simulation_epw_path = os.path.join(simulation_dir_path, CONF.default_model_name + ".epw")
    if isinstance(weather_data_or_epw_path, WeatherData):
        weather_data_or_epw_path.to_epw(simulation_epw_path)
    else:
        # no need to load: we copy directly
        _copy_without_read_only(weather_data_or_epw_path, simulation_epw_path)

    # copy epw if needed (depends on os/eplus version)
    temp_epw_path = get_simulated_epw_path()
    if temp_epw_path is not None:
        _copy_without_read_only(simulation_epw_path, temp_epw_path)

    # prepare command
    eplus_relative_cmd = get_simulation_base_command()
    eplus_cmd = os.path.join(CONF.eplus_base_dir_path, eplus_relative_cmd)

    # idf
    idf_command_style = get_simulation_input_command_style("idf")
    if idf_command_style == SIMULATION_INPUT_COMMAND_STYLES.simu_dir:
        idf_file_cmd = os.path.join(simulation_dir_path, CONF.default_model_name)
    elif idf_command_style == SIMULATION_INPUT_COMMAND_STYLES.file_path:
        idf_file_cmd = simulation_idf_path
    else:
        raise AssertionError("should not be here")

    # epw
    epw_command_style = get_simulation_input_command_style("epw")
    if epw_command_style == SIMULATION_INPUT_COMMAND_STYLES.simu_dir:
        epw_file_cmd = os.path.join(simulation_dir_path, CONF.default_model_name)
    elif epw_command_style == SIMULATION_INPUT_COMMAND_STYLES.file_path:
        epw_file_cmd = simulation_epw_path
    else:
        raise AssertionError("should not be here")

    # command list
    simulation_command_style = get_simulation_command_style()
    if simulation_command_style == SIMULATION_COMMAND_STYLES.args:
        cmd_l = [eplus_cmd, idf_file_cmd, epw_file_cmd]
    elif simulation_command_style == SIMULATION_COMMAND_STYLES.kwargs:
        cmd_l = [eplus_cmd, "-w", epw_file_cmd, "-r", idf_file_cmd]
    else:
        raise RuntimeError("should not be here")

    # launch calculation
    run_subprocess(
        cmd_l,
        cwd=simulation_dir_path,
        stdout=stdout,
        stderr=stderr,
        beat_freq=beat_freq
    )

    # if needed, we delete temp weather data (only on Windows, see above)
    if (temp_epw_path is not None) and os.path.isfile(temp_epw_path):
        os.remove(os.path.join(temp_epw_path))
def run_eplus ( epm_or_idf_path , weather_data_or_epw_path , simulation_dir_path , stdout = None , stderr = None , beat_freq = None ) : # work with absolute paths simulation_dir_path = os . path . abspath ( simulation_dir_path ) # check dir path if not os . path . isdir ( simulation_dir_path ) : raise NotADirectoryError ( "Simulation directory does not exist: '%s'." % simulation_dir_path ) # epm if not isinstance ( epm_or_idf_path , Epm ) : # we don't copy file directly because we want to manage it's external files # could be optimized (use _copy_without_read_only) epm = Epm . from_idf ( epm_or_idf_path ) else : epm = epm_or_idf_path # create idf simulation_idf_path = os . path . join ( simulation_dir_path , CONF . default_model_name + ".idf" ) epm . to_idf ( simulation_idf_path ) # weather data simulation_epw_path = os . path . join ( simulation_dir_path , CONF . default_model_name + ".epw" ) if isinstance ( weather_data_or_epw_path , WeatherData ) : weather_data_or_epw_path . to_epw ( simulation_epw_path ) else : # no need to load: we copy directly _copy_without_read_only ( weather_data_or_epw_path , simulation_epw_path ) # copy epw if needed (depends on os/eplus version) temp_epw_path = get_simulated_epw_path ( ) if temp_epw_path is not None : _copy_without_read_only ( simulation_epw_path , temp_epw_path ) # prepare command eplus_relative_cmd = get_simulation_base_command ( ) eplus_cmd = os . path . join ( CONF . eplus_base_dir_path , eplus_relative_cmd ) # idf idf_command_style = get_simulation_input_command_style ( "idf" ) if idf_command_style == SIMULATION_INPUT_COMMAND_STYLES . simu_dir : idf_file_cmd = os . path . join ( simulation_dir_path , CONF . default_model_name ) elif idf_command_style == SIMULATION_INPUT_COMMAND_STYLES . file_path : idf_file_cmd = simulation_idf_path else : raise AssertionError ( "should not be here" ) # epw epw_command_style = get_simulation_input_command_style ( "epw" ) if epw_command_style == SIMULATION_INPUT_COMMAND_STYLES . simu_dir : epw_file_cmd = os . path . join ( simulation_dir_path , CONF . default_model_name ) elif epw_command_style == SIMULATION_INPUT_COMMAND_STYLES . file_path : epw_file_cmd = simulation_epw_path else : raise AssertionError ( "should not be here" ) # command list simulation_command_style = get_simulation_command_style ( ) if simulation_command_style == SIMULATION_COMMAND_STYLES . args : cmd_l = [ eplus_cmd , idf_file_cmd , epw_file_cmd ] elif simulation_command_style == SIMULATION_COMMAND_STYLES . kwargs : cmd_l = [ eplus_cmd , "-w" , epw_file_cmd , "-r" , idf_file_cmd ] else : raise RuntimeError ( "should not be here" ) # launch calculation run_subprocess ( cmd_l , cwd = simulation_dir_path , stdout = stdout , stderr = stderr , beat_freq = beat_freq ) # if needed, we delete temp weather data (only on Windows, see above) if ( temp_epw_path is not None ) and os . path . isfile ( temp_epw_path ) : os . remove ( os . path . join ( temp_epw_path ) )
Parameters
    ----------
    epm_or_idf_path:
    weather_data_or_epw_path
    simulation_dir_path
    stdout: default sys.stdout
    stderr: default sys.stderr
    beat_freq: if not none, stdout will be used at least every beat_freq (in seconds)
Parameters ---------- epm_or_idf_path : weather_data_or_epw_path simulation_dir_path stdout : default sys . stdout stderr : default sys . stderr beat_freq : if not none stdout will be used at least every beat_freq ( in seconds )