Beispiel #1
0
    def to_eppy(self, idd_file: str) -> List[EpBunch]:
        """ Convert Material into Eppy material and construction objects """
        try:
            IDF.setiddname(str(idd_file))
        except IDDAlreadySetError as e:
            pass
        idf = IDF(io.StringIO(""))

        # Create list of eppy objects to populate
        eppy_objects = []

        material = idf.newidfobject("WINDOWMATERIAL:GLAZING")
        material.Name = self.name
        material.Optical_Data_Type = "SpectralAverage"
        material.Thickness = self.thickness
        material.Solar_Transmittance_at_Normal_Incidence = self.solar_transmittance
        material.Front_Side_Solar_Reflectance_at_Normal_Incidence = self.solar_reflectance
        material.Back_Side_Solar_Reflectance_at_Normal_Incidence = self.solar_reflectance
        material.Visible_Transmittance_at_Normal_Incidence = self.visible_transmittance
        material.Front_Side_Visible_Reflectance_at_Normal_Incidence = self.visible_reflectance
        material.Back_Side_Visible_Reflectance_at_Normal_Incidence = self.visible_reflectance
        material.Infrared_Transmittance_at_Normal_Incidence = self.transmittance
        material.Front_Side_Infrared_Hemispherical_Emissivity = self.emissivity
        material.Back_Side_Infrared_Hemispherical_Emissivity = self.emissivity
        material.Conductivity = self.conductivity
        material.Solar_Diffusing = False
        eppy_objects.append(material)

        construction = idf.newidfobject("CONSTRUCTION")
        construction.Name = self.name
        construction.Outside_Layer = self.name
        eppy_objects.append(construction)

        return eppy_objects
Beispiel #2
0
    def to_eppy(self, idd_file: str):
        try:
            IDF.setiddname(str(idd_file))
        except IDDAlreadySetError as e:
            pass
        idf = IDF(io.StringIO(""))
        eppy_objects = []

        # Create shade object
        transmittance_schedule_type_limit = idf.newidfobject("SCHEDULETYPELIMITS")
        transmittance_schedule_type_limit.Name = "constant"
        transmittance_schedule_type_limit.Lower_Limit_Value = 0
        transmittance_schedule_type_limit.Upper_Limit_Value = 1
        transmittance_schedule_type_limit.Numeric_Type = "Continuous"
        eppy_objects.append(transmittance_schedule_type_limit)

        transmittance_schedule = idf.newidfobject("SCHEDULE:CONSTANT")
        transmittance_schedule.Name = "constant"
        transmittance_schedule.Schedule_Type_Limits_Name = "constant"
        transmittance_schedule.Hourly_Value = 0
        eppy_objects.append(transmittance_schedule)

        shade = idf.newidfobject("SHADING:SITE:DETAILED")
        shade.Name = random_id()
        shade.Transmittance_Schedule_Name = "constant"
        shade.Number_of_Vertices = len(self.vertices)
        for nn, vtx in enumerate(self.vertices):
            setattr(shade, "Vertex_{}_Xcoordinate".format(nn + 1), vtx.x)
            setattr(shade, "Vertex_{}_Ycoordinate".format(nn + 1), vtx.y)
            setattr(shade, "Vertex_{}_Zcoordinate".format(nn + 1), vtx.z)
        eppy_objects.append(shade)

        return eppy_objects
Beispiel #3
0
def test_getobjectswithnode():
    """py.test for getobjectswithnode"""
    idf = IDF(StringIO(""))
    nodekeys = idf_helpers.getidfkeyswithnodes()
    plantloop = idf.newidfobject(
        "PlantLoop",
        Name="Chilled Water Loop",
        Plant_Side_Inlet_Node_Name="CW Supply Inlet Node",
    )
    branch = idf.newidfobject(
        "Branch",
        Name="CW Pump Branch",
        Component_1_Inlet_Node_Name="CW Supply Inlet Node",
    )
    pump = idf.newidfobject(
        "Pump:VariableSpeed",
        Name="CW Circ Pump",
        Inlet_Node_Name="CW Supply Inlet Node",
    )
    zone = idf.newidfobject("zone")
    foundobjs = idf_helpers.getobjectswithnode(idf, nodekeys,
                                               "CW Supply Inlet Node")
    expected = [plantloop, branch, pump]
    expectedset = set([item.key for item in expected])
    resultset = set([item.key for item in foundobjs])
    assert resultset == expectedset
    expectedset = set([item.Name for item in expected])
    resultset = set([item.Name for item in foundobjs])
    assert resultset == expectedset
Beispiel #4
0
    def inject_idf_outputs(self,
                           eppy_output_objs: List[IdfOutputPoint]) -> None:
        """create output variable idf objects as a string

        Args:
            eppy_output_objs: list of `IdfOutputPoint` objects to be injected into the IDF

        Returns:
            `None`. the created string to be injected is stored to `self.appending_str`

        """
        fhandle = StringIO("")
        output_idf_objs = IDF(fhandle)
        for output_obj in eppy_output_objs:
            output_idf_objs.newidfobject(
                "Output:Variable".upper(),
                Key_Value=output_obj.subject,
                Variable_Name=output_obj.variable,
                Reporting_Frequency=output_obj.frequency,
            )

        all_list = [
            str(obj)
            for obj in output_idf_objs.idfobjects["Output:Variable".upper()]
        ]
        self.appending_str = "\n".join(all_list)
Beispiel #5
0
    def to_eppy(self, idd_file: str) -> List[EpBunch]:
        """ Convert Material into Eppy material and construction objects """
        try:
            IDF.setiddname(str(idd_file))
        except IDDAlreadySetError as e:
            pass
        idf = IDF(io.StringIO(""))

        # Create list of eppy objects to populate
        eppy_objects = []

        material = idf.newidfobject("MATERIAL")
        material.Name = self.name
        material.Roughness = self.roughness
        material.Thickness = self.thickness
        material.Conductivity = self.conductivity
        material.Density = self.density
        material.Specific_Heat = self.specific_heat
        material.Thermal_Absorptance = self.thermal_absorptance
        material.Solar_Absorptance = self.solar_absorptance
        material.Visible_Absorptance = self.visible_absorptance
        eppy_objects.append(material)

        construction = idf.newidfobject("CONSTRUCTION")
        construction.Name = self.name
        construction.Outside_Layer = self.name
        eppy_objects.append(construction)

        return eppy_objects
Beispiel #6
0
def test_newidfobject():
    """py.test for newidfobject"""
    # make a blank idf
    # make a function for this and then continue.
    idf = IDF()
    idf.new()
    objtype = 'material:airgap'.upper()
    obj = idf.newidfobject(objtype, Name='Argon')
    obj = idf.newidfobject(objtype, Name='Krypton')
    obj = idf.newidfobject(objtype, Name='Xenon')
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Krypton'],
                                     ['MATERIAL:AIRGAP', 'Xenon'],
                                     ]
    # remove an object
    idf.popidfobject(objtype, 1)
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Xenon'],
                                     ]
    lastobject = idf.idfobjects[objtype][-1]
    idf.removeidfobject(lastobject)
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ]
    # copyidfobject
    onlyobject = idf.idfobjects[objtype][0]
    idf.copyidfobject(onlyobject)

    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Argon'],
                                     ]
    # test some functions
    objtype = 'FENESTRATIONSURFACE:DETAILED'
    obj = idf.newidfobject(objtype, Name='A Wall')
    assert obj.coords == []
    assert obj.fieldvalues[1] == 'A Wall'
