Ejemplo n.º 1
0
    def save_project(self, file_name=None, path=None):
        """Saves the project to a tXML file

        calls the function save_teaser_xml in data.TeaserXML.py

        Parameters
        ----------

        file_name : string
            name of the new file
        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified
        """
        if file_name is None:
            name = self.name
        else:
            name = file_name

        if path is None:
            new_path = os.path.join(utilities.get_default_path(), name)
        else:
            new_path = os.path.join(utilities.get_default_path(), name)
            utilities.create_path(utilities.get_full_path(path))

        txml_out.save_teaser_xml(new_path, self)
Ejemplo n.º 2
0
 def test_save_use_conditions(self):
     '''test of save_use_conditions, no parameter checking'''
     import os
     try:
         os.remove(utilities.get_default_path() + "\\" + "UseCondUT.xml")
     except:
         pass
     path = utilities.get_default_path()
     use_cond = prj.buildings[-1].thermal_zones[-1].use_conditions
     use_cond.parent = None
     use_cond.save_use_conditions(path=path, file_name="UseCondUT")
Ejemplo n.º 3
0
 def test_save_use_conditions(self):
     '''test of save_use_conditions, no parameter checking'''
     import os
     try:
         os.remove(utilities.get_default_path() + "/" + "UseCondUT.xml")
     except:
         pass
     path = utilities.get_default_path()
     use_cond = prj.buildings[-1].thermal_zones[-1].use_conditions
     use_cond.parent = None
     use_cond.save_use_conditions(path=path, file_name="UseCondUT")
Ejemplo n.º 4
0
 def test_save_use_conditions(self):
     """Test of save_use_conditions, no parameter checking."""
     try:
         os.remove(
             os.path.join(utilities.get_default_path(), "UseCondUT.json"))
     except OSError:
         pass
     path = os.path.join(utilities.get_default_path(), "UseCondUT.json")
     prj.data.path_uc = path
     prj.data.load_uc_binding()
     use_cond = prj.buildings[-1].thermal_zones[-1].use_conditions
     use_cond.save_use_conditions(data_class=prj.data)
Ejemplo n.º 5
0
def main():

    this_path = os.path.dirname(__file__)
    input_path = os.path.join(this_path,
                              'ExampleInputFiles',
                              'MelatenXML')

    output_path = utilitis.get_default_path()

    info_list = read_XMLs(input_path)

    prj = create_reference_project(info_list)
    prj.number_of_elements_calc = 2
    prj.merge_windows_calc = False
    prj.used_library_calc = "AixLib"
    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)

    """or we could also use the Annex60 models"""
    #prj.used_library_calc = "Annex60"
    #prj.export_annex(number_of_elements=2,
    #                 merge_windows=False,
    #                 internal_id=None,
    #                 path=None)
    prj.retrofit_all_buildings(2015)
    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)

    """or we could also use the Annex60 models"""
Ejemplo n.º 6
0
def main():

    this_path = os.path.dirname(__file__)
    input_path = os.path.join(this_path,
                              'examplefiles',
                              'MelatenXML')

    output_path = utilitis.get_default_path()

    info_list = read_XMLs(input_path)

    prj = create_reference_project(info_list)
    prj.number_of_elements_calc = 2
    prj.merge_windows_calc = False
    prj.used_library_calc = "AixLib"
    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)

    """or we could also use the Annex60 models"""
    #prj.used_library_calc = "Annex60"
    #prj.export_annex(number_of_elements=2,
    #                 merge_windows=False,
    #                 internal_id=None,
    #                 path=None)
    prj.retrofit_all_buildings(2015)
    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)

    """or we could also use the Annex60 models"""
Ejemplo n.º 7
0
    def export_annex(self,
                     internal_id=None,
                     path=None):
        """Exports values to a record file for Modelica simulation

        Parameters
        ----------

        internal_id : float
            setter of the used building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in OutputData, an alternative
            path can be specified as a full and absolute path
        """

        if path is None:
            path = utilitis.get_default_path() + "/" + self.name
        else:
            path = path + "/" + self.name

        utilitis.create_path(path)

        annex60_output.export_annex60(prj=self,
                                      number_of_elements=self.number_of_elements_calc,
                                      merge_windows=self.merge_windows_calc,
                                      internal_id=internal_id,
                                      path=path)
Ejemplo n.º 8
0
    def save_citygml(self, file_name=None, path=None):
        """Saves the project to a CityGML file

        calls the function save_gml in data.CityGML we make use of CityGML core
        and EnergyADE to store semantic information


        Parameters
        ----------

        file_name : string
            name of the new file
        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified

        """
        if file_name is None:
            name = self.name
        else:
            name = file_name

        if path is None:
            new_path = os.path.join(utilities.get_default_path(), name)
        else:
            new_path = os.path.join(path, name)
            utilities.create_path(utilities.get_full_path(path))

        citygml_out.save_gml(self, new_path)
Ejemplo n.º 9
0
    def save_citygml(self, file_name=None, path=None):
        '''Saves the project to a citygml file

        calls the function save_gml in data.CityGML we make use of CityGML core
        and EnergyADE to store semantic information


        Parameters
        ----------

        file_name : string
            name of the new file
        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified

        '''
        if file_name is None:
            name = self.name
        else:
            name = file_name

        if path is None:
            new_path = os.path.join(utilitis.get_default_path(), name)
        else:
            new_path = path + "/" + name
            utilitis.create_path(utilitis.get_full_path(path))

        citygml_out.save_gml(self, new_path)
Ejemplo n.º 10
0
    def save_project(self, file_name=None, path=None):
        '''Saves the project to a tXML file

        calls the function save_teaser_xml in data.TeaserXML.py

        Parameters
        ----------

        file_name : string
            name of the new file
        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified
        '''
        if file_name is None:
            name = self.name
        else:
            name = file_name

        if path is None:
            new_path = os.path.join(utilitis.get_default_path(), name)
        else:
            new_path = path + "/" + name
            utilitis.create_path(utilitis.get_full_path(path))

        txml_out.save_teaser_xml(new_path, self)
Ejemplo n.º 11
0
def example_save():
    """"This function demonstrates different saving options of TEASER"""

    # In e1_generate_archetype we created a Project with three archetype
    # buildings to get this Project we rerun this example

    prj = e1.example_generate_archetype()

    # First option is to use TEASERs own XML format to save all relevant
    # data into a more or less human readable format. The corresponding
    # function is called Project().save_project() you can specify a file name
    #  and a save path. If both are non (as in this case) it will use the
    # projects name and default path in your home folder.

    prj.save_project(file_name=None, path=None)

    # Second option is to use pickle from Python Standard Library ,
    # which will save the whole Python classes and all attributes into a
    # binary file. There is no specific API function for this, but you can
    # simply create an empty file with open() and then use pickle.dump().
    # Make sure you specify your path correctly. In this case we want to use
    # the default path of TEASERs output.

    import pickle

    pickle_file = os.path.join(
        utilities.get_default_path(),
        'teaser_pickle.p')

    pickle.dump(prj, open(pickle_file, "wb"))
