コード例 #1
0
def model_units_tolerance_check(model):
    """Convert a model to the current Rhino units and check the tolerance.

    Args:
        model: A honeybee Model, which will have its units checked.
    """
    # check the model units
    if model.units != units_system():
        print('Imported model units "{}" do not match that of the current Rhino '
            'model units "{}"\nThe model is being automatically converted '
            'to the Rhino doc units.'.format(model.units, units_system()))
        model.convert_to_units(units_system())

    # check that the model tolerance is not too far from the Rhino tolerance
    if model.tolerance / tolerance >= 100:
        msg = 'Imported Model tolerance "{}" is significantly coarser than the ' \
            'current Rhino model tolerance "{}".\nIt is recommended that the ' \
            'Rhino document tolerance be changed to be coarser and this ' \
            'component is re-run.'.format(model.tolerance, tolerance)
        print msg
        give_warning(ghenv.Component, msg)
コード例 #2
0
energy_output = (cool_out, heat_out, light_out, el_equip_out, gas_equip_out,
                 process1_out, process2_out, shw_out)

if all_required_inputs(ghenv.Component) and _run:
    # check the presence of energyplus and check that the version is compatible
    check_energyplus_version()

    # set defaults for COP
    _heat_cop_ = 1 if _heat_cop_ is None else _heat_cop_
    _cool_cop_ = 1 if _cool_cop_ is None else _cool_cop_

    # create the Model from the _rooms and shades_
    _model = Model('Annual_Loads',
                   _rooms,
                   orphaned_shades=shades_,
                   units=units_system(),
                   tolerance=tolerance,
                   angle_tolerance=angle_tolerance)
    floor_area = _model.floor_area
    assert floor_area != 0, 'Connected _rooms have no floors with which to compute EUI.'
    floor_area = floor_area * conversion_to_meters()**2
    mults = {rm.identifier.upper(): rm.multiplier for rm in _model.rooms}
    mults = None if all(mul == 1 for mul in mults.values()) else mults

    # process the simulation folder name and the directory
    directory = os.path.join(folders.default_simulation_folder,
                             _model.identifier)
    sch_directory = os.path.join(directory, 'schedules')
    nukedir(directory)  # delete any existing files in the directory

    # create simulation parameters for the coarsest/fastest E+ sim possible
コード例 #3
0
    if run_ > 0 and not no_report_meas:  # everything must run with OS CLI
        osm, idf = run_osw(osw, measures_only=False, silent=silent)
        sql, zsz, rdd, html, err = output_energyplus_files(
            os.path.dirname(idf))
    elif run_ > 0:  # no reporting measure; simulate separately from measure application
        osm, idf = run_osw(osw, silent=silent)
        # process the additional strings
        if add_str_ != [] and add_str_[0] is not None and idf is not None:
            add_str = '/n'.join(add_str_)
            with open(idf, "a") as idf_file:
                idf_file.write(add_str)
        if idf is None:  # measures failed to run correctly; parse out.osw
            log_osw = OSW(os.path.join(directory, 'out.osw'))
            for error, tb in zip(log_osw.errors, log_osw.error_tracebacks):
                if 'Cannot create a surface' in error:
                    error = 'Your Rhino Model units system is: {}\n{}'.format(
                        units_system(), error)
                print(tb)
                raise Exception(error)
        if run_ in (1, 3):  # run the resulting idf throught EnergyPlus
            sql, zsz, rdd, html, err = run_idf(idf, _epw_file, silent=silent)

    # parse the error log and report any warnings
    if run_ in (1, 3) and err is not None:
        err_obj = Err(err)
        print(err_obj.file_contents)
        for warn in err_obj.severe_errors:
            give_warning(ghenv.Component, warn)
        for error in err_obj.fatal_errors:
            raise Exception(error)
コード例 #4
0
    _folder_ = hb_config.folders.default_simulation_folder if _folder_ is None else _folder_
    clean_name = re.sub(r'[^.A-Za-z0-9_-]', '_', _model.display_name)
    directory = os.path.join(_folder_, clean_name, 'openstudio')

    # duplicate model to avoid mutating it as we edit it for energy simulation
    _model = _model.duplicate()
    # scale the model if the units are not meters
    if _model.units != 'Meters':
        _model.convert_to_units('Meters')
    # remove colinear vertices using the Model tolerance to avoid E+ tolerance issues
    for room in _model.rooms:
        try:
            room.remove_colinear_vertices_envelope(tolerance=0.01, delete_degenerate=True)
        except AssertionError as e:
            error = 'Your Rhino Model units system is: {}. ' \
                'Is this correct?\n{}'.format(units_system(), e)
            print(error)
            raise ValueError(error)
    # auto-assign stories if there are none since most OpenStudio measures need these
    if len(_model.stories) == 0:
        _model.assign_stories_by_floor_height()

    # delete any existing files in the directory and prepare it for simulation
    nukedir(directory, True)
    preparedir(directory)
    sch_directory = os.path.join(directory, 'schedules')
    preparedir(sch_directory)

    # write the model parameter JSONs
    model_dict = _model.to_dict(triangulate_sub_faces=True)
    _model.properties.energy.add_autocal_properties_to_dict(model_dict)
コード例 #5
0
try:
    from ladybug_rhino.togeometry import to_point2d
    from ladybug_rhino.fromgeometry import from_point2d, from_linesegment2d, \
        from_polyline2d
    from ladybug_rhino.config import tolerance, angle_tolerance, units_system, \
        conversion_to_meters
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if all_required_inputs(ghenv.Component) and _import:
    # set default inputs if not specified
    pt = to_point2d(_point_) if _point_ is not None else Point2D(0, 0)
    all_to_bldg = bool(all_to_bldg_)  # handle case of None
    model_units, con_fac = units_system(), 1 / conversion_to_meters()

    # convert the geoJSON to a dragonfly Model
    model, location = Model.from_geojson(_geojson,
                                         point=pt,
                                         all_polygons_to_buildings=all_to_bldg,
                                         units=model_units,
                                         tolerance=tolerance,
                                         angle_tolerance=angle_tolerance)
    point = from_point2d(pt)

    # if other geometry has been requested, then import it
    if other_geo_:
        # parse the geoJSON into a dictionary and get lat/lon converters
        with open(_geojson, 'r') as fp:
            data = json.load(fp)