Beispiel #7
0
def test_connectcomponents():
    """py.test for connectcomponents"""
    fhandle = StringIO("")
    idf = IDF(fhandle)

    tdata = (
        (
            [(idf.newidfobject("PIPE:ADIABATIC", Name="pipe1"), None),
             (idf.newidfobject("PIPE:ADIABATIC", Name="pipe2"), None)],
            ["pipe1_Inlet_Node_Name", ["pipe2_Inlet_Node_Name",
                                       "pipe1_pipe2_node"]],
            [["pipe1_Outlet_Node_Name", "pipe1_pipe2_node"],
             "pipe2_Outlet_Node_Name"], '',
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("Coil:Cooling:Water", Name="pipe1"),
              'Water_'),
             (idf.newidfobject("Coil:Cooling:Water", Name="pipe2"),
              'Water_')],
            ['pipe1_Water_Inlet_Node_Name', '',
             'pipe2_Water_Inlet_Node_Name',
             ['', 'pipe1_pipe2_node']],
            [['pipe1_Water_Outlet_Node_Name', 'pipe1_pipe2_node'], '',
             'pipe2_Water_Outlet_Node_Name', ''],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("PIPE:ADIABATIC", Name="pipe1"), None),
             (idf.newidfobject("Coil:Cooling:Water", Name="pipe2"),
              'Water_')],
            ["pipe1_Inlet_Node_Name", "pipe2_Water_Inlet_Node_Name",
             ['pipe2_Air_Inlet_Node_Name', 'pipe1_pipe2_node']],
            [['pipe1_Outlet_Node_Name', 'pipe1_pipe2_node'],
             "pipe2_Water_Outlet_Node_Name", ""],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
    )
    for components_thisnodes, inlets, outlets, fluid in tdata:
        # init the nodes in the new components
        for component, thisnode in components_thisnodes:
            hvacbuilder.initinletoutlet(idf, component, thisnode)
        hvacbuilder.connectcomponents(idf, components_thisnodes, fluid)
        inresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Inlet_Node_Name")
            for name in fldnames:
                inresult.append(component[name])
        assert inresult == inresult
        outresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Outlet_Node_Name")
            for name in fldnames:
                outresult.append(component[name])
        assert outresult == outlets
Beispiel #8
0
def test_connectcomponents():
    """py.test for connectcomponents"""
    fhandle = StringIO("")
    idf = IDF(fhandle)

    tdata = (
        (
            [(idf.newidfobject("PIPE:ADIABATIC", "pipe1"), None),
             (idf.newidfobject("PIPE:ADIABATIC", "pipe2"), None)],
            ["pipe1_Inlet_Node_Name", ["pipe2_Inlet_Node_Name",
                                       "pipe1_pipe2_node"]],
            [["pipe1_Outlet_Node_Name", "pipe1_pipe2_node"],
             "pipe2_Outlet_Node_Name"], '',
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("Coil:Cooling:Water".upper(), "pipe1"),
              'Water_'),
             (idf.newidfobject("Coil:Cooling:Water".upper(), "pipe2"),
              'Water_')],
            ['pipe1_Water_Inlet_Node_Name', '',
             'pipe2_Water_Inlet_Node_Name',
             ['', 'pipe1_pipe2_node']],
            [['pipe1_Water_Outlet_Node_Name', 'pipe1_pipe2_node'], '',
             'pipe2_Water_Outlet_Node_Name', ''],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("PIPE:ADIABATIC".upper(), "pipe1"), None),
             (idf.newidfobject("Coil:Cooling:Water".upper(), "pipe2"),
              'Water_')],
            ["pipe1_Inlet_Node_Name", "pipe2_Water_Inlet_Node_Name",
             ['pipe2_Air_Inlet_Node_Name', 'pipe1_pipe2_node']],
            [['pipe1_Outlet_Node_Name', 'pipe1_pipe2_node'],
             "pipe2_Water_Outlet_Node_Name", ""],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
    )
    for components_thisnodes, inlets, outlets, fluid in tdata:
        # init the nodes in the new components
        for component, thisnode in components_thisnodes:
            hvacbuilder.initinletoutlet(idf, component, thisnode)
        hvacbuilder.connectcomponents(idf, components_thisnodes, fluid)
        inresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Inlet_Node_Name")
            for name in fldnames:
                inresult.append(component[name])
        assert inresult == inresult
        outresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Outlet_Node_Name")
            for name in fldnames:
                outresult.append(component[name])
        assert outresult == outlets
Beispiel #9
0
def test_getanymentions():
    """py.test for getanymentions"""
    idf = IDF(StringIO(""))
    mat = idf.newidfobject("MATERIAL", Name="mat")
    aconst = idf.newidfobject("CONSTRUCTION", Name="const")
    foundobjs = idf_helpers.getanymentions(idf, mat)
    assert len(foundobjs) == 1
    assert foundobjs[0] == mat
Beispiel #10
0
def test_getanymentions():
    """py.test for getanymentions"""
    idf = IDF(StringIO(""))
    mat = idf.newidfobject('MATERIAL', Name='mat')
    aconst = idf.newidfobject('CONSTRUCTION', Name='const')
    foundobjs = idf_helpers.getanymentions(idf, mat)
    assert len(foundobjs) == 1
    assert foundobjs[0] == mat
Beispiel #11
0
def add_night_ventilation_for_zone(idf: IDF, idf_zone_name: str,
                                   night_vent_model: NightVent):
    """
    For description of model used for night ventilation please refer to docs/features/passive-cooling.rst.

    :param idf: eppy IDF object for which to add shading. Zones must already be defined in passed IDF object!
    :param idf_zone_name: zone name in idf for which to add night ventilation
    :param night_vent_model: parameters for the night ventilation
    :return: nothing, idf is extended in place
    """

    max_temp_profile_idf_name = add_schedule(
        idf,
        night_vent_model.maximum_indoor_temp_profile,
        required_type=cesarp.common.ScheduleTypeLimits.TEMPERATURE())
    night_vent_schedule_name = _adding_the_schedule(
        idf, night_vent_model.start_hour, night_vent_model.end_hour)

    night_vent_obj = idf.newidfobject("ZoneVentilation:DesignFlowRate")
    night_vent_obj.Name = idf_zone_name + "_night_vent"
    night_vent_obj.Zone_or_ZoneList_Name = idf_zone_name
    night_vent_obj.Schedule_Name = night_vent_schedule_name
    night_vent_obj.Design_Flow_Rate_Calculation_Method = idf_strings.FlowRateCalculationMethod.air_changes_per_hour
    night_vent_obj.Air_Changes_per_Hour = night_vent_model.flow_rate.to(
        "ACH").m
    night_vent_obj.Ventilation_Type = "Natural"
    night_vent_obj.Minimum_Indoor_Temperature = night_vent_model.min_indoor_temperature.to(
        "degreeC").m
    night_vent_obj.Maximum_Indoor_Temperature_Schedule_Name = max_temp_profile_idf_name
    night_vent_obj.Delta_Temperature = night_vent_model.maximum_in_out_deltaT.to(
        "degreeC").m
    night_vent_obj.Maximum_Wind_Speed = night_vent_model.max_wind_speed.to(
        "m/s").m