Ejemplo n.º 12
0
    def export_aixlib(
            self,
            building_model=None,
            zone_model=None,
            corG=None,
            internal_id=None,
            path=None):
        """Exports values to a record file for Modelica simulation

        Exports one (if internal_id is not None) or all buildings for
        AixLib.ThermalZones.ReducedOrder.Multizone.MultizoneEquipped models
        using the ThermalZoneEquipped model with a correction of g-value (
        double pane glazing) and supporting models, like tables and weather
        model. In contrast to versions < 0.5 TEASER now does not
        support any model options, as we observed no need, since single
        ThermalZones are identically with IBPSA models. If you miss one of
        the old options please contact us.

        Parameters
        ----------

        internal_id : float
            setter of a specific building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in default output path of TEASER,
            an alternative path can be specified as a full path
        """

        if building_model is not None or zone_model is not None or corG is \
                not None:

            warnings.warn("building_model, zone_model and corG are no longer "
                          "supported for AixLib export and have no effect. "
                          "The keywords will be deleted within the next "
                          "version, consider rewriting your code.")

        if path is None:
            path = os.path.join(
                utilities.get_default_path(),
                self.name)
        else:
            path = os.path.join(
                path,
                self.name)

        utilities.create_path(path)

        if internal_id is None:
            aixlib_output.export_multizone(
                buildings=self.buildings,
                prj=self,
                path=path)
        else:
            for bldg in self.buildings:
                if bldg.internal_id == internal_id:
                    aixlib_output.export_multizone(
                        buildings=[bldg],
                        prj=self,
                        path=path)
Ejemplo n.º 13
0
    def save_project(self, file_name=None, path=None):
        """Saves the project to a JSON file

        Calls the function save_teaser_json in data.output.teaserjson_output

        Parameters
        ----------

        file_name : string
            name of the new file
        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified
        """
        if file_name is None:
            name = self.name
        else:
            name = file_name

        if path is None:
            new_path = os.path.join(utilities.get_default_path(), name)
        else:
            new_path = os.path.join(path, name)

        tjson_out.save_teaser_json(new_path, self)
Ejemplo n.º 14
0
def example_save():
    """"This function demonstrates different loading options of TEASER"""

    # In example e4_save we saved two TEASER projects using *.teaserXML and
    # Python package pickle. This example shows how to import these
    # information into your python environment again.

    # To load data from *.teaserXML we can use a simple API function. So
    # first we need to instantiate our API (similar to example
    # e1_generate_archetype). The XML file is called
    # `ArchetypeExample.teaserXML` and saved in the default path. You need to
    #  run e4 first before you can load this example file.

    from teaser.project import Project

    prj = Project()

    load_xml = os.path.join(utilities.get_default_path(),
                            'ArchetypeExample.teaserXML')

    prj.load_project(path=load_xml)
    prj = Project()
    prj.load_project(
        utilities.get_full_path("examples/examplefiles/new.teaserXML"))
    prj.save_project(file_name="new", path=None)

    # To reload data from a pickle file, we do not need to instantiate an
    # API, as pickle will automatically instantiate all classes as they have
    # been saved. The saved file from example e4 is called ´teaser_pickle.p´

    import pickle

    load_pickle = os.path.join(utilities.get_default_path(), 'teaser_pickle.p')

    pickle_prj = pickle.load(open(load_pickle, "rb"))

    # The last option to import data into TEASER is using a CityGML file. The
    # import of CityGML underlies some limitations e.g. concerning data
    # given in the file and the way the buildings are modeled.

    prj_gml = Project()

    load_gml = utilities.get_full_path(
        os.path.join('examples', 'examplefiles', 'CityGMLSample.gml'))

    prj_gml.load_citygml(path=load_gml)
Ejemplo n.º 15
0
    def modelica_AHU_boundary(self, path=None):
        """Create .txt file for AHU boundary conditions (building).

        This function creates a txt for building AHU boundary
        conditions

        1. Column : time step
        2. Column : desired AHU profile temperature
        3. Column : Desired minimal relative humidity
        4. Column : desired maximal relative humidity
        5. Column : AHU status (On/Off)

        Parameters
        ----------
        path : str
            optional path, when matfile is exported separately

        Attributes
        ----------
        temperature_profile : [float]
            timeline of temperatures requirements for AHU simulation
        min_relative_humidity_profile : [float]
            timeline of relative humidity requirements for AHU simulation
        max_relative_humidity_profile : [float]
            timeline of relative humidity requirements for AHU simulation
        v_flow_profile : [int]
            timeline of desired relative v_flow of the AHU simulation (0..1)

        """
        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_ahu)

        if self.parent.with_ahu is True:
            export = self.parent.central_ahu.schedules
        else:  # Dummy values for Input Table
            export = pd.DataFrame(index=pd.date_range(
                "2019-01-01 00:00:00", periods=8760,
                freq="H").to_series().dt.strftime("%m-%d %H:%M:%S"))

            export["temperature_profile"] = list(
                islice(cycle([293.15, 293.15]), 8760))
            export["min_relative_humidity_profile"] = list(
                islice(cycle([0, 0]), 8760))
            export["max_relative_humidity_profile"] = list(
                islice(cycle([1, 1]), 8760))
            export["v_flow_profile"] = list(islice(cycle([0, 1]), 8760))

        export.index = [(i + 1) * 3600 for i in range(8760)]
        self._delete_file(path=path)
        with open(path, "a") as f:
            f.write("#1\n")
            f.write("double AHU({}, {})\n".format(8760, 5))
            export.to_csv(f, sep="\t", header=False, index_label=False)
Ejemplo n.º 16
0
 def test_save_use_conditions(self):
     '''test of save_use_conditions, no parameter checking'''
     import os
     
     path = os.path.join(utilities.get_default_path(),
                         'UseCondUT.xml')
     prj.data.path_uc = path
     prj.data.load_uc_binding()
     use_cond = prj.buildings[-1].thermal_zones[-1].use_conditions
     use_cond.save_use_conditions(data_class=prj.data)
Ejemplo n.º 17
0
    def modelica_gains_boundary(self, path=None):
        """Create .txt file for internal gains boundary conditions.

        This function creates a matfile (-v4) for building internal gains
        boundary conditions. It collects all internal gain profiles of the
        zones and stores them into one file. The file is extended for each
        zone. Only applicable if zones are defined

        1. Column : time step
        2,5,8,...  Column : profile_persons
        3,6,9,...  Column : profile_machines
        4,7,10,... Column : profile_lighting

        Note
        ----------
        When time line is created, we need to add a 0 to first element of
        all boundaries. This is due to to expected format in Modelica.

        Parameters
        ----------
        path : str
            optional path, when matfile is exported separately

        """
        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_internal_gains)

        export = pd.DataFrame(
            index=pd.date_range("2019-01-01 00:00:00", periods=8760, freq="H"
                                ).to_series().dt.strftime("%m-%d %H:%M:%S"))

        for zone_count in self.parent.thermal_zones:
            export["person_{}".format(
                zone_count.name
            )] = zone_count.use_conditions.schedules["persons_profile"]
            export["machines_{}".format(
                zone_count.name
            )] = zone_count.use_conditions.schedules["machines_profile"]
            export["lighting_{}".format(
                zone_count.name
            )] = zone_count.use_conditions.schedules["lighting_profile"]

        export.index = [(i + 1) * 3600 for i in range(8760)]
        self._delete_file(path=path)
        with open(path, "a") as f:
            f.write("#1\n")
            f.write("double Internals({}, {})\n".format(
                8760, (len(self.parent.thermal_zones) * 3 + 1)))
            export.to_csv(f, sep="\t", header=False, index_label=False)