Beispiel #12
0
def test_initinletoutlet():
    """py.test for initinletoutlet"""
    tdata = (
        ("PIPE:ADIABATIC", "apipe", None, True, ["apipe_Inlet_Node_Name"], ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ("PIPE:ADIABATIC", "apipe", None, False, ["Gumby"], ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        (
            "Coil:Cooling:Water".upper(),
            "acoil",
            "Water_",
            True,
            ["acoil_Water_Inlet_Node_Name", ""],
            ["acoil_Water_Outlet_Node_Name", ""],
        ),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
    )
    fhandle = StringIO("")
    idf = IDF(fhandle)
    for idfobjectkey, idfobjname, thisnode, force, inlets, outlets in tdata:
        idfobject = idf.newidfobject(idfobjectkey, idfobjname)
        inodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Inlet_Node_Name")
        idfobject[inodefields[0]] = "Gumby"
        hvacbuilder.initinletoutlet(idf, idfobject, thisnode, force=force)
        inodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Inlet_Node_Name")
        for nodefield, inlet in zip(inodefields, inlets):
            result = idfobject[nodefield]
            assert result == inlet
        onodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Outlet_Node_Name")
        for nodefield, outlet in zip(onodefields, outlets):
            result = idfobject[nodefield]
            assert result == outlet
Beispiel #13
0
def test_list2extensiblefields():
    """py.test for list2extensiblefields"""
    tdata = (
        ("branchlist", ["11", "22", "33"], ["11", "22",
                                            "33"]),  # idfkey, nlst, expected
        ("BuildingSurface:Detailed", [11, 22, 33, 1, 2, 3],
         [(11, 22, 33), (1, 2, 3)]),  # idfkey, nlst, expected
        ("BuildingSurface:Detailed", [(1, 2, 3), (11, 22, 33)],
         [(1, 2, 3), (11, 22, 33)]),  # idfkey, nlst, expected
        ("BuildingSurface:Detailed", [(1, 2, 3), (11, 22, 33)],
         [(1, 2, 3), (11, 22, 33)]),  # idfkey, nlst, expected
        ("BuildingSurface:Detailed", [(1, 2, 3), (11, 22, 33)],
         [(1, 2, 3), (11, 22, 33)]),  # idfkey, nlst, expected
        ("branchlist", ["11", "22", "33"], ["11", "22",
                                            "33"]),  # idfkey, nlst, expected
    )
    for idfkey, nlst, expected in tdata:
        idf = IDF(StringIO(idftxt))
        idfobject = idf.idfobjects[idfkey.upper()][0]
        extfields.list2extensiblefields(idfobject, nlst)
        result = extfields.extensiblefields2list(idfobject, nested=True)
        assert result == expected
    # test for edge conditions
    # there no values in the extensible fields
    # and the field just before begin-extensible field has no value
    key = "Schedule:Week:Compact".upper()
    idfobject = idf.newidfobject(key)
    nlst = [1, 2, 3, 4]
    expected = [1, 2, 3, 4]
    extfields.list2extensiblefields(idfobject, nlst)
    result = extfields.extensiblefields2list(idfobject, nested=False)
    assert result == expected
Beispiel #14
0
def test_extensiblefields2list():
    """py.test for extensiblefields2list"""
    tdata = (
        ("branchlist", False, [
            "Heating Supply Inlet Branch", "Central Boiler Branch",
            "Heating Supply Bypass Branch", "Heating Supply Outlet Branch"
        ]),  # idfkey, nested, expected
        ("BuildingSurface:Detailed", False,
         [0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 30.5, 0.0, 2.4, 30.5, 0.0,
          3.0]),  # idfkey, nested, expected
        ("BuildingSurface:Detailed", True, [(0.0, 0.0, 3.0), (0.0, 0.0, 2.4),
                                            (30.5, 0.0, 2.4), (30.5, 0.0, 3.0)
                                            ]),  # idfkey, nested, expected
        ("branchlist", True, [
            "Heating Supply Inlet Branch", "Central Boiler Branch",
            "Heating Supply Bypass Branch", "Heating Supply Outlet Branch"
        ]),  # idfkey, nested, expected
        ("version", False, None),  # idfkey, nested, expected
    )
    for idfkey, nested, expected in tdata:
        idf = IDF(StringIO(idftxt))
        idfobject = idf.idfobjects[idfkey.upper()][0]
        result = extfields.extensiblefields2list(idfobject, nested=nested)
        assert result == expected
    # test for edge conditions
    # there no values in the extensible fields
    key = "Schedule:Week:Compact".upper()
    idfobject = idf.newidfobject(key)
    result = extfields.extensiblefields2list(idfobject)
    assert result == []
def add_shading_surface_construction(idf: IDF,
                                     shading_constr: ShadingObjectConstruction,
                                     glazing_constr_idf_obj_name: str,
                                     ureg: pint.UnitRegistry) -> Any:
    """
    Adds a ShadingProperty:Reflectance idf object. The object is not linked to a surface geometry here,
    thus make sure to set property "Shading_Surface_Name" on the EpBunch object to link it to a geometry!

    :param idf: IDF object for which to add shading construction
    :param shading_constr: properties of shading construction
    :param glazing_constr_idf_obj_name: idf object name of the glazing construction; needs to be passed because here we cannot handle appropriately to add the
                                        glazing construction if needed as it might be a ConstructionAsIDF...
    :param ureg: pint unit registry
    :return: eppy EpBunch of added ShadingProperty:Reflectance idf object
    """
    shading_reflectence_idf_obj = idf.newidfobject(
        idf_strings.IDFObjects.shading_prop_reflectance)
    shading_reflectence_idf_obj.Diffuse_Solar_Reflectance_of_Unglazed_Part_of_Shading_Surface = shading_constr.diffuse_solar_reflectance_unglazed_part.to(
        ureg.dimensionless).m
    shading_reflectence_idf_obj.Diffuse_Visible_Reflectance_of_Unglazed_Part_of_Shading_Surface = shading_constr.diffuse_visible_reflectance_unglazed_part.to(
        ureg.dimensionless).m
    shading_reflectence_idf_obj.Fraction_of_Shading_Surface_That_Is_Glazed = shading_constr.glazing_ratio.to(
        ureg.dimensionless).m
    shading_reflectence_idf_obj.Glazing_Construction_Name = glazing_constr_idf_obj_name
    # make sure to set the name of returned idf obj to match the name of the shading geometry object you want to link it to!
    # e.g. shading_reflectence_idf_obj.Shading_Surface_Name = "xyz"
    return shading_reflectence_idf_obj
def add_window_glazing_material(idf: IDF, idf_obj_name: str,
                                mat_def: TransparentMaterial,
                                thickness: pint.Quantity,
                                ureg: pint.UnitRegistry) -> None:

    idf_obj_type = idf_strings.IDFObjects.win_material_glazing
    if not idf_writing_helpers.exists_in_idf(idf, idf_obj_type, idf_obj_name):
        win_glazing = idf.newidfobject(idf_obj_type)
        win_glazing.Name = idf_obj_name
        win_glazing.Thickness = thickness.to(ureg.m).m
        win_glazing.Optical_Data_Type = idf_strings.WindowMatGlazing.optical_data_type
        win_glazing.Solar_Transmittance_at_Normal_Incidence = mat_def.solar_transmittance.to(
            ureg.dimensionless).m
        win_glazing.Front_Side_Solar_Reflectance_at_Normal_Incidence = mat_def.front_side_solar_reflectance.to(
            ureg.dimensionless).m
        win_glazing.Back_Side_Solar_Reflectance_at_Normal_Incidence = mat_def.back_side_solar_reflectance.to(
            ureg.dimensionless).m
        win_glazing.Visible_Transmittance_at_Normal_Incidence = mat_def.visible_transmittance.to(
            ureg.dimensionless).m
        win_glazing.Front_Side_Visible_Reflectance_at_Normal_Incidence = mat_def.front_side_visible_reflectance.to(
            ureg.dimensionless).m
        win_glazing.Back_Side_Visible_Reflectance_at_Normal_Incidence = mat_def.back_side_visible_reflectance.to(
            ureg.dimensionless).m
        win_glazing.Infrared_Transmittance_at_Normal_Incidence = mat_def.infrared_transmittance.to(
            ureg.dimensionless).m
        win_glazing.Front_Side_Infrared_Hemispherical_Emissivity = mat_def.front_side_infrared_hemispherical_emissivity.to(
            ureg.dimensionless).m
        win_glazing.Back_Side_Infrared_Hemispherical_Emissivity = mat_def.back_side_infrared_hemispherical_emissivity.to(
            ureg.dimensionless).m
        win_glazing.Conductivity = mat_def.conductivity.to(ureg.W /
                                                           (ureg.m * ureg.K)).m
        win_glazing.Dirt_Correction_Factor_for_Solar_and_Visible_Transmittance = mat_def.dirt_correction_factor.to(
            ureg.dimensionless).m
Beispiel #17
0
def test_initinletoutlet():
    """py.test for initinletoutlet"""
    tdata = (
        ('PIPE:ADIABATIC', 'apipe', None, True, ["apipe_Inlet_Node_Name"],
         ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ('PIPE:ADIABATIC', 'apipe', None, False, ["Gumby"],
         ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ('Coil:Cooling:Water'.upper(), 'acoil', 'Water_', True,
         ["acoil_Water_Inlet_Node_Name",
          ""], ["acoil_Water_Outlet_Node_Name", ""]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
    )
    fhandle = StringIO("")
    idf = IDF(fhandle)
    for idfobjectkey, idfobjname, thisnode, force, inlets, outlets in tdata:
        idfobject = idf.newidfobject(idfobjectkey, idfobjname)
        inodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Inlet_Node_Name")
        idfobject[inodefields[0]] = "Gumby"
        hvacbuilder.initinletoutlet(idf, idfobject, thisnode, force=force)
        inodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Inlet_Node_Name")
        for nodefield, inlet in zip(inodefields, inlets):
            result = idfobject[nodefield]
            assert result == inlet
        onodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Outlet_Node_Name")
        for nodefield, outlet in zip(onodefields, outlets):
            result = idfobject[nodefield]
            assert result == outlet
def add_opaque_material(idf: IDF, idf_obj_name: str, mat_def: OpaqueMaterial,
                        thickness: pint.Quantity,
                        ureg: pint.UnitRegistry) -> None:
    """
    For materials without mass specified (e.g. vapour barriers) thickness is not
    :param idf:
    :param idf_obj_name:
    :param mat_def:
    :param thickness:
    :param ureg:
    :return:
    """
    if not idf_writing_helpers.exists_in_idf(
            idf, idf_strings.IDFObjects.material, idf_obj_name):
        assert mat_def.is_mass_fully_specified(
        ), f"trying to add opaque material {mat_def.name}, but no mass properties specified"
        idf_mat = idf.newidfobject(idf_strings.IDFObjects.material)
        idf_mat.Name = idf_obj_name
        idf_mat.Roughness = get_idf_roughness_string_for(mat_def.roughness)
        idf_mat.Thickness = thickness.to(ureg.m).m
        idf_mat.Conductivity = mat_def.conductivity.to(ureg.W /
                                                       (ureg.m * ureg.K)).m
        # checking for mass properties at begin, thus ignore type warning due to Optional[] declaration
        idf_mat.Density = mat_def.density.to(ureg.kg /
                                             ureg.m**3).m  # type: ignore
        idf_mat.Specific_Heat = mat_def.specific_heat.to(
            ureg.J / (ureg.kg * ureg.K)).m  # type: ignore
        idf_mat.Thermal_Absorptance = mat_def.thermal_absorptance.to(
            ureg.dimensionless).m
        idf_mat.Solar_Absorptance = mat_def.solar_absorptance.to(
            ureg.dimensionless).m
        idf_mat.Visible_Absorptance = mat_def.visible_absorptance.to(
            ureg.dimensionless).m
def add_material_no_mass(idf: IDF, idf_obj_name: str, mat_def: OpaqueMaterial,
                         thermal_resistance: pint.Quantity,
                         ureg: pint.UnitRegistry) -> None:
    """
    For materials without mass specified (e.g. vapour barriers)
    :param idf:
    :param idf_obj_name:
    :param mat_def:
    :param thermal_resistance:
    :param ureg:
    :return:
    """
    if not idf_writing_helpers.exists_in_idf(
            idf, idf_strings.IDFObjects.material_no_mass, idf_obj_name):
        idf_mat = idf.newidfobject(idf_strings.IDFObjects.material_no_mass)
        idf_mat.Name = idf_obj_name
        idf_mat.Roughness = get_idf_roughness_string_for(mat_def.roughness)
        idf_mat.Thermal_Resistance = thermal_resistance.to(
            (ureg.m**2 * ureg.K) / ureg.W).m
        idf_mat.Thermal_Absorptance = mat_def.thermal_absorptance.to(
            ureg.dimensionless).m
        idf_mat.Solar_Absorptance = mat_def.solar_absorptance.to(
            ureg.dimensionless).m
        idf_mat.Visible_Absorptance = mat_def.visible_absorptance.to(
            ureg.dimensionless).m
Beispiel #20
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        ("p_loop", ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'], [
            'db0', ['db1', 'db2', 'db3'], 'db4'
        ], 'sb0', [
            ("Chiller:Electric".upper(), 'Central_Chiller', 'Chilled_Water_'),
            ("PIPE:ADIABATIC", 'np1', None), ("PIPE:ADIABATIC", 'np2', None)
        ], 'Water', [
            'BRANCH',
            'sb0', '0',
            '', 'CHILLER:ELECTRIC',
            'Central_Chiller', 'p_loop Supply Inlet',
            'Central_Chiller_np1_node', '', 'PIPE:ADIABATIC', 'np1',
            'Central_Chiller_np1_node', 'np1_np2_node', '', 'PIPE:ADIABATIC',
            'np2', 'np1_np2_node', 'np2_Outlet_Node_Name', ''
        ]),  # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname, componenttuple, fluid,
         outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode)
                                for key, nm, thisnode in componenttuple]
        branch = idf.getobject('BRANCH', branchname)
        newbr = hvacbuilder.replacebranch(idf,
                                          loop,
                                          branch,
                                          components_thisnodes,
                                          fluid=fluid)
        assert newbr.obj == outbranch
Beispiel #21
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        (
            "p_loop", ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'],
            ['db0', ['db1', 'db2', 'db3'], 'db4'],
            'sb0',
            [
                ("Chiller:Electric".upper(), 'Central_Chiller',
                 'Chilled_Water_'),
                ("PIPE:ADIABATIC", 'np1', None),
                ("PIPE:ADIABATIC", 'np2', None)
            ],
            'Water',
            [
                'BRANCH', 'sb0', '0', '', 'CHILLER:ELECTRIC', 'Central_Chiller',
                'p_loop Supply Inlet', 'Central_Chiller_np1_node', '',
                'PIPE:ADIABATIC',
                'np1', 'Central_Chiller_np1_node', 'np1_np2_node', '',
                'PIPE:ADIABATIC',
                'np2', 'np1_np2_node', 'np2_Outlet_Node_Name', ''
            ]
        ), # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname,
         componenttuple, fluid, outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode)
                                for key, nm, thisnode in componenttuple]
        branch = idf.getobject('BRANCH', branchname)
        newbr = hvacbuilder.replacebranch(idf, loop, branch,
                                          components_thisnodes, fluid=fluid)
        assert newbr.obj == outbranch