Ejemplo n.º 18
0
    def test_save_type_element(self):
        '''test of save_type_element, no parameter checking'''
        import os
        try:
            os.remove(utilities.get_default_path() + "/" + "unitTestTB.xml")
        except:
            pass

        # test load function
        therm_zone = prj.buildings[-1].thermal_zones[-1]
        path = utilities.get_default_path()
        therm_zone.outer_walls[0].parent = None
        therm_zone.outer_walls[0].save_type_element(path=path,
                                                    file_name="unitTestTB")
        therm_zone.inner_walls[0].parent = None
        therm_zone.inner_walls[0].save_type_element(path=path,
                                                    file_name="unitTestTB")
        therm_zone.windows[0].parent = None
        therm_zone.windows[0].save_type_element(path=path,
                                                file_name="unitTestTB")
Ejemplo n.º 19
0
    def test_save_type_element(self):
        '''test of save_type_element, no parameter checking'''
        import os
        try:
            os.remove(utilities.get_default_path() + "\\" + "unitTestTB.xml")
        except:
            pass

        # test load function
        therm_zone = prj.buildings[-1].thermal_zones[-1]
        path = utilities.get_default_path()
        therm_zone.outer_walls[0].parent = None
        therm_zone.outer_walls[0].save_type_element(path=path,
                                                    file_name="unitTestTB")
        therm_zone.inner_walls[0].parent = None
        therm_zone.inner_walls[0].save_type_element(path=path,
                                                    file_name="unitTestTB")
        therm_zone.windows[0].parent = None
        therm_zone.windows[0].save_type_element(path=path,
                                                file_name="unitTestTB")
Ejemplo n.º 20
0
 def test_save_type_element(self):
     '''test of save_type_element, no parameter checking'''
     import os
     # test load function
     therm_zone = prj.buildings[-1].thermal_zones[-1]
     path = os.path.join(utilities.get_default_path(),
                     'unitTestTB.xml')
     prj.data.path_tb = path
     prj.data.load_tb_binding()
     therm_zone.outer_walls[0].save_type_element(data_class=prj.data)
     therm_zone.inner_walls[0].save_type_element(data_class=prj.data)
     therm_zone.windows[0].save_type_element(data_class=prj.data)
Ejemplo n.º 21
0
    def export_ibpsa(self, library="AixLib", internal_id=None, path=None):
        """Exports values to a record file for Modelica simulation

        For Annex 60 Library

        Parameters
        ----------

        library : str
            Used library within the framework of IBPSA library. The
            models are identical in each library, but IBPSA Modelica library is
            just a core set of models and should not be used standalone.
            Valid values are 'AixLib' (default), 'Buildings',
            'BuildingSystems' and 'IDEAS'.
        internal_id : float
            setter of a specific building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in default output path of TEASER,
            an alternative path can be specified as a full path
        """

        ass_error_1 = ("library for IBPSA export has to be 'AixLib', "
                       "'Buildings', 'BuildingSystems' or 'IDEAS'")

        assert library in [
            "AixLib",
            "Buildings",
            "BuildingSystems",
            "IDEAS",
        ], ass_error_1

        if path is None:
            path = os.path.join(utilities.get_default_path(), self.name)
        else:
            path = os.path.join(path, self.name)

        utilities.create_path(path)

        if internal_id is None:
            ibpsa_output.export_ibpsa(buildings=self.buildings,
                                      prj=self,
                                      path=path,
                                      library=library)
        else:
            for bldg in self.buildings:
                if bldg.internal_id == internal_id:
                    ibpsa_output.export_ibpsa(buildings=[bldg],
                                              prj=self,
                                              path=path)
        return path
Ejemplo n.º 22
0
def example_load():
    """"This function demonstrates different loading options of TEASER"""

    # In example e4_save we saved two TEASER projects using *.teaserjson and
    # Python package pickle. This example shows how to import these
    # information into your python environment again.

    # To load data from *.teaserjson we can use a simple API function. So
    # first we need to instantiate our API (similar to example
    # e1_generate_archetype). The json file is called
    # `ArchetypeExample.teaserjson` and saved in the default path. You need to
    #  run e4 first before you can load this example file.

    from teaser.project import Project

    prj = Project()

    load_json = os.path.join(utilities.get_default_path(),
                             "ArchetypeExample.json")

    prj.load_project(path=load_json)

    prj = Project()
    prj.load_project(
        utilities.get_full_path("examples/examplefiles/unitTest.json"))
    prj.save_project(file_name="unitTest", path=None)

    # To reload data from a pickle file, we do not need to instantiate an
    # API, as pickle will automatically instantiate all classes as they have
    # been saved. The saved file from example e4 is called ´teaser_pickle.p´

    import pickle

    load_pickle = os.path.join(utilities.get_default_path(), "teaser_pickle.p")

    pickle_prj = pickle.load(open(load_pickle, "rb"))
    print(pickle_prj)
Ejemplo n.º 23
0
    def export_parameters_txt(self, path=None):
        '''Exports parameters of all buildings in a readable text file

        Parameters
        ----------

        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified
        '''

        if path is None:
            path = os.path.join(utilitis.get_default_path(), self.name)
        else:
            path = path+"/"+self.name

        text_out.export_parameters_txt(prj=self,
                                       path=path)
Ejemplo n.º 24
0
    def export_ibpsa(
            self,
            internal_id=None,
            path=None):
        """Exports values to a record file for Modelica simulation

        For Annex 60 Library

        Parameters
        ----------

        internal_id : float
            setter of a specific building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in default output path of TEASER,
            an alternative path can be specified as a full path
        """

        if path is None:
            path = os.path.join(
                utilities.get_default_path(),
                self.name)
        else:
            path = os.path.join(
                path,
                self.name)

        utilities.create_path(path)

        if internal_id is None:
            ibpsa_output.export_ibpsa(
                buildings=self.buildings,
                prj=self,
                path=path)
        else:
            for bldg in self.buildings:
                if bldg.internal_id == internal_id:
                    ibpsa_output.export_ibpsa(
                        buildings=[bldg],
                        prj=self,
                        path=path)