def add_detailed_construction(idf: IDF,
                              construction: LayeredConstructionProtocol,
                              ureg: pint.UnitRegistry,
                              is_window=False) -> str:
    """
    Adds a construction to the idf.

    Note that in cesarp.model each layer of a construction or window construction is modelled with a separate
    Layer object having a thickness and material, whereas in the IDF definition a material object has a specific
    thickness, thus a construction has directly materials assigned without an intermediate layer object.
    """
    idf_obj_name = construction.name
    if not idf_writing_helpers.exists_in_idf(
            idf, idf_strings.IDFObjects.construction, idf_obj_name):
        # assert construction.external_layer_index == 0, \
        #    "external/outside layer of a construction is expected as layer 0. Either change your initialization " \
        #    "of the construction or add some code handling reverse layer order in idf_writer_construction"
        idf_constr = idf.newidfobject(idf_strings.IDFObjects.construction)
        idf_constr.Name = idf_obj_name
        idf_constr.Outside_Layer = add_layer(idf=idf,
                                             layer=construction.layers[0],
                                             ureg=ureg,
                                             is_window_layer=is_window)
        for idx in range(1, len(construction.layers)):
            mat_idf_name = add_layer(idf=idf,
                                     layer=construction.layers[idx],
                                     ureg=ureg,
                                     is_window_layer=is_window)
            idf_constr[f"Layer_{idx+1}"] = mat_idf_name

    return idf_obj_name
def add_airgap(idf: IDF, idf_obj_name: str, thermal_resistance: pint.Quantity,
               ureg: pint.UnitRegistry) -> None:
    if not idf_writing_helpers.exists_in_idf(
            idf, idf_strings.IDFObjects.material_air_gap, idf_obj_name):
        idf_mat = idf.newidfobject(idf_strings.IDFObjects.material_air_gap)
        idf_mat.Name = idf_obj_name
        idf_mat.Thermal_Resistance = thermal_resistance.to(ureg.m**2 * ureg.K /
                                                           ureg.W).m
Beispiel #24
0
def test_idfinmsequence():
    """py.test for setting of theidf in Idf_MSequence"""
    idftxt = """Version, 6.0;"""
    # theidf set in Idf_MSequence.__init__
    idf = IDF(StringIO(idftxt))
    versions = idf.idfobjects["version".upper()]
    assert versions.theidf == idf
    assert versions[0].theidf == idf
    # theidf set in Idf_MSequence.insert()
    material = idf.newidfobject("material".upper())
    assert material.theidf == idf
    # theidf set when you pop an item
    newmaterial = idf.newidfobject("material".upper())
    materials = idf.idfobjects["material".upper()]
    material = materials.pop(0)
    assert material.theidf == None
    assert materials[0].theidf == idf
Beispiel #25
0
def test_idfinmsequence():
    """py.test for setting of theidf in Idf_MSequence"""
    idftxt = """Version, 6.0;"""
    # theidf set in Idf_MSequence.__init__
    idf = IDF(StringIO(idftxt))
    versions = idf.idfobjects['version'.upper()]
    assert versions.theidf == idf
    assert versions[0].theidf == idf
    # theidf set in Idf_MSequence.insert()
    material = idf.newidfobject('material'.upper())
    assert material.theidf == idf
    # theidf set when you pop an item
    newmaterial = idf.newidfobject('material'.upper())
    materials = idf.idfobjects['material'.upper()]
    material = materials.pop(0)
    assert material.theidf == None
    assert materials[0].theidf == idf
def add_window_material_gas(idf: IDF, idf_obj_name: str,
                            thickness: pint.Quantity, mat_def: Gas,
                            ureg: pint.UnitRegistry) -> None:
    if not idf_writing_helpers.exists_in_idf(
            idf, idf_strings.IDFObjects.win_material_gas, idf_obj_name):
        idf_mat = idf.newidfobject(idf_strings.IDFObjects.win_material_gas)
        idf_mat.Name = idf_obj_name
        idf_mat.Gas_Type = get_gas_type(mat_def.name)
        idf_mat.Thickness = thickness.to(ureg.m).m
Beispiel #27
0
def getidfkeyswithnodes():
    """return a list of keys of idfobjects that hve 'None Name' fields"""
    idf = IDF(StringIO(""))
    keys = idfobjectkeys(idf)
    keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames) 
                for key in keys)
    keysnodefdnames = ((key,  (name for name in fdnames 
                                if (name.endswith('Node_Name')))) 
                            for key, fdnames in keysfieldnames)
    nodekeys = [key for key, fdnames in keysnodefdnames if list(fdnames)]
    return nodekeys
Beispiel #28
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew('test.idf')
        idf.newidfobject('VERSION')  # does not have a field "Name"

        # construction material
        construction = idf.newidfobject('CONSTRUCTION', Name='construction')
        construction.Outside_Layer = 'TestMaterial'

        expected = idf.newidfobject('MATERIAL', Name='TestMaterial')

        fetched = idf.getobject('MATERIAL', 'TestMaterial')
        assert fetched == expected

        material = construction.get_referenced_object('Outside_Layer')
        assert material == expected

        # window material
        glazing_group = idf.newidfobject(
            'WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC', Name='glazing_group')
        glazing_group.Window_Material_Glazing_Name_1 = 'TestWindowMaterial'

        expected = idf.newidfobject(
            'WINDOWMATERIAL:GLAZING', Name='TestWindowMaterial')  # has several \references

        fetched = idf.getobject('WINDOWMATERIAL:GLAZING', 'TestWindowMaterial')
        assert fetched == expected

        material = glazing_group.get_referenced_object(
            'Window_Material_Glazing_Name_1')
        assert material == expected
Beispiel #29
0
 def test_popidfobject(self):
     idftxt = ""
     idfhandle = StringIO(idftxt)
     idf = IDF(idfhandle)
     key = "BUILDING"
     idf.newidfobject(key, Name="Building_remove")
     idf.newidfobject(key, Name="Building1")
     idf.newidfobject(key, Name="Building_remove")
     idf.newidfobject(key, Name="Building2")
     buildings = idf.idfobjects["building"]
     removethis = buildings[-2]
     idf.popidfobject(key, 2)
     assert buildings[2].Name == "Building2"
     assert idf.model.dt[key][2][1] == "Building2"
Beispiel #30
0
 def test_popidfobject(self):
     idftxt = ""
     idfhandle = StringIO(idftxt)
     idf = IDF(idfhandle)
     key = "BUILDING"
     idf.newidfobject(key, Name="Building_remove")
     idf.newidfobject(key, Name="Building1")
     idf.newidfobject(key, Name="Building_remove")
     idf.newidfobject(key, Name="Building2")
     buildings = idf.idfobjects["building".upper()]
     removethis = buildings[-2]
     idf.popidfobject(key, 2)
     assert buildings[2].Name == "Building2"
     assert idf.model.dt[key][2][1] == "Building2"
Beispiel #31
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew('test.idf')
        idf.newidfobject('VERSION') # does not have a field "Name"

        # construction material        
        construction = idf.newidfobject('CONSTRUCTION', 'construction')
        construction.Outside_Layer = 'TestMaterial'
        
        expected = idf.newidfobject('MATERIAL', 'TestMaterial')
        
        fetched = idf.getobject('MATERIAL', 'TestMaterial')
        assert fetched == expected
    
        material = construction.get_referenced_object('Outside_Layer')
        assert material == expected
        
        # window material
        glazing_group = idf.newidfobject(
            'WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC', 'glazing_group')
        glazing_group.Window_Material_Glazing_Name_1 = 'TestWindowMaterial'

        expected = idf.newidfobject(
            'WINDOWMATERIAL:GLAZING', 'TestWindowMaterial') # has several \references
        
        fetched = idf.getobject('WINDOWMATERIAL:GLAZING', 'TestWindowMaterial')
        assert fetched == expected
        
        material = glazing_group.get_referenced_object(
            'Window_Material_Glazing_Name_1')
        assert material == expected
Beispiel #32
0
def test_name2idfobject():
    """py.test for name2idfobject"""
    idf = IDF(StringIO(""))
    plantloopname = "plantloopname"
    branchname = "branchname"
    pumpname = "pumpname"
    zonename = "zonename"
    plantloop = idf.newidfobject('PlantLoop'.upper(), 
                    Name=plantloopname,
                    Plant_Side_Inlet_Node_Name='CW Supply Inlet Node')
    branch = idf.newidfobject('Branch'.upper(), 
                    Name=branchname,
                    Component_1_Inlet_Node_Name='CW Supply Inlet Node')
    pump = idf.newidfobject('Pump:VariableSpeed'.upper(), 
                    Name=pumpname,
                    Inlet_Node_Name='CW Supply Inlet Node')
    zone = idf.newidfobject('zone'.upper(), Name=zonename)
    simulation = idf.newidfobject('SimulationControl'.upper()) 
    # - test
    names = [plantloopname, branchname, pumpname, zonename]
    idfobjs = [plantloop, branch, pump, zone]
    for name, idfobj in zip(names, idfobjs):
        result = idf_helpers.name2idfobject(idf, Name=name)
        assert result == idfobj
    # test when objkeys!=None
    objkey = 'ZoneHVAC:EquipmentConnections'.upper()
    equipconnections = idf.newidfobject(objkey,
                        Zone_Name=zonename)
    result = idf_helpers.name2idfobject(idf, Zone_Name=zonename, 
                    objkeys=[objkey, ])
    assert result == equipconnections