Ejemplo n.º 25
0
def modelica_set_temp(bldg, path = None):
    '''creates .mat file for set temperatures for each zone

    This function creates a matfile (-v4) for set temperatures of each
    zone

    !AixLib sepcific!

    1. Row: heat set temperature of all zones
    2. Row: cool set temperature of all zones

    Parameters
    ----------
    path : str
        optional path, when matfile is exported seperately

    '''

    if bldg.file_set_t is None:
        bldg.file_set_t = "\\Tset_"+bldg.name+".mat"
    else:
        pass

    if path is None:
        path = utilitis.get_default_path()
    else:
        pass

    utilitis.create_path(path)
    path = path + bldg.file_set_t

    t_set_heat = [0]

    for zone_count in bldg.thermal_zones:
        t_set_heat.append(zone_count.use_conditions.set_temp_heat)

    scipy.io.savemat(path,
                     mdict={'Tset': [t_set_heat]},
                     appendmat = False,
                     format = '4')
Ejemplo n.º 26
0
    def export_aixlib(self,
                      building_model="None",
                      zone_model="None",
                      corG=None,
                      internal_id=None,
                      path=None):
        """Exports values to a record file for Modelica simulation

        Parameters
        ----------

        building_model : string
            setter of the used Aixlib building model (None, MultizoneEquipped,
            Multizone)
        zone_model : string
            setter of the used Aixlib zone model (ThermalZoneEquipped,
            ThermalZone)
        corG : boolean
            setter of the used g value calculation in the model
        internal_id : float
            setter of the used building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in OutputData, an alternative
            path can be specified as a full and absolute path
        """

        if path is None:
            path = utilitis.get_default_path() + "\\" + self.name
        else:
            path = path + "\\" + self.name

        utilitis.create_path(path)

        aixlib_output.export_aixlib(prj=self,
                                    building_model=building_model,
                                    zone_model=zone_model,
                                    corG=corG,
                                    internal_id=internal_id,
                                    path=path)
Ejemplo n.º 27
0
    def export_aixlib(self,
                      building_model="None",
                      zone_model="None",
                      corG=None,
                      internal_id=None,
                      path=None):
        """Exports values to a record file for Modelica simulation

        Parameters
        ----------

        building_model : string
            setter of the used Aixlib building model (None, MultizoneEquipped,
            Multizone)
        zone_model : string
            setter of the used Aixlib zone model (ThermalZoneEquipped,
            ThermalZone)
        corG : boolean
            setter of the used g value calculation in the model
        internal_id : float
            setter of the used building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in OutputData, an alternative
            path can be specified as a full and absolute path
        """

        if path is None:
            path = utilitis.get_default_path() + "\\" + self.name
        else:
            path = path + "\\" + self.name

        utilitis.create_path(path)

        aixlib_output.export_aixlib(prj=self,
                                    building_model=building_model,
                                    zone_model=zone_model,
                                    corG=corG,
                                    internal_id=internal_id,
                                    path=path)
Ejemplo n.º 28
0
    def modelica_set_temp_cool(self, path=None):
        """Create .txt file for set temperatures cooling.

        This function creates a txt for set temperatures for cooling
        of each zone, that are all saved into one matrix.


        Parameters
        ----------
        path : str
            optional path, when matfile is exported separately

        """
        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_set_t_cool)

        export = pd.DataFrame(
            index=pd.date_range(
                "2019-01-01 00:00:00", periods=8760,
                freq="H").to_series().dt.strftime("%m-%d %H:%M:%S"),
            columns=[zone.name for zone in self.parent.thermal_zones],
        )

        for zone_count in self.parent.thermal_zones:
            export[zone_count.name] = zone_count.use_conditions.schedules[
                "cooling_profile"]

        export.index = [(i + 1) * 3600 for i in range(8760)]
        self._delete_file(path=path)
        with open(path, "a") as f:
            f.write("#1\n")
            f.write("double Tset({}, {})\n".format(
                8760,
                len(self.parent.thermal_zones) + 1))
            export.to_csv(f, sep="\t", header=False, index_label=False)
Ejemplo n.º 29
0
    def export_parameters_txt(self, path=None):
        """Exports parameters of all buildings in a readable text file

        Parameters
        ----------

        path : string
            if the Files should not be stored in OutputData, an alternative
            can be specified
        """

        if path is None:
            path = os.path.join(
                utilities.get_default_path(),
                self.name)
        else:
            path = os.path.join(
                path,
                self.name)

        text_out.export_parameters_txt(
            prj=self,
            path=path)
Ejemplo n.º 30
0
    def export_annex(self,
                     number_of_elements=2,
                     merge_windows=False,
                     internal_id=None,
                     path=None):
        """Exports values to a record file for Modelica simulation

        Parameters
        ----------

        number_of_elements : int
            defines the number of elements, that area aggregated, between 1
            and 4, default is 2
        merge_windows : bool
            True for merging the windows into the outer walls, False for
            separate resistance for window, default is False
        internal_id : float
            setter of the used building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in OutputData, an alternative
            path can be specified as a full and absolute path
        """

        if path is None:
            path = utilitis.get_default_path() + "\\" + self.name
        else:
            path = path + "\\" + self.name

        utilitis.create_path(path)

        annex60_output.export_annex60(
            prj=self,
            number_of_elements=self.number_of_elements_calc,
            merge_windows=self.merge_windows_calc,
            internal_id=internal_id,
            path=path)
Ejemplo n.º 31
0
    def export_annex(self,
                     number_of_elements=2,
                     merge_windows=False,
                     internal_id=None,
                     path=None):
        """Exports values to a record file for Modelica simulation

        Parameters
        ----------

        number_of_elements : int
            defines the number of elements, that area aggregated, between 1
            and 4, default is 2
        merge_windows : bool
            True for merging the windows into the outer walls, False for
            separate resistance for window, default is False
        internal_id : float
            setter of the used building which will be exported, if None then
            all buildings will be exported
        path : string
            if the Files should not be stored in OutputData, an alternative
            path can be specified as a full and absolute path
        """

        if path is None:
            path = utilitis.get_default_path() + "\\" + self.name
        else:
            path = path + "\\" + self.name

        utilitis.create_path(path)

        annex60_output.export_annex60(prj=self,
                                      number_of_elements=self.number_of_elements_calc,
                                      merge_windows=self.merge_windows_calc,
                                      internal_id=internal_id,
                                      path=path)
Ejemplo n.º 32
0
    def modelica_gains_boundary(self, zone, path=None):
        """creates .mat file for internal gains boundary conditions

        This function creates a matfile (-v4) for building internal gains
        boundary conditions. It collects internal gain profiles of a specific
        zones and stores them into one file. It also calculates the internal
        gains from relative presence and values for heat output into W for
        direct usage in Annex models.

        Only person (convective and radiative) and machines (convective) are
        used in the simple Annex 60 examples.

        1. Column : time step
        2 Column : profile_persons, radiative
        3 Column : profile_persons, convective
        4 Column : profile_machines, convective

        Note
        ----------
        When time line is created, we need to add a 0 to first element of
        all boundaries. This is due to to expected format in Modelica.

        Parameters
        ----------
        zone : ThermalZone()
            TEASER instance of ThermalZone. As IBPSA computes single models
            for single zones, we need to generate individual files for zones
            and internal gains
        path : str
            optional path, when matfile is exported separately

        """
        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_internal_gains)

        export = pd.DataFrame(
            index=pd.date_range("2019-01-01 00:00:00", periods=8760, freq="H")
            .to_series()
            .dt.strftime("%m-%d %H:%M:%S")
        )

        export["person_rad_{}".format(zone.name)] = (
            zone.use_conditions.schedules["persons_profile"]
            * (1 - zone.use_conditions.ratio_conv_rad_persons)
            * zone.use_conditions.fixed_heat_flow_rate_persons
            * zone.use_conditions.persons
            * zone.area
        )
        export["person_conv_{}".format(zone.name)] = (
            zone.use_conditions.schedules["persons_profile"]
            * zone.use_conditions.ratio_conv_rad_persons
            * zone.use_conditions.fixed_heat_flow_rate_persons
            * zone.use_conditions.persons
            * zone.area
        )
        export["machines_conv_{}".format(zone.name)] = (
            zone.use_conditions.schedules["machines_profile"]
            * zone.use_conditions.ratio_conv_rad_machines
            * zone.use_conditions.machines
            * zone.area
        )

        export.index = [(i + 1) * 3600 for i in range(8760)]
        self._delete_file(path=path)
        with open(path, "a") as f:
            f.write("#1\n")
            f.write(
                "double Internals({}, {})\n".format(
                    8760, (len(self.parent.thermal_zones) * 3 + 1)
                )
            )
            export.to_csv(f, sep="\t", header=False, index_label=False)
Ejemplo n.º 33
0
def modelica_gains_boundary(bldg,
                            time_line = None,
                            path = None):
    '''creates .mat file for internal gains boundary conditions (building)

    This function creates a matfile (-v4) for building internal gains
    boundary conditions. It collects all internal gain profiles of the
    zones and stores them into one file. The file is extended for each
    zone. Only applicable if zones are defined

    !AixLib sepcific!

    1. Column : time step
    2,5,8,...  Column : profile_persons
    3,6,9,...  Column : profile_machines
    4,7,10,... Column : profile_lighting

    Note
    ----------
    When time line is created, we need to add a 0 to first element of
    all boundaries. This is due to to expected format in Modelica.

    Parameters
    ----------
    time_line :[[int]]
        list of time steps
    path : str
        optional path, when matfile is exported seperately

    '''

    if bldg.file_internal_gains is None:
        bldg.file_internal_gains = "\\InternalGains_"+bldg.name+".mat"
    else:
        pass

    if path is None:
        path = utilitis.get_default_path()
    else:
        pass

    utilitis.create_path(path)
    path = path + bldg.file_internal_gains

    for zone_count in bldg.thermal_zones:
        if time_line is None:
            duration= len(zone_count.use_conditions.profile_persons) * \
                        3600
            time_line = create_timeline(bldg=bldg,
                                        duration_profile = duration)

#            zone_count.use_conditions.profile_persons.insert(0,0)
#            zone_count.use_conditions.profile_machines.insert(0,0)
#            zone_count.use_conditions.profile_lighting.insert(0,0)

        ass_error_1 = "time line and input have to have the same length"

        assert len(time_line)-1 == len(zone_count.use_conditions.profile_persons), \
                            (ass_error_1 + ",profile_persons")
        assert len(time_line)-1 == len(zone_count.use_conditions.profile_machines), \
                            (ass_error_1 + ",profile_machines")
        assert len(time_line)-1 == len(zone_count.use_conditions.profile_lighting), \
                            (ass_error_1 + ",profile_lighting")

        for i, time in enumerate(time_line):

            if i == 0:
                time.append(0)
                time.append(0)
                time.append(0)
            else:
                time.append(zone_count.use_conditions.profile_persons[i-1])
                time.append(zone_count.use_conditions.profile_machines[i-1])
                time.append(zone_count.use_conditions.profile_lighting[i-1])

#            zone_count.use_conditions.profile_persons.pop(0)
#            zone_count.use_conditions.profile_machines.pop(0)
#            zone_count.use_conditions.profile_lighting.pop(0)
    internal_boundary = np.array(time_line)

    scipy.io.savemat(path,
                     mdict={'Internals': internal_boundary},
                     appendmat=False,
                     format='4')
Ejemplo n.º 34
0
def main():

    this_path = os.path.dirname(__file__)
    input_path = os.path.join(this_path,
                              'examplefiles',
                              'MelatenXML')

    output_path = utilitis.get_default_path()

    info_list = read_XMLs(input_path)

    prj = create_reference_project(info_list)
    prj.name = "Melaten_Ref"

    '''
    We need to set the projects calculation method. The library we want to
    use is AixLib, we are using a two element model and want an extra resistance
    for the windows. To export the parameters to a Modelica record, we use
    the export_aixlib function. path = None indicates, that we want to store
    the records in TEASER'S Output folder
    '''

    prj.used_library_calc = 'AixLib'
    prj.number_of_elements_calc = 2
    prj.merge_windows_calc = False

    prj.calc_all_buildings()

    '''
    Export the Modelica Record. If you have a Dymola License you can  export
    the model with a central AHU (MultizoneEquipped) (only default for office
    and institute buildings)
    '''

    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)

    '''
    For OpenModelica you need to exclude the centralAHU (because it is using
    state machines). Therefore use the building_model "Multizone"
    '''

    #prj.export_aixlib(building_model="Multizone",
    #                  zone_model="ThermalZoneEquipped",
    #                  corG=True,
    #                  internal_id=None,
    #                  path=None)


    '''Or we use Annex60 method (e.g with four elements). Which exports one
    Model per zone'''

    #prj.used_library_calc = 'Annex60'
    #prj.number_of_elements_calc = 4
    #prj.merge_windows_calc = False

    #prj.calc_all_buildings()
    #prj.export_annex()

    prj.name = "Melaten_Retrofit"
    prj.retrofit_all_buildings(2015)

    '''You could also change the exports here as seen above'''

    prj.export_aixlib(building_model="MultizoneEquipped",
                      zone_model="ThermalZoneEquipped",
                      corG=True,
                      internal_id=None,
                      path=None)