Beispiel #33
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew("test.idf")
        idf.newidfobject("VERSION")  # does not have a field "Name"

        # construction material
        construction = idf.newidfobject("CONSTRUCTION", Name="construction")
        construction.Outside_Layer = "TestMaterial"

        expected = idf.newidfobject("MATERIAL", Name="TestMaterial")

        fetched = idf.getobject("MATERIAL", "TestMaterial")
        assert fetched == expected

        material = construction.get_referenced_object("Outside_Layer")
        assert material == expected

        # window material
        glazing_group = idf.newidfobject(
            "WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC", Name="glazing_group"
        )
        glazing_group.Window_Material_Glazing_Name_1 = "TestWindowMaterial"

        expected = idf.newidfobject(
            "WINDOWMATERIAL:GLAZING", Name="TestWindowMaterial"
        )  # has several \references

        fetched = idf.getobject("WINDOWMATERIAL:GLAZING", "TestWindowMaterial")
        assert fetched == expected

        material = glazing_group.get_referenced_object("Window_Material_Glazing_Name_1")
        assert material == expected
Beispiel #34
0
def test_getobject_use_prevfield():
    """py.test for getobject_use_prevfield"""
    idf = IDF(StringIO(""))
    branch = idf.newidfobject(
        "BRANCH",
        Name="CW Pump Branch",
        Component_1_Object_Type="Pump:VariableSpeed",
        Component_1_Name="CW Circ Pump",
    )
    pump = idf.newidfobject("PUMP:VARIABLESPEED", Name="CW Circ Pump")
    foundobject = idf_helpers.getobject_use_prevfield(idf, branch,
                                                      "Component_1_Name")
    assert foundobject == pump
    # test for all times it should return None
    foundobject = idf_helpers.getobject_use_prevfield(idf, branch, "Name")
    foundobject = None  # prev field not end with Object_Type
    foundobject = idf_helpers.getobject_use_prevfield(
        idf, branch, "Component_11_Object_Type")
    foundobject = None  # field does not end with "Name"
    foundobject = idf_helpers.getobject_use_prevfield(idf, branch,
                                                      "Component_3_Name")
    foundobject = None  # bad idfobject key
Beispiel #35
0
def test_getobject_use_prevfield():
    """py.test for getobject_use_prevfield"""
    idf = IDF(StringIO(""))
    branch = idf.newidfobject('BRANCH', 
                    Name='CW Pump Branch',
                    Component_1_Object_Type='Pump:VariableSpeed',
                    Component_1_Name='CW Circ Pump')    
    pump = idf.newidfobject('PUMP:VARIABLESPEED', 
                    Name='CW Circ Pump')
    foundobject = idf_helpers.getobject_use_prevfield(idf, 
                                branch, 'Component_1_Name')
    assert foundobject == pump
    # test for all times it should return None
    foundobject = idf_helpers.getobject_use_prevfield(idf, 
                                branch, 'Name')
    foundobject = None # prev field not end with Object_Type
    foundobject = idf_helpers.getobject_use_prevfield(idf, 
                                branch, u'Component_11_Object_Type')
    foundobject = None# field does not end with "Name"
    foundobject = idf_helpers.getobject_use_prevfield(idf, 
                                branch,  u'Component_3_Name')
    foundobject = None # bad idfobject key
Beispiel #36
0
def test_newidfobject():
    """py.test for newidfobject"""
    # make a blank idf
    # make a function for this and then continue.
    idf = IDF()
    idf.new()
    objtype = 'material:airgap'.upper()
    obj = idf.newidfobject(objtype, Name='Argon')
    obj = idf.newidfobject(objtype, Name='Krypton')
    obj = idf.newidfobject(objtype, Name='Xenon')
    assert idf.model.dt[objtype] == [
        ['MATERIAL:AIRGAP', 'Argon'],
        ['MATERIAL:AIRGAP', 'Krypton'],
        ['MATERIAL:AIRGAP', 'Xenon'],
    ]
    # remove an object
    idf.popidfobject(objtype, 1)
    assert idf.model.dt[objtype] == [
        ['MATERIAL:AIRGAP', 'Argon'],
        ['MATERIAL:AIRGAP', 'Xenon'],
    ]
    lastobject = idf.idfobjects[objtype][-1]
    idf.removeidfobject(lastobject)
    assert idf.model.dt[objtype] == [
        ['MATERIAL:AIRGAP', 'Argon'],
    ]
    # copyidfobject
    onlyobject = idf.idfobjects[objtype][0]
    idf.copyidfobject(onlyobject)

    assert idf.model.dt[objtype] == [
        ['MATERIAL:AIRGAP', 'Argon'],
        ['MATERIAL:AIRGAP', 'Argon'],
    ]
    # test some functions
    objtype = 'FENESTRATIONSURFACE:DETAILED'
    obj = idf.newidfobject(objtype, Name='A Wall')
    assert obj.coords == []
    assert obj.fieldvalues[1] == 'A Wall'
Beispiel #37
0
    def to_eppy(self, idd_file: str) -> List[EpBunch]:
        """ Convert Material into Eppy material and construction objects """
        try:
            IDF.setiddname(str(idd_file))
        except IDDAlreadySetError as e:
            pass
        idf = IDF(io.StringIO(""))

        # Create list of eppy objects
        eppy_objects = []

        material = idf.newidfobject("MATERIAL:ROOFVEGETATION")
        material.Name = self.name
        material.Height_of_Plants = self.plant_height
        material.Leaf_Area_Index = self.leaf_area_index
        material.Leaf_Reflectivity = self.leaf_reflectivity
        material.Leaf_Emissivity = self.leaf_emissivity
        material.Minimum_Stomatal_Resistance = self.minimum_stomatal_resistance
        material.Soil_Layer_Name = self.soil_layer_name
        material.Roughness = self.roughness
        material.Thickness = self.thickness
        material.Conductivity_of_Dry_Soil = self.conductivity
        material.Density_of_Dry_Soil = self.density
        material.Specific_Heat_of_Dry_Soil = self.specific_heat
        material.Thermal_Absorptance = self.thermal_absorptance
        material.Solar_Absorptance = self.solar_absorptance
        material.Visible_Absorptance = self.visible_absorptance
        material.Saturation_Volumetric_Moisture_Content_of_the_Soil_Layer = self.saturation_volumetric_moisture_content_of_the_soil_layer
        material.Residual_Volumetric_Moisture_Content_of_the_Soil_Layer = self.residual_volumetric_moisture_content_of_the_soil_layer
        material.Initial_Volumetric_Moisture_Content_of_the_Soil_Layer = self.initial_volumetric_moisture_content_of_the_soil_layer
        material.Moisture_Diffusion_Calculation_Method = self.moisture_diffusion_calculation_method
        eppy_objects.append(material)

        construction = idf.newidfobject("CONSTRUCTION")
        construction.Name = self.name
        construction.Outside_Layer = self.name
        eppy_objects.append(construction)

        return eppy_objects