Ejemplo n.º 35
0
def modelica_AHU_boundary(bldg,
                          time_line = None,
                          path = None):
    '''creates .mat file for AHU boundary conditions (building)

    This function creates a matfile (-v4) for building AHU boundary
    conditions

    !AixLib sepcific!

    Known limitation:

    1. Column : time step
    2. Column : desired AHU profile temperature
    3. Column : Desired minimal relative humidity
    4. Column : desired maximal relative humidity
    5. Columb : AHU status (On/Off)

    Parameters
    ----------
    time_line :[[int]]
        list of time steps
    path : str
        optional path, when matfile is exported seperately

    Attributes
    ----------
    profile_temperature : [float]
        timeline of temperatures requirements for AHU simulation
    profile_min_relative_humidity : [float]
        timeline of relative humidity requirements for AHU simulation
    profile_max_relative_humidity : [float]
        timeline of relative humidity requirements for AHU simulation
    profile_v_flow : [int]
        timeline of desired relative v_flow of the AHU simulation (0..1)

    '''

    if bldg.file_ahu is None:
        bldg.file_ahu = "\\AHU_"+bldg.name+".mat"
    else:
        pass

    if path is None:
        path = utilitis.get_default_path()
    else:
        pass

    utilitis.create_path(path)
    path = path + bldg.file_ahu

    if time_line is None:
        time_line = create_timeline(bldg)
    if bldg.with_ahu is True:
        profile_temperature = \
                    bldg.central_ahu.profile_temperature
        profile_min_relative_humidity = \
                    bldg.central_ahu.profile_min_relative_humidity
        profile_max_relative_humidity = \
                    bldg.central_ahu.profile_max_relative_humidity
        profile_v_flow = \
                    bldg.central_ahu.profile_v_flow
    else:
        #Dummy values for Input Table (based on discussion with pme)
        time_line = [[0],[3600]]
        profile_temperature = [293.15,293.15]
        profile_min_relative_humidity = [0,0]
        profile_max_relative_humidity = [1,1]
        profile_v_flow = [0,1]


    ass_error_1 = "time line and input have to have the same length"

    assert len(time_line) == len(profile_temperature), \
                        (ass_error_1 + ",profile_temperature_AHU")
    assert len(time_line) == len(profile_min_relative_humidity), \
                        (ass_error_1 + ",profile_min_relative_humidity")
    assert len(time_line) == len(profile_max_relative_humidity), \
                        (ass_error_1 + ",profile_max_relative_humidity")
    assert len(time_line) == len(profile_v_flow), \
                        (ass_error_1 + ",profile_status_AHU")


    for i, time in enumerate(time_line):

        time.append(profile_temperature[i])
        time.append(profile_min_relative_humidity[i])
        time.append(profile_max_relative_humidity[i])
        time.append(profile_v_flow[i])

    ahu_boundary = np.array(time_line)

    scipy.io.savemat(path,
                     mdict={'AHU': ahu_boundary},
                     appendmat = False,
                     format = '4')