Beispiel #38
0
def test_componentsintobranch():
    """py.test for componentsintobranch"""
    tdata = (
    ("""BRANCH,
         sb0,
         0,
         ,
         Pipe:Adiabatic,
         sb0_pipe,
         p_loop Supply Inlet,
         sb0_pipe_outlet,
         Bypass;
    """, 
    [("PIPE:ADIABATIC", "pipe1"), ("PIPE:ADIABATIC", "pipe2")],
    '',
    ['PIPE:ADIABATIC', 'pipe1', 'pipe1_Inlet_Node_Name', 
    'pipe1_Outlet_Node_Name', '', 'PIPE:ADIABATIC', 'pipe2', 
    'pipe2_Inlet_Node_Name', 'pipe2_Outlet_Node_Name', '']
    ), 
    # idftxt, complst, fluid, branchcomps
    
    ("""BRANCH,
         sb0,
         0,
         ,
         Pipe:Adiabatic,
         sb0_pipe,
         p_loop Supply Inlet,
         sb0_pipe_outlet,
         Bypass;
    """, 
    [("PIPE:ADIABATIC", "pipe1"), ('CHILLER:ELECTRIC', "chiller")],
    '',
    ['PIPE:ADIABATIC', 'pipe1', 'pipe1_Inlet_Node_Name', 
    'pipe1_Outlet_Node_Name', '', 'CHILLER:ELECTRIC', 'chiller', 
    'chiller_Chilled_Water_Inlet_Node_Name', 
    'chiller_Chilled_Water_Outlet_Node_Name', '']
    ), 
    # idftxt, complst, fluid, branchcomps
    )                                                    
    for idftxt, complst, fluid, branchcomps in tdata:
        fhandle = StringIO(idftxt)
        idf = IDF(fhandle)
        components = [idf.newidfobject(key, nm) for key, nm in complst]
        fnc = hvacbuilder.initinletoutlet
        components = [fnc(idf, cp) for cp in components]
        branch = idf.idfobjects['BRANCH'][0]
        branch = hvacbuilder.componentsintobranch(idf, branch, components, 
                                                                    fluid)
        assert branch.obj[4:] == branchcomps
Beispiel #39
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        (
            "p_loop",
            ["sb0", ["sb1", "sb2", "sb3"], "sb4"],
            ["db0", ["db1", "db2", "db3"], "db4"],
            "sb0",
            [
                ("Chiller:Electric".upper(), "Central_Chiller", "Chilled_Water_"),
                ("PIPE:ADIABATIC", "np1", None),
                ("PIPE:ADIABATIC", "np2", None),
            ],
            "Water",
            [
                "BRANCH",
                "sb0",
                "0",
                "",
                "CHILLER:ELECTRIC",
                "Central_Chiller",
                "p_loop Supply Inlet",
                "Central_Chiller_np1_node",
                "",
                "PIPE:ADIABATIC",
                "np1",
                "Central_Chiller_np1_node",
                "np1_np2_node",
                "",
                "PIPE:ADIABATIC",
                "np2",
                "np1_np2_node",
                "np2_Outlet_Node_Name",
                "",
            ],
        ),  # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode) for key, nm, thisnode in componenttuple]
        branch = idf.getobject("BRANCH", branchname)
        newbr = hvacbuilder.replacebranch(idf, loop, branch, components_thisnodes, fluid=fluid)
        assert newbr.obj == outbranch
Beispiel #40
0
def test_getnodefieldname():
    """py.test for getnodefieldname"""
    tdata = (
        ("PIPE:ADIABATIC", "pipe1", "Inlet_Node_Name", "", "Inlet_Node_Name"),
        # objtype, objname, endswith, fluid, nodefieldname
        ("CHILLER:ELECTRIC", "pipe1", "Inlet_Node_Name", "", "Chilled_Water_Inlet_Node_Name"),
        # objtype, objname, endswith, fluid, nodefieldname
        ("COIL:COOLING:WATER", "pipe1", "Inlet_Node_Name", "Water", "Water_Inlet_Node_Name"),
        # objtype, objname, endswith, fluid, nodefieldname
        ("COIL:COOLING:WATER", "pipe1", "Inlet_Node_Name", "Air", "Air_Inlet_Node_Name"),
        # objtype, objname, endswith, fluid, nodefieldname
        ("COIL:COOLING:WATER", "pipe1", "Outlet_Node_Name", "Air", "Air_Outlet_Node_Name"),
        # objtype, objname, endswith, fluid, nodefieldname
    )
    for objtype, objname, endswith, fluid, nodefieldname in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        idfobject = idf.newidfobject(objtype, objname)
        result = hvacbuilder.getnodefieldname(idfobject, endswith, fluid)
        assert result == nodefieldname
Beispiel #41
0
def test_getnodefieldname():
    """py.test for getnodefieldname"""
    tdata = (
        ('PIPE:ADIABATIC', 'pipe1', 'Inlet_Node_Name', '', 'Inlet_Node_Name'),
        # objtype, objname, endswith, fluid, nodefieldname
        ('CHILLER:ELECTRIC', 'pipe1', 'Inlet_Node_Name', '',
         'Chilled_Water_Inlet_Node_Name'),
        # objtype, objname, endswith, fluid, nodefieldname
        ('COIL:COOLING:WATER', 'pipe1', 'Inlet_Node_Name', 'Water',
         'Water_Inlet_Node_Name'),
        # objtype, objname, endswith, fluid, nodefieldname
        ('COIL:COOLING:WATER', 'pipe1', 'Inlet_Node_Name', 'Air',
         'Air_Inlet_Node_Name'),
        # objtype, objname, endswith, fluid, nodefieldname
        ('COIL:COOLING:WATER', 'pipe1', 'Outlet_Node_Name', 'Air',
         'Air_Outlet_Node_Name'),
        # objtype, objname, endswith, fluid, nodefieldname
        )
    for objtype, objname, endswith, fluid, nodefieldname in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        idfobject = idf.newidfobject(objtype, objname)
        result = hvacbuilder.getnodefieldname(idfobject, endswith, fluid)
        assert result == nodefieldname
Beispiel #42
0
def test_newidfobject_warning():
    """Test that the warning for newidfobject created with `aname` is working.

    Fails if the warning is not issued when `aname` is used, or if the warning
    is issued when `aname` is not used.
    """
    # make a blank idf
    # make a function for this and then continue.
    idf = IDF()
    idf.new()
    objtype = 'material:airgap'.upper()
    # expect warnings here
    with pytest.warns(UserWarning):
        idf.newidfobject(objtype, aname="Krypton")
    with pytest.warns(UserWarning):
        idf.newidfobject(objtype, "Krypton")

    # expect no warnings here - we pass None so as not to trigger the `Failed: DID NOT WARN` message from pytest
    with pytest.warns(None) as captured_warnings:
        idf.newidfobject(objtype, Name="Krypton")
    assert len(captured_warnings) == 0
Beispiel #43
0
def test_newidfobject():
    """py.test for newidfobject"""
    # make a blank idf
    # make a function for this and then continue.
    idf = IDF()
    idf.new()
    objtype = 'material:airgap'.upper()
    obj = idf.newidfobject(objtype, Name='Argon')
    obj = idf.newidfobject(objtype, Name='Krypton')
    obj = idf.newidfobject(objtype, Name='Xenon')
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Krypton'],
                                     ['MATERIAL:AIRGAP', 'Xenon'],
                                     ]
    # remove an object
    idf.popidfobject(objtype, 1)
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Xenon'],
                                     ]
    lastobject = idf.idfobjects[objtype][-1]
    idf.removeidfobject(lastobject)
    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ]
    # copyidfobject
    onlyobject = idf.idfobjects[objtype][0]
    idf.copyidfobject(onlyobject)

    assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'],
                                     ['MATERIAL:AIRGAP', 'Argon'],
                                     ]
    # test some functions
    objtype = 'FENESTRATIONSURFACE:DETAILED'
    obj = idf.newidfobject(objtype, Name='A Wall')
    assert obj.coords == []
    assert obj.fieldvalues[1] == 'A Wall'
    
    # test defaultvalues=True and defaultvalues=False
    sim_deftrue = idf.newidfobject('SimulationControl'.upper(), defaultvalues=True)
    assert sim_deftrue.Do_Zone_Sizing_Calculation == 'No'
    sim_deffalse = idf.newidfobject('SimulationControl'.upper(), defaultvalues=False)
    assert sim_deffalse.Do_Zone_Sizing_Calculation == ''
Beispiel #44
0
# <headingcell level=4>

# Add a new material to the model

# <markdowncell>

# So far we have been working only with materials that were already in the list.
#
# What if we want to make new material?
#
# Obviously we would use the function 'newidfobject'.

# <codecell>

idf1.newidfobject("MATERIAL")

# <codecell>

len(materials)

# <markdowncell>

# We have 11 items in the materials list.
#
# Let us take a look at the last material in the list, where this fancy new material was added

# <codecell>

print(materials[-1])
Beispiel #45
0
# Modifying the topology of the loop

# <markdowncell>

# Let us make a new branch and replace the exisiting branch 
# 
# The existing branch name is "sb0" and it contains a single pipe component sb0_pipe.
# 
# Let us replace it with a branch that has a chiller that is connected to a pipe which is turn connected to another pipe. So the connections in the new branch would look like "chiller-> pipe1->pipe2"

# <codecell>

# make a new branch chiller->pipe1-> pipe2

# make a new pipe component
pipe1 = idf.newidfobject("PIPE:ADIABATIC", 'np1')

# make a new chiller
chiller = idf.newidfobject("Chiller:Electric".upper(), 'Central_Chiller')

# make another pipe component
pipe2 = idf.newidfobject("PIPE:ADIABATIC", 'np2')

# get the loop we are trying to modify
loop = idf.getobject('PLANTLOOP', 'p_loop') # args are (key, name)
# get the branch we are trying to modify
branch = idf.getobject('BRANCH', 'sb0') # args are (key, name)
listofcomponents = [chiller, pipe1, pipe2] # the new components are connected in this order

newbr = hvacbuilder.replacebranch(idf, loop, branch, listofcomponents, fluid='Water')
# in "loop"
Beispiel #46
0
pathnameto_eppy = '../'
sys.path.append(pathnameto_eppy)

from eppy import modeleditor
from eppy.modeleditor import IDF
import StringIO

iddfile = "./eppy/resources/iddfiles/Energy+V7_2_0.idd"
iddfile = "./eppy/resources/iddfiles/Energy+V8_0_0.idd"

IDF.setiddname(iddfile)
idf = IDF(StringIO.StringIO(""))

okeys = idf.idfobjects.keys()
for okey in okeys:
    idf.newidfobject(okey)
    
for okey in okeys:
    referreds = idf.idfobjects[okey.upper()]    
    referred = referreds[0]
    try:
        nameidd = referred.getfieldidd('Name')
    except ValueError as e:
        # print 'no Name', okey
        continue
    try:
        references = nameidd['reference']
    except KeyError as e:
        # print 'no reference', okey
        continue
Beispiel #47
0
# if you have not done so, uncomment the following three lines
import sys
# pathnameto_eppy = 'c:/eppy'
pathnameto_eppy = '../../'
sys.path.append(pathnameto_eppy)

from eppy import modeleditor
from eppy.modeleditor import IDF
iddfile = "../resources/iddfiles/Energy+V7_2_0.idd"
IDF.setiddname(iddfile)

idftxt = "" # empty string
from io import StringIO
fhandle = StringIO(idftxt) # we can make a file handle of a string
new_idf = IDF(fhandle) # initialize the IDF object with the file handle

# add an object to the idf file
objtype = "BUILDING"
new_idf.newidfobject(objtype, Name="Taj Mahal")

buildings = new_idf.idfobjects["BUILDING"]
building = buildings[0]
# print building
new_idf.newidfobject("LIGHTS", Name="light one")

lights = new_idf.idfobjects["LIGHTS"]
light = lights[0]
print(light)

new_idf.printidf()
Beispiel #48
0
"""script to work with frog Imapct"""

from eppy import modeleditor
from eppy.modeleditor import IDF
iddfile = "./eppy/resources/iddfiles/Energy+V7_2_0.idd"
fname = "/Volumes/Server/Active_Projects/FROG_all/Frog15_Impact/3_Simulation/2_Energy/EnergyPlus/37_SSFUSD_systems2/37_SSFUSD_UnconditionednoVent1.idf"
IDF.setiddname(iddfile)
idf = IDF(fname)

# idf.newidfobject("HVACTemplate:Zone:IdealLoadsAirSystem".upper())
idealkey = "HVACTemplate:Zone:IdealLoadsAirSystem".upper()
idf.newidfobject(idealkey, Zone_Name="west")

# try to copy from other idf
otherfname = "/Volumes/Server/Active_Projects/FROG_all/Frog15_Impact/3_Simulation/2_Energy/EnergyPlus/37_SSFUSD_systems2/37_SSFUSD_Furnace_IdealLoads.idf"

otheridf = IDF(otherfname)

Beispiel #49
0
def test_componentsintobranch():
    """py.test for componentsintobranch"""
    tdata = (
        (
            """BRANCH,
             sb0,
             0,
             ,
             Pipe:Adiabatic,
             sb0_pipe,
             p_loop Supply Inlet,
             sb0_pipe_outlet,
             Bypass;
             """,
            [("PIPE:ADIABATIC", "pipe1", None), ("PIPE:ADIABATIC", "pipe2", None)],
            "",
            [
                "PIPE:ADIABATIC",
                "pipe1",
                "pipe1_Inlet_Node_Name",
                "pipe1_Outlet_Node_Name",
                "",
                "PIPE:ADIABATIC",
                "pipe2",
                "pipe2_Inlet_Node_Name",
                "pipe2_Outlet_Node_Name",
                "",
            ],
        ),
        # idftxt, complst, fluid, branchcomps
        (
            """BRANCH,
            sb0,
            0,
            ,
            Pipe:Adiabatic,
            sb0_pipe,
            p_loop Supply Inlet,
            sb0_pipe_outlet,
            Bypass;
            """,
            [("PIPE:ADIABATIC", "pipe1", None), ("CHILLER:ELECTRIC", "chiller", "Chilled_Water_")],
            "",
            [
                "PIPE:ADIABATIC",
                "pipe1",
                "pipe1_Inlet_Node_Name",
                "pipe1_Outlet_Node_Name",
                "",
                "CHILLER:ELECTRIC",
                "chiller",
                "chiller_Chilled_Water_Inlet_Node_Name",
                "chiller_Chilled_Water_Outlet_Node_Name",
                "",
            ],
        ),
        # idftxt, complst, fluid, branchcomps
    )
    for ii, (idftxt, complst, fluid, branchcomps) in enumerate(tdata):
        fhandle = StringIO(idftxt)
        idf = IDF(fhandle)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode) for key, nm, thisnode in complst]
        fnc = hvacbuilder.initinletoutlet
        components_thisnodes = [(fnc(idf, cp, thisnode), thisnode) for cp, thisnode in components_thisnodes]
        branch = idf.idfobjects["BRANCH"][0]
        branch = hvacbuilder.componentsintobranch(idf, branch, components_thisnodes, fluid)
        assert branch.obj[4:] == branchcomps
Beispiel #50
0
# Let us start with a blank idf file and make some new "MATERIAL" objects in it

# <codecell>

# making a blank idf object
blankstr = ""
from io import StringIO
idf = IDF(StringIO(blankstr))

# <markdowncell>

# To make and add a new idfobject object, we use the function IDF.newidfobject(). We want to make an object of type "MATERIAL"

# <codecell>

newobject = idf.newidfobject("material".upper()) # the key for the object type has to be in upper case
                                     # .upper() makes it upper case
    

# <codecell>

print(newobject)

# <markdowncell>

# Let us give this a name, say "Shiny new material object"

# <codecell>

newobject.Name = "Shiny new material object"
print(newobject)