def from_scratch(
        number_of_elements,
        save=False,
        path=utilities.get_default_path()):
    """This function creates the test room from scratch.

    Notes: The standard defines an solar absorption coefficient for interior
    surfaces of 0.6. We do not consider this, but we could by multiplying
    the solar radiation after the window by 0.6.

    Parameters
    ----------
    number_of_elements: int
        Number of elements of model
    path: str (optional)
        Path where Project should be stored as .teaserXML
    save: bool (optional)
        True if Project should be stored as .teaserXML at path

    Returns
    -------

    prj: Project
        Project that contains the building with the test room

    """
    prj = Project(load_data=True)
    prj.name = "ASHRAE140Verification"

    bldg = Building(parent=prj)
    bldg.name = "TestBuilding"

    tz = ThermalZone(parent=bldg)
    tz.name = "TestRoom900"
    tz.area = 8.0 * 6.0
    tz.volume = tz.area * 2.7
    tz.infiltration_rate = 0.41

    tz.use_conditions = BoundaryConditions(parent=tz)

    roof = Rooftop(parent=tz)
    roof.name = "Roof"
    roof.area = 8.0 * 6.0
    roof.orientation = -1.0
    roof.tilt = 0.0
    roof.inner_convection = 1
    roof.outer_convection = 24.67
    roof.inner_radiation = 5.13
    roof.outer_radiation = 4.63

    layer_r1 = Layer(parent=roof, id=0)
    layer_r1.thickness = 0.01

    material_r1 = Material(layer_r1)
    material_r1.name = "Plasterboard"
    material_r1.density = 950.0
    material_r1.heat_capac = 840.0 / 1000
    material_r1.thermal_conduc = 0.16
    material_r1.ir_emissivity = 0.9

    layer_r2 = Layer(parent=roof, id=1)
    layer_r2.thickness = 0.1118

    material_r2 = Material(layer_r2)
    material_r2.name = "Fiberglass"
    material_r2.density = 12
    material_r2.heat_capac = 840 / 1000
    material_r2.thermal_conduc = 0.04

    layer_r3 = Layer(parent=roof, id=2)
    layer_r3.thickness = 0.019

    material_r3 = Material(layer_r3)
    material_r3.name = "Roofdeck"
    material_r3.density = 530
    material_r3.heat_capac = 900 / 1000
    material_r3.thermal_conduc = 0.14
    material_r3.solar_absorp = 0.6
    material_r3.ir_emissivity = 0.9

    out_wall_north = OuterWall(parent=tz)
    out_wall_north.name = "OuterWallNorth"
    out_wall_north.area = 8.0 * 2.7
    out_wall_north.orientation = 0.0
    out_wall_north.tilt = 90.0
    out_wall_north.inner_convection = 3.16
    out_wall_north.outer_convection = 24.67
    out_wall_north.inner_radiation = 5.13
    out_wall_north.outer_radiation = 4.63

    layer_own1 = Layer(parent=out_wall_north, id=0)
    layer_own1.thickness = 0.1

    material_own1 = Material(layer_own1)
    material_own1.name = "Concrete"
    material_own1.density = 1400.0
    material_own1.heat_capac = 1000 / 1000
    material_own1.thermal_conduc = 0.51
    material_own1.ir_emissivity = 0.9

    layer_own2 = Layer(parent=out_wall_north, id=1)
    layer_own2.thickness = 0.062

    material_own2 = Material(layer_own2)
    material_own2.name = "FoamInsulation"
    material_own2.density = 10
    material_own2.heat_capac = 1400 / 1000
    material_own2.thermal_conduc = 0.04

    layer_own3 = Layer(parent=out_wall_north, id=2)
    layer_own3.thickness = 0.009

    material_own3 = Material(layer_own3)
    material_own3.name = "WoodSiding"
    material_own3.density = 530
    material_own3.heat_capac = 900 / 1000
    material_own3.thermal_conduc = 0.14
    material_own3.solar_absorp = 0.6
    material_own3.ir_emissivity = 0.9

    out_wall_east = OuterWall(parent=tz)
    out_wall_east.name = "OuterWallEast"
    out_wall_east.area = 6.0 * 2.7
    out_wall_east.orientation = 90.0
    out_wall_east.tilt = 90.0
    out_wall_east.inner_convection = 3.16
    out_wall_east.outer_convection = 24.67
    out_wall_east.inner_radiation = 5.13
    out_wall_east.outer_radiation = 4.63

    layer_owe1 = Layer(parent=out_wall_east, id=0)
    layer_owe1.thickness = 0.1

    material_owe1 = Material(layer_owe1)
    material_owe1.name = "Concrete"
    material_owe1.density = 1400.0
    material_owe1.heat_capac = 1000 / 1000
    material_owe1.thermal_conduc = 0.51
    material_owe1.ir_emissivity = 0.9

    layer_owe2 = Layer(parent=out_wall_east, id=1)
    layer_owe2.thickness = 0.062

    material_owe2 = Material(layer_owe2)
    material_owe2.name = "FoamInsulation"
    material_owe2.density = 10
    material_owe2.heat_capac = 1400 / 1000
    material_owe2.thermal_conduc = 0.04

    layer_owe3 = Layer(parent=out_wall_east, id=2)
    layer_owe3.thickness = 0.009

    material_owe3 = Material(layer_owe3)
    material_owe3.name = "WoodSiding"
    material_owe3.density = 530
    material_owe3.heat_capac = 900 / 1000
    material_owe3.thermal_conduc = 0.14
    material_owe3.solar_absorp = 0.6
    material_owe3.ir_emissivity = 0.9

    out_wall_south = OuterWall(parent=tz)
    out_wall_south.name = "OuterWallSouth"
    out_wall_south.area = (8.0 * 2.7) - 2 * (3 * 2)  # minus two windows
    out_wall_south.orientation = 180.0
    out_wall_south.tilt = 90.0
    out_wall_south.inner_convection = 3.16
    out_wall_south.outer_convection = 24.67
    out_wall_south.inner_radiation = 5.13
    out_wall_south.outer_radiation = 4.63

    layer_ows1 = Layer(parent=out_wall_south, id=0)
    layer_ows1.thickness = 0.1

    material_ows1 = Material(layer_ows1)
    material_ows1.name = "Concrete"
    material_ows1.density = 1400.0
    material_ows1.heat_capac = 1000.0 / 1000
    material_ows1.thermal_conduc = 0.51
    material_ows1.ir_emissivity = 0.9

    layer_ows2 = Layer(parent=out_wall_south, id=1)
    layer_ows2.thickness = 0.062

    material_ows2 = Material(layer_ows2)
    material_ows2.name = "FoamInsulation"
    material_ows2.density = 10
    material_ows2.heat_capac = 1400 / 1000
    material_ows2.thermal_conduc = 0.04

    layer_ows3 = Layer(parent=out_wall_south, id=2)
    layer_ows3.thickness = 0.009

    material_ows3 = Material(layer_ows3)
    material_ows3.name = "WoodSiding"
    material_ows3.density = 530
    material_ows3.heat_capac = 900 / 1000
    material_ows3.thermal_conduc = 0.14
    material_ows3.solar_absorp = 0.6
    material_ows3.ir_emissivity = 0.9

    out_wall_west = OuterWall(parent=tz)
    out_wall_west.name = "OuterWallWest"
    out_wall_west.area = 6 * 2.7
    out_wall_west.orientation = 270.0
    out_wall_west.tilt = 90.0
    out_wall_west.inner_convection = 3.16
    out_wall_west.outer_convection = 24.67
    out_wall_west.inner_radiation = 5.13
    out_wall_west.outer_radiation = 4.63

    layer_oww1 = Layer(parent=out_wall_west, id=0)
    layer_oww1.thickness = 0.1

    material_oww1 = Material(layer_oww1)
    material_oww1.name = "Concrete"
    material_oww1.density = 1400.0
    material_oww1.heat_capac = 1000.0 / 1000
    material_oww1.thermal_conduc = 0.51
    material_oww1.ir_emissivity = 0.9

    layer_oww2 = Layer(parent=out_wall_west, id=1)
    layer_oww2.thickness = 0.062

    material_oww2 = Material(layer_oww2)
    material_oww2.name = "FoamInsulation"
    material_oww2.density = 10
    material_oww2.heat_capac = 1400 / 1000
    material_oww2.thermal_conduc = 0.04

    layer_oww3 = Layer(parent=out_wall_west, id=2)
    layer_oww3.thickness = 0.009

    material_oww3 = Material(layer_oww3)
    material_oww3.name = "WoodSiding"
    material_oww3.density = 530
    material_oww3.heat_capac = 900 / 1000
    material_oww3.thermal_conduc = 0.14
    material_oww3.solar_absorp = 0.6
    material_oww3.ir_emissivity = 0.9

    in_wall_floor = Floor(parent=tz)
    in_wall_floor.name = "InnerWallFloor"
    in_wall_floor.area = 6 * 8
    in_wall_floor.orientation = -2.0
    in_wall_floor.tilt = 0.0
    in_wall_floor.inner_convection = 4.13
    in_wall_floor.inner_radiation = 5.13

    layer_iwf1 = Layer(parent=in_wall_floor, id=0)
    layer_iwf1.thickness = 0.025

    material_iwf1 = Material(layer_iwf1)
    material_iwf1.name = "Concrete"
    material_iwf1.density = 1400
    material_iwf1.heat_capac = 1000 / 1000
    material_iwf1.thermal_conduc = 1.13
    material_iwf1.ir_emissivity = 0.9

    layer_iwf2 = Layer(parent=in_wall_floor, id=1)
    layer_iwf2.thickness = 1.007

    material_iwf2 = Material(layer_iwf2)
    material_iwf2.name = "Insulation"
    material_iwf2.density = 0.000000000001  # 0.0001, as small as possible
    material_iwf2.heat_capac = 0.000000000001  # 0.0001, as small as possible
    material_iwf2.thermal_conduc = 0.04

    win_1 = Window(parent=tz)
    win_1.name = "WindowSouthLeft"
    win_1.area = 3 * 2
    win_1.tilt = 90.0
    win_1.orientation = 180.0
    win_1.inner_convection = 3.16
    win_1.inner_radiation = 5.13
    win_1.outer_convection = 16.37
    win_1.outer_radiation = 4.63
    win_1.g_value = 0.789
    win_1.a_conv = 0.03  # for the given U-value extracted from VDI 6007-2/-3

    win_1_layer = Layer(parent=win_1)
    win_1_layer.id = 1
    win_1_layer.thickness = 0.024

    win_1_material = Material(win_1_layer)
    win_1_material.name = "GlasWindow"
    win_1_material.thermal_conduc = 0.15
    win_1_material.transmittance = 0.907
    win_1_material.ir_emissivity = 0.9

    win_2 = Window(parent=tz)
    win_2.name = "WindowSouthRight"
    win_2.area = 3 * 2
    win_2.tilt = 90.0
    win_2.orientation = 180.0
    win_2.inner_convection = 3.16
    win_2.inner_radiation = 5.13
    win_2.outer_convection = 16.37
    win_2.outer_radiation = 4.63
    win_2.g_value = 0.789
    win_2.a_conv = 0.03  # for the given U-value extracted from VDI 6007-2/-3

    win_2_layer = Layer(parent=win_2)
    win_2_layer.id = 1
    win_2_layer.thickness = 0.024

    win_2_material = Material(win_2_layer)
    win_2_material.name = "GlasWindow"
    win_2_material.thermal_conduc = 0.15
    win_2_material.transmittance = 0.907
    win_2_material.ir_emissivity = 0.9

    #  This is a dummy ground floor to export three and four elements models.
    #  Please set values for floor plate in three element and four element
    #  models to default.

    if number_of_elements >= 3:
        out_wall_gf = GroundFloor(parent=tz)
        out_wall_gf.name = "ExtWallGroundFloor"
        out_wall_gf.area = 6 * 8
        out_wall_gf.orientation = -2.0
        out_wall_gf.tilt = 0.0
        out_wall_gf.inner_convection = 4.13
        out_wall_gf.inner_radiation = 5.13

        layer_ofgw1 = Layer(parent=out_wall_gf, id=0)
        layer_ofgw1.thickness = 1.003

        material_ofgw1 = Material(layer_ofgw1)
        material_ofgw1.name = "Insulation"
        material_ofgw1.density = 0.0001  # as small as possible
        material_ofgw1.heat_capac = 0.0001  # as small as possible
        material_ofgw1.thermal_conduc = 0.04

    if save:
        prj.save_project(file_name='ASHRAE140_900', path=path)

    return prj
Ejemplo n.º 37
0
    def modelica_gains_boundary(
            self,
            time_line=None,
            path=None):
        """creates .mat file for internal gains boundary conditions

        This function creates a matfile (-v4) for building internal gains
        boundary conditions. It collects all internal gain profiles of the
        zones and stores them into one file. The file is extended for each
        zone. Only applicable if zones are defined

        1. Column : time step
        2,5,8,...  Column : profile_persons
        3,6,9,...  Column : profile_machines
        4,7,10,... Column : profile_lighting

        Note
        ----------
        When time line is created, we need to add a 0 to first element of
        all boundaries. This is due to to expected format in Modelica.

        Parameters
        ----------
        time_line :[[int]]
            list of time steps
        path : str
            optional path, when matfile is exported separately
        """

        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_internal_gains)

        for zone_count in self.parent.thermal_zones:
            if time_line is None:
                duration = len(zone_count.use_conditions.profile_persons) * \
                    3600
                time_line = self.create_profile(duration_profile=duration)

            ass_error_1 = "time line and input have to have the same length"

            assert len(time_line) - 1 == len(
                zone_count.use_conditions.profile_persons), \
                (ass_error_1 + ",profile_persons")
            assert len(time_line) - 1 == len(
                zone_count.use_conditions.profile_machines), \
                (ass_error_1 + ",profile_machines")
            assert len(time_line) - 1 == len(
                zone_count.use_conditions.profile_lighting), \
                (ass_error_1 + ",profile_lighting")

            for i, time in enumerate(time_line):
                if i == 0:
                    time.append(
                        zone_count.use_conditions.profile_persons[i + 1])
                    time.append(
                        zone_count.use_conditions.profile_machines[i + 1])
                    time.append(
                        zone_count.use_conditions.profile_lighting[i + 1])
                else:
                    time.append(
                        zone_count.use_conditions.profile_persons[i - 1])
                    time.append(
                        zone_count.use_conditions.profile_machines[i - 1])
                    time.append(
                        zone_count.use_conditions.profile_lighting[i - 1])

        internal_boundary = np.array(time_line)

        scipy.io.savemat(
            path,
            mdict={'Internals': internal_boundary},
            appendmat=False,
            format='4')

        return internal_boundary
Ejemplo n.º 38
0
    def modelica_set_temp(self, path=None):
        """creates .mat file for set temperatures

        This function creates a matfile (-v4) for set temperatures of each
        zone, that are all saved into one matrix.

        1. Row: heat set temperature of all zones
        2. Row: cool set temperature of all zones

        Parameters
        ----------
        path : str
            optional path, when matfile is exported separately
        """

        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_set_t)

        time_line = self.create_profile(double=True)

        for zone_count in self.parent.thermal_zones:
            for i in range(len(time_line)):
                if self.use_set_back is False:
                    time_line[i].append(zone_count.use_conditions.set_temp_heat)
                else:
                    i -= 1
                    if i % 2 == 0:
                        if zone_count.use_conditions.heating_time[0] == 0:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat)
                        elif time_line[i][0] < \
                                zone_count.use_conditions.heating_time[0] * 3600:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                        elif time_line[i][0] == \
                                zone_count.use_conditions.heating_time[0] * 3600:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat)
                        elif time_line[i][0] == \
                            (zone_count.use_conditions.heating_time[1] + 1) * \
                                3600:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                        elif time_line[i][0] > \
                            (zone_count.use_conditions.heating_time[1] + 1) * \
                                3600:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat -
                                zone_count.use_conditions.temp_set_back)
                        else:
                            time_line[i].append(
                                zone_count.use_conditions.set_temp_heat)
                            time_line[i + 1].append(
                                zone_count.use_conditions.set_temp_heat)

                    else:
                        pass

        scipy.io.savemat(
            path,
            mdict={'Tset': time_line},
            appendmat=False,
            format='4')
Ejemplo n.º 39
0
    def modelica_gains_boundary(self, zone, time_line=None, path=None):
        """creates .mat file for internal gains boundary conditions

        This function creates a matfile (-v4) for building internal gains
        boundary conditions. It collects internal gain profiles of a specific
        zones and stores them into one file. It also calculates the internal
        gains from relative presence and values for heat output into W for
        direct usage in Annex models.

        Only person (convective and radiative) and machines (convective) are
        used in the simple Annex 60 examples.

        1. Column : time step
        2 Column : profile_persons, radiative
        3 Column : profile_persons, convective
        4 Column : profile_machines, convective

        Note
        ----------
        When time line is created, we need to add a 0 to first element of
        all boundaries. This is due to to expected format in Modelica.

        Parameters
        ----------
        zone : ThermalZone()
            TEASER instance of ThermalZone. As IBPSA computes single models
            for single zones, we need to generate individual files for zones
            and internal gains
        time_line :[[int]]
            list of time steps
        path : str
            optional path, when matfile is exported separately
        """

        if path is None:
            path = utilities.get_default_path()
        else:
            pass

        utilities.create_path(path)
        path = os.path.join(path, self.file_internal_gains)

        if time_line is None:
            duration = len(zone.use_conditions.profile_persons) * \
                3600
            time_line = self.create_profile(duration_profile=duration)

        ass_error_1 = "time line and input have to have the same length"

        assert len(time_line) - 1 == len(
            zone.use_conditions.profile_persons), \
            (ass_error_1 + ",profile_persons")
        assert len(time_line) - 1 == len(
            zone.use_conditions.profile_machines), \
            (ass_error_1 + ",profile_machines")

        for i, time in enumerate(time_line):
            if i == 0:
                time.append(0)
                time.append(0)
                time.append(0)
            else:
                time.append(zone.use_conditions.profile_persons[i - 1] *
                            zone.use_conditions.persons *
                            zone.use_conditions.activity_type_persons * 50 *
                            (1 - zone.use_conditions.ratio_conv_rad_persons))
                time.append(zone.use_conditions.profile_persons[i - 1] *
                            zone.use_conditions.persons *
                            zone.use_conditions.activity_type_persons * 50 *
                            zone.use_conditions.ratio_conv_rad_persons)
                time.append(zone.use_conditions.profile_machines[i - 1] *
                            zone.use_conditions.machines *
                            zone.use_conditions.activity_type_machines * 50)

        internal_boundary = np.array(time_line)

        scipy.io.savemat(path,
                         mdict={'Internals': internal_boundary},
                         appendmat=False,
                         format='4')